diff --git a/include/ui/Avatar.h b/include/ui/Avatar.h
new file mode 100644
index 00000000..afbf6aad
--- /dev/null
+++ b/include/ui/Avatar.h
@@ -0,0 +1,51 @@
+#ifndef UI_AVATAR_H
+#define UI_AVATAR_H
+
+#include <QIcon>
+#include <QImage>
+#include <QPixmap>
+#include <QWidget>
+
+#include "Theme.h"
+
+class Avatar : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
+ Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
+
+public:
+ explicit Avatar(QWidget *parent = 0);
+ ~Avatar();
+
+ void setBackgroundColor(const QColor &color);
+ void setIcon(const QIcon &icon);
+ void setImage(const QImage &image);
+ void setLetter(const QChar &letter);
+ void setSize(int size);
+ void setTextColor(const QColor &color);
+
+ QColor backgroundColor() const;
+ QColor textColor() const;
+ int size() const;
+
+ QSize sizeHint() const override;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ void init();
+
+ ui::AvatarType type_;
+ QChar letter_;
+ QColor background_color_;
+ QColor text_color_;
+ QIcon icon_;
+ QImage image_;
+ QPixmap pixmap_;
+ int size_;
+};
+
+#endif // UI_AVATAR_H
diff --git a/include/ui/Badge.h b/include/ui/Badge.h
new file mode 100644
index 00000000..774b03ad
--- /dev/null
+++ b/include/ui/Badge.h
@@ -0,0 +1,63 @@
+#ifndef UI_BADGE_H
+#define UI_BADGE_H
+
+#include <QColor>
+#include <QIcon>
+#include <QWidget>
+#include <QtGlobal>
+
+#include "OverlayWidget.h"
+
+class Badge : public OverlayWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
+ Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
+ Q_PROPERTY(QPointF relativePosition WRITE setRelativePosition READ relativePosition)
+
+public:
+ explicit Badge(QWidget *parent = 0);
+ explicit Badge(const QIcon &icon, QWidget *parent = 0);
+ explicit Badge(const QString &text, QWidget *parent = 0);
+ ~Badge();
+
+ void setBackgroundColor(const QColor &color);
+ void setTextColor(const QColor &color);
+ void setIcon(const QIcon &icon);
+ void setRelativePosition(const QPointF &pos);
+ void setRelativePosition(qreal x, qreal y);
+ void setRelativeXPosition(qreal x);
+ void setRelativeYPosition(qreal y);
+ void setText(const QString &text);
+
+ QIcon icon() const;
+ QString text() const;
+ QColor backgroundColor() const;
+ QColor textColor() const;
+ QPointF relativePosition() const;
+ QSize sizeHint() const override;
+ qreal relativeXPosition() const;
+ qreal relativeYPosition() const;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ int getDiameter() const;
+
+private:
+ void init();
+
+ QColor background_color_;
+ QColor text_color_;
+
+ QIcon icon_;
+ QSize size_;
+ QString text_;
+
+ int padding_;
+
+ qreal x_;
+ qreal y_;
+};
+
+#endif // UI_BADGE_H
diff --git a/include/ui/FlatButton.h b/include/ui/FlatButton.h
new file mode 100644
index 00000000..047890c7
--- /dev/null
+++ b/include/ui/FlatButton.h
@@ -0,0 +1,210 @@
+#ifndef UI_FLAT_BUTTON_H
+#define UI_FLAT_BUTTON_H
+
+#include <QPaintEvent>
+#include <QPainter>
+#include <QPushButton>
+#include <QSequentialAnimationGroup>
+#include <QStateMachine>
+
+#include "RippleOverlay.h"
+#include "Theme.h"
+
+class FlatButton;
+
+class FlatButtonStateMachine : public QStateMachine
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal overlayOpacity WRITE setOverlayOpacity READ overlayOpacity)
+ Q_PROPERTY(qreal checkedOverlayProgress WRITE setCheckedOverlayProgress READ checkedOverlayProgress)
+ Q_PROPERTY(qreal haloOpacity WRITE setHaloOpacity READ haloOpacity)
+ Q_PROPERTY(qreal haloSize WRITE setHaloSize READ haloSize)
+ Q_PROPERTY(qreal haloScaleFactor WRITE setHaloScaleFactor READ haloScaleFactor)
+
+public:
+ explicit FlatButtonStateMachine(FlatButton *parent);
+ ~FlatButtonStateMachine();
+
+ void setOverlayOpacity(qreal opacity);
+ void setCheckedOverlayProgress(qreal opacity);
+ void setHaloOpacity(qreal opacity);
+ void setHaloSize(qreal size);
+ void setHaloScaleFactor(qreal factor);
+
+ inline qreal overlayOpacity() const;
+ inline qreal checkedOverlayProgress() const;
+ inline qreal haloOpacity() const;
+ inline qreal haloSize() const;
+ inline qreal haloScaleFactor() const;
+
+ void startAnimations();
+ void setupProperties();
+ void updateCheckedStatus();
+
+signals:
+ void buttonPressed();
+ void buttonChecked();
+ void buttonUnchecked();
+
+protected:
+ bool eventFilter(QObject *watched, QEvent *event) override;
+
+private:
+ void addTransition(QObject *object, const char *signal, QState *fromState, QState *toState);
+ void addTransition(QObject *object, QEvent::Type eventType, QState *fromState, QState *toState);
+ void addTransition(QAbstractTransition *transition, QState *fromState, QState *toState);
+
+ FlatButton *const button_;
+
+ QState *const top_level_state_;
+ QState *const config_state_;
+ QState *const checkable_state_;
+ QState *const checked_state_;
+ QState *const unchecked_state_;
+ QState *const neutral_state_;
+ QState *const neutral_focused_state_;
+ QState *const hovered_state_;
+ QState *const hovered_focused_state_;
+ QState *const pressed_state_;
+
+ QSequentialAnimationGroup *const halo_animation_;
+
+ qreal overlay_opacity_;
+ qreal checked_overlay_progress_;
+ qreal halo_opacity_;
+ qreal halo_size_;
+ qreal halo_scale_factor_;
+
+ bool was_checked_;
+};
+
+inline qreal FlatButtonStateMachine::overlayOpacity() const
+{
+ return overlay_opacity_;
+}
+
+inline qreal FlatButtonStateMachine::checkedOverlayProgress() const
+{
+ return checked_overlay_progress_;
+}
+
+inline qreal FlatButtonStateMachine::haloOpacity() const
+{
+ return halo_opacity_;
+}
+
+inline qreal FlatButtonStateMachine::haloSize() const
+{
+ return halo_size_;
+}
+
+inline qreal FlatButtonStateMachine::haloScaleFactor() const
+{
+ return halo_scale_factor_;
+}
+
+class FlatButton : public QPushButton
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor)
+ Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
+ Q_PROPERTY(QColor overlayColor WRITE setOverlayColor READ overlayColor)
+ Q_PROPERTY(QColor disabledForegroundColor WRITE setDisabledForegroundColor READ disabledForegroundColor)
+ Q_PROPERTY(QColor disabledBackgroundColor WRITE setDisabledBackgroundColor READ disabledBackgroundColor)
+ 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);
+ ~FlatButton();
+
+ void applyPreset(ui::ButtonPreset preset);
+
+ void setBackgroundColor(const QColor &color);
+ void setBackgroundMode(Qt::BGMode mode);
+ void setBaseOpacity(qreal opacity);
+ void setCheckable(bool value);
+ void setCornerRadius(qreal radius);
+ void setDisabledBackgroundColor(const QColor &color);
+ void setDisabledForegroundColor(const QColor &color);
+ void setFixedRippleRadius(qreal radius);
+ void setFontSize(qreal size);
+ void setForegroundColor(const QColor &color);
+ void setHaloVisible(bool visible);
+ void setHasFixedRippleRadius(bool value);
+ void setIconPlacement(ui::ButtonIconPlacement placement);
+ void setOverlayColor(const QColor &color);
+ void setOverlayStyle(ui::OverlayStyle style);
+ void setRippleStyle(ui::RippleStyle style);
+ void setRole(ui::Role role);
+
+ QColor foregroundColor() const;
+ QColor backgroundColor() const;
+ QColor overlayColor() const;
+ QColor disabledForegroundColor() const;
+ QColor disabledBackgroundColor() const;
+
+ qreal fontSize() const;
+ qreal cornerRadius() const;
+ qreal baseOpacity() const;
+
+ bool isHaloVisible() const;
+ bool hasFixedRippleRadius() const;
+
+ ui::Role role() const;
+ ui::OverlayStyle overlayStyle() const;
+ ui::RippleStyle rippleStyle() const;
+ ui::ButtonIconPlacement iconPlacement() const;
+
+ Qt::BGMode backgroundMode() const;
+
+ QSize sizeHint() const override;
+
+protected:
+ enum {
+ IconPadding = 12
+ };
+
+ void checkStateSet() override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+
+ virtual void paintBackground(QPainter *painter);
+ virtual void paintHalo(QPainter *painter);
+ virtual void paintForeground(QPainter *painter);
+ virtual void updateClipPath();
+
+ void init();
+
+private:
+ RippleOverlay *ripple_overlay_;
+ FlatButtonStateMachine *state_machine_;
+
+ ui::Role role_;
+ ui::RippleStyle ripple_style_;
+ ui::ButtonIconPlacement icon_placement_;
+ ui::OverlayStyle overlay_style_;
+
+ Qt::BGMode bg_mode_;
+
+ QColor background_color_;
+ QColor foreground_color_;
+ QColor overlay_color_;
+ QColor disabled_color_;
+ QColor disabled_background_color_;
+
+ qreal fixed_ripple_radius_;
+ qreal corner_radius_;
+ qreal base_opacity_;
+ qreal font_size_;
+
+ bool use_fixed_ripple_radius_;
+ bool halo_visible_;
+};
+
+#endif // UI_FLAT_BUTTON_H
diff --git a/include/ui/OverlayWidget.h b/include/ui/OverlayWidget.h
new file mode 100644
index 00000000..020393ad
--- /dev/null
+++ b/include/ui/OverlayWidget.h
@@ -0,0 +1,23 @@
+#ifndef UI_OVERLAY_WIDGET_H
+#define UI_OVERLAY_WIDGET_H
+
+#include <QEvent>
+#include <QObject>
+#include <QWidget>
+
+class OverlayWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit OverlayWidget(QWidget *parent = 0);
+ ~OverlayWidget();
+
+protected:
+ bool event(QEvent *event) override;
+ bool eventFilter(QObject *obj, QEvent *event) override;
+
+ QRect overlayGeometry() const;
+};
+
+#endif // UI_OVERLAY_WIDGET_H
diff --git a/include/ui/RaisedButton.h b/include/ui/RaisedButton.h
new file mode 100644
index 00000000..7a46173f
--- /dev/null
+++ b/include/ui/RaisedButton.h
@@ -0,0 +1,31 @@
+#ifndef UI_RAISED_BUTTON_H
+#define UI_RAISED_BUTTON_H
+
+#include <QGraphicsDropShadowEffect>
+#include <QState>
+#include <QStateMachine>
+
+#include "FlatButton.h"
+
+class RaisedButton : public FlatButton
+{
+ Q_OBJECT
+
+public:
+ explicit RaisedButton(QWidget *parent = 0);
+ explicit RaisedButton(const QString &text, QWidget *parent = 0);
+ ~RaisedButton();
+
+protected:
+ bool event(QEvent *event) override;
+
+private:
+ void init();
+
+ QStateMachine *shadow_state_machine_;
+ QState *normal_state_;
+ QState *pressed_state_;
+ QGraphicsDropShadowEffect *effect_;
+};
+
+#endif // UI_RAISED_BUTTON_H
diff --git a/include/ui/Ripple.h b/include/ui/Ripple.h
new file mode 100644
index 00000000..a66a583e
--- /dev/null
+++ b/include/ui/Ripple.h
@@ -0,0 +1,136 @@
+#ifndef UI_RIPPLE_H
+#define UI_RIPPLE_H
+
+#include <QBrush>
+#include <QEasingCurve>
+#include <QParallelAnimationGroup>
+#include <QPoint>
+#include <QPropertyAnimation>
+
+class RippleOverlay;
+
+class Ripple : public QParallelAnimationGroup
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal radius WRITE setRadius READ radius)
+ Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
+
+public:
+ explicit Ripple(const QPoint ¢er, QObject *parent = 0);
+ Ripple(const QPoint ¢er, RippleOverlay *overlay, QObject *parent = 0);
+ ~Ripple();
+
+ inline void setOverlay(RippleOverlay *overlay);
+
+ void setRadius(qreal radius);
+ void setOpacity(qreal opacity);
+ void setColor(const QColor &color);
+ void setBrush(const QBrush &brush);
+
+ inline qreal radius() const;
+ inline qreal opacity() const;
+ inline QColor color() const;
+ inline QBrush brush() const;
+ inline QPoint center() const;
+
+ inline QPropertyAnimation *radiusAnimation() const;
+ inline QPropertyAnimation *opacityAnimation() const;
+
+ inline void setOpacityStartValue(qreal value);
+ inline void setOpacityEndValue(qreal value);
+ inline void setRadiusStartValue(qreal value);
+ inline void setRadiusEndValue(qreal value);
+ inline void setDuration(int msecs);
+
+protected slots:
+ void destroy();
+
+private:
+ Q_DISABLE_COPY(Ripple)
+
+ QPropertyAnimation *animate(const QByteArray &property,
+ const QEasingCurve &easing = QEasingCurve::OutQuad,
+ int duration = 800);
+
+ void init();
+
+ RippleOverlay *overlay_;
+
+ QPropertyAnimation *const radius_anim_;
+ QPropertyAnimation *const opacity_anim_;
+
+ qreal radius_;
+ qreal opacity_;
+
+ QPoint center_;
+ QBrush brush_;
+};
+
+inline void Ripple::setOverlay(RippleOverlay *overlay)
+{
+ overlay_ = overlay;
+}
+
+inline qreal Ripple::radius() const
+{
+ return radius_;
+}
+
+inline qreal Ripple::opacity() const
+{
+ return opacity_;
+}
+
+inline QColor Ripple::color() const
+{
+ return brush_.color();
+}
+
+inline QBrush Ripple::brush() const
+{
+ return brush_;
+}
+
+inline QPoint Ripple::center() const
+{
+ return center_;
+}
+
+inline QPropertyAnimation *Ripple::radiusAnimation() const
+{
+ return radius_anim_;
+}
+
+inline QPropertyAnimation *Ripple::opacityAnimation() const
+{
+ return opacity_anim_;
+}
+
+inline void Ripple::setOpacityStartValue(qreal value)
+{
+ opacity_anim_->setStartValue(value);
+}
+
+inline void Ripple::setOpacityEndValue(qreal value)
+{
+ opacity_anim_->setEndValue(value);
+}
+
+inline void Ripple::setRadiusStartValue(qreal value)
+{
+ radius_anim_->setStartValue(value);
+}
+
+inline void Ripple::setRadiusEndValue(qreal value)
+{
+ radius_anim_->setEndValue(value);
+}
+
+inline void Ripple::setDuration(int msecs)
+{
+ radius_anim_->setDuration(msecs);
+ opacity_anim_->setDuration(msecs);
+}
+
+#endif // UI_RIPPLE_H
diff --git a/include/ui/RippleOverlay.h b/include/ui/RippleOverlay.h
new file mode 100644
index 00000000..54398efa
--- /dev/null
+++ b/include/ui/RippleOverlay.h
@@ -0,0 +1,58 @@
+#ifndef UI_RIPPLE_OVERLAY_H
+#define UI_RIPPLE_OVERLAY_H
+
+#include <QPainterPath>
+
+#include "OverlayWidget.h"
+
+class Ripple;
+
+class RippleOverlay : public OverlayWidget
+{
+ Q_OBJECT
+
+public:
+ explicit RippleOverlay(QWidget *parent = 0);
+ ~RippleOverlay();
+
+ void addRipple(Ripple *ripple);
+ void addRipple(const QPoint &position, qreal radius = 300);
+
+ void removeRipple(Ripple *ripple);
+
+ inline void setClipping(bool enable);
+ inline bool hasClipping() const;
+
+ inline void setClipPath(const QPainterPath &path);
+
+protected:
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(RippleOverlay)
+
+ void paintRipple(QPainter *painter, Ripple *ripple);
+
+ QList<Ripple *> ripples_;
+ QPainterPath clip_path_;
+ bool use_clip_;
+};
+
+inline void RippleOverlay::setClipping(bool enable)
+{
+ use_clip_ = enable;
+ update();
+}
+
+inline bool RippleOverlay::hasClipping() const
+{
+ return use_clip_;
+}
+
+inline void RippleOverlay::setClipPath(const QPainterPath &path)
+{
+ clip_path_ = path;
+ update();
+}
+
+#endif // UI_RIPPLE_OVERLAY_H
diff --git a/include/ui/TextField.h b/include/ui/TextField.h
new file mode 100644
index 00000000..953c8f29
--- /dev/null
+++ b/include/ui/TextField.h
@@ -0,0 +1,170 @@
+#ifndef UI_TEXT_FIELD_H
+#define UI_TEXT_FIELD_H
+
+#include <QColor>
+#include <QLineEdit>
+#include <QPaintEvent>
+#include <QPropertyAnimation>
+#include <QStateMachine>
+#include <QtGlobal>
+
+class TextField;
+class TextFieldLabel;
+class TextFieldStateMachine;
+
+class TextField : public QLineEdit
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
+ Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor)
+ Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor)
+
+public:
+ explicit TextField(QWidget *parent = 0);
+ ~TextField();
+
+ void setInkColor(const QColor &color);
+ void setBackgroundColor(const QColor &color);
+ void setLabel(const QString &label);
+ void setLabelColor(const QColor &color);
+ void setLabelFontSize(qreal size);
+ void setShowLabel(bool value);
+ void setTextColor(const QColor &color);
+ void setUnderlineColor(const QColor &color);
+
+ QColor inkColor() const;
+ QColor labelColor() const;
+ QColor textColor() const;
+ QColor underlineColor() const;
+ QColor backgroundColor() const;
+ QString label() const;
+ bool hasLabel() const;
+ qreal labelFontSize() const;
+
+protected:
+ bool event(QEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ void init();
+
+ QColor ink_color_;
+ QColor background_color_;
+ QColor label_color_;
+ QColor text_color_;
+ QColor underline_color_;
+ QString label_text_;
+ TextFieldLabel *label_;
+ TextFieldStateMachine *state_machine_;
+ bool show_label_;
+ qreal label_font_size_;
+};
+
+class TextFieldLabel : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal scale WRITE setScale READ scale)
+ Q_PROPERTY(QPointF offset WRITE setOffset READ offset)
+ Q_PROPERTY(QColor color WRITE setColor READ color)
+
+public:
+ TextFieldLabel(TextField *parent);
+ ~TextFieldLabel();
+
+ inline void setColor(const QColor &color);
+ inline void setOffset(const QPointF &pos);
+ inline void setScale(qreal scale);
+
+ inline QColor color() const;
+ inline QPointF offset() const;
+ inline qreal scale() const;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ TextField *const text_field_;
+
+ QColor color_;
+ qreal scale_;
+ qreal x_;
+ qreal y_;
+};
+
+inline void TextFieldLabel::setColor(const QColor &color)
+{
+ color_ = color;
+ update();
+}
+
+inline void TextFieldLabel::setOffset(const QPointF &pos)
+{
+ x_ = pos.x();
+ y_ = pos.y();
+ update();
+}
+
+inline void TextFieldLabel::setScale(qreal scale)
+{
+ scale_ = scale;
+ update();
+}
+
+inline QPointF TextFieldLabel::offset() const
+{
+ return QPointF(x_, y_);
+}
+inline qreal TextFieldLabel::scale() const
+{
+ return scale_;
+}
+inline QColor TextFieldLabel::color() const
+{
+ return color_;
+}
+
+class TextFieldStateMachine : public QStateMachine
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal progress WRITE setProgress READ progress)
+
+public:
+ TextFieldStateMachine(TextField *parent);
+ ~TextFieldStateMachine();
+
+ inline void setProgress(qreal progress);
+ void setLabel(TextFieldLabel *label);
+
+ inline qreal progress() const;
+
+public slots:
+ void setupProperties();
+
+private:
+ QPropertyAnimation *color_anim_;
+ QPropertyAnimation *offset_anim_;
+
+ QState *focused_state_;
+ QState *normal_state_;
+
+ TextField *text_field_;
+ TextFieldLabel *label_;
+
+ qreal progress_;
+};
+
+inline void TextFieldStateMachine::setProgress(qreal progress)
+{
+ progress_ = progress;
+ text_field_->update();
+}
+
+inline qreal TextFieldStateMachine::progress() const
+{
+ return progress_;
+}
+
+#endif // UI_TEXT_FIELD_H
diff --git a/include/ui/Theme.h b/include/ui/Theme.h
new file mode 100644
index 00000000..41739a98
--- /dev/null
+++ b/include/ui/Theme.h
@@ -0,0 +1,89 @@
+#ifndef UI_THEME_H
+#define UI_THEME_H
+
+#include <QColor>
+#include <QHash>
+#include <QObject>
+
+namespace ui
+{
+enum AvatarType {
+ Icon,
+ Image,
+ Letter
+};
+
+// Default font size.
+const int FontSize = 16;
+
+// Default avatar size. Width and height.
+const int AvatarSize = 40;
+
+enum ButtonPreset {
+ FlatPreset,
+ CheckablePreset
+};
+
+enum RippleStyle {
+ CenteredRipple,
+ PositionedRipple,
+ NoRipple
+};
+
+enum OverlayStyle {
+ NoOverlay,
+ TintedOverlay,
+ GrayOverlay
+};
+
+enum Role {
+ Default,
+ Primary,
+ Secondary
+};
+
+enum ButtonIconPlacement {
+ LeftIcon,
+ RightIcon
+};
+
+enum ProgressType {
+ DeterminateProgress,
+ IndeterminateProgress
+};
+
+enum Color {
+ Black,
+ BrightWhite,
+ FadedWhite,
+ MediumWhite,
+ DarkGreen,
+ LightGreen,
+ BrightGreen,
+ Gray,
+ Red,
+ Blue,
+ Transparent
+};
+
+} // namespace ui
+
+class Theme : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Theme(QObject *parent = 0);
+ ~Theme();
+
+ QColor getColor(const QString &key) const;
+
+ void setColor(const QString &key, const QColor &color);
+ void setColor(const QString &key, ui::Color &color);
+
+private:
+ QColor rgba(int r, int g, int b, qreal a) const;
+
+ QHash<QString, QColor> colors_;
+};
+
+#endif // UI_THEME_H
diff --git a/include/ui/ThemeManager.h b/include/ui/ThemeManager.h
new file mode 100644
index 00000000..426d71ec
--- /dev/null
+++ b/include/ui/ThemeManager.h
@@ -0,0 +1,33 @@
+#ifndef UI_THEME_MANAGER_H
+#define UI_THEME_MANAGER_H
+
+#include <QCommonStyle>
+
+#include "Theme.h"
+
+class ThemeManager : public QCommonStyle
+{
+ Q_OBJECT
+
+public:
+ inline static ThemeManager &instance();
+
+ void setTheme(Theme *theme);
+ QColor themeColor(const QString &key) const;
+
+private:
+ ThemeManager();
+
+ ThemeManager(ThemeManager const &);
+ void operator=(ThemeManager const &);
+
+ Theme *theme_;
+};
+
+inline ThemeManager &ThemeManager::instance()
+{
+ static ThemeManager instance;
+ return instance;
+}
+
+#endif // UI_THEME_MANAGER_H
|