start moving startup XML-files to /home/nemu/.musrfit

This commit is contained in:
suter_a 2016-02-17 10:47:18 +01:00
parent 4fec25e423
commit bd05f57523
13 changed files with 191 additions and 132 deletions

View File

@ -5,6 +5,8 @@
changes since 0.16.0 changes since 0.16.0
=================================== ===================================
NEW 2016-01-22 update of the docu which now describes the RRF option. NEW 2016-01-22 update of the docu which now describes the RRF option.
CHANGED 2016-02-17 start to move the startup XML-files to $HOME/.musrfit
rather than having it within $prefix/bin.
CHANGED 2016-02-16 if the LEM file is created 2012 or later and the CHANGED 2016-02-16 if the LEM file is created 2012 or later and the
data-file-format tag is still ROOT-NPP or ROOT-PPC, it data-file-format tag is still ROOT-NPP or ROOT-PPC, it
will automatically switched to MUSR-ROOT. This way red/green will automatically switched to MUSR-ROOT. This way red/green

View File

@ -603,6 +603,7 @@ PAdmin::PAdmin() : QObject()
fFontName = QString("Courier"); // default font fFontName = QString("Courier"); // default font
fFontSize = 11; // default font size fFontSize = 11; // default font size
fPrefPathName = QString("");
fExecPath = QString(""); fExecPath = QString("");
fDefaultSavePath = QString(""); fDefaultSavePath = QString("");
fMsrDefaultFilePath = QString(""); fMsrDefaultFilePath = QString("");
@ -641,25 +642,28 @@ PAdmin::PAdmin() : QObject()
fMsr2DataParam.globalPlus = false; fMsr2DataParam.globalPlus = false;
// XML Parser part // XML Parser part
QString fln = "musredit_startup.xml"; // 1st: check local directory
// check if it is a MacOSX QString path = QString("./");
#ifdef Q_WS_MAC QString fln = QString("musredit_startup.xml");
fln = "./musredit_startup.xml"; QString pathFln = path + fln;
if (!QFile::exists(fln)) { if (!QFile::exists(pathFln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml"; // 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
path = std::getenv("HOME");
pathFln = path + "/.musrfit/musredit/" + fln;
if (!QFile::exists(pathFln)) {
// 3rd: check $MUSRFITPATH/musredit_startup.xml
path = std::getenv("MUSRFITPATH");
pathFln = path + "/" + fln;
if (!QFile::exists(pathFln)) {
// 4th: check $ROOTSYS/bin/musredit_startup.xml
path = std::getenv("ROOTSYS");
pathFln = path + "/bin/" + fln;
}
}
} }
#else fPrefPathName = pathFln;
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
loadPrefs(fln); loadPrefs(fPrefPathName);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -769,25 +773,10 @@ int PAdmin::savePrefs(QString pref_fln)
{ {
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to // check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml // save the recent file names otherwise use the "master" musredit_startup.xml
QString fln = QString("./musredit_startup.xml");
if (!QFile::exists(fln))
fln = fPrefPathName;
QString str;
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_WS_MAC
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present if (QFile::exists(fln)) { // administration file present
QVector<QString> data; QVector<QString> data;
QFile file(fln); QFile file(fln);
@ -842,6 +831,12 @@ int PAdmin::savePrefs(QString pref_fln)
else else
data[i] = " <estimate_n0>n</estimate_n0>"; data[i] = " <estimate_n0>n</estimate_n0>";
} }
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
if (fMusrviewShowFourier)
data[i] = " <musrview_show_fourier>y</musrview_show_fourier>";
else
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
}
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) { if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
if (fEnableMusrT0) if (fEnableMusrT0)
data[i] = " <enable_musrt0>y</enable_musrt0>"; data[i] = " <enable_musrt0>y</enable_musrt0>";
@ -853,13 +848,16 @@ int PAdmin::savePrefs(QString pref_fln)
// write prefs // write prefs
file.setFileName(pref_fln); file.setFileName(pref_fln);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for writing." << endl; cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << pref_fln.toLatin1().data() << " for writing." << endl;
return 0; return 0;
} }
fin.setDevice(&file); fin.setDevice(&file);
for (int i=0; i<data.size(); i++) for (int i=0; i<data.size(); i++)
fin << data[i] << endl; fin << data[i] << endl;
file.close(); file.close();
} else {
QString msg("Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
} }
return 1; return 1;
@ -894,25 +892,11 @@ void PAdmin::saveRecentFiles()
{ {
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to // check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml // save the recent file names otherwise use the "master" musredit_startup.xml
QString str("");
QString fln = QString("./musredit_startup.xml");
if (!QFile::exists(fln))
fln = fPrefPathName;
QString str;
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_WS_MAC
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present if (QFile::exists(fln)) { // administration file present
QVector<QString> data; QVector<QString> data;
QFile file(fln); QFile file(fln);
@ -959,6 +943,9 @@ void PAdmin::saveRecentFiles()
for (int i=0; i<data.size(); i++) for (int i=0; i<data.size(); i++)
fin << data[i] << endl; fin << data[i] << endl;
file.close(); file.close();
} else {
QString msg("Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
} }
} }

