diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index fbbb4cf969edd4eade56c72458548b393d427bf2..ce350169809149aa2046a8a5396e36f90608812b 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -121,8 +121,6 @@ MainWindow::MainWindow(QWidget *parent): changingViewsFlag(false), mavlink(new MAVLinkProtocol()), centerStackActionGroup(new QActionGroup(this)), - darkStyleFileName(defaultDarkStyle), - lightStyleFileName(defaultLightStyle), autoReconnect(false), simulationLink(NULL), lowPowerMode(false), @@ -141,14 +139,7 @@ void MainWindow::init() emit initStatusChanged(tr("Loading style"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); qApp->setStyle("plastique"); - if (currentStyle == QGC_MAINWINDOW_STYLE_LIGHT) - { - loadStyle(currentStyle, lightStyleFileName); - } - else - { - loadStyle(currentStyle, darkStyleFileName); - } + loadStyle(currentStyle); if (settings.contains("ADVANCED_MODE")) { @@ -961,8 +952,6 @@ void MainWindow::loadSettings() settings.beginGroup("QGC_MAINWINDOW"); autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool(); currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt(); - darkStyleFileName = settings.value("DARK_STYLE_FILENAME", darkStyleFileName).toString(); - lightStyleFileName = settings.value("LIGHT_STYLE_FILENAME", lightStyleFileName).toString(); lowPowerMode = settings.value("LOW_POWER_MODE", lowPowerMode).toBool(); bool dockWidgetTitleBarEnabled = settings.value("DOCK_WIDGET_TITLEBARS",menuActionHelper->dockWidgetTitleBarsEnabled()).toBool(); settings.endGroup(); @@ -975,8 +964,6 @@ void MainWindow::storeSettings() settings.beginGroup("QGC_MAINWINDOW"); settings.setValue("AUTO_RECONNECT", autoReconnect); settings.setValue("CURRENT_STYLE", currentStyle); - settings.setValue("DARK_STYLE_FILENAME", darkStyleFileName); - settings.setValue("LIGHT_STYLE_FILENAME", lightStyleFileName); settings.endGroup(); if (!aboutToCloseFlag && isVisible()) { @@ -1065,11 +1052,11 @@ void MainWindow::enableAutoReconnect(bool enabled) autoReconnect = enabled; } -bool MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style, QString cssFile) +bool MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style) { + qDebug() << "LOAD STYLE" << style; bool success = true; QString styles; - static const char* masterCssFile = ":/files/styles/style-dark.css"; // Signal to the user that the app will pause to apply a new stylesheet qApp->setOverrideCursor(Qt::WaitCursor); @@ -1079,43 +1066,31 @@ bool MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style, QString cssFile) // The dark style sheet is the master. Any other selected style sheet just overrides // the colors of the master sheet. - QFile masterStyleSheet(masterCssFile); + QFile masterStyleSheet(defaultDarkStyle); if (masterStyleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) { styles = masterStyleSheet.readAll(); } else { - qDebug() << "Unable to load master style sheet"; + qDebug() << "Unable to load master dark style sheet"; success = false; } - if (success && cssFile != masterCssFile) { - // Load the slave user specified stylesheet. - QFile styleSheet(cssFile); - if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) - { - + if (success && style == QGC_MAINWINDOW_STYLE_LIGHT) { + qDebug() << "LOADING LIGHT"; + // Load the slave light stylesheet. + QFile styleSheet(defaultLightStyle); + if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) { styles += styleSheet.readAll(); - - qApp->setStyleSheet(styles); - - // And save the new stylesheet path. - if (currentStyle == QGC_MAINWINDOW_STYLE_LIGHT) - { - lightStyleFileName = cssFile; - } - else - { - darkStyleFileName = cssFile; - } - - // And trigger any changes to other UI elements that are watching for - // theme changes. - emit styleChanged(style); } else { - qDebug() << "Unable to load slave style sheet:" << cssFile; + qDebug() << "Unable to load slave light sheet:"; success = false; } } + if (!styles.isEmpty()) { + qApp->setStyleSheet(styles); + emit styleChanged(style); + } + // Finally restore the cursor before returning. qApp->restoreOverrideCursor(); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 2dfec84aacdc770286c5b716039e4bf63c56d979..f3e2e5ab6fd07ff975a2d3774561ba7eba7fb7ea 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -142,17 +142,6 @@ public: return currentStyle; } - /** @brief Get current light visual stylesheet */ - QString getLightStyleSheet() const - { - return lightStyleFileName; - } - - /** @brief Get current dark visual stylesheet */ - QString getDarkStyleSheet() const - { - return darkStyleFileName; - } /** @brief Get auto link reconnect setting */ bool autoReconnectEnabled() const { @@ -249,10 +238,8 @@ public slots: /** @brief Save power by reducing update rates */ void enableLowPowerMode(bool enabled) { lowPowerMode = enabled; } - /** @brief Load a specific style. - * If it's a custom style, load the file indicated by the cssFile path. - */ - bool loadStyle(QGC_MAINWINDOW_STYLE style, QString cssFile); + /** @brief Load the specified style. */ + bool loadStyle(QGC_MAINWINDOW_STYLE style); /** @brief Add a custom tool widget */ void createCustomWidget(); @@ -481,8 +468,6 @@ protected: LogCompressor* comp; QString screenFileName; QTimer* videoTimer; - QString darkStyleFileName; - QString lightStyleFileName; bool autoReconnect; MAVLinkSimulationLink* simulationLink; Qt::WindowStates windowStateVal;