allow to set the default size of musredit via the musredit_startup.xml.

This commit is contained in:
suter_a 2021-10-02 09:26:13 +02:00
parent df03277c4c
commit 4f2041c141
12 changed files with 72 additions and 5 deletions

View File

@ -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; i<fAdmin->getNumRecentFiles(); 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("");

View File

@ -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.

View File

@ -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();

View File

@ -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<QString, QAction*> fActions;
QAction *fMusrT0Action;

View File

@ -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() ) );

View File

@ -20,7 +20,9 @@
<enable_musrt0>y</enable_musrt0>
<dark_theme_icons_menu>n</dark_theme_icons_menu>
<dark_theme_icons_toolbar>n</dark_theme_icons_toolbar>
</general>
<edit_w>900</edit_w>
<edit_h>800</edit_h>
</general>
<recent_files>
<path_file_name>@DOCDIR@/examples/test-histo-PSI-BIN.msr</path_file_name>
</recent_files>

View File

@ -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; i<fAdmin->getNumRecentFiles(); i++) {

View File

@ -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.

View File

@ -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();

View File

@ -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<QString, QAction*> fActions;
QAction *fMusrT0Action;

View File

@ -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() ) );

View File

@ -20,6 +20,8 @@
<enable_musrt0>y</enable_musrt0>
<dark_theme_icons_menu>n</dark_theme_icons_menu>
<dark_theme_icons_toolbar>n</dark_theme_icons_toolbar>
<edit_w>900</edit_w>
<edit_h>800</edit_h>
</general>
<recent_files>
<path_file_name>@DOCDIR@/examples/test-histo-PSI-BIN.msr</path_file_name>