feat: add SettingWidget::dropdown support for int style enums (#6303)
This commit is contained in:
@@ -62,6 +62,9 @@ using StringSetting = ChatterinoSetting<std::string>;
|
||||
using QStringSetting = ChatterinoSetting<QString>;
|
||||
using QSizeSetting = ChatterinoSetting<QSize>;
|
||||
|
||||
/// Accepts any enum and saves the enum value as an integer
|
||||
///
|
||||
/// e.g. for enum class {Foo = 2, Bar = 6}, Foo would be saved as 2 and Bar would be saved as 6
|
||||
template <typename Enum>
|
||||
class EnumSetting : public ChatterinoSetting<std::underlying_type_t<Enum>>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <QBrush>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
/// The values must always be castable to a Qt::BrushStyle
|
||||
// NOLINTNEXTLINE(performance-enum-size)
|
||||
enum class LastMessageLineStyle : std::underlying_type_t<Qt::BrushStyle> {
|
||||
Solid = Qt::SolidPattern,
|
||||
Dotted = Qt::VerPattern,
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
enum class ThumbnailPreviewMode : std::uint8_t {
|
||||
DontShow,
|
||||
|
||||
AlwaysShow,
|
||||
|
||||
ShowOnShift,
|
||||
};
|
||||
|
||||
constexpr std::optional<std::string_view> qmagicenumDisplayName(
|
||||
ThumbnailPreviewMode value) noexcept
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case ThumbnailPreviewMode::DontShow:
|
||||
return "Don't show";
|
||||
case ThumbnailPreviewMode::AlwaysShow:
|
||||
return "Always show";
|
||||
case ThumbnailPreviewMode::ShowOnShift:
|
||||
return "Hold shift";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user