summary refs log tree commit diff
path: root/src/ui
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 /src/ui
parentUse timeline to retrieve state events (diff)
downloadnheko-e44cc374e184396d32ec196186f2a6578fa0860e.tar.xz
Use strongly typed enums
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CircularProgress.cc2
-rw-r--r--src/ui/FlatButton.cc38
-rw-r--r--src/ui/Theme.cc4
3 files changed, 22 insertions, 22 deletions
diff --git a/src/ui/CircularProgress.cc b/src/ui/CircularProgress.cc

index fa74b64c..edf06d4b 100644 --- a/src/ui/CircularProgress.cc +++ b/src/ui/CircularProgress.cc
@@ -145,7 +145,7 @@ void CircularProgress::paintEvent(QPaintEvent *event) pen.setWidthF(width_); pen.setColor(color()); - if (ui::IndeterminateProgress == progress_type_) { + if (ui::ProgressType::IndeterminateProgress == progress_type_) { QVector<qreal> pattern; pattern << delegate_->dashLength() * size_ / 50 << 30 * size_ / 50; diff --git a/src/ui/FlatButton.cc b/src/ui/FlatButton.cc
index e860e7d7..a4f42a5d 100644 --- a/src/ui/FlatButton.cc +++ b/src/ui/FlatButton.cc
@@ -15,10 +15,10 @@ void FlatButton::init() { ripple_overlay_ = new RippleOverlay(this); state_machine_ = new FlatButtonStateMachine(this); - role_ = ui::Default; - ripple_style_ = ui::PositionedRipple; - icon_placement_ = ui::LeftIcon; - overlay_style_ = ui::GrayOverlay; + role_ = ui::Role::Default; + ripple_style_ = ui::RippleStyle::PositionedRipple; + icon_placement_ = ui::ButtonIconPlacement::LeftIcon; + overlay_style_ = ui::OverlayStyle::GrayOverlay; bg_mode_ = Qt::TransparentMode; fixed_ripple_radius_ = 64; corner_radius_ = 3; @@ -69,11 +69,11 @@ FlatButton::~FlatButton() void FlatButton::applyPreset(ui::ButtonPreset preset) { switch (preset) { - case ui::FlatPreset: - setOverlayStyle(ui::NoOverlay); + case ui::ButtonPreset::FlatPreset: + setOverlayStyle(ui::OverlayStyle::NoOverlay); break; - case ui::CheckablePreset: - setOverlayStyle(ui::NoOverlay); + case ui::ButtonPreset::CheckablePreset: + setOverlayStyle(ui::OverlayStyle::NoOverlay); setCheckable(true); break; default: @@ -105,11 +105,11 @@ QColor FlatButton::foregroundColor() const } switch (role_) { - case ui::Primary: + case ui::Role::Primary: return ThemeManager::instance().themeColor("Blue"); - case ui::Secondary: + case ui::Role::Secondary: return ThemeManager::instance().themeColor("Gray"); - case ui::Default: + case ui::Role::Default: default: return ThemeManager::instance().themeColor("Black"); } @@ -127,11 +127,11 @@ QColor FlatButton::backgroundColor() const { if (!background_color_.isValid()) { switch (role_) { - case ui::Primary: + case ui::Role::Primary: return ThemeManager::instance().themeColor("Blue"); - case ui::Secondary: + case ui::Role::Secondary: return ThemeManager::instance().themeColor("Gray"); - case ui::Default: + case ui::Role::Default: default: return ThemeManager::instance().themeColor("Black"); } @@ -143,7 +143,7 @@ QColor FlatButton::backgroundColor() const void FlatButton::setOverlayColor(const QColor &color) { overlay_color_ = color; - setOverlayStyle(ui::TintedOverlay); + setOverlayStyle(ui::OverlayStyle::TintedOverlay); } QColor FlatButton::overlayColor() const @@ -314,11 +314,11 @@ void FlatButton::checkStateSet() void FlatButton::mousePressEvent(QMouseEvent *event) { - if (ui::NoRipple != ripple_style_) { + if (ui::RippleStyle::NoRipple != ripple_style_) { QPoint pos; qreal radiusEndValue; - if (ui::CenteredRipple == ripple_style_) { + if (ui::RippleStyle::CenteredRipple == ripple_style_) { pos = rect().center(); } else { pos = event->pos(); @@ -410,8 +410,8 @@ void FlatButton::paintBackground(QPainter *painter) return; } - if ((ui::NoOverlay != overlay_style_) && (overlayOpacity > 0)) { - if (ui::TintedOverlay == overlay_style_) { + if ((ui::OverlayStyle::NoOverlay != overlay_style_) && (overlayOpacity > 0)) { + if (ui::OverlayStyle::TintedOverlay == overlay_style_) { brush.setColor(overlayColor()); } else { brush.setColor(Qt::gray); diff --git a/src/ui/Theme.cc b/src/ui/Theme.cc
index 4c5c19de..ff32c92d 100644 --- a/src/ui/Theme.cc +++ b/src/ui/Theme.cc
@@ -49,7 +49,7 @@ void Theme::setColor(const QString &key, const QColor &color) colors_.insert(key, color); } -void Theme::setColor(const QString &key, ui::Color &color) +void Theme::setColor(const QString &key, ui::Color color) { static const QColor palette[] = { QColor("#171919"), @@ -69,5 +69,5 @@ void Theme::setColor(const QString &key, ui::Color &color) rgba(0, 0, 0, 0), }; - colors_.insert(key, palette[color]); + colors_.insert(key, palette[static_cast<int>(color)]); }