Merge branch 'master' into root6

This commit is contained in:
suter_a 2016-02-17 13:10:13 +01:00
commit fe4c0ddede
18 changed files with 228 additions and 153 deletions

View File

@ -2,9 +2,16 @@
# ChangeLog # ChangeLog
#--------------------------------------------------------------------- #---------------------------------------------------------------------
changes since 0.17.0
===================================
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 move the startup XML-files to $HOME/.musrfit
rather than having it within $prefix/bin. Increase
therefore the version number to 0.17.0
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

@ -30,3 +30,4 @@ For a more exhaustive user documentation see:
### Contact ### ### Contact ###
<andreas.suter@psi.ch> <andreas.suter@psi.ch>

View File

@ -1,7 +1,7 @@
AC_REVISION([m4_esyscmd_s([git describe --always])]) AC_REVISION([m4_esyscmd_s([git describe --always])])
AC_PREREQ(2.63) AC_PREREQ(2.63)
AC_INIT([musrfit],[0.16.0],[andreas.suter@psi.ch]) AC_INIT([musrfit],[0.17.0],[andreas.suter@psi.ch])
AC_CONFIG_AUX_DIR(admin) AC_CONFIG_AUX_DIR(admin)
AC_CANONICAL_HOST AC_CANONICAL_HOST
#AC_MSG_RESULT([${host} ${host_cpu} ${host_vendor} ${host_os}]) #AC_MSG_RESULT([${host} ${host_cpu} ${host_vendor} ${host_os}])
@ -35,7 +35,7 @@ dnl -----------------------------------------------
#release versioning #release versioning
MUSR_MAJOR_VERSION=0 MUSR_MAJOR_VERSION=0
MUSR_MINOR_VERSION=16 MUSR_MINOR_VERSION=17
MUSR_MICRO_VERSION=0 MUSR_MICRO_VERSION=0
#release versioning #release versioning
@ -1404,6 +1404,7 @@ echo ""
echo " Installation directories:" echo " Installation directories:"
echo " -------------------------" echo " -------------------------"
echo "" echo ""
echo " Programs and XML configuration files: ${INSTALLDIR}/bin" echo " Programs: ${INSTALLDIR}/bin"
echo " XML configuration files: ${HOME}/.musrfit"
echo " Documentation: ${DOCDIR}" echo " Documentation: ${DOCDIR}"
echo "" echo ""

View File

@ -60,7 +60,7 @@ write_musrRoot_runHeader_SOURCES = write_musrRoot_runHeader.cpp
musrRootValidation_SOURCES = musrRootValidation.cpp musrRootValidation_SOURCES = musrRootValidation.cpp
dump_header_SOURCES = dump_header.cpp dump_header_SOURCES = dump_header.cpp
xmldir = $(bindir) xmldir = $(HOME)/.musrfit
xml_DATA = musrfit_startup.xml xml_DATA = musrfit_startup.xml
LIBADD = $(PMUSR_LIBS) $(MUSR_ROOT_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) LIBADD = $(PMUSR_LIBS) $(MUSR_ROOT_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS)
@ -82,7 +82,7 @@ install-xmlDATA: $(xml_DATA)
DIFF="$$(diff "$(DESTDIR)$(xmldir)/$(xml_DATA)" "$(xml_DATA)" 2>&1)"; \ DIFF="$$(diff "$(DESTDIR)$(xmldir)/$(xml_DATA)" "$(xml_DATA)" 2>&1)"; \
if test "x$$DIFF" != "x"; then \ if test "x$$DIFF" != "x"; then \
echo " " && \ echo " " && \
echo " musrfit_startup.xml in $(bindir)" && \ echo " musrfit_startup.xml in $(xmldir)" && \
echo " is different from the distribution's version." && \ echo " is different from the distribution's version." && \
echo " Do you want to overwrite it? [y/N]" && \ echo " Do you want to overwrite it? [y/N]" && \
read OVERWRITE && \ read OVERWRITE && \
@ -101,7 +101,7 @@ uninstall-xmlDATA:
DIFF="$$(diff "$(DESTDIR)$(xmldir)/$(xml_DATA)" "$(xml_DATA)" 2>&1)"; \ DIFF="$$(diff "$(DESTDIR)$(xmldir)/$(xml_DATA)" "$(xml_DATA)" 2>&1)"; \
if test "x$$DIFF" != "x"; then \ if test "x$$DIFF" != "x"; then \
echo " " && \ echo " " && \
echo " musrfit_startup.xml in $(bindir)" && \ echo " musrfit_startup.xml in $(xmldir)" && \
echo " is different from the distribution's version." && \ echo " is different from the distribution's version." && \
echo " Do you want to remove it? [y/N]" && \ echo " Do you want to remove it? [y/N]" && \
read REMOVE && \ read REMOVE && \

