diff --git a/app/graphicsview.cpp b/app/graphicsview.cpp index 3557f3e..91fb50b 100644 --- a/app/graphicsview.cpp +++ b/app/graphicsview.cpp @@ -5,6 +5,7 @@ #include "graphicsview.h" #include "graphicsscene.h" +#include "settings.h" #include #include @@ -338,16 +339,16 @@ bool GraphicsView::shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) con void GraphicsView::setCheckerboardEnabled(bool enabled, bool invertColor) { m_checkerboardEnabled = enabled; - m_isLastCheckerboardColorInverted = invertColor; + bool isLightCheckerboard = Settings::instance()->useLightCheckerboard() ^ invertColor; if (m_checkerboardEnabled) { // Prepare background check-board pattern QPixmap tilePixmap(0x20, 0x20); - tilePixmap.fill(invertColor ? QColor(220, 220, 220, 170) : QColor(35, 35, 35, 170)); + tilePixmap.fill(isLightCheckerboard ? QColor(220, 220, 220, 170) : QColor(35, 35, 35, 170)); QPainter tilePainter(&tilePixmap); constexpr QColor color(45, 45, 45, 170); constexpr QColor invertedColor(210, 210, 210, 170); - tilePainter.fillRect(0, 0, 0x10, 0x10, invertColor ? invertedColor : color); - tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, invertColor ? invertedColor : color); + tilePainter.fillRect(0, 0, 0x10, 0x10, isLightCheckerboard ? invertedColor : color); + tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, isLightCheckerboard ? invertedColor : color); tilePainter.end(); setBackgroundBrush(tilePixmap); diff --git a/app/graphicsview.h b/app/graphicsview.h index 694557c..87fed81 100644 --- a/app/graphicsview.h +++ b/app/graphicsview.h @@ -70,7 +70,7 @@ private: bool m_enableFitInView = false; bool m_avoidResetTransform = false; bool m_checkerboardEnabled = false; - bool m_isLastCheckerboardColorInverted = false; + bool m_useLightCheckerboard = false; }; #endif // GRAPHICSVIEW_H diff --git a/app/settings.cpp b/app/settings.cpp index b1233e6..502800b 100644 --- a/app/settings.cpp +++ b/app/settings.cpp @@ -47,6 +47,11 @@ bool Settings::stayOnTop() return m_qsettings->value("stay_on_top", true).toBool(); } +bool Settings::useLightCheckerboard() +{ + return m_qsettings->value("use_light_checkerboard", false).toBool(); +} + Settings::DoubleClickBehavior Settings::doubleClickBehavior() const { QString result = m_qsettings->value("double_click_behavior", "Close").toString(); @@ -81,6 +86,12 @@ void Settings::setStayOnTop(bool on) m_qsettings->sync(); } +void Settings::setUseLightCheckerboard(bool light) +{ + m_qsettings->setValue("use_light_checkerboard", light); + m_qsettings->sync(); +} + void Settings::setDoubleClickBehavior(DoubleClickBehavior dcb) { m_qsettings->setValue("double_click_behavior", QEnumHelper::toString(dcb)); diff --git a/app/settings.h b/app/settings.h index 9800fe1..ed5cc37 100644 --- a/app/settings.h +++ b/app/settings.h @@ -33,12 +33,14 @@ public: static Settings *instance(); bool stayOnTop(); + bool useLightCheckerboard(); DoubleClickBehavior doubleClickBehavior() const; MouseWheelBehavior mouseWheelBehavior() const; WindowSizeBehavior initWindowSizeBehavior() const; Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const; void setStayOnTop(bool on); + void setUseLightCheckerboard(bool light); void setDoubleClickBehavior(DoubleClickBehavior dcb); void setMouseWheelBehavior(MouseWheelBehavior mwb); void setInitWindowSizeBehavior(WindowSizeBehavior wsb); diff --git a/app/settingsdialog.cpp b/app/settingsdialog.cpp index e1d1e75..ae3b5b2 100644 --- a/app/settingsdialog.cpp +++ b/app/settingsdialog.cpp @@ -14,6 +14,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) , m_stayOnTop(new QCheckBox) + , m_useLightCheckerboard(new QCheckBox) , m_doubleClickBehavior(new QComboBox) , m_mouseWheelBehavior(new QComboBox) , m_initWindowSizeBehavior(new QComboBox) @@ -67,12 +68,14 @@ SettingsDialog::SettingsDialog(QWidget *parent) } settingsForm->addRow(tr("Stay on top when start-up"), m_stayOnTop); + settingsForm->addRow(tr("Use light-color checkerboard"), m_useLightCheckerboard); settingsForm->addRow(tr("Double-click behavior"), m_doubleClickBehavior); settingsForm->addRow(tr("Mouse wheel behavior"), m_mouseWheelBehavior); settingsForm->addRow(tr("Default window size"), m_initWindowSizeBehavior); settingsForm->addRow(tr("HiDPI scale factor rounding policy"), m_hiDpiRoundingPolicyBehavior); m_stayOnTop->setChecked(Settings::instance()->stayOnTop()); + m_useLightCheckerboard->setChecked(Settings::instance()->useLightCheckerboard()); m_doubleClickBehavior->setModel(new QStringListModel(dcbDropDown)); Settings::DoubleClickBehavior dcb = Settings::instance()->doubleClickBehavior(); m_doubleClickBehavior->setCurrentIndex(static_cast(dcb)); @@ -95,6 +98,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) Settings::instance()->setStayOnTop(state == Qt::Checked); }); + connect(m_useLightCheckerboard, &QCheckBox::stateChanged, this, [ = ](int state){ + Settings::instance()->setUseLightCheckerboard(state == Qt::Checked); + }); + connect(m_doubleClickBehavior, QOverload::of(&QComboBox::currentIndexChanged), this, [ = ](int index){ Settings::instance()->setDoubleClickBehavior(_dc_options.at(index).first); }); diff --git a/app/settingsdialog.h b/app/settingsdialog.h index 166cbe8..b567e04 100644 --- a/app/settingsdialog.h +++ b/app/settingsdialog.h @@ -23,6 +23,7 @@ public slots: private: QCheckBox * m_stayOnTop = nullptr; + QCheckBox * m_useLightCheckerboard = nullptr; QComboBox * m_doubleClickBehavior = nullptr; QComboBox * m_mouseWheelBehavior = nullptr; QComboBox * m_initWindowSizeBehavior = nullptr;