summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-08 00:51:03 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-08 00:51:03 +0300
commite44cc374e184396d32ec196186f2a6578fa0860e (patch)
treefd67af7442372c76682e48def6dd6edd6f7107bb /include
parentUse timeline to retrieve state events (diff)
downloadnheko-e44cc374e184396d32ec196186f2a6578fa0860e.tar.xz
Use strongly typed enums
Diffstat (limited to 'include')
-rw-r--r--include/MatrixClient.h2
-rw-r--r--include/SlidingStackWidget.h2
-rw-r--r--include/events/Event.h2
-rw-r--r--include/events/HistoryVisibilityEventContent.h2
-rw-r--r--include/events/JoinRulesEventContent.h2
-rw-r--r--include/events/MemberEventContent.h2
-rw-r--r--include/events/MessageEventContent.h2
-rw-r--r--include/events/PowerLevelsEventContent.h16
-rw-r--r--include/ui/FlatButton.h10
-rw-r--r--include/ui/Theme.h18
10 files changed, 28 insertions, 30 deletions
diff --git a/include/MatrixClient.h b/include/MatrixClient.h

index ad768eeb..2520c6bc 100644 --- a/include/MatrixClient.h +++ b/include/MatrixClient.h
@@ -82,7 +82,7 @@ private slots: void onResponse(QNetworkReply *reply); private: - enum Endpoint { + enum class Endpoint { GetOwnProfile, GetOwnAvatar, GetProfile, diff --git a/include/SlidingStackWidget.h b/include/SlidingStackWidget.h
index 7686c6eb..56d523b0 100644 --- a/include/SlidingStackWidget.h +++ b/include/SlidingStackWidget.h
@@ -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 diff --git a/include/events/Event.h b/include/events/Event.h
index a7e4fb2d..e5a71c39 100644 --- a/include/events/Event.h +++ b/include/events/Event.h
@@ -26,7 +26,7 @@ namespace matrix { namespace events { -enum EventType { +enum class EventType { /// m.room.aliases RoomAliases, /// m.room.avatar diff --git a/include/events/HistoryVisibilityEventContent.h b/include/events/HistoryVisibilityEventContent.h
index 84738480..7b00d85e 100644 --- a/include/events/HistoryVisibilityEventContent.h +++ b/include/events/HistoryVisibilityEventContent.h
@@ -26,7 +26,7 @@ namespace matrix { namespace events { -enum HistoryVisibility { +enum class HistoryVisibility { Invited, Joined, Shared, diff --git a/include/events/JoinRulesEventContent.h b/include/events/JoinRulesEventContent.h
index ff03a26e..9b3d27c3 100644 --- a/include/events/JoinRulesEventContent.h +++ b/include/events/JoinRulesEventContent.h
@@ -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, diff --git a/include/events/MemberEventContent.h b/include/events/MemberEventContent.h
index 39ff0db1..9fd1d7d9 100644 --- a/include/events/MemberEventContent.h +++ b/include/events/MemberEventContent.h
@@ -27,7 +27,7 @@ namespace matrix { namespace events { -enum Membership { +enum class Membership { // The user is banned. BanState, diff --git a/include/events/MessageEventContent.h b/include/events/MessageEventContent.h
index adc0f3ff..1ef730ed 100644 --- a/include/events/MessageEventContent.h +++ b/include/events/MessageEventContent.h
@@ -26,7 +26,7 @@ namespace matrix { namespace events { -enum MessageEventType { +enum class MessageEventType { // m.audio Audio, diff --git a/include/events/PowerLevelsEventContent.h b/include/events/PowerLevelsEventContent.h
index c51755d8..bac4a42b 100644 --- a/include/events/PowerLevelsEventContent.h +++ b/include/events/PowerLevelsEventContent.h
@@ -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_; diff --git a/include/ui/FlatButton.h b/include/ui/FlatButton.h
index 8053f430..6e2eb149 100644 --- a/include/ui/FlatButton.h +++ b/include/ui/FlatButton.h
@@ -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; diff --git a/include/ui/Theme.h b/include/ui/Theme.h
index 41739a98..795425e4 100644 --- a/include/ui/Theme.h +++ b/include/ui/Theme.h
@@ -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;