View File

@ -93,11 +93,13 @@ PStartupHandler::PStartupHandler()
fStartupFilePath = ""; fStartupFilePath = "";
// get default path (for the moment only linux like) // get default path (for the moment only linux like)
Char_t *pmusrpath; Char_t *pmusrpath=0;
Char_t *home; Char_t *home=0;
Char_t musrpath[128]; Char_t musrpath[128];
Char_t startup_path_name[128]; Char_t startup_path_name[128];
Bool_t pmusrpathfound = false; Bool_t found = false;
strncpy(musrpath, "", sizeof(musrpath));
// check if the startup file is found in the current directory // check if the startup file is found in the current directory
strcpy(startup_path_name, "./musrfit_startup.xml"); strcpy(startup_path_name, "./musrfit_startup.xml");
@ -105,20 +107,27 @@ PStartupHandler::PStartupHandler()
fStartupFileFound = true; fStartupFileFound = true;
fStartupFilePath = TString(startup_path_name); fStartupFilePath = TString(startup_path_name);
} else { // startup file is not found in the current directory } else { // startup file is not found in the current directory
// check if the MUSRFITPATH system variable is set // check if the startup file is found under $HOME/.musrfit
home = getenv("HOME");
if (home != 0) {
sprintf(musrpath, "%s/.musrfit", home);
found = true;
}
pmusrpath = getenv("MUSRFITPATH"); pmusrpath = getenv("MUSRFITPATH");
if (!found) {
// check if the MUSRFITPATH system variable is set
if (pmusrpath != 0) { if (pmusrpath != 0) {
if (strcmp(pmusrpath, "")) { // MUSRFITPATH variable set but empty if (strcmp(pmusrpath, "")) { // MUSRFITPATH variable set but empty
pmusrpathfound = true; found = true;
} }
} }
if (!pmusrpathfound) { // MUSRFITPATH not set or empty, will try default one }
if (!found) { // MUSRFITPATH not set or empty, will try default one
home = getenv("ROOTSYS"); home = getenv("ROOTSYS");
sprintf(musrpath, "%s/bin", home); sprintf(musrpath, "%s/bin", home);
cerr << endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << endl; cerr << endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << endl;
} else {
strncpy(musrpath, pmusrpath, sizeof(musrpath));
} }
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath); sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
fStartupFilePath = TString(startup_path_name); fStartupFilePath = TString(startup_path_name);
if (StartupFileExists(startup_path_name)) { if (StartupFileExists(startup_path_name)) {

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
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 }
fPrefPathName = pathFln;
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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<musredit_startup xmlns="http://lmu.web.psi.ch/facilities/software/musrfit/user/MUSR/MusrGui.html"> <musredit_startup xmlns="http://lmu.web.psi.ch/musrfit/user/MUSR/MusrGui.html">
<comment> <comment>
This is handling default setting parameters for the musredit. This is handling default setting parameters for the musredit.
</comment> </comment>
@ -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
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 }
fPrefPathName = pathFln;
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; }
@ -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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<musredit_startup xmlns="http://lmu.web.psi.ch/facilities/software/musrfit/user/MUSR/MusrGui.html"> <musredit_startup xmlns="http://lmu.web.psi.ch/musrfit/user/MUSR/MusrGui.html">
<comment> <comment>
This is handling default setting parameters for the musredit. This is handling default setting parameters for the musredit.
</comment> </comment>
@ -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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<musrfit xmlns="http://lmu.web.psi.ch/facilities/software/musrfit/user/MUSR/MusrFit.html"> <musrfit xmlns="http://lmu.web.psi.ch/musrfit/user/MUSR/WebHome.html">
<comment> <comment>
Defines default settings for the musrfit package Defines default settings for the musrfit package
</comment> </comment>