View File

@ -136,6 +136,7 @@ class PAdmin : public QObject
PTheory* getTheoryItem(const unsigned int idx); PTheory* getTheoryItem(const unsigned int idx);
PMsr2DataParam getMsr2DataParam() { return fMsr2DataParam; } PMsr2DataParam getMsr2DataParam() { return fMsr2DataParam; }
int getNumRecentFiles() { return fRecentFile.size(); } int getNumRecentFiles() { return fRecentFile.size(); }
QString getDefaultPrefPathName() { return fPrefPathName; }
QString getRecentFile(int idx); QString getRecentFile(int idx);
void setTimeout(const int ival) { fTimeout = ival; } void setTimeout(const int ival) { fTimeout = ival; }
@ -175,6 +176,7 @@ class PAdmin : public QObject
QString fFontName; ///< default font name QString fFontName; ///< default font name
int fFontSize; ///< default font size int fFontSize; ///< default font size
QString fPrefPathName; ///< path-name of the musredit_startup.xml
QString fExecPath; ///< system path to the musrfit executables QString fExecPath; ///< system path to the musrfit executables
QString fDefaultSavePath; ///< default path where the msr-file should be saved QString fDefaultSavePath; ///< default path where the msr-file should be saved
QString fMsrDefaultFilePath; ///< path where to find musredit source QString fMsrDefaultFilePath; ///< path where to find musredit source

View File

