Qt: Add theme selection and dark theme
|
@ -3,7 +3,7 @@ set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
add_executable(duckstation-qt
|
add_executable(duckstation-qt
|
||||||
resources/icons.qrc
|
resources/resources.qrc
|
||||||
aboutdialog.cpp
|
aboutdialog.cpp
|
||||||
aboutdialog.h
|
aboutdialog.h
|
||||||
advancedsettingswidget.cpp
|
advancedsettingswidget.cpp
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
</QtUi>
|
</QtUi>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtResource Include="resources\icons.qrc">
|
<QtResource Include="resources\resources.qrc">
|
||||||
<FileType>Document</FileType>
|
<FileType>Document</FileType>
|
||||||
</QtResource>
|
</QtResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
<ClCompile Include="$(IntDir)moc_qthostinterface.cpp" />
|
<ClCompile Include="$(IntDir)moc_qthostinterface.cpp" />
|
||||||
<ClCompile Include="$(IntDir)moc_qtprogresscallback.cpp" />
|
<ClCompile Include="$(IntDir)moc_qtprogresscallback.cpp" />
|
||||||
<ClCompile Include="$(IntDir)moc_settingsdialog.cpp" />
|
<ClCompile Include="$(IntDir)moc_settingsdialog.cpp" />
|
||||||
<ClCompile Include="$(IntDir)qrc_icons.cpp" />
|
<ClCompile Include="$(IntDir)qrc_resources.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Natvis Include="qt5.natvis" />
|
<Natvis Include="qt5.natvis" />
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "settingwidgetbinder.h"
|
#include "settingwidgetbinder.h"
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtGui/QCursor>
|
#include <QtGui/QCursor>
|
||||||
|
@ -40,6 +41,7 @@ MainWindow::MainWindow(QtHostInterface* host_interface) : QMainWindow(nullptr),
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setupAdditionalUi();
|
setupAdditionalUi();
|
||||||
connectSignals();
|
connectSignals();
|
||||||
|
updateTheme();
|
||||||
|
|
||||||
resize(800, 700);
|
resize(800, 700);
|
||||||
}
|
}
|
||||||
|
@ -603,6 +605,52 @@ void MainWindow::connectSignals()
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowTimersState,
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowTimersState,
|
||||||
"Debug/ShowTimersState");
|
"Debug/ShowTimersState");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowMDECState, "Debug/ShowMDECState");
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowMDECState, "Debug/ShowMDECState");
|
||||||
|
|
||||||
|
addThemeToMenu(tr("Default"), QStringLiteral("default"));
|
||||||
|
addThemeToMenu(tr("Dark"), QStringLiteral("qdarkstyle"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::addThemeToMenu(const QString& name, const QString& key)
|
||||||
|
{
|
||||||
|
QAction* action = m_ui.menuSettingsTheme->addAction(name);
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setData(key);
|
||||||
|
connect(action, &QAction::toggled, [this, key](bool) { setTheme(key); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setTheme(const QString& theme)
|
||||||
|
{
|
||||||
|
m_host_interface->putSettingValue(QStringLiteral("UI/Theme"), theme);
|
||||||
|
updateTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateTheme()
|
||||||
|
{
|
||||||
|
QString theme = m_host_interface->getSettingValue(QStringLiteral("UI/Theme"), QStringLiteral("default")).toString();
|
||||||
|
if (theme == QStringLiteral("qdarkstyle"))
|
||||||
|
{
|
||||||
|
QFile f(QStringLiteral(":qdarkstyle/style.qss"));
|
||||||
|
if (f.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
qApp->setStyleSheet(f.readAll());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qApp->setStyleSheet(QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (QObject* obj : m_ui.menuSettingsTheme->children())
|
||||||
|
{
|
||||||
|
QAction* action = qobject_cast<QAction*>(obj);
|
||||||
|
if (action)
|
||||||
|
{
|
||||||
|
QVariant action_data(action->data());
|
||||||
|
if (action_data.isValid())
|
||||||
|
{
|
||||||
|
QSignalBlocker blocker(action);
|
||||||
|
action->setChecked(action_data == theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog* MainWindow::getSettingsDialog()
|
SettingsDialog* MainWindow::getSettingsDialog()
|
||||||
|
|
|
@ -35,6 +35,9 @@ private Q_SLOTS:
|
||||||
void destroyDisplay();
|
void destroyDisplay();
|
||||||
void focusDisplayWidget();
|
void focusDisplayWidget();
|
||||||
|
|
||||||
|
void setTheme(const QString& theme);
|
||||||
|
void updateTheme();
|
||||||
|
|
||||||
void onEmulationStarting();
|
void onEmulationStarting();
|
||||||
void onEmulationStarted();
|
void onEmulationStarted();
|
||||||
void onEmulationStopped();
|
void onEmulationStopped();
|
||||||
|
@ -65,6 +68,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void setupAdditionalUi();
|
void setupAdditionalUi();
|
||||||
void connectSignals();
|
void connectSignals();
|
||||||
|
void addThemeToMenu(const QString& name, const QString& key);
|
||||||
void updateEmulationActions(bool starting, bool running);
|
void updateEmulationActions(bool starting, bool running);
|
||||||
void switchToGameListView();
|
void switchToGameListView();
|
||||||
void switchToEmulationView();
|
void switchToEmulationView();
|
||||||
|
|
|
@ -85,6 +85,11 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>S&ettings</string>
|
<string>S&ettings</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuSettingsTheme">
|
||||||
|
<property name="title">
|
||||||
|
<string>Theme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="actionFullscreen"/>
|
<addaction name="actionFullscreen"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionGeneralSettings"/>
|
<addaction name="actionGeneralSettings"/>
|
||||||
|
@ -101,6 +106,7 @@
|
||||||
<addaction name="actionScanForNewGames"/>
|
<addaction name="actionScanForNewGames"/>
|
||||||
<addaction name="actionRescanAllGames"/>
|
<addaction name="actionRescanAllGames"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="menuSettingsTheme"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down.png
Normal file
After Width: | Height: | Size: 525 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down@2x.png
Normal file
After Width: | Height: | Size: 977 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down_disabled.png
Normal file
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down_focus.png
Normal file
After Width: | Height: | Size: 530 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down_focus@2x.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_down_pressed.png
Normal file
After Width: | Height: | Size: 518 B |
After Width: | Height: | Size: 1,007 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left.png
Normal file
After Width: | Height: | Size: 546 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left@2x.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left_disabled.png
Normal file
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left_focus.png
Normal file
After Width: | Height: | Size: 565 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left_focus@2x.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_left_pressed.png
Normal file
After Width: | Height: | Size: 541 B |
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right@2x.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right_disabled.png
Normal file
After Width: | Height: | Size: 553 B |
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right_focus.png
Normal file
After Width: | Height: | Size: 543 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right_focus@2x.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_right_pressed.png
Normal file
After Width: | Height: | Size: 544 B |
After Width: | Height: | Size: 1.1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up.png
Normal file
After Width: | Height: | Size: 512 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up@2x.png
Normal file
After Width: | Height: | Size: 969 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_disabled.png
Normal file
After Width: | Height: | Size: 538 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_disabled@2x.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_focus.png
Normal file
After Width: | Height: | Size: 530 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_focus@2x.png
Normal file
After Width: | Height: | Size: 1,017 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_pressed.png
Normal file
After Width: | Height: | Size: 518 B |
BIN
src/duckstation-qt/resources/qdarkstyle/arrow_up_pressed@2x.png
Normal file
After Width: | Height: | Size: 998 B |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon@2x.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon_disabled.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon_focus.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon_focus@2x.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon_pressed.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/base_icon_pressed@2x.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_closed.png
Normal file
After Width: | Height: | Size: 350 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_closed@2x.png
Normal file
After Width: | Height: | Size: 704 B |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 729 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_closed_focus.png
Normal file
After Width: | Height: | Size: 380 B |
After Width: | Height: | Size: 717 B |
After Width: | Height: | Size: 372 B |
After Width: | Height: | Size: 725 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end.png
Normal file
After Width: | Height: | Size: 142 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end@2x.png
Normal file
After Width: | Height: | Size: 220 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end_disabled.png
Normal file
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 225 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end_focus.png
Normal file
After Width: | Height: | Size: 146 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end_focus@2x.png
Normal file
After Width: | Height: | Size: 226 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_end_pressed.png
Normal file
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 225 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line.png
Normal file
After Width: | Height: | Size: 130 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line@2x.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line_disabled.png
Normal file
After Width: | Height: | Size: 134 B |
After Width: | Height: | Size: 248 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line_focus.png
Normal file
After Width: | Height: | Size: 134 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line_focus@2x.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_line_pressed.png
Normal file
After Width: | Height: | Size: 134 B |
After Width: | Height: | Size: 248 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more.png
Normal file
After Width: | Height: | Size: 155 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more@2x.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more_disabled.png
Normal file
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 265 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more_focus.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more_focus@2x.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_more_pressed.png
Normal file
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 265 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open@2x.png
Normal file
After Width: | Height: | Size: 657 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open_disabled.png
Normal file
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 682 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open_focus.png
Normal file
After Width: | Height: | Size: 367 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open_focus@2x.png
Normal file
After Width: | Height: | Size: 665 B |
BIN
src/duckstation-qt/resources/qdarkstyle/branch_open_pressed.png
Normal file
After Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 661 B |
BIN
src/duckstation-qt/resources/qdarkstyle/checkbox_checked.png
Normal file
After Width: | Height: | Size: 452 B |
BIN
src/duckstation-qt/resources/qdarkstyle/checkbox_checked@2x.png
Normal file
After Width: | Height: | Size: 825 B |
After Width: | Height: | Size: 467 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 441 B |
After Width: | Height: | Size: 823 B |
After Width: | Height: | Size: 418 B |
After Width: | Height: | Size: 829 B |
After Width: | Height: | Size: 581 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 1 KiB |
After Width: | Height: | Size: 563 B |