From 7fc43d2fc6b466ab742e7531c7f93f2adc2f767a Mon Sep 17 00:00:00 2001 From: ronso0 Date: Wed, 8 Nov 2023 14:17:01 +0100 Subject: [PATCH 1/2] skins: read updated skins/default.qss without requiring a rebuild --- src/mixxxmainwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index 2df5f1f0f9e..32008ddc8eb 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -315,13 +315,14 @@ void MixxxMainWindow::initialize() { QWidget* oldWidget = m_pCentralWidget; // Load default styles that can be overridden by skins - QFile file(":/skins/default.qss"); + const QString resPath = m_pCoreServices->getSettings()->getResourcePath(); + QFile file(resPath + "/skins/default.qss"); if (file.open(QIODevice::ReadOnly)) { QByteArray fileBytes = file.readAll(); QString style = QString::fromLocal8Bit(fileBytes); setStyleSheet(style); } else { - qWarning() << "Failed to load default skin styles!"; + qWarning() << "Failed to load default skin styles /skins/default.qss!"; } if (!loadConfiguredSkin()) { From 2608a9d1e9a5b37e4895033ee58ce2f1d9c44fbc Mon Sep 17 00:00:00 2001 From: ronso0 Date: Wed, 8 Nov 2023 14:18:22 +0100 Subject: [PATCH 2/2] skins: reload default.qss when (re)loading a skin, read in member function --- src/mixxxmainwindow.cpp | 26 ++++++++++++++++---------- src/mixxxmainwindow.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index 32008ddc8eb..c427a611845 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -314,16 +314,7 @@ void MixxxMainWindow::initialize() { QWidget* oldWidget = m_pCentralWidget; - // Load default styles that can be overridden by skins - const QString resPath = m_pCoreServices->getSettings()->getResourcePath(); - QFile file(resPath + "/skins/default.qss"); - if (file.open(QIODevice::ReadOnly)) { - QByteArray fileBytes = file.readAll(); - QString style = QString::fromLocal8Bit(fileBytes); - setStyleSheet(style); - } else { - qWarning() << "Failed to load default skin styles /skins/default.qss!"; - } + tryParseAndSetDefaultStyleSheet(); if (!loadConfiguredSkin()) { reportCriticalErrorAndQuit( @@ -1096,6 +1087,8 @@ void MixxxMainWindow::rebootMixxxView() { bool wasFullScreen = isFullScreen(); slotViewFullScreen(false); + tryParseAndSetDefaultStyleSheet(); + if (!loadConfiguredSkin()) { QMessageBox::critical(this, tr("Error in skin file"), @@ -1143,6 +1136,19 @@ bool MixxxMainWindow::loadConfiguredSkin() { return m_pCentralWidget != nullptr; } +// Try to load default styles that can be overridden by skins +void MixxxMainWindow::tryParseAndSetDefaultStyleSheet() { + const QString resPath = m_pCoreServices->getSettings()->getResourcePath(); + QFile file(resPath + "/skins/default.qss"); + if (file.open(QIODevice::ReadOnly)) { + QByteArray fileBytes = file.readAll(); + QString style = QString::fromUtf8(fileBytes); + setStyleSheet(style); + } else { + qWarning() << "Failed to load default skin styles /skins/default.qss!"; + } +} + bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::ToolTip) { // always show tooltips in the preferences window diff --git a/src/mixxxmainwindow.h b/src/mixxxmainwindow.h index eeeb755162c..0bfc7dce0c0 100644 --- a/src/mixxxmainwindow.h +++ b/src/mixxxmainwindow.h @@ -101,6 +101,7 @@ class MixxxMainWindow : public QMainWindow { /// Load skin to a QWidget that we set as the central widget. bool loadConfiguredSkin(); + void tryParseAndSetDefaultStyleSheet(); bool confirmExit(); QDialog::DialogCode soundDeviceErrorDlg(