diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index 1f53aa6b..308fcf74 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -94,6 +94,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&, fKeyWord = eMusrviewShowAvg; } else if (qName == "enable_musrt0") { fKeyWord = eEnableMusrT0; + } else if (qName == "dark_theme_icons") { + fKeyWord = eDarkThemeIcons; } else if (qName == "keep_minuit2_output") { fKeyWord = eKeepMinuit2Output; } else if (qName == "dump_ascii") { @@ -268,6 +270,13 @@ bool PAdminXMLParser::characters(const QString& str) flag = false; fAdmin->setEnableMusrT0Flag(flag); break; + case eDarkThemeIcons: + if (str == "y") + flag = true; + else + flag = false; + fAdmin->setDarkThemeIconsFlag(flag); + break; case eKeepMinuit2Output: if (str == "y") flag = true; @@ -867,6 +876,12 @@ int PAdmin::savePrefs(QString pref_fln) else data[i] = " n"; } + if (data[i].contains("") && data[i].contains("")) { + if (fDarkThemeIcons) + data[i] = " y"; + else + data[i] = " n"; + } if (data[i].contains("") && data[i].contains("")) { data[i] = QString(" %1").arg(fFontName); } diff --git a/src/musredit_qt5/musredit/PAdmin.h b/src/musredit_qt5/musredit/PAdmin.h index 1de8330b..c0ca954f 100644 --- a/src/musredit_qt5/musredit/PAdmin.h +++ b/src/musredit_qt5/musredit/PAdmin.h @@ -70,7 +70,7 @@ class PAdminXMLParser : public QXmlDefaultHandler private: enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot, eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, - eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0, + eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0, eDarkThemeIcons, eFontName, eFontSize, eExecPath, eDefaultSavePath, eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel, diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index 9d50bfa2..5b77e8b2 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -85,13 +85,19 @@ PTextEdit::PTextEdit( QWidget *parent, Qt::WindowFlags f ) : QMainWindow( parent, f ) { - getTheme(); + bool gotTheme = getTheme(); // reads and manages the conents of the xml-startup (musredit_startup.xml) file fAdmin = new PAdmin(); - // set default setting of the fDarkThemeIcons - fAdmin->setDarkThemeIconsFlag(fDarkToolBarIcon); + // set default setting of the fDarkThemeIcons only if a theme has been recognized, otherwise take the + // one from the xml startup file. + if (gotTheme) { + fAdmin->setDarkThemeIconsFlag(fDarkToolBarIcon); + } else { + fDarkTheme = fAdmin->getDarkThemeIconsFlag(); + fDarkToolBarIcon = fAdmin->getDarkThemeIconsFlag(); + } // enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime fFileSystemWatcherActive = true; @@ -3244,23 +3250,22 @@ void PTextEdit::setFileSystemWatcherActive() /** * @brief PTextEdit::getTheme */ -void PTextEdit::getTheme() +bool PTextEdit::getTheme() { fDarkTheme = false; // true if theme is dark fDarkToolBarIcon = false; // needed for ubuntu dark since there the menu icons are dark, however the toolbar icons are plain! QString str = QIcon::themeName(); - qDebug() << "debug> theme name=" << str << endl; if (str.isEmpty()) { // this is ugly and eventually needs to be fixed in a more coherent way str = QProcessEnvironment::systemEnvironment().value("HOME", QString("??")); str += "/.kde4/share/config/kdeglobals"; + bool done = false; if (QFile::exists(str)) { QFile fln(str); fln.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream fin(&fln); QString line(""); - bool done = false; while (!fin.atEnd() && !done) { line = fin.readLine(); if (line.contains("ColorScheme")) { @@ -3273,7 +3278,7 @@ void PTextEdit::getTheme() } fln.close(); } - return; + return done; } if (str.contains("dark", Qt::CaseInsensitive)) { @@ -3287,6 +3292,8 @@ void PTextEdit::getTheme() fDarkToolBarIcon = true; } } + + return true; } //---------------------------------------------------------------------------------------------------- diff --git a/src/musredit_qt5/musredit/PTextEdit.h b/src/musredit_qt5/musredit/PTextEdit.h index 38ad7385..8121b048 100644 --- a/src/musredit_qt5/musredit/PTextEdit.h +++ b/src/musredit_qt5/musredit/PTextEdit.h @@ -187,7 +187,7 @@ private: QMenu *fRecentFilesMenu; ///< recent file menu QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions - void getTheme(); + bool getTheme(); void fillRecentFiles(); QStringList getRunList(QString runListStr, bool &ok); bool fileAlreadyOpen(QFileInfo &finfo, int &idx);