Skip to content

Commit

Permalink
Merge pull request mixxxdj#12219 from ronso0/skins-reload-default.qss
Browse files Browse the repository at this point in the history
Skins: reload default.qss when (re)loading a skin
  • Loading branch information
daschuer authored Feb 7, 2024
2 parents 5af6e10 + 2608a9d commit 45c85d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,7 @@ void MixxxMainWindow::initialize() {

QWidget* oldWidget = m_pCentralWidget;

// Load default styles that can be overridden by skins
QFile file(":/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!";
}
tryParseAndSetDefaultStyleSheet();

if (!loadConfiguredSkin()) {
reportCriticalErrorAndQuit(
Expand Down Expand Up @@ -1082,6 +1074,8 @@ void MixxxMainWindow::rebootMixxxView() {
bool wasFullScreen = isFullScreen();
slotViewFullScreen(false);

tryParseAndSetDefaultStyleSheet();

if (!loadConfiguredSkin()) {
QMessageBox::critical(this,
tr("Error in skin file"),
Expand Down Expand Up @@ -1129,6 +1123,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
Expand Down
1 change: 1 addition & 0 deletions src/mixxxmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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(
Expand Down

0 comments on commit 45c85d8

Please sign in to comment.