Added initial dark mode theme using https://github.com/ColinDuquesnoy/

QDarkStyleSheet

--HG--
branch : develop
This commit is contained in:
Emmanuel Nyachoke 2018-10-29 15:05:49 +03:00
parent 0e9d789d90
commit 6d9105729f
54 changed files with 1668 additions and 252 deletions

View File

@ -53,6 +53,9 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare
//-------------------- Decimal separator setup //-------------------- Decimal separator setup
ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator()); ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator());
// Theme
ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode());
//---------------------- Pattern making system //---------------------- Pattern making system
ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing());
connect(ui->systemCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->systemCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
@ -122,6 +125,8 @@ void TapePreferencesConfigurationPage::Apply()
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
settings->SetDarkMode(ui->darkModeCheck->isChecked());
if (m_langChanged || m_systemChanged) if (m_langChanged || m_systemChanged)
{ {
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData()); const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>501</width> <width>501</width>
<height>550</height> <height>726</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -156,10 +156,10 @@
<string>Default height and size</string> <string>Default height and size</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="2"> <item row="0" column="0">
<widget class="QLabel" name="labelHeightUnit"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string notr="true">Height unit</string> <string>Default height:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -173,10 +173,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelHeightUnit">
<property name="text"> <property name="text">
<string>Default height:</string> <string notr="true">Height unit</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -234,17 +234,24 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="groupBox_4">
<property name="orientation"> <property name="title">
<enum>Qt::Vertical</enum> <string>User Interface</string>
</property> </property>
<property name="sizeHint" stdset="0"> <widget class="QCheckBox" name="darkModeCheck">
<size> <property name="geometry">
<width>20</width> <rect>
<height>40</height> <x>20</x>
</size> <y>30</y>
<width>351</width>
<height>20</height>
</rect>
</property> </property>
</spacer> <property name="text">
<string>Activate dark mode(Restart required)</string>
</property>
</widget>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -40,6 +40,7 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(icon); Q_INIT_RESOURCE(icon);
Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(schema);
Q_INIT_RESOURCE(flags); Q_INIT_RESOURCE(flags);
Q_INIT_RESOURCE(style);
QT_REQUIRE_VERSION(argc, argv, "5.2.0")// clazy:exclude=qstring-arg QT_REQUIRE_VERSION(argc, argv, "5.2.0")// clazy:exclude=qstring-arg

View File

@ -409,9 +409,30 @@ void MApplication::InitOptions()
//This does not happen under GNOME or KDE //This does not happen under GNOME or KDE
QIcon::setThemeName("win.icon.theme"); QIcon::setThemeName("win.icon.theme");
} }
ActivateDarkMode();
QResource::registerResource(diagramsPath()); QResource::registerResource(diagramsPath());
} }
// Dark mode
void MApplication::ActivateDarkMode()
{
VTapeSettings *settings = qApp->TapeSettings();
if (settings->GetDarkMode())
{
QFile f(":qdarkstyle/style.qss");
if (!f.exists())
{
qDebug()<<"Unable to set stylesheet, file not found\n";
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MApplication::InitTrVars() void MApplication::InitTrVars()

View File

@ -68,6 +68,7 @@ public:
virtual void OpenSettings() override; virtual void OpenSettings() override;
VTapeSettings *TapeSettings(); VTapeSettings *TapeSettings();
void ActivateDarkMode();
QString diagramsPath() const; QString diagramsPath() const;

View File

@ -276,7 +276,6 @@ VApplication::VApplication(int &argc, char **argv)
setOrganizationDomain(VER_COMPANYDOMAIN_STR); setOrganizationDomain(VER_COMPANYDOMAIN_STR);
// Setting the Application version // Setting the Application version
setApplicationVersion(APP_VERSION_STR); setApplicationVersion(APP_VERSION_STR);
// making sure will create new instance...just in case we will ever do 2 objects of VApplication // making sure will create new instance...just in case we will ever do 2 objects of VApplication
VCommandLine::Reset(); VCommandLine::Reset();
VCommandLine::Get(*this); VCommandLine::Get(*this);
@ -407,6 +406,27 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
return false; return false;
} }
void VApplication::ActivateDarkMode()
{
VSettings *settings = qApp->ValentinaSettings();
if (settings->GetDarkMode())
{
QFile f(":qdarkstyle/style.qss");
if (!f.exists())
{
qDebug()<<"Unable to set stylesheet, file not found\n";
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VApplication::TapeFilePath() const QString VApplication::TapeFilePath() const
{ {
@ -596,6 +616,7 @@ void VApplication::InitOptions()
//This does not happen under GNOME or KDE //This does not happen under GNOME or KDE
QIcon::setThemeName("win.icon.theme"); QIcon::setThemeName("win.icon.theme");
} }
ActivateDarkMode();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -66,6 +66,7 @@ public:
static QStringList LabelLanguages(); static QStringList LabelLanguages();
void StartLogging(); void StartLogging();
void ActivateDarkMode();
QTextStream *LogFile(); QTextStream *LogFile();
virtual const VTranslateVars *TrVars() override; virtual const VTranslateVars *TrVars() override;

View File

@ -124,6 +124,9 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
//----------------------- Toolbar //----------------------- Toolbar
ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle()); ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle());
// Theme
ui->darkModeCheck->setChecked(settings->GetDarkMode());
// Tab Scrolling // Tab Scrolling
ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin); ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin);
ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax); ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax);
@ -168,6 +171,7 @@ QStringList PreferencesConfigurationPage::Apply()
settings->SetOsSeparator(ui->osOptionCheck->isChecked()); settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
settings->SetDarkMode(ui->darkModeCheck->isChecked());
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked()); settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked()); settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked());

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>516</width> <width>516</width>
<height>691</height> <height>751</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -23,9 +23,15 @@
<attribute name="title"> <attribute name="title">
<string>General</string> <string>General</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="saveGroup"> <widget class="QGroupBox" name="saveGroup">
<property name="geometry">
<rect>
<x>20</x>
<y>0</y>
<width>441</width>
<height>70</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Save</string> <string>Save</string>
</property> </property>
@ -68,9 +74,15 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>441</width>
<height>173</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Language</string> <string>Language</string>
</property> </property>
@ -127,9 +139,15 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>20</x>
<y>243</y>
<width>446</width>
<height>185</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Pattern making system</string> <string>Pattern making system</string>
</property> </property>
@ -177,9 +195,15 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>20</x>
<y>428</y>
<width>451</width>
<height>131</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Pattern editing</string> <string>Pattern editing</string>
</property> </property>
@ -222,9 +246,15 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>20</x>
<y>560</y>
<width>451</width>
<height>71</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Toolbar</string> <string>Toolbar</string>
</property> </property>
@ -241,22 +271,32 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item> <widget class="QGroupBox" name="groupBox_8">
<property name="geometry">
<rect>
<x>20</x>
<y>630</y>
<width>446</width>
<height>71</height>
</rect>
</property>
<property name="title">
<string>User Interface</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<spacer name="verticalSpacer"> <widget class="QCheckBox" name="darkModeCheck">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Activate dark mode(Restart required)</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="checked">
<size> <bool>true</bool>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<widget class="QWidget" name="tabScrolling"> <widget class="QWidget" name="tabScrolling">
<attribute name="title"> <attribute name="title">
<string>Scrolling</string> <string>Scrolling</string>

