Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,29 @@ int main(int argc, char *argv[])
QSettings set;
bool isDark = set.value("darkMode", true).toBool();
Utility::setDarkMode(isDark);
bool pureBlack = set.value("pureBlackDarkMode", false).toBool();
Utility::setPureBlack(pureBlack);
QPixmapCache::setCacheLimit(256000);

if (isDark) {
qputenv("QT_QUICK_CONTROLS_CONF", ":/qtquickcontrols2_dark.conf");

Utility::setAppQColor("lightestBackground", QColor(80,80,80));
Utility::setAppQColor("lightBackground", QColor(72,72,72));
Utility::setAppQColor("normalBackground", QColor(48,48,48));
Utility::setAppQColor("darkBackground", QColor(39,39,39));
Utility::setAppQColor("plotBackground", QColor(39,39,39));
if (pureBlack) {
qputenv("QT_QUICK_CONTROLS_MATERIAL_BACKGROUND", "#000000");
qputenv("QT_QUICK_CONTROLS_MATERIAL_DIALOG_COLOR", "#000000");

Utility::setAppQColor("lightestBackground", QColor(0,0,0));
Utility::setAppQColor("lightBackground", QColor(0,0,0));
Utility::setAppQColor("normalBackground", QColor(0,0,0));
Utility::setAppQColor("darkBackground", QColor(0,0,0));
Utility::setAppQColor("plotBackground", QColor(0,0,0));
} else {
Utility::setAppQColor("lightestBackground", QColor(80,80,80));
Utility::setAppQColor("lightBackground", QColor(72,72,72));
Utility::setAppQColor("normalBackground", QColor(48,48,48));
Utility::setAppQColor("darkBackground", QColor(39,39,39));
Utility::setAppQColor("plotBackground", QColor(39,39,39));
}
Utility::setAppQColor("normalText", QColor(180,180,180));
Utility::setAppQColor("lightText", QColor(215,215,215));
Utility::setAppQColor("disabledText", QColor(127,127,127));
Expand Down
14 changes: 13 additions & 1 deletion mobile/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import Vedder.vesc.utility 1.0

Item {
property bool mLastDarkMode: false
property bool mLastPureBlack: false
property var dialogParent: ApplicationWindow.overlay

function openDialog() {
mLastDarkMode = Utility.isDarkMode()
mLastPureBlack = Utility.isPureBlack()
dialog.open()
}

Expand Down Expand Up @@ -133,6 +135,16 @@ Item {
Utility.setDarkMode(checked)
}
}

CheckBox {
id: pureBlackBox
Layout.fillWidth: true
text: "Use Pure Black for Dark Mode"
checked: Utility.isPureBlack()
onCheckedChanged: {
Utility.setPureBlack(checked)
}
}
}
}

Expand Down Expand Up @@ -166,7 +178,7 @@ Item {
VescIf.setWakeLock(VescIf.isPortConnected())
}

if (Utility.isDarkMode() !== mLastDarkMode) {
if (Utility.isDarkMode() !== mLastDarkMode || Utility.isPureBlack() !== mLastPureBlack) {
darkChangedDialog.open()
}

Expand Down
13 changes: 13 additions & 0 deletions utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ QMap<QString, QColor> Utility::mAppColors = {
};

bool Utility::isDark = false;
bool Utility::mIsPureBlack = false;

Utility::Utility(QObject *parent) : QObject(parent)
{
Expand Down Expand Up @@ -2548,6 +2549,18 @@ bool Utility::isDarkMode()
return isDark;
}

void Utility::setPureBlack(bool pureBlackSetting)
{
mIsPureBlack = pureBlackSetting;
QSettings set;
set.setValue("pureBlackDarkMode", pureBlackSetting);
}

bool Utility::isPureBlack()
{
return mIsPureBlack;
}

QString Utility::getThemePath()
{
if (isDark) {
Expand Down
3 changes: 3 additions & 0 deletions utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class Utility : public QObject
Q_INVOKABLE static QString getAppHexColor(QString colorName);
Q_INVOKABLE static void setDarkMode(bool isDark);
Q_INVOKABLE static bool isDarkMode();
Q_INVOKABLE static void setPureBlack(bool pureBlack);
Q_INVOKABLE static bool isPureBlack();
Q_INVOKABLE static QString getThemePath();
Q_INVOKABLE static QVariantMap getSafeAreaMargins(QQuickWindow *window);

Expand Down Expand Up @@ -169,6 +171,7 @@ public slots:

static QMap<QString,QColor> mAppColors;
static bool isDark;
static bool mIsPureBlack;
};

#endif // UTILITY_H