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