View File

@ -45,6 +45,7 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(flags); Q_INIT_RESOURCE(flags);
Q_INIT_RESOURCE(icons); Q_INIT_RESOURCE(icons);
Q_INIT_RESOURCE(toolicon); Q_INIT_RESOURCE(toolicon);
Q_INIT_RESOURCE(style);
QT_REQUIRE_VERSION(argc, argv, "5.2.0")// clazy:exclude=qstring-arg,qstring-allocations QT_REQUIRE_VERSION(argc, argv, "5.2.0")// clazy:exclude=qstring-arg,qstring-allocations

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

View File

@ -0,0 +1,46 @@
<RCC>
<qresource prefix="qss_icons">
<file>rc/up_arrow_disabled.png</file>
<file>rc/Hmovetoolbar.png</file>
<file>rc/stylesheet-branch-end.png</file>
<file>rc/branch_closed-on.png</file>
<file>rc/stylesheet-vline.png</file>
<file>rc/branch_closed.png</file>
<file>rc/branch_open-on.png</file>
<file>rc/transparent.png</file>
<file>rc/right_arrow_disabled.png</file>
<file>rc/sizegrip.png</file>
<file>rc/close.png</file>
<file>rc/close-hover.png</file>
<file>rc/close-pressed.png</file>
<file>rc/down_arrow.png</file>
<file>rc/Vmovetoolbar.png</file>
<file>rc/left_arrow.png</file>
<file>rc/stylesheet-branch-more.png</file>
<file>rc/up_arrow.png</file>
<file>rc/right_arrow.png</file>
<file>rc/left_arrow_disabled.png</file>
<file>rc/Hsepartoolbar.png</file>
<file>rc/branch_open.png</file>
<file>rc/Vsepartoolbar.png</file>
<file>rc/down_arrow_disabled.png</file>
<file>rc/undock.png</file>
<file>rc/checkbox_checked_disabled.png</file>
<file>rc/checkbox_checked_focus.png</file>
<file>rc/checkbox_checked.png</file>
<file>rc/checkbox_indeterminate.png</file>
<file>rc/checkbox_indeterminate_focus.png</file>
<file>rc/checkbox_unchecked_disabled.png</file>
<file>rc/checkbox_unchecked_focus.png</file>
<file>rc/checkbox_unchecked.png</file>
<file>rc/radio_checked_disabled.png</file>
<file>rc/radio_checked_focus.png</file>
<file>rc/radio_checked.png</file>
<file>rc/radio_unchecked_disabled.png</file>
<file>rc/radio_unchecked_focus.png</file>
<file>rc/radio_unchecked.png</file>
</qresource>
<qresource prefix="qdarkstyle">
<file>style.qss</file>
</qresource>
</RCC>

