commit
2bf2973a23
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "params.h"
|
#include "params.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "thememanager.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -84,6 +85,8 @@ int main(int argc, char* argv[])
|
|||||||
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
||||||
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
||||||
|
|
||||||
|
ThemeManager::instance()->setTheme(appSettings->value(kThemeKey).toString());
|
||||||
|
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
mainWindow = new MainWindow;
|
mainWindow = new MainWindow;
|
||||||
|
@ -128,12 +128,23 @@ SOURCES += \
|
|||||||
streamstatsmodel.cpp \
|
streamstatsmodel.cpp \
|
||||||
streamstatswindow.cpp \
|
streamstatswindow.cpp \
|
||||||
streamswidget.cpp \
|
streamswidget.cpp \
|
||||||
|
thememanager.cpp \
|
||||||
variablefieldswidget.cpp
|
variablefieldswidget.cpp
|
||||||
|
|
||||||
|
THEMES += \
|
||||||
|
themes/material-dark.qss \
|
||||||
|
themes/material-dark.rcc \
|
||||||
|
themes/material-light.qss \
|
||||||
|
themes/material-light.rcc \
|
||||||
|
themes/qds-dark.qss \
|
||||||
|
themes/qds-dark.rcc \
|
||||||
|
themes/qds-light.qss \
|
||||||
|
themes/qds-light.rcc \
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
|
||||||
include(../install.pri)
|
include(../install.pri)
|
||||||
|
include(../shared.pri)
|
||||||
include(../version.pri)
|
include(../version.pri)
|
||||||
include(../options.pri)
|
include(../options.pri)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "../common/ostprotolib.h"
|
#include "../common/ostprotolib.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "thememanager.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@ -40,6 +41,7 @@ Preferences::Preferences()
|
|||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
// Program paths
|
||||||
wiresharkPathEdit->setText(appSettings->value(kWiresharkPathKey,
|
wiresharkPathEdit->setText(appSettings->value(kWiresharkPathKey,
|
||||||
kWiresharkPathDefaultValue).toString());
|
kWiresharkPathDefaultValue).toString());
|
||||||
tsharkPathEdit->setText(appSettings->value(kTsharkPathKey,
|
tsharkPathEdit->setText(appSettings->value(kTsharkPathKey,
|
||||||
@ -51,6 +53,10 @@ Preferences::Preferences()
|
|||||||
awkPathEdit->setText(appSettings->value(kAwkPathKey,
|
awkPathEdit->setText(appSettings->value(kAwkPathKey,
|
||||||
kAwkPathDefaultValue).toString());
|
kAwkPathDefaultValue).toString());
|
||||||
|
|
||||||
|
// Theme
|
||||||
|
theme->addItems(ThemeManager::instance()->themeList());
|
||||||
|
theme->setCurrentText(appSettings->value(kThemeKey).toString());
|
||||||
|
|
||||||
// TODO(only if required): kUserKey
|
// TODO(only if required): kUserKey
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +84,7 @@ void Preferences::initDefaults()
|
|||||||
|
|
||||||
void Preferences::accept()
|
void Preferences::accept()
|
||||||
{
|
{
|
||||||
|
// Program paths
|
||||||
appSettings->setValue(kWiresharkPathKey, wiresharkPathEdit->text());
|
appSettings->setValue(kWiresharkPathKey, wiresharkPathEdit->text());
|
||||||
appSettings->setValue(kTsharkPathKey, tsharkPathEdit->text());
|
appSettings->setValue(kTsharkPathKey, tsharkPathEdit->text());
|
||||||
appSettings->setValue(kGzipPathKey, gzipPathEdit->text());
|
appSettings->setValue(kGzipPathKey, gzipPathEdit->text());
|
||||||
@ -90,6 +97,9 @@ void Preferences::accept()
|
|||||||
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
||||||
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
||||||
|
|
||||||
|
// Theme
|
||||||
|
ThemeManager::instance()->setTheme(theme->currentText());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
<class>Preferences</class>
|
<class>Preferences</class>
|
||||||
<widget class="QDialog" name="Preferences" >
|
<widget class="QDialog" name="Preferences">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
@ -9,148 +10,149 @@
|
|||||||
<height>220</height>
|
<height>220</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>Preferences</string>
|
<string>Preferences</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon" >
|
<property name="windowIcon">
|
||||||
<iconset resource="ostinato.qrc" >:/icons/preferences.png</iconset>
|
<iconset resource="ostinato.qrc">
|
||||||
|
<normaloff>:/icons/preferences.png</normaloff>:/icons/preferences.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame" >
|
<widget class="QFrame" name="frame">
|
||||||
<property name="frameShape" >
|
<property name="frameShape">
|
||||||
<enum>QFrame::Box</enum>
|
<enum>QFrame::Box</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow" >
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>'wireshark' Path</string>
|
<string>'wireshark' Path</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>wiresharkPathEdit</cstring>
|
<cstring>wiresharkPathEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="wiresharkPathEdit" >
|
<widget class="QLineEdit" name="wiresharkPathEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" >
|
<item row="0" column="2">
|
||||||
<widget class="QToolButton" name="wiresharkPathButton" >
|
<widget class="QToolButton" name="wiresharkPathButton">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>'tshark' Path</string>
|
<string>'tshark' Path</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>tsharkPathEdit</cstring>
|
<cstring>tsharkPathEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="tsharkPathEdit" >
|
<widget class="QLineEdit" name="tsharkPathEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2" >
|
<item row="1" column="2">
|
||||||
<widget class="QToolButton" name="tsharkPathButton" >
|
<widget class="QToolButton" name="tsharkPathButton">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_5" >
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>'gzip' Path</string>
|
<string>'gzip' Path</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>diffPathEdit</cstring>
|
<cstring>diffPathEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="gzipPathEdit" >
|
<widget class="QLineEdit" name="gzipPathEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2" >
|
<item row="2" column="2">
|
||||||
<widget class="QToolButton" name="gzipPathButton" >
|
<widget class="QToolButton" name="gzipPathButton">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" >
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>'diff' Path</string>
|
<string>'diff' Path</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>diffPathEdit</cstring>
|
<cstring>diffPathEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" >
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="diffPathEdit" >
|
<widget class="QLineEdit" name="diffPathEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2" >
|
<item row="3" column="2">
|
||||||
<widget class="QToolButton" name="diffPathButton" >
|
<widget class="QToolButton" name="diffPathButton">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" >
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_4" >
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>'awk' Path</string>
|
<string>'awk' Path</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>awkPathEdit</cstring>
|
<cstring>awkPathEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1" >
|
<item row="4" column="1">
|
||||||
<widget class="QLineEdit" name="awkPathEdit" >
|
<widget class="QLineEdit" name="awkPathEdit">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2" >
|
<item row="4" column="2">
|
||||||
<widget class="QToolButton" name="awkPathButton" >
|
<widget class="QToolButton" name="awkPathButton">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1" >
|
<item row="5" column="1">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>21</width>
|
<width>21</width>
|
||||||
<height>61</height>
|
<height>61</height>
|
||||||
@ -162,12 +164,26 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation" >
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Theme (Experimental)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="theme"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons" >
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -187,7 +203,7 @@
|
|||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="ostinato.qrc" />
|
<include location="ostinato.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
@ -196,11 +212,11 @@
|
|||||||
<receiver>Preferences</receiver>
|
<receiver>Preferences</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel">
|
||||||
<x>248</x>
|
<x>248</x>
|
||||||
<y>254</y>
|
<y>254</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>157</x>
|
||||||
<y>274</y>
|
<y>274</y>
|
||||||
</hint>
|
</hint>
|
||||||
@ -212,11 +228,11 @@
|
|||||||
<receiver>Preferences</receiver>
|
<receiver>Preferences</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel">
|
||||||
<x>316</x>
|
<x>316</x>
|
||||||
<y>260</y>
|
<y>260</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
<y>274</y>
|
<y>274</y>
|
||||||
</hint>
|
</hint>
|
||||||
|
@ -74,6 +74,8 @@ const QString kAwkPathDefaultValue("/usr/bin/awk");
|
|||||||
const QString kAwkPathDefaultValue("/usr/bin/awk");
|
const QString kAwkPathDefaultValue("/usr/bin/awk");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const QString kThemeKey("Theme");
|
||||||
|
|
||||||
const QString kUserKey("User");
|
const QString kUserKey("User");
|
||||||
extern QString kUserDefaultValue;
|
extern QString kUserDefaultValue;
|
||||||
|
|
||||||
|
130
client/thememanager.cpp
Normal file
130
client/thememanager.cpp
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2021 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "thememanager.h"
|
||||||
|
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QResource>
|
||||||
|
|
||||||
|
ThemeManager *ThemeManager::instance_{nullptr};
|
||||||
|
|
||||||
|
ThemeManager::ThemeManager()
|
||||||
|
{
|
||||||
|
themeDir_ = QCoreApplication::applicationDirPath() + "/themes/";
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
/*
|
||||||
|
* Executable and Theme directory location inside app bundle -
|
||||||
|
* Ostinato.app/Contents/MacOS/
|
||||||
|
* Ostinato.app/Contents/SharedSupport/themes/
|
||||||
|
*/
|
||||||
|
themeDir_.replace("/MacOS/", "/SharedSupport/");
|
||||||
|
#elif defined(Q_OS_UNIX)
|
||||||
|
/*
|
||||||
|
* Possible (but not comprehensive) locations for Ostinato executable
|
||||||
|
* and theme directory locations
|
||||||
|
*
|
||||||
|
* non-install-dir/
|
||||||
|
* non-install-dir/themes/
|
||||||
|
*
|
||||||
|
* /usr/[local]/bin/
|
||||||
|
* /usr/[local]/share/ostinato/themes/
|
||||||
|
*
|
||||||
|
* /opt/ostinato/bin/
|
||||||
|
* /opt/ostinato/share/themes/
|
||||||
|
*/
|
||||||
|
if (themeDir_.contains(QRegularExpression("^/usr/.*/bin/")))
|
||||||
|
themeDir_.replace("/bin/", "/share/ostinato/");
|
||||||
|
else if (themeDir_.contains(QRegularExpression("^/opt/.*/bin/")))
|
||||||
|
themeDir_.replace("/bin/", "/share/");
|
||||||
|
#endif
|
||||||
|
qDebug("Themes directory: %s", qPrintable(themeDir_));
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ThemeManager::themeList()
|
||||||
|
{
|
||||||
|
QDir themeDir(themeDir_);
|
||||||
|
|
||||||
|
themeDir.setFilter(QDir::Files);
|
||||||
|
themeDir.setNameFilters(QStringList() << "*.qss");
|
||||||
|
themeDir.setSorting(QDir::Name);
|
||||||
|
|
||||||
|
QStringList themes = themeDir.entryList();
|
||||||
|
for (QString& theme : themes)
|
||||||
|
theme.remove(".qss");
|
||||||
|
themes.prepend("default");
|
||||||
|
|
||||||
|
return themes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemeManager::setTheme(QString theme)
|
||||||
|
{
|
||||||
|
// Remove current theme, if we have one
|
||||||
|
QString oldTheme = appSettings->value(kThemeKey).toString();
|
||||||
|
if (!oldTheme.isEmpty()) {
|
||||||
|
// Remove stylesheet first so that there are
|
||||||
|
// no references to resources when unregistering 'em
|
||||||
|
qApp->setStyleSheet("");
|
||||||
|
QString rccFile = themeDir_ + oldTheme + ".rcc";
|
||||||
|
if (QResource::unregisterResource(rccFile)) {
|
||||||
|
qDebug("Unable to unregister theme rccFile %s",
|
||||||
|
qPrintable(rccFile));
|
||||||
|
}
|
||||||
|
appSettings->setValue(kThemeKey, QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theme.isEmpty() || (theme == "default"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Apply new theme
|
||||||
|
QFile qssFile(themeDir_ + theme + ".qss");
|
||||||
|
if (!qssFile.open(QFile::ReadOnly)) {
|
||||||
|
qDebug("Unable to open theme qssFile %s",
|
||||||
|
qPrintable(qssFile.fileName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register theme resource before applying theme style sheet
|
||||||
|
QString rccFile = themeDir_ + theme + ".rcc";
|
||||||
|
if (!QResource::registerResource(rccFile))
|
||||||
|
qDebug("Unable to register theme rccFile %s", qPrintable(rccFile));
|
||||||
|
|
||||||
|
#if 0 // FIXME: debug only
|
||||||
|
QDirIterator it(":", QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
qDebug() << it.next();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString styleSheet { qssFile.readAll() };
|
||||||
|
qApp->setStyleSheet(styleSheet);
|
||||||
|
appSettings->setValue(kThemeKey, theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
ThemeManager* ThemeManager::instance()
|
||||||
|
{
|
||||||
|
if (!instance_)
|
||||||
|
instance_ = new ThemeManager();
|
||||||
|
return instance_;
|
||||||
|
}
|
42
client/thememanager.h
Normal file
42
client/thememanager.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2021 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _THEME_MANAGER_H
|
||||||
|
#define _THEME_MANAGER_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
class ThemeManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ThemeManager();
|
||||||
|
|
||||||
|
QStringList themeList();
|
||||||
|
void setTheme(QString theme);
|
||||||
|
|
||||||
|
static ThemeManager* instance();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString themeDir_;
|
||||||
|
|
||||||
|
static ThemeManager *instance_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
1307
client/themes/material-dark.qss
Normal file
1307
client/themes/material-dark.qss
Normal file
File diff suppressed because it is too large
Load Diff
BIN
client/themes/material-dark.rcc
Normal file
BIN
client/themes/material-dark.rcc
Normal file
Binary file not shown.
1307
client/themes/material-light.qss
Normal file
1307
client/themes/material-light.qss
Normal file
File diff suppressed because it is too large
Load Diff
BIN
client/themes/material-light.rcc
Normal file
BIN
client/themes/material-light.rcc
Normal file
Binary file not shown.
2213
client/themes/qds-dark.qss
Normal file
2213
client/themes/qds-dark.qss
Normal file
File diff suppressed because it is too large
Load Diff
BIN
client/themes/qds-dark.rcc
Normal file
BIN
client/themes/qds-dark.rcc
Normal file
Binary file not shown.
2213
client/themes/qds-light.qss
Normal file
2213
client/themes/qds-light.qss
Normal file
File diff suppressed because it is too large
Load Diff
BIN
client/themes/qds-light.rcc
Normal file
BIN
client/themes/qds-light.rcc
Normal file
Binary file not shown.
29
shared.pri
Normal file
29
shared.pri
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#
|
||||||
|
# Qt qmake integration for installing files other than executables
|
||||||
|
# Author: Srivats P
|
||||||
|
#
|
||||||
|
# To install files other than executables, specify them in SHARED variable
|
||||||
|
# and include this file AFTER install.pri
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# SHARED = file1 file2
|
||||||
|
# include(install.pri)
|
||||||
|
# include(shared.pri)
|
||||||
|
#
|
||||||
|
|
||||||
|
macx {
|
||||||
|
shared.path = $${PREFIX}/Ostinato/Ostinato.app/Contents/SharedSupport/
|
||||||
|
} else: unix {
|
||||||
|
shared.path = $${PREFIX}/share/ostinato/
|
||||||
|
} else {
|
||||||
|
shared.path = $${PREFIX}/bin
|
||||||
|
}
|
||||||
|
shared.files = $${SHARED}
|
||||||
|
|
||||||
|
INSTALLS += shared
|
||||||
|
|
||||||
|
# Themes - need a subdir inside shared
|
||||||
|
themes.files = $${THEMES}
|
||||||
|
themes.path = $${shared.path}/themes
|
||||||
|
|
||||||
|
INSTALLS += themes
|
Loading…
Reference in New Issue
Block a user