From 4f2041c141da669150cc383b52bffd4d3fb12826 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 2 Oct 2021 09:26:13 +0200 Subject: [PATCH] allow to set the default size of musredit via the musredit_startup.xml. --- src/musredit_qt5/musredit/PAdmin.cpp | 19 +++++++++++++++++++ src/musredit_qt5/musredit/PAdmin.h | 8 +++++++- src/musredit_qt5/musredit/PTextEdit.cpp | 4 ++++ src/musredit_qt5/musredit/PTextEdit.h | 4 ++++ src/musredit_qt5/musredit/main.cpp | 2 +- .../musredit/musredit_startup.xml.in | 4 +++- src/musredit_qt6/musredit/PAdmin.cpp | 16 ++++++++++++++++ src/musredit_qt6/musredit/PAdmin.h | 8 +++++++- src/musredit_qt6/musredit/PTextEdit.cpp | 4 ++++ src/musredit_qt6/musredit/PTextEdit.h | 4 ++++ src/musredit_qt6/musredit/main.cpp | 2 +- .../musredit/musredit_startup.xml.in | 2 ++ 12 files changed, 72 insertions(+), 5 deletions(-) diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index a447902a..d7c9129d 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -148,6 +148,10 @@ bool PAdminXMLParser::startElement() fKeyWord = eDarkThemeIconsMenu; } else if (qName == "dark_theme_icons_toolbar") { fKeyWord = eDarkThemeIconsToolbar; + } else if (qName == "edit_w") { + fKeyWord = eEditW; + } else if (qName == "edit_h") { + fKeyWord = eEditH; } else if (qName == "keep_minuit2_output") { fKeyWord = eKeepMinuit2Output; } else if (qName == "dump_ascii") { @@ -345,6 +349,16 @@ bool PAdminXMLParser::characters() flag = false; fAdmin->setDarkThemeIconsToolbarFlag(flag); break; + case eEditW: + ival = QString(str.toLatin1()).trimmed().toInt(&ok); + if (ok) + fAdmin->setEditWidth(ival); + break; + case eEditH: + ival = QString(str.toLatin1()).trimmed().toInt(&ok); + if (ok) + fAdmin->setEditHeight(ival); + break; case eKeepMinuit2Output: if (str == "y") flag = true; @@ -599,6 +613,8 @@ void PAdminXMLParser::dump() std::cout << "debug> enable_musrt0 : " << fAdmin->getEnableMusrT0Flag() << 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; + std::cout << "debug> edit_h : " << fAdmin->getEditHeight() << std::endl; std::cout << "debug> +++++++++++++++++++++++" << std::endl; std::cout << "debug> recent_files:" << std::endl; for (int i=0; igetNumRecentFiles(); i++) { @@ -732,6 +748,9 @@ PAdmin::PAdmin() : QObject() fEstimateN0 = true; fChisqPreRunBlock = false; + fEditWidth = 900; + fEditHeight = 800; + fMsr2DataParam.runList = QString(""); fMsr2DataParam.runListFileName = QString(""); fMsr2DataParam.msrFileExtension = QString(""); diff --git a/src/musredit_qt5/musredit/PAdmin.h b/src/musredit_qt5/musredit/PAdmin.h index 73015f8d..c63f8126 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, eMusrviewShowFourier, eMusrviewShowAvg, eMusrviewShowOneToOne, eEnableMusrT0, - eDarkThemeIconsMenu, eDarkThemeIconsToolbar, + eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eEditW, eEditH, eFontName, eFontSize, eExecPath, eDefaultSavePath, eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel, @@ -132,6 +132,8 @@ class PAdmin : public QObject bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; } + int getEditWidth() { return fEditWidth; } + int getEditHeight() { return fEditHeight; } QString getBeamline() { return fBeamline; } QString getInstitute() { return fInstitute; } QString getFileFormat() { return fFileFormat; } @@ -158,6 +160,8 @@ class PAdmin : public QObject void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; } void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; } void setDarkThemeIconsToolbarFlag(const bool flag) { fDarkThemeIconsToolbar = flag; } + void setEditWidth(const int width) { fEditWidth = width; } + void setEditHeight(const int height) { fEditHeight = height; } void setFontName(const QString str) { fFontName = str; } void setFontSize(const int ival) { fFontSize = ival; } @@ -204,6 +208,8 @@ class PAdmin : public QObject 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) + int fEditWidth; ///< startup edit width + int fEditHeight; ///< 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. diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index fec39552..53db930f 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -102,6 +102,10 @@ PTextEdit::PTextEdit( QWidget *parent ) fDarkToolBarIcon = fAdmin->getDarkThemeIconsToolbarFlag(); } + // keep the default editor width/height + fEditW = fAdmin->getEditWidth(); + fEditH = fAdmin->getEditHeight(); + // enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime fFileSystemWatcherActive = true; fFileSystemWatcher = new QFileSystemWatcher(); diff --git a/src/musredit_qt5/musredit/PTextEdit.h b/src/musredit_qt5/musredit/PTextEdit.h index 50b78b60..d7cdc15c 100644 --- a/src/musredit_qt5/musredit/PTextEdit.h +++ b/src/musredit_qt5/musredit/PTextEdit.h @@ -67,6 +67,9 @@ public: PTextEdit( QWidget *parent = nullptr ); virtual ~PTextEdit() {} + int getEditW() { return fEditW; } + int getEditH() { return fEditH; } + public slots: void aboutToQuit(); @@ -170,6 +173,7 @@ private: 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. QStringList fMusrFTPrevCmd; + int fEditW, fEditH; QMap fActions; QAction *fMusrT0Action; diff --git a/src/musredit_qt5/musredit/main.cpp b/src/musredit_qt5/musredit/main.cpp index 021fa07c..0ef57187 100644 --- a/src/musredit_qt5/musredit/main.cpp +++ b/src/musredit_qt5/musredit/main.cpp @@ -69,7 +69,7 @@ int main( int argc, char ** argv ) PTextEdit *mw = new PTextEdit(); mw->setWindowTitle( "MusrFit Editor" ); - mw->resize( 800, 800 ); + mw->resize( mw->getEditW(), mw->getEditH() ); mw->show(); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); diff --git a/src/musredit_qt5/musredit/musredit_startup.xml.in b/src/musredit_qt5/musredit/musredit_startup.xml.in index 5e657266..8372f837 100644 --- a/src/musredit_qt5/musredit/musredit_startup.xml.in +++ b/src/musredit_qt5/musredit/musredit_startup.xml.in @@ -20,7 +20,9 @@ y n n - + 900 + 800 + @DOCDIR@/examples/test-histo-PSI-BIN.msr diff --git a/src/musredit_qt6/musredit/PAdmin.cpp b/src/musredit_qt6/musredit/PAdmin.cpp index 8b34ae07..cbc1e433 100644 --- a/src/musredit_qt6/musredit/PAdmin.cpp +++ b/src/musredit_qt6/musredit/PAdmin.cpp @@ -150,6 +150,10 @@ bool PAdminXMLParser::startElement() fKeyWord = eDarkThemeIconsMenu; } else if (qName == "dark_theme_icons_toolbar") { fKeyWord = eDarkThemeIconsToolbar; + } else if (qName == "edit_w") { + fKeyWord = eEditW; + } else if (qName == "edit_h") { + fKeyWord = eEditH; } else if (qName =="keep_minuit2_output") { fKeyWord = eKeepMinuit2Output; } else if (qName == "dump_ascii") { @@ -348,6 +352,16 @@ bool PAdminXMLParser::characters() flag = false; fAdmin->setDarkThemeIconsToolbarFlag(flag); break; + case eEditW: + ival = QString(str.toLatin1()).trimmed().toInt(&ok); + if (ok) + fAdmin->setEditWidth(ival); + break; + case eEditH: + ival = QString(str.toLatin1()).trimmed().toInt(&ok); + if (ok) + fAdmin->setEditHeight(ival); + break; case eKeepMinuit2Output: if (str == "y") flag = true; @@ -602,6 +616,8 @@ void PAdminXMLParser::dump() std::cout << "debug> enable_musrt0 : " << fAdmin->getEnableMusrT0Flag() << 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; + std::cout << "debug> edit_h : " << fAdmin->getEditHeight() << std::endl; std::cout << "debug> +++++++++++++++++++++++" << std::endl; std::cout << "debug> recent_files:" << std::endl; for (int i=0; igetNumRecentFiles(); i++) { diff --git a/src/musredit_qt6/musredit/PAdmin.h b/src/musredit_qt6/musredit/PAdmin.h index 73015f8d..2622bfe4 100644 --- a/src/musredit_qt6/musredit/PAdmin.h +++ b/src/musredit_qt6/musredit/PAdmin.h @@ -73,7 +73,7 @@ class PAdminXMLParser enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot, eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eMusrviewShowAvg, eMusrviewShowOneToOne, eEnableMusrT0, - eDarkThemeIconsMenu, eDarkThemeIconsToolbar, + eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eEditW, eEditH, eFontName, eFontSize, eExecPath, eDefaultSavePath, eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel, @@ -132,6 +132,8 @@ class PAdmin : public QObject bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; } bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; } bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; } + int getEditWidth() { return fEditWidth; } + int getEditHeight() { return fEditHeight; } QString getBeamline() { return fBeamline; } QString getInstitute() { return fInstitute; } QString getFileFormat() { return fFileFormat; } @@ -158,6 +160,8 @@ class PAdmin : public QObject void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; } void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; } void setDarkThemeIconsToolbarFlag(const bool flag) { fDarkThemeIconsToolbar = flag; } + void setEditWidth(const int width) { fEditWidth = width; } + void setEditHeight(const int height) { fEditHeight = height; } void setFontName(const QString str) { fFontName = str; } void setFontSize(const int ival) { fFontSize = ival; } @@ -204,6 +208,8 @@ class PAdmin : public QObject 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) + 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. diff --git a/src/musredit_qt6/musredit/PTextEdit.cpp b/src/musredit_qt6/musredit/PTextEdit.cpp index fb519ab0..591fded3 100644 --- a/src/musredit_qt6/musredit/PTextEdit.cpp +++ b/src/musredit_qt6/musredit/PTextEdit.cpp @@ -102,6 +102,10 @@ PTextEdit::PTextEdit( QWidget *parent ) fDarkToolBarIcon = fAdmin->getDarkThemeIconsToolbarFlag(); } + // keep the default editor width/height + fEditW = fAdmin->getEditWidth(); + fEditH = fAdmin->getEditHeight(); + // enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime fFileSystemWatcherActive = true; fFileSystemWatcher = new QFileSystemWatcher(); diff --git a/src/musredit_qt6/musredit/PTextEdit.h b/src/musredit_qt6/musredit/PTextEdit.h index 50b78b60..d7cdc15c 100644 --- a/src/musredit_qt6/musredit/PTextEdit.h +++ b/src/musredit_qt6/musredit/PTextEdit.h @@ -67,6 +67,9 @@ public: PTextEdit( QWidget *parent = nullptr ); virtual ~PTextEdit() {} + int getEditW() { return fEditW; } + int getEditH() { return fEditH; } + public slots: void aboutToQuit(); @@ -170,6 +173,7 @@ private: 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. QStringList fMusrFTPrevCmd; + int fEditW, fEditH; QMap fActions; QAction *fMusrT0Action; diff --git a/src/musredit_qt6/musredit/main.cpp b/src/musredit_qt6/musredit/main.cpp index 313ae7de..813888c7 100644 --- a/src/musredit_qt6/musredit/main.cpp +++ b/src/musredit_qt6/musredit/main.cpp @@ -68,7 +68,7 @@ int main( int argc, char ** argv ) PTextEdit *mw = new PTextEdit(); mw->setWindowTitle( "MusrFit Editor" ); - mw->resize( 800, 800 ); + mw->resize( mw->getEditW(), mw->getEditH() ); mw->show(); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); diff --git a/src/musredit_qt6/musredit/musredit_startup.xml.in b/src/musredit_qt6/musredit/musredit_startup.xml.in index 5e657266..28d13604 100644 --- a/src/musredit_qt6/musredit/musredit_startup.xml.in +++ b/src/musredit_qt6/musredit/musredit_startup.xml.in @@ -20,6 +20,8 @@ y n n + 900 + 800 @DOCDIR@/examples/test-histo-PSI-BIN.msr