File diff suppressed because it is too large Load Diff

View File

@ -81,6 +81,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralWindowState, (QLatin1String("windowState"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralWindowState, (QLatin1String("windowState")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize")))
@ -513,6 +514,19 @@ void VCommonSettings::SetToolBarStyle(const bool &value)
setValue(*settingConfigurationToolBarStyle, value); setValue(*settingConfigurationToolBarStyle, value);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetDarkMode() const
{
return value(*settingConfigurationDarkMode, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetDarkMode(const bool &value)
{
setValue(*settingConfigurationDarkMode, value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::IsFreeCurveMode() const bool VCommonSettings::IsFreeCurveMode() const
{ {

View File

@ -99,6 +99,9 @@ public:
bool GetToolBarStyle() const; bool GetToolBarStyle() const;
void SetToolBarStyle(const bool &value); void SetToolBarStyle(const bool &value);
bool GetDarkMode() const;
void SetDarkMode(const bool &value);
bool IsFreeCurveMode() const; bool IsFreeCurveMode() const;
void SetFreeCurveMode(bool value); void SetFreeCurveMode(bool value);

View File

@ -49,7 +49,8 @@ include(vmisc.pri)
RESOURCES += \ RESOURCES += \
share/resources/theme.qrc \ # Windows theme icons. share/resources/theme.qrc \ # Windows theme icons.
share/resources/icon.qrc \ # All other icons except cursors and Windows theme. share/resources/icon.qrc \ # All other icons except cursors and Windows theme.
share/resources/flags.qrc share/resources/flags.qrc \
share/resources/qdarkstyle/style.qrc
# This is static library so no need in "make install" # This is static library so no need in "make install"