Use strongly typed enums
This commit is contained in:
parent
1f90c58076
commit
e44cc374e1
17 changed files with 76 additions and 78 deletions
|
|
@ -82,7 +82,7 @@ private slots:
|
|||
void onResponse(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
enum Endpoint {
|
||||
enum class Endpoint {
|
||||
GetOwnProfile,
|
||||
GetOwnAvatar,
|
||||
GetProfile,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class SlidingStackWidget : public QStackedWidget
|
|||
|
||||
public:
|
||||
// Defines the animation direction.
|
||||
enum AnimationDirection {
|
||||
enum class AnimationDirection {
|
||||
LEFT_TO_RIGHT,
|
||||
RIGHT_TO_LEFT,
|
||||
AUTOMATIC
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum EventType {
|
||||
enum class EventType {
|
||||
/// m.room.aliases
|
||||
RoomAliases,
|
||||
/// m.room.avatar
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum HistoryVisibility {
|
||||
enum class HistoryVisibility {
|
||||
Invited,
|
||||
Joined,
|
||||
Shared,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum JoinRule {
|
||||
enum class JoinRule {
|
||||
// A user who wishes to join the room must first receive
|
||||
// an invite to the room from someone already inside of the room.
|
||||
Invite,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum Membership {
|
||||
enum class Membership {
|
||||
// The user is banned.
|
||||
BanState,
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum MessageEventType {
|
||||
enum class MessageEventType {
|
||||
// m.audio
|
||||
Audio,
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace matrix
|
|||
{
|
||||
namespace events
|
||||
{
|
||||
enum PowerLevels {
|
||||
enum class PowerLevels {
|
||||
User = 0,
|
||||
Moderator = 50,
|
||||
Admin = 100,
|
||||
|
|
@ -55,14 +55,14 @@ public:
|
|||
int userLevel(QString user_id) const;
|
||||
|
||||
private:
|
||||
int ban_ = PowerLevels::Moderator;
|
||||
int invite_ = PowerLevels::Moderator;
|
||||
int kick_ = PowerLevels::Moderator;
|
||||
int redact_ = PowerLevels::Moderator;
|
||||
int ban_ = static_cast<int>(PowerLevels::Moderator);
|
||||
int invite_ = static_cast<int>(PowerLevels::Moderator);
|
||||
int kick_ = static_cast<int>(PowerLevels::Moderator);
|
||||
int redact_ = static_cast<int>(PowerLevels::Moderator);
|
||||
|
||||
int events_default_ = PowerLevels::User;
|
||||
int state_default_ = PowerLevels::Moderator;
|
||||
int users_default_ = PowerLevels::User;
|
||||
int events_default_ = static_cast<int>(PowerLevels::User);
|
||||
int state_default_ = static_cast<int>(PowerLevels::Moderator);
|
||||
int users_default_ = static_cast<int>(PowerLevels::User);
|
||||
|
||||
QMap<QString, int> events_;
|
||||
QMap<QString, int> users_;
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ class FlatButton : public QPushButton
|
|||
Q_PROPERTY(qreal fontSize WRITE setFontSize READ fontSize)
|
||||
|
||||
public:
|
||||
explicit FlatButton(QWidget *parent = 0, ui::ButtonPreset preset = ui::FlatPreset);
|
||||
explicit FlatButton(const QString &text, QWidget *parent = 0, ui::ButtonPreset preset = ui::FlatPreset);
|
||||
FlatButton(const QString &text, ui::Role role, QWidget *parent = 0, ui::ButtonPreset preset = ui::FlatPreset);
|
||||
explicit FlatButton(QWidget *parent = 0, ui::ButtonPreset preset = ui::ButtonPreset::FlatPreset);
|
||||
explicit FlatButton(const QString &text, QWidget *parent = 0, ui::ButtonPreset preset = ui::ButtonPreset::FlatPreset);
|
||||
FlatButton(const QString &text, ui::Role role, QWidget *parent = 0, ui::ButtonPreset preset = ui::ButtonPreset::FlatPreset);
|
||||
~FlatButton();
|
||||
|
||||
void applyPreset(ui::ButtonPreset preset);
|
||||
|
|
@ -132,9 +132,7 @@ public:
|
|||
QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
enum {
|
||||
IconPadding = 0
|
||||
};
|
||||
int IconPadding = 0;
|
||||
|
||||
void checkStateSet() override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace ui
|
||||
{
|
||||
enum AvatarType {
|
||||
enum class AvatarType {
|
||||
Icon,
|
||||
Image,
|
||||
Letter
|
||||
|
|
@ -19,40 +19,40 @@ const int FontSize = 16;
|
|||
// Default avatar size. Width and height.
|
||||
const int AvatarSize = 40;
|
||||
|
||||
enum ButtonPreset {
|
||||
enum class ButtonPreset {
|
||||
FlatPreset,
|
||||
CheckablePreset
|
||||
};
|
||||
|
||||
enum RippleStyle {
|
||||
enum class RippleStyle {
|
||||
CenteredRipple,
|
||||
PositionedRipple,
|
||||
NoRipple
|
||||
};
|
||||
|
||||
enum OverlayStyle {
|
||||
enum class OverlayStyle {
|
||||
NoOverlay,
|
||||
TintedOverlay,
|
||||
GrayOverlay
|
||||
};
|
||||
|
||||
enum Role {
|
||||
enum class Role {
|
||||
Default,
|
||||
Primary,
|
||||
Secondary
|
||||
};
|
||||
|
||||
enum ButtonIconPlacement {
|
||||
enum class ButtonIconPlacement {
|
||||
LeftIcon,
|
||||
RightIcon
|
||||
};
|
||||
|
||||
enum ProgressType {
|
||||
enum class ProgressType {
|
||||
DeterminateProgress,
|
||||
IndeterminateProgress
|
||||
};
|
||||
|
||||
enum Color {
|
||||
enum class Color {
|
||||
Black,
|
||||
BrightWhite,
|
||||
FadedWhite,
|
||||
|
|
@ -78,7 +78,7 @@ public:
|
|||
QColor getColor(const QString &key) const;
|
||||
|
||||
void setColor(const QString &key, const QColor &color);
|
||||
void setColor(const QString &key, ui::Color &color);
|
||||
void setColor(const QString &key, ui::Color color);
|
||||
|
||||
private:
|
||||
QColor rgba(int r, int g, int b, qreal a) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue