From 9f8f89db6de5c148b2558c2fdd3f1c38eaa925f1 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 11 Dec 2024 09:25:28 +0100 Subject: [PATCH] make the theme handling in musredit more flexible. At the same time adopted some part to more modern c++. --- src/musredit_qt5/musredit/PAdmin.cpp | 51 +- src/musredit_qt5/musredit/PAdmin.h | 53 +- src/musredit_qt5/musredit/PPrefsDialog.cpp | 6 + src/musredit_qt5/musredit/PPrefsDialog.h | 1 + src/musredit_qt5/musredit/PTextEdit.cpp | 22 +- src/musredit_qt5/musredit/PTextEdit.h | 10 +- .../musredit/forms/PPrefsDialog.ui | 571 +++++++++--------- .../musredit/musredit_startup.xml.in | 1 + src/musredit_qt6/musredit/PAdmin.cpp | 54 +- src/musredit_qt6/musredit/PAdmin.h | 43 +- src/musredit_qt6/musredit/PPrefsDialog.cpp | 6 + src/musredit_qt6/musredit/PPrefsDialog.h | 1 + src/musredit_qt6/musredit/PTextEdit.cpp | 25 +- src/musredit_qt6/musredit/PTextEdit.h | 14 +- .../musredit/forms/PPrefsDialog.ui | 571 +++++++++--------- .../musredit/musredit_startup.xml.in | 1 + 16 files changed, 716 insertions(+), 714 deletions(-) diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index 9963bbcb..7d849d23 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -144,6 +144,8 @@ bool PAdminXMLParser::startElement() fKeyWord = eMusrviewShowOneToOne; } else if (qName == "enable_musrt0") { fKeyWord = eEnableMusrT0; + } else if (qName == "ignore_theme_auto_detection") { + fKeyWord = eIgnoreThemeAutoDetection; } else if (qName == "dark_theme_icons_menu") { fKeyWord = eDarkThemeIconsMenu; } else if (qName == "dark_theme_icons_toolbar") { @@ -337,6 +339,13 @@ bool PAdminXMLParser::characters() flag = false; fAdmin->setEnableMusrT0Flag(flag); break; + case eIgnoreThemeAutoDetection: + if (str == "y") + flag = true; + else + flag = false; + fAdmin->setIgnoreThemeAutoDetection(flag); + break; case eDarkThemeIconsMenu: if (str == "y") flag = true; @@ -622,6 +631,7 @@ void PAdminXMLParser::dump() std::cout << "debug> musrview_show_fourier : " << fAdmin->getMusrviewShowFourierFlag() << std::endl; std::cout << "debug> musrview_show_avg : " << fAdmin->getMusrviewShowAvgFlag() << std::endl; std::cout << "debug> enable_musrt0 : " << fAdmin->getEnableMusrT0Flag() << std::endl; + std::cout << "debug> ignore_theme_auto_detection : " << fAdmin->getIgnoreThemeAutoDetection() << std::endl; std::cout << "debug> dark_theme_icons_menu : " << fAdmin->getDarkThemeIconsMenuFlag() << std::endl; std::cout << "debug> dark_theme_icons_toolbar : " << fAdmin->getDarkThemeIconsToolbarFlag() << std::endl; std::cout << "debug> edit_w : " << fAdmin->getEditWidth() << std::endl; @@ -736,33 +746,6 @@ QString PAdminXMLParser::expandPath(const QString &str) */ PAdmin::PAdmin() : QObject() { - fTimeout = 3600; - - fFontName = QString("Courier"); // default font - fFontSize = 11; // default font size - - fPrefPathName = QString(""); - fExecPath = QString(""); - fDefaultSavePath = QString(""); - fTheoFuncPixmapPath = QString(""); - - fBeamline = QString(""); - fInstitute = QString(""); - fFileFormat = QString(""); - - fMusrviewShowFourier = false; - fMusrviewShowAvg = false; - - fTitleFromDataFile = false; - fEnableMusrT0 = false; - fLifetimeCorrection = true; - fEstimateN0 = true; - fYamlOut = false; - fChisqPreRunBlock = false; - - fEditWidth = 900; - fEditHeight = 800; - fMsr2DataParam.runList = QString(""); fMsr2DataParam.runListFileName = QString(""); fMsr2DataParam.msrFileExtension = QString(""); @@ -1028,17 +1011,23 @@ int PAdmin::savePrefs(QString pref_fln) else data[i] = " n"; } + if (data[i].contains("")) { + if (fIgnoreThemeAutoDetection) + data[i] = " y"; + else + data[i] = " n"; + } if (data[i].contains("") && data[i].contains("")) { if (fDarkThemeIconsMenu) - data[i] = " y"; + data[i] = " y"; else - data[i] = " n"; + data[i] = " n"; } if (data[i].contains("") && data[i].contains("")) { if (fDarkThemeIconsToolbar) - data[i] = " y"; + data[i] = " y"; else - data[i] = " n"; + 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 1866d77b..79d2a416 100644 --- a/src/musredit_qt5/musredit/PAdmin.h +++ b/src/musredit_qt5/musredit/PAdmin.h @@ -73,7 +73,7 @@ class PAdminXMLParser enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot, eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eYamlOut, eMusrviewShowFourier, eMusrviewShowAvg, eMusrviewShowOneToOne, eEnableMusrT0, - eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eEditW, eEditH, + eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eIgnoreThemeAutoDetection, eEditW, eEditH, eFontName, eFontSize, eExecPath, eDefaultSavePath, eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel, @@ -131,6 +131,7 @@ class PAdmin : public QObject bool getEstimateN0Flag() { return fEstimateN0; } bool getYamlOutFlag() { return fYamlOut; } bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; } + bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection; } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; } int getEditWidth() { return fEditWidth; } @@ -160,6 +161,7 @@ class PAdmin : public QObject void setEstimateN0Flag(const bool flag) { fEstimateN0 = flag; } void setYamlOutFlag(const bool flag) { fYamlOut = flag; } void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; } + void setIgnoreThemeAutoDetection(const bool flag) { fIgnoreThemeAutoDetection = flag; } void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; } void setDarkThemeIconsToolbarFlag(const bool flag) { fDarkThemeIconsToolbar = flag; } void setEditWidth(const int width) { fEditWidth = width; } @@ -186,38 +188,39 @@ class PAdmin : public QObject private: friend class PAdminXMLParser; - int fTimeout; ///< timeout in seconds + int fTimeout{3600}; ///< timeout in seconds - QString fFontName; ///< default font name - int fFontSize; ///< default font size + QString fFontName{QString("Monospace")}; ///< default font name + int fFontSize{11}; ///< default font size - QString fPrefPathName; ///< path-name of the musredit_startup.xml - QString fExecPath; ///< system path to the musrfit executables - QString fDefaultSavePath; ///< default path where the msr-file should be saved - QString fTheoFuncPixmapPath; ///< path where the default pixmaps can be found + QString fPrefPathName{QString("")}; ///< path-name of the musredit_startup.xml + QString fExecPath{QString("")}; ///< system path to the musrfit executables + QString fDefaultSavePath{QString("")}; ///< default path where the msr-file should be saved + QString fTheoFuncPixmapPath{QString("")}; ///< path where the default pixmaps can be found QVector fRecentFile; ///< keep vector of recent path-file names - bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true). - bool fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier. - bool fMusrviewShowOneToOne; ///< flag indicating if theory points are calculate only at the data points (=true) or a higher density theory points is calculated - bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no) - bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no). - bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no). - bool fTitleFromDataFile; ///< flag indicating if the title should be extracted from the data file (default: yes). - bool fChisqPreRunBlock; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no). - bool fEstimateN0; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes). - bool fYamlOut; ///< flag indicating if the MINUIT2.OUTPUT file should also be written as .yaml output. (default: no). - bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes). - bool fDarkThemeIconsMenu; ///< flag indicating if dark theme icons shall be used in the menu (default: no) - bool fDarkThemeIconsToolbar; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no) + bool fMusrviewShowFourier{false}; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true). + bool fMusrviewShowAvg{false}; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier. + bool fMusrviewShowOneToOne{false}; ///< flag indicating if theory points are calculate only at the data points (=true) or a higher density theory points is calculated + bool fKeepMinuit2Output{false}; ///< flag indicating if the Minuit2 output shall be kept (default: no) + bool fDumpAscii{false}; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no). + bool fDumpRoot{false}; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no). + bool fTitleFromDataFile{true}; ///< flag indicating if the title should be extracted from the data file (default: yes). + bool fChisqPreRunBlock{false}; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no). + bool fEstimateN0{true}; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes). + bool fYamlOut{false}; ///< flag indicating if the MINUIT2.OUTPUT file should also be written as .yaml output. (default: no). + bool fEnableMusrT0{true}; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes). + bool fIgnoreThemeAutoDetection{false}; ///< flag indicating that the theme autodetection shall be ignored. (default: no) + bool fDarkThemeIconsMenu{false}; ///< flag indicating if dark theme icons shall be used in the menu (default: no) + bool fDarkThemeIconsToolbar{false}; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no) int fEditWidth{900}; ///< startup edit width int fEditHeight{800}; ///< startup edit height - QString fBeamline; ///< name of the beamline. Used to generate default run header lines. - QString fInstitute; ///< name of the institute. Used to generate default run header lines. - QString fFileFormat; ///< default file format. Used to generate default run header lines. - bool fLifetimeCorrection; ///< flag indicating if by default the lifetime-correction-flag in a single histo file shall be set. + QString fBeamline{QString("")}; ///< name of the beamline. Used to generate default run header lines. + QString fInstitute{QString("")}; ///< name of the institute. Used to generate default run header lines. + QString fFileFormat{QString("")}; ///< default file format. Used to generate default run header lines. + bool fLifetimeCorrection{true}; ///< flag indicating if by default the lifetime-correction-flag in a single histo file shall be set. mutable PMsr2DataParam fMsr2DataParam; ///< keeps msr2data default parameter flags diff --git a/src/musredit_qt5/musredit/PPrefsDialog.cpp b/src/musredit_qt5/musredit/PPrefsDialog.cpp index 0683edd4..d65475af 100644 --- a/src/musredit_qt5/musredit/PPrefsDialog.cpp +++ b/src/musredit_qt5/musredit/PPrefsDialog.cpp @@ -59,6 +59,12 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin) fDarkThemeIconsToolbar_checkBox->setCheckState(Qt::Unchecked); } + if (fAdmin->getIgnoreThemeAutoDetection()) { + fIgnoreThemeAutoDetection_checkBox->setCheckState(Qt::Checked); + } else { + fIgnoreThemeAutoDetection_checkBox->setCheckState(Qt::Unchecked); + } + fKeepMn2Output_checkBox->setChecked(fAdmin->getKeepMinuit2OutputFlag()); if (fAdmin->getDumpAsciiFlag() && !fAdmin->getDumpRootFlag()) { diff --git a/src/musredit_qt5/musredit/PPrefsDialog.h b/src/musredit_qt5/musredit/PPrefsDialog.h index 25c4b372..f78eafed 100644 --- a/src/musredit_qt5/musredit/PPrefsDialog.h +++ b/src/musredit_qt5/musredit/PPrefsDialog.h @@ -55,6 +55,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog bool getKeepRunPerBlockChisqFlag() { return fPerRunBlockChisq_checkBox->isChecked(); } bool getEstimateN0Flag() { return fEstimateN0_checkBox->isChecked(); } bool getYamlOutFlag() { return fYamlOut_checkBox->isChecked(); } + bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection_checkBox->isChecked(); } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu_checkBox->isChecked(); } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar_checkBox->isChecked(); } bool getOneToOneFlag() { return fOneToOne_checkBox->isChecked(); } diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index cd879eda..4841a742 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -88,11 +88,11 @@ PTextEdit::PTextEdit( QWidget *parent ) : QMainWindow( parent ) { - bool gotTheme = getTheme(); - // reads and manages the conents of the xml-startup (musredit_startup.xml) file fAdmin = std::make_unique(); + bool gotTheme = getTheme(); + // set default setting of the fDarkMenuIconIcons only if a theme has been recognized, otherwise take the // one from the xml startup file. if (gotTheme) { @@ -134,7 +134,6 @@ PTextEdit::PTextEdit( QWidget *parent ) textFamily(fAdmin->getFontName()); textSize(QString("%1").arg(fAdmin->getFontSize())); - fFontChanging = false; QString iconName(""); if (fDarkMenuIcon) @@ -1967,7 +1966,7 @@ void PTextEdit::editUncomment() //---------------------------------------------------------------------------------------------------- /** - *

Chances the font. + *

Changes the font. * * \param f font name */ @@ -1984,7 +1983,7 @@ void PTextEdit::textFamily( const QString &f ) //---------------------------------------------------------------------------------------------------- /** - *

Chances the font size. + *

Changes the font size. * * \param p font size in points. */ @@ -2213,6 +2212,7 @@ void PTextEdit::musrMsr2Data() fMsr2DataParam->keepMinuit2Output = fAdmin->getKeepMinuit2OutputFlag(); fMsr2DataParam->titleFromDataFile = fAdmin->getTitleFromDataFileFlag(); fMsr2DataParam->estimateN0 = fAdmin->getEstimateN0Flag(); + fMsr2DataParam->yamlOut = fAdmin->getYamlOutFlag(); fMsr2DataParam->perRunBlockChisq = fAdmin->getChisqPerRunBlockFlag(); PMsr2DataDialog *dlg = new PMsr2DataDialog(fMsr2DataParam, fAdmin->getHelpUrl("msr2data")); @@ -2235,6 +2235,7 @@ void PTextEdit::musrMsr2Data() fAdmin->setKeepMinuit2OutputFlag(fMsr2DataParam->keepMinuit2Output); fAdmin->setTitleFromDataFileFlag(fMsr2DataParam->titleFromDataFile); fAdmin->setEstimateN0Flag(fMsr2DataParam->estimateN0); + fAdmin->setYamlOutFlag(fMsr2DataParam->yamlOut); fAdmin->setChisqPerRunBlockFlag(fMsr2DataParam->perRunBlockChisq); // analyze parameters @@ -2735,6 +2736,7 @@ void PTextEdit::musrPrefs() } if (dlg->exec() == QDialog::Accepted) { + fAdmin->setIgnoreThemeAutoDetection(dlg->getIgnoreThemeAutoDetection()); fAdmin->setDarkThemeIconsMenuFlag(dlg->getDarkThemeIconsMenuFlag()); fAdmin->setDarkThemeIconsToolbarFlag(dlg->getDarkThemeIconsToolbarFlag()); fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag()); @@ -3358,6 +3360,9 @@ void PTextEdit::jumpToBlock(int idx) */ bool PTextEdit::getTheme() { + if (fAdmin->getIgnoreThemeAutoDetection()) + return false; + fDarkMenuIcon = 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! @@ -3389,10 +3394,9 @@ bool PTextEdit::getTheme() if (str.contains("dark", Qt::CaseInsensitive)) { fDarkMenuIcon = true; - if (str.contains("ubuntu", Qt::CaseInsensitive)) { - fDarkMenuIcon = false; - fDarkToolBarIcon = false; - } else if (str.contains("xfce", Qt::CaseInsensitive)) { + if (str.contains("ubuntu", Qt::CaseInsensitive) || + str.contains("xfce", Qt::CaseInsensitive) || + str.contains("mx", Qt::CaseInsensitive)) { fDarkMenuIcon = false; fDarkToolBarIcon = false; } else { diff --git a/src/musredit_qt5/musredit/PTextEdit.h b/src/musredit_qt5/musredit/PTextEdit.h index 11e8b0b4..0ecc95f9 100644 --- a/src/musredit_qt5/musredit/PTextEdit.h +++ b/src/musredit_qt5/musredit/PTextEdit.h @@ -171,15 +171,15 @@ private slots: void jumpToBlock(int idx); private: - bool fDarkMenuIcon; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs - bool fDarkToolBarIcon; ///< flag indicating if a dark or plain icon shall be used in the toolbar + bool fDarkMenuIcon{false}; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs + bool fDarkToolBarIcon{false}; ///< flag indicating if a dark or plain icon shall be used in the toolbar std::unique_ptr fAdmin; ///< pointer to the xml-startup file informations. Needed for different purposes like default working- and executable directories etc. std::unique_ptr fFileSystemWatcher; ///< checks if msr-files are changing on the disk while being open in musredit. bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling - QString fLastDirInUse; ///< string holding the path from where the last file was loaded. + QString fLastDirInUse{QString("")}; ///< string holding the path from where the last file was loaded. QStringList fMusrFTPrevCmd; - int fEditW, fEditH; + int fEditW{900}, fEditH{800}; QMap fActions; std::unique_ptr fMusrT0Action; @@ -189,7 +189,7 @@ private: std::unique_ptr fComboFont; ///< combo box for the font selector std::unique_ptr fComboSize; ///< combo box for the font size - bool fFontChanging; ///< flag needed to prevent some textChanged feature to occure when only the font changed + bool fFontChanging{false}; ///< flag needed to prevent some textChanged feature to occure when only the font changed std::unique_ptr fJumpToBlock; ///< combo box used to jump to the msr-file blocks std::unique_ptr fTabWidget; ///< tab widget in which the text editor(s) are placed diff --git a/src/musredit_qt5/musredit/forms/PPrefsDialog.ui b/src/musredit_qt5/musredit/forms/PPrefsDialog.ui index 5a8060c9..79054cdb 100644 --- a/src/musredit_qt5/musredit/forms/PPrefsDialog.ui +++ b/src/musredit_qt5/musredit/forms/PPrefsDialog.ui @@ -9,8 +9,8 @@ 0 0 - 452 - 180 + 460 + 200 @@ -20,292 +20,293 @@ :/images/musrfit.xpm:/images/musrfit.xpm - - - - 0 - 5 - 451 - 171 - - - - - - - 1 - - - - general - - - - - 10 - 70 - 421 - 31 - - - - Change Default Search Paths - + + + + + + + 0 + + + + general + + + + + 10 + 80 + 421 + 31 + + + + Change Default Search Paths + + + + + + 10 + 10 + 416 + 61 + + + + + + + + + + timeout + + + + + + + Qt::Horizontal + + + + 38 + 30 + + + + + + + + + + Ignore Theme Auto Detect + + + + + + + Dark Theme Icons Menu + + + + + + + Dark Theme Icons Toolbar + + + + + + + - - - - 12 - 10 - 415 - 62 - - - - - - - - - - timeout - - - - - - - Qt::Horizontal - - - - 38 - 30 - - - - - - - - - - Dark Theme Icons Menu - - - - - - - Dark Theme Icons Toolbar - - - - - - + + + musrfit + + + + + 10 + 10 + 161 + 23 + + + + keep minuit2 output + + + + + + 10 + 35 + 151 + 23 + + + + dump ascii + + + + + + 10 + 60 + 131 + 23 + + + + dump root + + + + + + 170 + 10 + 161 + 23 + + + + take title from data file + + + + + + 170 + 35 + 181 + 22 + + + + keep per run block chisq + + + + + + 170 + 60 + 171 + 22 + + + + estimate N0 + + + + + + 350 + 10 + 85 + 21 + + + + yaml out + + + + + + musrview + + + + + 10 + 10 + 421 + 22 + + + + start with Fourier + + + + + + 10 + 40 + 421 + 21 + + + + start with averaged data/Fourier + + + + + + 260 + 10 + 181 + 26 + + + + theo at data points only + + + + + + musrt0 + + + + + 10 + 10 + 131 + 23 + + + + enable it + + - - - musrfit - - - - - 10 - 10 - 161 - 23 - - - - keep minuit2 output - - - - - - 10 - 35 - 151 - 23 - - - - dump ascii - - - - - - 10 - 60 - 131 - 23 - - - - dump root - - - - - - 170 - 10 - 161 - 23 - - - - take title from data file - - - - - - 170 - 35 - 181 - 22 - - - - keep per run block chisq - - - - - - 170 - 60 - 171 - 22 - - - - estimate N0 - - - - - - 350 - 10 - 85 - 21 - - - - yaml out - - - - - - musrview - - - - - 10 - 10 - 421 - 22 - - - - start with Fourier - - - - - - 10 - 40 - 421 - 21 - - - - start with averaged data/Fourier - - - - - - 260 - 10 - 181 - 26 - - - - theo at data points only - - - - - - musrt0 - - - - - 10 - 10 - 131 - 23 - - - - enable it - - - - - - - - - - - &Help - - - - - - - Qt::Horizontal - - - - 88 - 20 - - - - - - - - &OK - - - - - - - &Cancel - - - - - - - + + + + + + + &Help + + + + + + + Qt::Horizontal + + + + 88 + 20 + + + + + + + + &OK + + + + + + + &Cancel + + + + + + + + fTabWidget diff --git a/src/musredit_qt5/musredit/musredit_startup.xml.in b/src/musredit_qt5/musredit/musredit_startup.xml.in index c2ae2e77..225ca6ec 100644 --- a/src/musredit_qt5/musredit/musredit_startup.xml.in +++ b/src/musredit_qt5/musredit/musredit_startup.xml.in @@ -19,6 +19,7 @@ n n y + n n n 900 diff --git a/src/musredit_qt6/musredit/PAdmin.cpp b/src/musredit_qt6/musredit/PAdmin.cpp index fe5eeb76..e7f3a748 100644 --- a/src/musredit_qt6/musredit/PAdmin.cpp +++ b/src/musredit_qt6/musredit/PAdmin.cpp @@ -150,6 +150,8 @@ bool PAdminXMLParser::startElement() fKeyWord = eMusrviewShowOneToOne; } else if (qName == "enable_musrt0") { fKeyWord = eEnableMusrT0; + } else if (qName == "ignore_theme_auto_detection") { + fKeyWord = eIgnoreThemeAutoDetection; } else if (qName == "dark_theme_icons_menu") { fKeyWord = eDarkThemeIconsMenu; } else if (qName == "dark_theme_icons_toolbar") { @@ -158,11 +160,11 @@ bool PAdminXMLParser::startElement() fKeyWord = eEditW; } else if (qName == "edit_h") { fKeyWord = eEditH; - } else if (qName =="keep_minuit2_output") { + } else if (qName == "keep_minuit2_output") { fKeyWord = eKeepMinuit2Output; } else if (qName == "dump_ascii") { fKeyWord = eDumpAscii; - } else if (qName =="dump_root") { + } else if (qName == "dump_root") { fKeyWord = eDumpRoot; } else if (qName == "estimate_n0") { fKeyWord = eEstimateN0; @@ -281,7 +283,6 @@ bool PAdminXMLParser::endElement() bool PAdminXMLParser::characters() { QString str = fXml.text().toString(); - if (str.isEmpty()) return true; @@ -344,6 +345,13 @@ bool PAdminXMLParser::characters() flag = false; fAdmin->setEnableMusrT0Flag(flag); break; + case eIgnoreThemeAutoDetection: + if (str == "y") + flag = true; + else + flag = false; + fAdmin->setIgnoreThemeAutoDetection(flag); + break; case eDarkThemeIconsMenu: if (str == "y") flag = true; @@ -405,6 +413,7 @@ bool PAdminXMLParser::characters() flag = false; fAdmin->fMsr2DataParam.yamlOut = flag; fAdmin->setYamlOutFlag(flag); + break; case eChisqPreRunBlock: if (str == "y") flag = true; @@ -628,6 +637,7 @@ void PAdminXMLParser::dump() std::cout << "debug> musrview_show_fourier : " << fAdmin->getMusrviewShowFourierFlag() << std::endl; std::cout << "debug> musrview_show_avg : " << fAdmin->getMusrviewShowAvgFlag() << std::endl; std::cout << "debug> enable_musrt0 : " << fAdmin->getEnableMusrT0Flag() << std::endl; + std::cout << "debug> ignore_theme_auto_detection : " << fAdmin->getIgnoreThemeAutoDetection() << std::endl; std::cout << "debug> dark_theme_icons_menu : " << fAdmin->getDarkThemeIconsMenuFlag() << std::endl; std::cout << "debug> dark_theme_icons_toolbar : " << fAdmin->getDarkThemeIconsToolbarFlag() << std::endl; std::cout << "debug> edit_w : " << fAdmin->getEditWidth() << std::endl; @@ -742,30 +752,6 @@ QString PAdminXMLParser::expandPath(const QString &str) */ PAdmin::PAdmin() : QObject() { - fTimeout = 3600; - - fFontName = QString("Courier"); // default font - fFontSize = 11; // default font size - - fPrefPathName = QString(""); - fExecPath = QString(""); - fDefaultSavePath = QString(""); - fTheoFuncPixmapPath = QString(""); - - fBeamline = QString(""); - fInstitute = QString(""); - fFileFormat = QString(""); - - fMusrviewShowFourier = false; - fMusrviewShowAvg = false; - - fTitleFromDataFile = false; - fEnableMusrT0 = false; - fLifetimeCorrection = true; - fEstimateN0 = true; - fYamlOut = false; - fChisqPreRunBlock = false; - fMsr2DataParam.runList = QString(""); fMsr2DataParam.runListFileName = QString(""); fMsr2DataParam.msrFileExtension = QString(""); @@ -1031,17 +1017,23 @@ int PAdmin::savePrefs(QString pref_fln) else data[i] = " n"; } + if (data[i].contains("")) { + if (fIgnoreThemeAutoDetection) + data[i] = " y"; + else + data[i] = " n"; + } if (data[i].contains("") && data[i].contains("")) { if (fDarkThemeIconsMenu) - data[i] = " y"; + data[i] = " y"; else - data[i] = " n"; + data[i] = " n"; } if (data[i].contains("") && data[i].contains("")) { if (fDarkThemeIconsToolbar) - data[i] = " y"; + data[i] = " y"; else - data[i] = " n"; + data[i] = " n"; } if (data[i].contains("") && data[i].contains("")) { data[i] = QString(" %1").arg(fFontName); diff --git a/src/musredit_qt6/musredit/PAdmin.h b/src/musredit_qt6/musredit/PAdmin.h index ea3657e3..a2d2fff6 100644 --- a/src/musredit_qt6/musredit/PAdmin.h +++ b/src/musredit_qt6/musredit/PAdmin.h @@ -131,6 +131,7 @@ class PAdmin : public QObject bool getDumpRootFlag() { return fDumpRoot; } bool getEstimateN0Flag() { return fEstimateN0; } bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; } + bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection; } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; } int getEditWidth() { return fEditWidth; } @@ -160,6 +161,7 @@ class PAdmin : public QObject void setEstimateN0Flag(const bool flag) { fEstimateN0 = flag; } void setYamlOutFlag(const bool flag) { fYamlOut = flag; } void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; } + void setIgnoreThemeAutoDetection(const bool flag) { fIgnoreThemeAutoDetection = flag; } void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; } void setDarkThemeIconsToolbarFlag(const bool flag) { fDarkThemeIconsToolbar = flag; } void setEditWidth(const int width) { fEditWidth = width; } @@ -186,31 +188,32 @@ class PAdmin : public QObject private: friend class PAdminXMLParser; - int fTimeout; ///< timeout in seconds + int fTimeout{3600}; ///< timeout in seconds - QString fFontName; ///< default font name - int fFontSize; ///< default font size + QString fFontName{QString("Monospace")}; ///< default font name + int fFontSize{11}; ///< default font size - QString fPrefPathName; ///< path-name of the musredit_startup.xml - QString fExecPath; ///< system path to the musrfit executables - QString fDefaultSavePath; ///< default path where the msr-file should be saved - QString fTheoFuncPixmapPath; ///< path where the default pixmaps can be found + QString fPrefPathName{QString("")}; ///< path-name of the musredit_startup.xml + QString fExecPath{QString("")}; ///< system path to the musrfit executables + QString fDefaultSavePath{QString("")}; ///< default path where the msr-file should be saved + QString fTheoFuncPixmapPath{QString("")}; ///< path where the default pixmaps can be found QVector fRecentFile; ///< keep vector of recent path-file names - bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true). - bool fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier. - bool fMusrviewShowOneToOne; ///< flag indicating if theory points are calculate only at the data points (=true) or a higher density theory points is calculated - bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no) - bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no). - bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no). - bool fTitleFromDataFile; ///< flag indicating if the title should be extracted from the data file (default: yes). - bool fChisqPreRunBlock; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no). - bool fEstimateN0; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes). - bool fYamlOut; ///< flag indicating if the MINUIT2.OUTPUT file should also be written as .yaml output. (default: no). - bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes). - bool fDarkThemeIconsMenu; ///< flag indicating if dark theme icons shall be used in the menu (default: no) - bool fDarkThemeIconsToolbar; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no) + bool fMusrviewShowFourier{false}; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true). + bool fMusrviewShowAvg{false}; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier. + bool fMusrviewShowOneToOne{false}; ///< flag indicating if theory points are calculate only at the data points (=true) or a higher density theory points is calculated + bool fKeepMinuit2Output{false}; ///< flag indicating if the Minuit2 output shall be kept (default: no) + bool fDumpAscii{false}; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no). + bool fDumpRoot{false}; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no). + bool fTitleFromDataFile{true}; ///< flag indicating if the title should be extracted from the data file (default: yes). + bool fChisqPreRunBlock{false}; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no). + bool fEstimateN0{true}; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes). + bool fYamlOut{false}; ///< flag indicating if the MINUIT2.OUTPUT file should also be written as .yaml output. (default: no). + bool fEnableMusrT0{true}; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes). + bool fIgnoreThemeAutoDetection{false}; ///< flag indicating that the theme autodetection shall be ignored. (default: no) + bool fDarkThemeIconsMenu{false}; ///< flag indicating if dark theme icons shall be used in the menu (default: no) + bool fDarkThemeIconsToolbar{false}; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no) int fEditWidth{900}; ///< startup edit width int fEditHeight{800}; ///< startup edit height diff --git a/src/musredit_qt6/musredit/PPrefsDialog.cpp b/src/musredit_qt6/musredit/PPrefsDialog.cpp index 0683edd4..d65475af 100644 --- a/src/musredit_qt6/musredit/PPrefsDialog.cpp +++ b/src/musredit_qt6/musredit/PPrefsDialog.cpp @@ -59,6 +59,12 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin) fDarkThemeIconsToolbar_checkBox->setCheckState(Qt::Unchecked); } + if (fAdmin->getIgnoreThemeAutoDetection()) { + fIgnoreThemeAutoDetection_checkBox->setCheckState(Qt::Checked); + } else { + fIgnoreThemeAutoDetection_checkBox->setCheckState(Qt::Unchecked); + } + fKeepMn2Output_checkBox->setChecked(fAdmin->getKeepMinuit2OutputFlag()); if (fAdmin->getDumpAsciiFlag() && !fAdmin->getDumpRootFlag()) { diff --git a/src/musredit_qt6/musredit/PPrefsDialog.h b/src/musredit_qt6/musredit/PPrefsDialog.h index 25c4b372..f78eafed 100644 --- a/src/musredit_qt6/musredit/PPrefsDialog.h +++ b/src/musredit_qt6/musredit/PPrefsDialog.h @@ -55,6 +55,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog bool getKeepRunPerBlockChisqFlag() { return fPerRunBlockChisq_checkBox->isChecked(); } bool getEstimateN0Flag() { return fEstimateN0_checkBox->isChecked(); } bool getYamlOutFlag() { return fYamlOut_checkBox->isChecked(); } + bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection_checkBox->isChecked(); } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu_checkBox->isChecked(); } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar_checkBox->isChecked(); } bool getOneToOneFlag() { return fOneToOne_checkBox->isChecked(); } diff --git a/src/musredit_qt6/musredit/PTextEdit.cpp b/src/musredit_qt6/musredit/PTextEdit.cpp index 46c710ed..648af007 100644 --- a/src/musredit_qt6/musredit/PTextEdit.cpp +++ b/src/musredit_qt6/musredit/PTextEdit.cpp @@ -88,11 +88,11 @@ PTextEdit::PTextEdit( QWidget *parent ) : QMainWindow( parent ) { - bool gotTheme = getTheme(); - // reads and manages the conents of the xml-startup (musredit_startup.xml) file fAdmin = std::make_unique(); + bool gotTheme = getTheme(); + // set default setting of the fDarkMenuIconIcons only if a theme has been recognized, otherwise take the // one from the xml startup file. if (gotTheme) { @@ -117,8 +117,6 @@ PTextEdit::PTextEdit( QWidget *parent ) } // initialize stuff -//as35 fMusrT0Action = nullptr; - fMsr2DataParam = nullptr; fFindReplaceData = nullptr; @@ -136,7 +134,6 @@ PTextEdit::PTextEdit( QWidget *parent ) textFamily(fAdmin->getFontName()); textSize(QString("%1").arg(fAdmin->getFontSize())); - fFontChanging = false; QString iconName(""); if (fDarkMenuIcon) @@ -165,12 +162,6 @@ PTextEdit::PTextEdit( QWidget *parent ) */ void PTextEdit::aboutToQuit() { -/* //as35 - if (fMusrT0Action) { - delete fMusrT0Action; - fMusrT0Action = nullptr; - } -*/ //as35 if (fMsr2DataParam) { delete fMsr2DataParam; fMsr2DataParam = nullptr; @@ -1193,7 +1184,6 @@ void PTextEdit::fileNew() PSubTextEdit *edit = new PSubTextEdit( fAdmin.get() ); edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize())); edit->setCenterOnScroll(true); - doConnections( edit ); fTabWidget->addTab( edit, tr( "noname" ) ); fTabWidget->setCurrentIndex(fTabWidget->indexOf(edit)); @@ -2732,6 +2722,7 @@ void PTextEdit::musrPrefs() } if (dlg->exec() == QDialog::Accepted) { + fAdmin->setIgnoreThemeAutoDetection(dlg->getIgnoreThemeAutoDetection()); fAdmin->setDarkThemeIconsMenuFlag(dlg->getDarkThemeIconsMenuFlag()); fAdmin->setDarkThemeIconsToolbarFlag(dlg->getDarkThemeIconsToolbarFlag()); fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag()); @@ -3346,6 +3337,9 @@ void PTextEdit::jumpToBlock(int idx) */ bool PTextEdit::getTheme() { + if (fAdmin->getIgnoreThemeAutoDetection()) + return false; + fDarkMenuIcon = 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! @@ -3377,10 +3371,9 @@ bool PTextEdit::getTheme() if (str.contains("dark", Qt::CaseInsensitive)) { fDarkMenuIcon = true; - if (str.contains("ubuntu", Qt::CaseInsensitive)) { - fDarkMenuIcon = false; - fDarkToolBarIcon = false; - } else if (str.contains("xfce", Qt::CaseInsensitive)) { + if (str.contains("ubuntu", Qt::CaseInsensitive) || + str.contains("xfce", Qt::CaseInsensitive) || + str.contains("mx", Qt::CaseInsensitive)) { fDarkMenuIcon = false; fDarkToolBarIcon = false; } else { diff --git a/src/musredit_qt6/musredit/PTextEdit.h b/src/musredit_qt6/musredit/PTextEdit.h index c234dcba..0ecc95f9 100644 --- a/src/musredit_qt6/musredit/PTextEdit.h +++ b/src/musredit_qt6/musredit/PTextEdit.h @@ -30,6 +30,8 @@ #ifndef _PTEXTEDIT_H_ #define _PTEXTEDIT_H_ +#include + #include #include #include @@ -46,8 +48,6 @@ #include -#include - #include "PAdmin.h" #include "musredit.h" @@ -171,15 +171,15 @@ private slots: void jumpToBlock(int idx); private: - bool fDarkMenuIcon; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs - bool fDarkToolBarIcon; ///< flag indicating if a dark or plain icon shall be used in the toolbar + bool fDarkMenuIcon{false}; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs + bool fDarkToolBarIcon{false}; ///< flag indicating if a dark or plain icon shall be used in the toolbar std::unique_ptr fAdmin; ///< pointer to the xml-startup file informations. Needed for different purposes like default working- and executable directories etc. std::unique_ptr fFileSystemWatcher; ///< checks if msr-files are changing on the disk while being open in musredit. bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling - QString fLastDirInUse; ///< string holding the path from where the last file was loaded. + QString fLastDirInUse{QString("")}; ///< string holding the path from where the last file was loaded. QStringList fMusrFTPrevCmd; - int fEditW, fEditH; + int fEditW{900}, fEditH{800}; QMap fActions; std::unique_ptr fMusrT0Action; @@ -189,7 +189,7 @@ private: std::unique_ptr fComboFont; ///< combo box for the font selector std::unique_ptr fComboSize; ///< combo box for the font size - bool fFontChanging; ///< flag needed to prevent some textChanged feature to occure when only the font changed + bool fFontChanging{false}; ///< flag needed to prevent some textChanged feature to occure when only the font changed std::unique_ptr fJumpToBlock; ///< combo box used to jump to the msr-file blocks std::unique_ptr fTabWidget; ///< tab widget in which the text editor(s) are placed diff --git a/src/musredit_qt6/musredit/forms/PPrefsDialog.ui b/src/musredit_qt6/musredit/forms/PPrefsDialog.ui index 85bcbfe4..79054cdb 100644 --- a/src/musredit_qt6/musredit/forms/PPrefsDialog.ui +++ b/src/musredit_qt6/musredit/forms/PPrefsDialog.ui @@ -9,8 +9,8 @@ 0 0 - 452 - 180 + 460 + 200 @@ -20,292 +20,293 @@ :/images/musrfit.xpm:/images/musrfit.xpm - - - - 0 - 5 - 451 - 171 - - - - - - - 1 - - - - general - - - - - 10 - 70 - 421 - 31 - - - - Change Default Search Paths - + + + + + + + 0 + + + + general + + + + + 10 + 80 + 421 + 31 + + + + Change Default Search Paths + + + + + + 10 + 10 + 416 + 61 + + + + + + + + + + timeout + + + + + + + Qt::Horizontal + + + + 38 + 30 + + + + + + + + + + Ignore Theme Auto Detect + + + + + + + Dark Theme Icons Menu + + + + + + + Dark Theme Icons Toolbar + + + + + + + - - - - 12 - 10 - 415 - 62 - - - - - - - - - - timeout - - - - - - - Qt::Horizontal - - - - 38 - 30 - - - - - - - - - - Dark Theme Icons Menu - - - - - - - Dark Theme Icons Toolbar - - - - - - + + + musrfit + + + + + 10 + 10 + 161 + 23 + + + + keep minuit2 output + + + + + + 10 + 35 + 151 + 23 + + + + dump ascii + + + + + + 10 + 60 + 131 + 23 + + + + dump root + + + + + + 170 + 10 + 161 + 23 + + + + take title from data file + + + + + + 170 + 35 + 181 + 22 + + + + keep per run block chisq + + + + + + 170 + 60 + 171 + 22 + + + + estimate N0 + + + + + + 350 + 10 + 85 + 21 + + + + yaml out + + + + + + musrview + + + + + 10 + 10 + 421 + 22 + + + + start with Fourier + + + + + + 10 + 40 + 421 + 21 + + + + start with averaged data/Fourier + + + + + + 260 + 10 + 181 + 26 + + + + theo at data points only + + + + + + musrt0 + + + + + 10 + 10 + 131 + 23 + + + + enable it + + - - - musrfit - - - - - 10 - 10 - 161 - 23 - - - - keep minuit2 output - - - - - - 10 - 35 - 151 - 23 - - - - dump ascii - - - - - - 10 - 60 - 131 - 23 - - - - dump root - - - - - - 170 - 10 - 171 - 23 - - - - take title from data file - - - - - - 170 - 35 - 241 - 22 - - - - keep per run block chisq - - - - - - 170 - 60 - 101 - 22 - - - - estimate N0 - - - - - - 360 - 10 - 85 - 21 - - - - yaml out - - - - - - musrview - - - - - 10 - 10 - 421 - 22 - - - - start with Fourier - - - - - - 10 - 40 - 421 - 21 - - - - start with averaged data/Fourier - - - - - - 260 - 10 - 181 - 26 - - - - theo at data points only - - - - - - musrt0 - - - - - 10 - 10 - 131 - 23 - - - - enable it - - - - - - - - - - - &Help - - - - - - - Qt::Horizontal - - - - 88 - 20 - - - - - - - - &OK - - - - - - - &Cancel - - - - - - - + + + + + + + &Help + + + + + + + Qt::Horizontal + + + + 88 + 20 + + + + + + + + &OK + + + + + + + &Cancel + + + + + + + + fTabWidget diff --git a/src/musredit_qt6/musredit/musredit_startup.xml.in b/src/musredit_qt6/musredit/musredit_startup.xml.in index 70e20664..c7d6f375 100644 --- a/src/musredit_qt6/musredit/musredit_startup.xml.in +++ b/src/musredit_qt6/musredit/musredit_startup.xml.in @@ -19,6 +19,7 @@ n n y + n n n 900