From 21a32def3553ffafc23b2cb4925aa0edbdef0846 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Sat, 20 Apr 2019 09:08:36 -0500 Subject: [PATCH] UI: Simplify locked/visibility checkboxes --- UI/locked-checkbox.cpp | 42 -------------------------------------- UI/locked-checkbox.hpp | 12 ----------- UI/visibility-checkbox.cpp | 42 -------------------------------------- UI/visibility-checkbox.hpp | 12 ----------- 4 files changed, 108 deletions(-) delete mode 100644 UI/locked-checkbox.cpp delete mode 100644 UI/visibility-checkbox.cpp diff --git a/UI/locked-checkbox.cpp b/UI/locked-checkbox.cpp deleted file mode 100644 index 2d0d688ed..000000000 --- a/UI/locked-checkbox.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include "locked-checkbox.hpp" - -#include - -LockedCheckBox::LockedCheckBox() : QCheckBox() -{ - QString lockedFile; - QString unlockedFile; - if (devicePixelRatio() >= 2) { - lockedFile = ":/res/images/locked_mask_2x.png"; - unlockedFile = ":/res/images/unlocked_mask_2x.png"; - } else { - lockedFile = ":/res/images/locked_mask.png"; - unlockedFile = ":/res/images/unlocked_mask.png"; - } - lockedImage = QPixmap::fromImage(QImage(lockedFile)); - unlockedImage = QPixmap::fromImage(QImage(unlockedFile)); - setMinimumSize(16, 16); - - setStyleSheet("outline: none;"); -} - -void LockedCheckBox::paintEvent(QPaintEvent *event) -{ - UNUSED_PARAMETER(event); - - QPixmap &pixmap = isChecked() ? lockedImage : unlockedImage; - QImage image(pixmap.size(), QImage::Format_ARGB32); - - QPainter draw(&image); - draw.setCompositionMode(QPainter::CompositionMode_Source); - draw.drawPixmap(0, 0, pixmap.width(), pixmap.height(), pixmap); - draw.setCompositionMode(QPainter::CompositionMode_SourceIn); - draw.fillRect(QRectF(QPointF(0.0f, 0.0f), pixmap.size()), - palette().color(foregroundRole())); - - QPainter p(this); - p.drawPixmap(0, 0, 16, 16, QPixmap::fromImage(image)); -} diff --git a/UI/locked-checkbox.hpp b/UI/locked-checkbox.hpp index 8510f4668..0eb2d82ab 100644 --- a/UI/locked-checkbox.hpp +++ b/UI/locked-checkbox.hpp @@ -1,19 +1,7 @@ #pragma once #include -#include - -class QPaintEvernt; class LockedCheckBox : public QCheckBox { Q_OBJECT - - QPixmap lockedImage; - QPixmap unlockedImage; - -public: - LockedCheckBox(); - -protected: - void paintEvent(QPaintEvent *event) override; }; diff --git a/UI/visibility-checkbox.cpp b/UI/visibility-checkbox.cpp deleted file mode 100644 index d80cab2d4..000000000 --- a/UI/visibility-checkbox.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include "visibility-checkbox.hpp" - -#include - -VisibilityCheckBox::VisibilityCheckBox() : QCheckBox() -{ - QString checkedFile; - QString uncheckedFile; - if (devicePixelRatio() >= 2) { - checkedFile = ":/res/images/visible_mask_2x.png"; - uncheckedFile = ":/res/images/invisible_mask_2x.png"; - } else { - checkedFile = ":/res/images/visible_mask.png"; - uncheckedFile = ":/res/images/invisible_mask.png"; - } - checkedImage = QPixmap::fromImage(QImage(checkedFile)); - uncheckedImage = QPixmap::fromImage(QImage(uncheckedFile)); - setMinimumSize(16, 16); - - setStyleSheet("outline: none;"); -} - -void VisibilityCheckBox::paintEvent(QPaintEvent *event) -{ - UNUSED_PARAMETER(event); - - QPixmap &pixmap = isChecked() ? checkedImage : uncheckedImage; - QImage image(pixmap.size(), QImage::Format_ARGB32); - - QPainter draw(&image); - draw.setCompositionMode(QPainter::CompositionMode_Source); - draw.drawPixmap(0, 0, pixmap.width(), pixmap.height(), pixmap); - draw.setCompositionMode(QPainter::CompositionMode_SourceIn); - draw.fillRect(QRectF(QPointF(0.0f, 0.0f), pixmap.size()), - palette().color(foregroundRole())); - - QPainter p(this); - p.drawPixmap(0, 0, 16, 16, QPixmap::fromImage(image)); -} diff --git a/UI/visibility-checkbox.hpp b/UI/visibility-checkbox.hpp index 3112c5db1..ff21df2c4 100644 --- a/UI/visibility-checkbox.hpp +++ b/UI/visibility-checkbox.hpp @@ -1,19 +1,7 @@ #pragma once #include -#include - -class QPaintEvernt; class VisibilityCheckBox : public QCheckBox { Q_OBJECT - - QPixmap checkedImage; - QPixmap uncheckedImage; - -public: - VisibilityCheckBox(); - -protected: - void paintEvent(QPaintEvent *event) override; };