mirror of https://github.com/EspoTek/Labrador.git
Dark Mode
This commit is contained in:
parent
2aa9340c03
commit
19454671e2
|
@ -31,6 +31,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
|
defaultPalette = qApp->palette();
|
||||||
|
defaultStyleName = qApp->style()->objectName();
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName(kOrganisationName);
|
QCoreApplication::setOrganizationName(kOrganisationName);
|
||||||
QCoreApplication::setApplicationName(kApplicationName);
|
QCoreApplication::setApplicationName(kApplicationName);
|
||||||
|
|
||||||
|
@ -1247,6 +1250,12 @@ void MainWindow::readSettingsFile(){
|
||||||
ui->actionShow_Range_Dialog_on_Main_Page->setChecked(true);
|
ui->actionShow_Range_Dialog_on_Main_Page->setChecked(true);
|
||||||
on_actionShow_Range_Dialog_on_Main_Page_triggered(true);
|
on_actionShow_Range_Dialog_on_Main_Page_triggered(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(settings->value("DarkModeEnabled").toBool())
|
||||||
|
{
|
||||||
|
ui->actionDark_Mode->setChecked(true);
|
||||||
|
setDarkMode(true);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
daq_num_to_average = settings->value("daq_defaultAverage", 1).toInt();
|
daq_num_to_average = settings->value("daq_defaultAverage", 1).toInt();
|
||||||
|
@ -2511,3 +2520,50 @@ void MainWindow::on_actionHide_Widget_LogicAnalyzer_triggered(bool checked)
|
||||||
ui->busSnifferGroup_CH2->setVisible(!checked);
|
ui->busSnifferGroup_CH2->setVisible(!checked);
|
||||||
ui->digitalOutputGroup->setVisible(!checked);
|
ui->digitalOutputGroup->setVisible(!checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Thanks Medo
|
||||||
|
// https://www.medo64.com/2020/08/dark-mode-for-qt-application/
|
||||||
|
void MainWindow::setDarkMode(bool dark)
|
||||||
|
{
|
||||||
|
if(dark)
|
||||||
|
{
|
||||||
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
|
||||||
|
QPalette newPalette;
|
||||||
|
newPalette.setColor(QPalette::Window, QColor( 37, 37, 37));
|
||||||
|
newPalette.setColor(QPalette::WindowText, QColor(212, 212, 212));
|
||||||
|
newPalette.setColor(QPalette::Base, QColor( 60, 60, 60));
|
||||||
|
newPalette.setColor(QPalette::AlternateBase, QColor( 45, 45, 45));
|
||||||
|
newPalette.setColor(QPalette::PlaceholderText, QColor(127, 127, 127));
|
||||||
|
newPalette.setColor(QPalette::Text, QColor(212, 212, 212));
|
||||||
|
newPalette.setColor(QPalette::Button, QColor( 45, 45, 45));
|
||||||
|
newPalette.setColor(QPalette::ButtonText, QColor(212, 212, 212));
|
||||||
|
newPalette.setColor(QPalette::BrightText, QColor(240, 240, 240));
|
||||||
|
newPalette.setColor(QPalette::Highlight, QColor( 38, 79, 120));
|
||||||
|
newPalette.setColor(QPalette::HighlightedText, QColor(240, 240, 240));
|
||||||
|
|
||||||
|
newPalette.setColor(QPalette::Light, QColor( 60, 60, 60));
|
||||||
|
newPalette.setColor(QPalette::Midlight, QColor( 52, 52, 52));
|
||||||
|
newPalette.setColor(QPalette::Dark, QColor( 30, 30, 30) );
|
||||||
|
newPalette.setColor(QPalette::Mid, QColor( 37, 37, 37));
|
||||||
|
newPalette.setColor(QPalette::Shadow, QColor( 0, 0, 0));
|
||||||
|
|
||||||
|
newPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
|
||||||
|
|
||||||
|
qApp->setPalette(newPalette);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qApp->setStyle(defaultStyleName);
|
||||||
|
qApp->setPalette(defaultPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("DarkModeEnabled", dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_actionDark_Mode_triggered(bool checked)
|
||||||
|
{
|
||||||
|
setDarkMode(checked);
|
||||||
|
}
|
||||||
|
|
|
@ -227,6 +227,8 @@ private slots:
|
||||||
|
|
||||||
void on_actionHide_Widget_LogicAnalyzer_triggered(bool checked);
|
void on_actionHide_Widget_LogicAnalyzer_triggered(bool checked);
|
||||||
|
|
||||||
|
void on_actionDark_Mode_triggered(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Generic Vars
|
//Generic Vars
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
@ -247,12 +249,16 @@ private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
bool calibrationCanceled = false;
|
bool calibrationCanceled = false;
|
||||||
|
|
||||||
|
QPalette defaultPalette;
|
||||||
|
QString defaultStyleName;
|
||||||
|
|
||||||
//Generic Functions
|
//Generic Functions
|
||||||
void initialisePlot();
|
void initialisePlot();
|
||||||
void labelPsu();
|
void labelPsu();
|
||||||
void menuSetup();
|
void menuSetup();
|
||||||
void initShortcuts();
|
void initShortcuts();
|
||||||
void readSettingsFile();
|
void readSettingsFile();
|
||||||
|
void setDarkMode(bool dark);
|
||||||
|
|
||||||
//Shortcut pointers
|
//Shortcut pointers
|
||||||
QActionGroup *gainGroup;
|
QActionGroup *gainGroup;
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
#include "deviceconnecteddisplay.h"
|
#include "deviceconnecteddisplay.h"
|
||||||
#include "platformspecific.h"
|
#include "platformspecific.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
deviceConnectedDisplay::deviceConnectedDisplay(QWidget *parent) : QLabel(parent)
|
deviceConnectedDisplay::deviceConnectedDisplay(QWidget *parent) : QLabel(parent)
|
||||||
{
|
{
|
||||||
this->setText("Device Not Connected!");
|
setText("Device Not Connected!");
|
||||||
this->setStyleSheet("QLabel { color:red; }");
|
setStyleSheet("QLabel { color:red; }");
|
||||||
}
|
}
|
||||||
|
|
||||||
void deviceConnectedDisplay::connectedStatusChanged(bool status){
|
void deviceConnectedDisplay::connectedStatusChanged(bool status){
|
||||||
qDebug() << "deviceConnectedDisplay::connectedStatusChanged running!";
|
qDebug() << "deviceConnectedDisplay::connectedStatusChanged running!";
|
||||||
if(status){
|
if(status){
|
||||||
this->setText("Device Connected");
|
setText("Device Connected");
|
||||||
this->setStyleSheet("QLabel { color:black; }");
|
setStyleSheet("");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this->setText("Device Not Connected!");
|
setText("Device Not Connected!");
|
||||||
this->setStyleSheet("QLabel { color:red; }");
|
setStyleSheet("QLabel { color:red; }");
|
||||||
}
|
}
|
||||||
#ifdef PLATFORM_ANDROID
|
#ifdef PLATFORM_ANDROID
|
||||||
this->setVisible(!status);
|
this->setVisible(!status);
|
||||||
|
@ -24,6 +25,6 @@ void deviceConnectedDisplay::connectedStatusChanged(bool status){
|
||||||
|
|
||||||
void deviceConnectedDisplay::flashingFirmware(void){
|
void deviceConnectedDisplay::flashingFirmware(void){
|
||||||
qDebug() << "deviceConnectedDisplay::flashingFirmware";
|
qDebug() << "deviceConnectedDisplay::flashingFirmware";
|
||||||
this->setText("Flashing Device Firmware");
|
setText("Flashing Device Firmware");
|
||||||
this->setStyleSheet("QLabel { color:green; }");
|
setStyleSheet("QLabel { color:green; }");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1797,6 +1797,12 @@
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionHide_Widget_SignalGen"/>
|
<addaction name="actionHide_Widget_SignalGen"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuAccessibility">
|
||||||
|
<property name="title">
|
||||||
|
<string>Accessibility</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionDark_Mode"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuOscilloscope_2"/>
|
<addaction name="menuOscilloscope_2"/>
|
||||||
<addaction name="menuSignal_Generator"/>
|
<addaction name="menuSignal_Generator"/>
|
||||||
|
@ -1805,6 +1811,7 @@
|
||||||
<addaction name="menuPower_Supply"/>
|
<addaction name="menuPower_Supply"/>
|
||||||
<addaction name="menuConnection_Type"/>
|
<addaction name="menuConnection_Type"/>
|
||||||
<addaction name="menuHelp"/>
|
<addaction name="menuHelp"/>
|
||||||
|
<addaction name="menuAccessibility"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionGainAuto">
|
<action name="actionGainAuto">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -2629,6 +2636,14 @@
|
||||||
<string>Hide Widget</string>
|
<string>Hide Widget</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionDark_Mode">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Dark Mode</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
Loading…
Reference in New Issue