@ -129,7 +129,7 @@ PTextEdit::PTextEdit( QWidget *parent, Qt::WindowFlags f )
fileNew(); fileNew();
} }
connect( fTabWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( applyFontSettings(QWidget*) )); connect( fTabWidget, SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
fLastDirInUse = fAdmin->getDefaultSavePath(); fLastDirInUse = fAdmin->getDefaultSavePath();
} }
@ -903,12 +903,31 @@ void PTextEdit::fileReload()
*/ */
void PTextEdit::fileOpenPrefs() void PTextEdit::fileOpenPrefs()
{ {
QString fln = QFileDialog::getOpenFileName( this, tr("Open Prefs"), QString fln("");
QString msg("");
QMessageBox msgBox;
msgBox.setText("Which Preferences do you want to open?");
msgBox.addButton("Default", QMessageBox::AcceptRole);
msgBox.addButton("Custom", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Cancel);
int result = msgBox.exec();
if (result == QMessageBox::Cancel) {
return;
} else if (result == 0) { // default dir
fln = fAdmin->getDefaultPrefPathName();
msg = QString("Current Default Preferences Path-Name:\n") + fln;
if (QMessageBox::information(this, "Info", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
return;
} else if (result == 1) { // custom dir
fln = QFileDialog::getOpenFileName( this, tr("Open Prefs"),
fLastDirInUse, fLastDirInUse,
tr( "xml-Files (*.xml);; All Files (*)" )); tr( "xml-Files (*.xml);; All Files (*)" ));
}
if (fAdmin->loadPrefs(fln)) if (fAdmin->loadPrefs(fln)) {
QMessageBox::information(0, "Prefs", "<b>Prefs Loaded.</b>"); msg = QString("Prefs from '") + fln + QString("' loaded.");
QMessageBox::information(0, "Info", msg);
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -970,12 +989,31 @@ void PTextEdit::fileSaveAs()
*/ */
void PTextEdit::fileSavePrefs() void PTextEdit::fileSavePrefs()
{ {
QString fn = QFileDialog::getSaveFileName( this, QString fln("");
QString msg("");
QMessageBox msgBox;
msgBox.setText("Which Preferences do you want to open?");
msgBox.addButton("Default", QMessageBox::AcceptRole);
msgBox.addButton("Custom", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Cancel);
int result = msgBox.exec();
if (result == QMessageBox::Cancel) {
return;
} else if (result == 0) { // default dir
fln = fAdmin->getDefaultPrefPathName();
msg = QString("Current Default Preferences Path-Name:\n") + fln;
if (QMessageBox::information(this, "Info", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
return;
} else if (result == 1) { // custom dir
fln = QFileDialog::getSaveFileName( this,
tr( "Save Prefs As" ), "musredit_startup.xml", tr( "Save Prefs As" ), "musredit_startup.xml",
tr( "xml-Files (*.xml);;All Files (*)" ) ); tr( "xml-Files (*.xml);;All Files (*)" ) );
}
if ( !fn.isEmpty() ) { if ( !fln.isEmpty() ) {
fAdmin->savePrefs(fn); fAdmin->savePrefs(fln);
msg = QString("Prefs to '") + fln + QString("' saved.");
QMessageBox::information(0, "Info", msg);
} }
} }
@ -2508,7 +2546,7 @@ void PTextEdit::replaceAll()
/** /**
* <p>SLOT: updates the fonts if the textedit tab has changed. * <p>SLOT: updates the fonts if the textedit tab has changed.
*/ */
void PTextEdit::applyFontSettings(QWidget*) void PTextEdit::applyFontSettings(int)
{ {
QFont font(fAdmin->getFontName(), fAdmin->getFontSize()); QFont font(fAdmin->getFontName(), fAdmin->getFontSize());
fontChanged(font); fontChanged(font);

View File

@ -147,7 +147,7 @@ private slots:
void replaceAndClose(); void replaceAndClose();
void replaceAll(); void replaceAll();
void applyFontSettings(QWidget*); void applyFontSettings(int);
void fileChanged(const QString &fileName); void fileChanged(const QString &fileName);
void setFileSystemWatcherActive(); void setFileSystemWatcherActive();

View File

@ -58,8 +58,8 @@ QMAKE_CXX = $${CXX}
QMAKE_LINK = $${CXX} QMAKE_LINK = $${CXX}
# install path for the XML configuration file # install path for the XML configuration file
unix:xml.path = $${MUSREDIT_INSTALL_PATH} unix:xml.path = $$(HOME)/.musrfit/musredit
macx:xml.path = /Applications/musredit.app/Contents/Resources macx:xml.path = $$(HOME)/.musrfit/musredit
win32:xml.path = c:/musrfit/bin win32:xml.path = c:/musrfit/bin
xml.files = musredit_startup.xml xml.files = musredit_startup.xml
INSTALLS += xml INSTALLS += xml

View File

@ -14,6 +14,7 @@
<title_from_data_file>y</title_from_data_file> <title_from_data_file>y</title_from_data_file>
<chisq_per_run_block>n</chisq_per_run_block> <chisq_per_run_block>n</chisq_per_run_block>
<estimate_n0>y</estimate_n0> <estimate_n0>y</estimate_n0>
<musrview_show_fourier>n</musrview_show_fourier>
<enable_musrt0>y</enable_musrt0> <enable_musrt0>y</enable_musrt0>
</general> </general>
<recent_files> <recent_files>

View File

@ -603,6 +603,7 @@ PAdmin::PAdmin() : QObject()
fFontName = QString("Courier"); // default font fFontName = QString("Courier"); // default font
fFontSize = 11; // default font size fFontSize = 11; // default font size
fPrefPathName = QString("");
fExecPath = QString(""); fExecPath = QString("");
fDefaultSavePath = QString(""); fDefaultSavePath = QString("");
fMsrDefaultFilePath = QString(""); fMsrDefaultFilePath = QString("");
@ -641,25 +642,28 @@ PAdmin::PAdmin() : QObject()
fMsr2DataParam.globalPlus = false; fMsr2DataParam.globalPlus = false;
// XML Parser part // XML Parser part
QString fln = "musredit_startup.xml"; // 1st: check local directory
// check if it is a MacOSX QString path = QString("./");
#ifdef Q_OS_OSX QString fln = QString("musredit_startup.xml");
fln = "./musredit_startup.xml"; QString pathFln = path + fln;
if (!QFile::exists(fln)) { if (!QFile::exists(pathFln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml"; // 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
path = std::getenv("HOME");
pathFln = path + "/.musrfit/musredit/" + fln;
if (!QFile::exists(pathFln)) {
// 3rd: check $MUSRFITPATH/musredit_startup.xml
path = std::getenv("MUSRFITPATH");
pathFln = path + "/" + fln;
if (!QFile::exists(pathFln)) {
// 4th: check $ROOTSYS/bin/musredit_startup.xml
path = std::getenv("ROOTSYS");
pathFln = path + "/bin/" + fln;
}
}
} }
#else fPrefPathName = pathFln;
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
loadPrefs(fln); loadPrefs(fPrefPathName);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -769,25 +773,10 @@ int PAdmin::savePrefs(QString pref_fln)
{ {
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to // check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml // save the recent file names otherwise use the "master" musredit_startup.xml
QString fln = QString("./musredit_startup.xml");
if (!QFile::exists(fln))
fln = fPrefPathName;
QString str;
QString fln = "musredit_startup.xml";
// check if it is a MacOSX
#ifdef Q_OS_OSX
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present if (QFile::exists(fln)) { // administration file present
QVector<QString> data; QVector<QString> data;
QFile file(fln); QFile file(fln);
@ -842,6 +831,12 @@ int PAdmin::savePrefs(QString pref_fln)
else else
data[i] = " <estimate_n0>n</estimate_n0>"; data[i] = " <estimate_n0>n</estimate_n0>";
} }
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
if (fMusrviewShowFourier)
data[i] = " <musrview_show_fourier>y</musrview_show_fourier>";
else
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
}
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) { if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
if (fEnableMusrT0) if (fEnableMusrT0)
data[i] = " <enable_musrt0>y</enable_musrt0>"; data[i] = " <enable_musrt0>y</enable_musrt0>";
@ -853,13 +848,16 @@ int PAdmin::savePrefs(QString pref_fln)
// write prefs // write prefs
file.setFileName(pref_fln); file.setFileName(pref_fln);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for writing." << endl; cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << pref_fln.toLatin1().data() << " for writing." << endl;
return 0; return 0;
} }
fin.setDevice(&file); fin.setDevice(&file);
for (int i=0; i<data.size(); i++) for (int i=0; i<data.size(); i++)
fin << data[i] << endl; fin << data[i] << endl;
file.close(); file.close();
} else {
QString msg("Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
} }
return 1; return 1;
@ -895,24 +893,11 @@ void PAdmin::saveRecentFiles()
// check if musredit_startup.xml is present in the current directory, and if yes, use this file to // check if musredit_startup.xml is present in the current directory, and if yes, use this file to
// save the recent file names otherwise use the "master" musredit_startup.xml // save the recent file names otherwise use the "master" musredit_startup.xml
QString str; QString str("");
QString fln = "musredit_startup.xml"; QString fln = QString("./musredit_startup.xml");
// check if it is a MacOSX if (!QFile::exists(fln))
#ifdef Q_OS_OSX fln = fPrefPathName;
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
fln = "/Applications/musredit.app/Contents/Resources/musredit_startup.xml";
}
#else
fln = "./musredit_startup.xml";
if (!QFile::exists(fln)) {
QString path = std::getenv("MUSRFITPATH");
QString rootsys = std::getenv("ROOTSYS");
if (path.isEmpty())
path = rootsys + "/bin";
fln = path + "/musredit_startup.xml";
}
#endif
if (QFile::exists(fln)) { // administration file present if (QFile::exists(fln)) { // administration file present
QVector<QString> data; QVector<QString> data;
QFile file(fln); QFile file(fln);
@ -959,6 +944,9 @@ void PAdmin::saveRecentFiles()
for (int i=0; i<data.size(); i++) for (int i=0; i<data.size(); i++)
fin << data[i] << endl; fin << data[i] << endl;
file.close(); file.close();
} else {
QString msg("Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
QMessageBox::warning(0, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
} }
} }

View File

@ -136,6 +136,7 @@ class PAdmin : public QObject
PTheory* getTheoryItem(const unsigned int idx); PTheory* getTheoryItem(const unsigned int idx);
PMsr2DataParam getMsr2DataParam() { return fMsr2DataParam; } PMsr2DataParam getMsr2DataParam() { return fMsr2DataParam; }
int getNumRecentFiles() { return fRecentFile.size(); } int getNumRecentFiles() { return fRecentFile.size(); }
QString getDefaultPrefPathName() { return fPrefPathName; }
QString getRecentFile(int idx); QString getRecentFile(int idx);
void setTimeout(const int ival) { fTimeout = ival; } void setTimeout(const int ival) { fTimeout = ival; }
@ -153,7 +154,7 @@ class PAdmin : public QObject
void addRecentFile(const QString str); void addRecentFile(const QString str);
int loadPrefs(QString fln); int loadPrefs(QString fln);
int savePrefs(QString pref_fln); int savePrefs(QString pref_fln);
protected: protected:
void setExecPath(const QString str) { fExecPath = str; } void setExecPath(const QString str) { fExecPath = str; }
@ -175,6 +176,7 @@ class PAdmin : public QObject
QString fFontName; ///< default font name QString fFontName; ///< default font name
int fFontSize; ///< default font size int fFontSize; ///< default font size
QString fPrefPathName; ///< path-name of the musredit_startup.xml
QString fExecPath; ///< system path to the musrfit executables QString fExecPath; ///< system path to the musrfit executables
QString fDefaultSavePath; ///< default path where the msr-file should be saved QString fDefaultSavePath; ///< default path where the msr-file should be saved
QString fMsrDefaultFilePath; ///< path where to find musredit source QString fMsrDefaultFilePath; ///< path where to find musredit source

View File

@ -127,7 +127,7 @@ PTextEdit::PTextEdit( QWidget *parent, Qt::WindowFlags f )
fileNew(); fileNew();
} }
connect( fTabWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( applyFontSettings(QWidget*) )); connect( fTabWidget, SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
fLastDirInUse = fAdmin->getDefaultSavePath(); fLastDirInUse = fAdmin->getDefaultSavePath();
} }
@ -901,12 +901,31 @@ void PTextEdit::fileReload()
*/ */
void PTextEdit::fileOpenPrefs() void PTextEdit::fileOpenPrefs()
{ {
QString fln = QFileDialog::getOpenFileName( this, tr("Open Prefs"), QString fln("");
QString msg("");
QMessageBox msgBox;
msgBox.setText("Which Preferences do you want to open?");
msgBox.addButton("Default", QMessageBox::AcceptRole);
msgBox.addButton("Custom", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Cancel);
int result = msgBox.exec();
if (result == QMessageBox::Cancel) {
return;
} else if (result == 0) { // default dir
fln = fAdmin->getDefaultPrefPathName();
msg = QString("Current Default Preferences Path-Name:\n") + fln;
if (QMessageBox::information(this, "Info", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
return;
} else if (result == 1) { // custom dir
fln = QFileDialog::getOpenFileName( this, tr("Open Prefs"),
fLastDirInUse, fLastDirInUse,
tr( "xml-Files (*.xml);; All Files (*)" )); tr( "xml-Files (*.xml);; All Files (*)" ));
}
if (fAdmin->loadPrefs(fln)) if (fAdmin->loadPrefs(fln)) {
QMessageBox::information(0, "Prefs", "<b>Prefs Loaded.</b>"); msg = QString("Prefs from '") + fln + QString("' loaded.");
QMessageBox::information(0, "Info", msg);
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -968,12 +987,31 @@ void PTextEdit::fileSaveAs()
*/ */
void PTextEdit::fileSavePrefs() void PTextEdit::fileSavePrefs()
{ {
QString fn = QFileDialog::getSaveFileName( this, QString fln("");
QString msg("");
QMessageBox msgBox;
msgBox.setText("Which Preferences do you want to open?");
msgBox.addButton("Default", QMessageBox::AcceptRole);
msgBox.addButton("Custom", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Cancel);
int result = msgBox.exec();
if (result == QMessageBox::Cancel) {
return;
} else if (result == 0) { // default dir
fln = fAdmin->getDefaultPrefPathName();
msg = QString("Current Default Preferences Path-Name:\n") + fln;
if (QMessageBox::information(this, "Info", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
return;
} else if (result == 1) { // custom dir
fln = QFileDialog::getSaveFileName( this,
tr( "Save Prefs As" ), "musredit_startup.xml", tr( "Save Prefs As" ), "musredit_startup.xml",
tr( "xml-Files (*.xml);;All Files (*)" ) ); tr( "xml-Files (*.xml);;All Files (*)" ) );
}
if ( !fn.isEmpty() ) { if ( !fln.isEmpty() ) {
fAdmin->savePrefs(fn); fAdmin->savePrefs(fln);
msg = QString("Prefs to '") + fln + QString("' saved.");
QMessageBox::information(0, "Info", msg);
} }
} }
@ -2506,7 +2544,7 @@ void PTextEdit::replaceAll()
/** /**
* <p>SLOT: updates the fonts if the textedit tab has changed. * <p>SLOT: updates the fonts if the textedit tab has changed.
*/ */
void PTextEdit::applyFontSettings(QWidget*) void PTextEdit::applyFontSettings(int)
{ {
QFont font(fAdmin->getFontName(), fAdmin->getFontSize()); QFont font(fAdmin->getFontName(), fAdmin->getFontSize());
fontChanged(font); fontChanged(font);

View File

@ -147,7 +147,7 @@ private slots:
void replaceAndClose(); void replaceAndClose();
void replaceAll(); void replaceAll();
void applyFontSettings(QWidget*); void applyFontSettings(int);
void fileChanged(const QString &fileName); void fileChanged(const QString &fileName);
void setFileSystemWatcherActive(); void setFileSystemWatcherActive();

View File

@ -31,8 +31,8 @@ unix {
unix:target.path = $${MUSREDIT_INSTALL_PATH} unix:target.path = $${MUSREDIT_INSTALL_PATH}
macx:target.path = /Applications macx:target.path = /Applications
win32:target.path = c:/musrfit/bin win32:target.path = c:/musrfit/bin
INSTALLS += target INSTALLS += target
# This is only needed for SL5.1 # This is only needed for SL5.1
@ -58,8 +58,8 @@ QMAKE_CXX = $${CXX}
QMAKE_LINK = $${CXX} QMAKE_LINK = $${CXX}
# install path for the XML configuration file # install path for the XML configuration file
unix:xml.path = $${MUSREDIT_INSTALL_PATH} unix:xml.path = $$(HOME)/.musrfit/musredit
macx:xml.path = /Applications/musredit.app/Contents/Resources macx:xml.path = $$(HOME)/.musrfit/musredit
win32:xml.path = c:/musrfit/bin win32:xml.path = c:/musrfit/bin
xml.files = musredit_startup.xml xml.files = musredit_startup.xml
INSTALLS += xml INSTALLS += xml

View File

@ -14,6 +14,7 @@
<title_from_data_file>y</title_from_data_file> <title_from_data_file>y</title_from_data_file>
<chisq_per_run_block>n</chisq_per_run_block> <chisq_per_run_block>n</chisq_per_run_block>
<estimate_n0>y</estimate_n0> <estimate_n0>y</estimate_n0>
<musrview_show_fourier>n</musrview_show_fourier>
<enable_musrt0>y</enable_musrt0> <enable_musrt0>y</enable_musrt0>
</general> </general>
<recent_files> <recent_files>