From 5ac75cee7c9453b3da29a77a8ec0bbde4a02fd2f Mon Sep 17 00:00:00 2001 From: PianetaRadio <78976006+PianetaRadio@users.noreply.github.com> Date: Sat, 19 Nov 2022 21:13:20 +0100 Subject: [PATCH] Dark theme #33 --- CatRadio.pro | 5 ++++- CatRadio.pro.user | 10 +++++++--- ChangeLog.txt | 3 ++- dialogsetup.cpp | 27 ++++++++++++++++----------- dialogsetup.h | 6 ------ dialogsetup.ui | 30 ++++++++++++++++++++++++++++-- guidata.h | 1 + mainwindow.cpp | 34 ++++++++++++++++++++++++++++++++++ mainwindow.ui | 12 +++++++++++- smeter.cpp | 25 +++++++++++++++++++++++-- smeter.h | 6 ++++++ submeter.cpp | 23 ++++++++++++++++++++++- submeter.h | 6 ++++++ vfodisplay.cpp | 15 +++++++++++++++ vfodisplay.h | 4 ++++ 15 files changed, 179 insertions(+), 28 deletions(-) diff --git a/CatRadio.pro b/CatRadio.pro index 3662d8a..f9be121 100644 --- a/CatRadio.pro +++ b/CatRadio.pro @@ -47,7 +47,10 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin LIBS += -L$$PWD/hamlib/ -lhamlib INCLUDEPATH += $$PWD/hamlib -VERSION = 1.2.0 +RESOURCES += qdarkstyle/dark/darkstyle.qrc +# RESOURCES += qdarkstyle/light/lightstyle.qrc + +VERSION = 1.3.0 RC_ICONS = catradio.ico diff --git a/CatRadio.pro.user b/CatRadio.pro.user index 8738be0..ac93298 100644 --- a/CatRadio.pro.user +++ b/CatRadio.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -85,6 +85,9 @@ true + + true + @@ -240,8 +243,9 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro - C:/Users/Johnny/Documents/QT/CatRadio/CatRadio.pro + CatRadio2 + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Johnny/Documents/QT/CatRadio_dark/CatRadio.pro + C:/Users/Johnny/Documents/QT/CatRadio_dark/CatRadio.pro false true true diff --git a/ChangeLog.txt b/ChangeLog.txt index 3b02d70..8e4d56f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,9 +3,10 @@ CatRadio (+ New, * Updated, - Removed) 1.3.0 - 2022-xx-xx + + Dark theme + MIC levels * Bug fix: Sort bandwidth list - * General improvements + * General GUI and code improvements + NB2 * Bug fix: Sliders + Sub meter COMP, ID, VDD diff --git a/dialogsetup.cpp b/dialogsetup.cpp index 5360422..7b355b4 100644 --- a/dialogsetup.cpp +++ b/dialogsetup.cpp @@ -5,6 +5,7 @@ #include #include +#include extern guiConfig guiConf; @@ -17,6 +18,7 @@ DialogSetup::DialogSetup(QWidget *parent) : ui->setupUi(this); if (guiConf.vfoDisplayMode) ui->radioButton_vfoDispMode_UD->setChecked(true); + if (guiConf.darkTheme) ui->radioButton_themeDark->setChecked(true); } DialogSetup::~DialogSetup() @@ -24,20 +26,23 @@ DialogSetup::~DialogSetup() delete ui; } -void DialogSetup::on_radioButton_vfoDispMode_LR_toggled(bool checked) -{ - if (checked) guiConf.vfoDisplayMode=0; -} - -void DialogSetup::on_radioButton_vfoDispMode_UD_toggled(bool checked) -{ - if (checked) guiConf.vfoDisplayMode=1; -} - void DialogSetup::on_buttonBox_accepted() { + if ((guiConf.darkTheme != ui->radioButton_themeDark->isChecked())) + { + QMessageBox msgBox; + msgBox.setWindowTitle("Theme"); + msgBox.setText("Please, restart CatRadio to make effective the theme."); + msgBox.setIcon(QMessageBox::Information); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + } + + guiConf.vfoDisplayMode = ui->radioButton_vfoDispMode_UD->isChecked(); + guiConf.darkTheme = ui->radioButton_themeDark->isChecked(); + //* Save settings in catradio.ini QSettings configFile(QString("catradio.ini"), QSettings::IniFormat); configFile.setValue("vfoDisplayMode", guiConf.vfoDisplayMode); + configFile.setValue("darkTheme", guiConf.darkTheme); } - diff --git a/dialogsetup.h b/dialogsetup.h index c39b453..44f7e63 100644 --- a/dialogsetup.h +++ b/dialogsetup.h @@ -16,12 +16,6 @@ public: ~DialogSetup(); private slots: - - - void on_radioButton_vfoDispMode_LR_toggled(bool checked); - - void on_radioButton_vfoDispMode_UD_toggled(bool checked); - void on_buttonBox_accepted(); private: diff --git a/dialogsetup.ui b/dialogsetup.ui index 9a40c03..bc4754c 100644 --- a/dialogsetup.ui +++ b/dialogsetup.ui @@ -14,7 +14,7 @@ Setup - + Qt::Horizontal @@ -50,7 +50,7 @@ - + Qt::Vertical @@ -63,6 +63,32 @@ + + + + Theme + + + + + + Default + + + true + + + + + + + Dark + + + + + + diff --git a/guidata.h b/guidata.h index 0a794ab..751958b 100644 --- a/guidata.h +++ b/guidata.h @@ -6,6 +6,7 @@ typedef struct { int vfoDisplayMode; //0: use Left/Right mouse button, 1: click digit Up or Down + bool darkTheme; //flag for Dark theme } guiConfig; diff --git a/mainwindow.cpp b/mainwindow.cpp index 558a126..08d23fe 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent) rigCom.rigRefresh = configFile.value("rigRefresh", 100).toInt(); rigCom.fullPoll = configFile.value("fullPolling", true).toBool(); guiConf.vfoDisplayMode = configFile.value("vfoDisplayMode", 0).toInt(); + guiConf.darkTheme = configFile.value("darkTheme", false).toBool(); //Window settings restoreGeometry(configFile.value("WindowSettings/geometry").toByteArray()); restoreState(configFile.value("WindowSettings/state").toByteArray()); @@ -120,6 +121,39 @@ MainWindow::MainWindow(QWidget *parent) //* Style //ui->pushButton_PTT->setStyleSheet("QPushButton::checked {font: bold; color: red;}"); + //Dark theme + if (guiConf.darkTheme) + { + QFile darkStyleFile(":qdarkstyle/dark/darkstyle.qss"); + + if (!darkStyleFile.exists()) ui->statusbar->showMessage("Unable to set stylesheet, file not found!"); + else + { + darkStyleFile.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&darkStyleFile); + qApp->setStyleSheet(ts.readAll()); + + ui->progressBar_Smeter->setBgColor(Qt::black); + ui->progressBar_Smeter->setScaleColor(Qt::white); + ui->progressBar_Smeter->setLineColor(Qt::white); + ui->progressBar_Smeter->setProgressColor(QColor(0x66, 0x8f, 0xb8)); + + ui->progressBar_subMeter->setBgColor(Qt::black); + ui->progressBar_subMeter->setScaleColor(Qt::white); + ui->progressBar_subMeter->setLineColor(Qt::white); + ui->progressBar_subMeter->setProgressColor(Qt::blue); + + ui->lineEdit_vfoMain->setBgColor(Qt::black); + ui->lineEdit_vfoMain->setLineColor(Qt::white); + ui->lineEdit_vfoMain->setTextColor(Qt::white); + + ui->lineEdit_vfoSub->setBgColor(Qt::black); + ui->lineEdit_vfoSub->setLineColor(Qt::white); + ui->lineEdit_vfoSub->setTextColor(Qt::white); + } + } + //Light QFile darkStyleFile(":qdarkstyle/light/lightstyle.qss"); + QApplication::setWheelScrollLines(10); //Mouse wheel scroll step } diff --git a/mainwindow.ui b/mainwindow.ui index 68510f0..9597015 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -25,7 +25,7 @@ 610 - 601 + 605 @@ -1550,6 +1550,11 @@ 0 + + + 8 + + Comp @@ -1662,6 +1667,11 @@ 0 + + + 8 + + Mon diff --git a/smeter.cpp b/smeter.cpp index d23bfd8..ad26a6b 100644 --- a/smeter.cpp +++ b/smeter.cpp @@ -26,6 +26,7 @@ SMeter::SMeter(QWidget *parent) : QWidget(parent) lineColor = QColor(Qt::black); bgColor = QColor(Qt::white); progressColor = QColor(Qt::green); + scaleColor = QColor(Qt::black); //Default value minValue = 0; @@ -118,7 +119,7 @@ void SMeter::drawProgress(QPainter *painter) void SMeter::drawScalePWRMeter(QPainter *painter) { painter->save(); - painter->setPen(lineColor); + painter->setPen(scaleColor); double initX = 0; double initTopY = height()*2/3-2; @@ -190,7 +191,7 @@ void SMeter::drawScaleSMeter(QPainter *painter) double textHeight = meterFont.height(); painter->save(); - painter->setPen(lineColor); + painter->setPen(scaleColor); //Draw scale and scale values based on range values int longStep = 12; @@ -302,6 +303,26 @@ void SMeter::setPrecision(int value) update(); } +void SMeter::setBgColor(QColor color) +{ + bgColor = color; +} + +void SMeter::setLineColor(QColor color) +{ + lineColor = color; +} + +void SMeter::setProgressColor(QColor color) +{ + progressColor = color; +} + +void SMeter::setScaleColor(QColor color) +{ + scaleColor = color; +} + void SMeter::setValue(double value) { currentValue = value; diff --git a/smeter.h b/smeter.h index f35c0f3..107c93e 100644 --- a/smeter.h +++ b/smeter.h @@ -37,6 +37,11 @@ public slots: void setShortStep(double value); void setPrecision(int value); + void setBgColor(QColor color); + void setLineColor(QColor color); + void setProgressColor(QColor color); + void setScaleColor(QColor color); + void setValue(double value); void setValue(int value); @@ -65,6 +70,7 @@ private: QColor bgColor; //background color QColor lineColor; //line color QColor progressColor; //progress color + QColor scaleColor; //scale text color signals: diff --git a/submeter.cpp b/submeter.cpp index e37a886..1b5a734 100644 --- a/submeter.cpp +++ b/submeter.cpp @@ -27,6 +27,7 @@ SubMeter::SubMeter(QWidget *parent) : QWidget(parent) lineColor = QColor(Qt::black); bgColor = QColor(Qt::white); progressColor = QColor(Qt::green); + scaleColor = QColor(Qt::black); //Default value minValue = 0; @@ -118,7 +119,7 @@ void SubMeter::drawProgress(QPainter *painter) void SubMeter::drawScale(QPainter *painter) { painter->save(); - painter->setPen(lineColor); + painter->setPen(scaleColor); double initX = 0; double initTopY = height()*2/3-2; @@ -240,6 +241,26 @@ void SubMeter::setPrecision(int value) update(); } +void SubMeter::setBgColor(QColor color) +{ + bgColor = color; +} + +void SubMeter::setLineColor(QColor color) +{ + lineColor = color; +} + +void SubMeter::setProgressColor(QColor color) +{ + progressColor = color; +} + +void SubMeter::setScaleColor(QColor color) +{ + scaleColor = color; +} + void SubMeter::setValue(double value) { currentValue = value; diff --git a/submeter.h b/submeter.h index a4e1b29..52cf23a 100644 --- a/submeter.h +++ b/submeter.h @@ -36,6 +36,11 @@ public slots: void setShortStep(double value); void setPrecision(int value); + void setBgColor(QColor color); + void setLineColor(QColor color); + void setProgressColor(QColor color); + void setScaleColor(QColor color); + void setValue(double value); void setValue(int value); @@ -63,6 +68,7 @@ private: QColor bgColor; //background color QColor lineColor; //line color QColor progressColor; //progress color + QColor scaleColor; //scale text color signals: diff --git a/vfodisplay.cpp b/vfodisplay.cpp index 5265c8e..2b04054 100644 --- a/vfodisplay.cpp +++ b/vfodisplay.cpp @@ -95,6 +95,21 @@ void vfoDisplay::drawText(QPainter *painter) painter->restore(); } +void vfoDisplay::setBgColor(QColor color) +{ + bgColor = color; +} + +void vfoDisplay::setLineColor(QColor color) +{ + lineColor = color; +} + +void vfoDisplay::setTextColor(QColor color) +{ + textColor = color; +} + void vfoDisplay::setValue(unsigned long value) { currentValue = value; diff --git a/vfodisplay.h b/vfodisplay.h index 3006611..75373af 100644 --- a/vfodisplay.h +++ b/vfodisplay.h @@ -14,6 +14,10 @@ public slots: void setValue(unsigned long value); void setMode(int mode); + void setBgColor(QColor color); + void setLineColor(QColor color); + void setTextColor(QColor color); + signals: void on_valueChanged(int value);