Compare commits

...

15 Commits

Author SHA1 Message Date
f99f71a8db slight improvement on mud.h needed that it doesn't crash on macos15.4 m3pro. 2025-04-09 17:11:14 +02:00
6e60013037 updated mud.h (thanks to Donald Arseneau). Makes modern compiler happy again. 2025-04-08 17:00:04 +02:00
e38fa47961 add skeleton for MusrRoot which will handle TDirectoryFile rather than TFolder. 2025-04-04 18:37:42 +02:00
764cdf4e51 start implementing TDirectoryFile instead of TFolder, since TFolder is depricated. First I added the necessary parts on the validator. The read/write are still missing. 2025-04-04 16:58:57 +02:00
e5ff0fa743 switched from raw to QScopedPointer pointer in mupp.cpp. 2025-04-01 14:10:59 +02:00
e26fa4eea2 removed my quick and dirty fix. It doesn't work for all compilers. Reported bug to triumf and wait for a fix. 2025-03-31 07:54:25 +02:00
5648757389 back ported some qt6 recent file handling. 2025-03-30 18:14:04 +02:00
Andreas Suter
c3b4c7c3b1 improved recent file handling for macos. 2025-03-30 17:09:04 +02:00
e233c860d1 slight improvement in handling of the recent msr-files. 2025-03-30 15:30:46 +02:00
c230bfb1bc updated the icon switching by adding the missing View2Dat. 2025-03-29 22:36:48 +01:00
5119b1cd13 fixed typo and added necessary update for the theme flags. 2025-03-29 21:48:23 +01:00
d937324885 improved dark theme handling on mupp for qt5. 2025-03-29 20:54:03 +01:00
f7e5c53879 improved dark theme handling on mupp for qt6. 2025-03-29 20:17:28 +01:00
3796925e93 needed to adopt mud.h to make it gcc15.0.1 ready. 2025-03-26 17:05:16 +01:00
d5343a0073 activate the status bar. 2025-03-25 15:35:10 +01:00
24 changed files with 310 additions and 170 deletions

View File

@ -22,7 +22,7 @@ set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\$\{prefix\}")
set(libdir "\$\{exec_prefix\}/lib")
set(includedir "\$\{prefix\}/include")
set(MUSR_ROOT_VERSION "1.0.0")
set(MUSR_ROOT_VERSION "1.1.0")
set(MUSR_ROOT_LIBRARY_NAME "TMusrRunHeader")
configure_file("TMusrRunHeader.pc.in" "TMusrRunHeader.pc" @ONLY)

View File

@ -395,6 +395,23 @@ Bool_t TMusrRunHeader::FillFolder(TFolder *folder)
return true;
}
//--------------------------------------------------------------------------
// FillDirectory (public)
//--------------------------------------------------------------------------
/**
* <p>Fills the RunHeader directory. This is needed to write it to a ROOT file.
* It walks through all information and attaches it to the directory or replaces
* it, if it is already present.
*
* \param dir to be filled
*/
Bool_t TMusrRunHeader::FillDirectory(TDirectoryFile *dir)
{
// NOT YET IMPLEMENTED
return true;
}
//--------------------------------------------------------------------------
// GetTypeOfPath (public)
//--------------------------------------------------------------------------
@ -873,6 +890,22 @@ Bool_t TMusrRunHeader::ExtractAll(TFolder *folder)
return true;
}
//--------------------------------------------------------------------------
// ExtractAll (public)
//--------------------------------------------------------------------------
/**
* <p>Reads all data from an open ROOT-file structure and feeds all the necessary
* internal data objects.
*
* \param dir
*/
Bool_t TMusrRunHeader::ExtractAll(TDirectoryFile *dir)
{
// NOT YET IMPLEMENTED
return true;
}
//--------------------------------------------------------------------------
// ExtractHeaderInformation (public)
//--------------------------------------------------------------------------

View File

@ -38,6 +38,7 @@
#include <TObjString.h>
#include <TObjArray.h>
#include <TFolder.h>
#include <TDirectoryFile.h>
#define MRH_UNDEFINED -9.99e99
@ -129,8 +130,10 @@ public:
virtual TString GetFileName() { return fFileName; }
virtual Bool_t FillFolder(TFolder *folder);
virtual Bool_t FillDirectory(TDirectoryFile *dir);
virtual Bool_t ExtractAll(TFolder *folder);
virtual Bool_t ExtractAll(TDirectoryFile *folder);
virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path);
virtual TString GetTypeOfPath(TString pathName);

View File

@ -4,7 +4,7 @@
* mud.h Declarations for MUD
* v1.3
*
* Copyright (C) 1994-2025 TRIUMF (Vancouver, Canada)
* Copyright (C) 1994-2021 TRIUMF (Vancouver, Canada)
*
* Authors: T. Whidden, D. Arseneau, S. Daviel
*
@ -25,14 +25,13 @@
* 25-Nov-2009 DJA 64-bit linux
* 25-Jun-2017 DJA Allow use in C++ (ROOT); shared lib.
* 14-Aug-2019 DJA Use stdint.h, casts in printf
* 01-Jun-2021 DJA Add arm64 arch as little-endian
* 26-Aug-2021 DJA Declare caddr_t in all Win.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __CINT__
typedef char* caddr_t;
#endif /* __CINT __ */
/*
* FORMAT IDs - Must be unique!
@ -133,25 +132,25 @@ typedef int32_t INT32;
typedef uint32_t UINT32;
typedef float REAL32;
typedef double REAL64;
#else /*no stding.h */
#else /*no stdint.h */
typedef int STATUS;
typedef char INT8;
typedef unsigned char UINT8;
typedef short INT16;
typedef unsigned short UINT16;
#if defined(__alpha) || defined(__linux) || defined(__MACH__) || defined(__arm64)
#if defined(__alpha)||defined(__linux)||defined(__MACH__) || defined(__arm64)
typedef int INT32;
typedef unsigned int UINT32;
#else
typedef long INT32;
typedef unsigned long UINT32;
#endif /* __alpha || __linux || __MACH__*/
#endif /* __alpha || __linux || __MACH__ || __arm64 */
typedef float REAL32;
typedef double REAL64;
#if (defined(__alpha)&&defined(vms)) || defined(__BORLANDC__) || defined(__TURBOC__)
#endif /* _STDINT_H */
#if (defined(__alpha)&&defined(vms)) || defined( __CINT__ ) || defined(_WIN32)
typedef char* caddr_t;
#endif
#endif /* _STDINT_HNOSTDINT */
typedef UINT32 TIME;
#ifndef BOOL_DEFINED
#define BOOL_DEFINED
@ -184,10 +183,10 @@ typedef UINT32 BOOL;
/*
* c_utils.h, Defines for C utilities
*/
#if defined(vms) || defined(__MSDOS__)
#if defined(vms) || defined(__MSDOS__) || defined(_WIN32)
#define bcopy( b1, b2, len ) memcpy(b2,b1,len)
#define bzero( b, len ) memset(b,(char)0,len)
#endif /* vms || __MSDOS__ */
#endif /* vms || __MSDOS__ || _WIN32 */
#ifndef _C_UTILS_H_ /* conflict with c_utils.h */
#define _max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
#define _min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
@ -204,7 +203,6 @@ typedef UINT32 BOOL;
#define strdup( s ) strcpy((char*)malloc(strlen(s)+1),s)
#endif /* vms || mips&&!sgi */
/*#endif */
typedef int (*MUD_PROC)();
typedef enum {
MUD_ENCODE = 0,
@ -215,6 +213,8 @@ typedef enum {
MUD_HEADS = 5
} MUD_OPT;
typedef int (*MUD_PROC)(MUD_OPT, void *p1, void *p2);
typedef enum {
MUD_ONE = 1,
MUD_ALL = 2,
@ -427,7 +427,7 @@ typedef struct {
#define MUD_instanceID( pM ) (((MUD_SEC*)pM)->core.instanceID)
#if defined(__MSDOS__) || defined(__i386__) || defined(__i586__) || defined(__i686__) || defined(vax) || defined(__alpha) || defined(__amd64) || defined(__arm64) || (defined(__mips)&&!defined(__sgi))
#if defined(__MSDOS__) || defined(_WIN32) || defined(__i386__) || defined(__i586__) || defined(__i686__) || defined(vax) || defined(__alpha) || defined(__amd64) || defined(__arm64) || (defined(__mips)&&!defined(__sgi))
#define MUD_LITTLE_ENDIAN 1
#else
#define MUD_BIG_ENDIAN 1

View File

@ -39,7 +39,9 @@
#include "TString.h"
#include "TFile.h"
#include "TFolder.h"
#include "TDirectoryFile.h"
#include "TKey.h"
#include "TList.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "TSystemFile.h"
@ -73,7 +75,7 @@ class PMusrRoot2Xml
virtual UInt_t GetNoOfDetectors() { return fNoOfDetectors; }
private:
enum EFolderTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule};
enum fNodeTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule};
std::vector<std::string> fXmlData; ///< keeps the XML structure dump of the ROOT file
@ -82,14 +84,15 @@ class PMusrRoot2Xml
Bool_t fValid; ///< true if the conversion was fine
TString fFileName; ///< file name of the ROOT file
TString fXmlDumpFileName; ///< file name of the XML dump file
EFolderTag fFolderTag; ///< switch indicating which kind of TFolder object is found
fNodeTag fNodeTag; ///< switch indicating which kind of TFolder or TDirectoryFile object is found
UInt_t fNoOfDecayHistos; ///< number of decay histos in the DecayAnaModule
UInt_t fNoOfHistos; ///< number of histos from run header
UInt_t fNoOfRedGreenOffsets; ///< number of RedGreen offsets
UInt_t fNoOfDetectors; ///< number of detector entries in the header
UInt_t fNoOfDecayHistos{0}; ///< number of decay histos in the DecayAnaModule
UInt_t fNoOfHistos{0}; ///< number of histos from run header
UInt_t fNoOfRedGreenOffsets{0}; ///< number of RedGreen offsets
UInt_t fNoOfDetectors{0}; ///< number of detector entries in the header
virtual void SortHistoFolders();
virtual void DumpDirectory(TDirectoryFile *dir, UInt_t offset);
virtual void DumpFolder(TFolder *folder, UInt_t offset);
virtual void DumpObjArray(TObjArray *obj, UInt_t offset);
virtual void DumpEntry(TObject *obj, UInt_t offset);
@ -105,13 +108,9 @@ class PMusrRoot2Xml
PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQuiet(quiet), fKeep(keep), fFileName(fileName)
{
fXmlDumpFileName = "__MusrRootXmlDump.xml";
fFolderTag = eUnkown;
fNodeTag = eUnkown;
fValid = false;
fXmlData.clear();
fNoOfDecayHistos = 0;
fNoOfHistos = 0;
fNoOfRedGreenOffsets = 0;
fNoOfDetectors = 0;
// read assumed MusrRoot file
TFile f(fFileName.Data());
@ -127,7 +126,8 @@ PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQui
TIter next = f.GetListOfKeys();
TKey *key;
TFolder *folder;
TString str, tag;
TDirectoryFile *dir;
TString str;
UInt_t offset = 2;
@ -137,6 +137,9 @@ PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQui
if (str == "TFolder") {
folder = dynamic_cast<TFolder*>(key->ReadObj());
CheckClass(folder, str, offset);
} else if (str == "TDirectoryFile") {
dir = dynamic_cast<TDirectoryFile*>(key->ReadObj());
CheckClass(dir, str, offset);
}
}
if (!fQuiet) std::cout << std::endl;
@ -226,6 +229,30 @@ void PMusrRoot2Xml::SortHistoFolders()
temp_xml_data.clear();
}
//-----------------------------------------------------------------------
/**
* <p>Dump TDirectoryFile structure.
*
* \param dir TDirectoryFile object found in the ROOT file
* \param offset needed to indent dump info
*/
void PMusrRoot2Xml::DumpDirectory(TDirectoryFile *dir, UInt_t offset)
{
TString offsetStr="";
for (UInt_t i=0; i<offset; i++)
offsetStr += " ";
TList *ll = dir->GetListOfKeys();
TString str;
TObject *oo;
for (TObject *obj: *ll) {
oo = static_cast<TKey*>(obj)->ReadObj();
if (!fQuiet) std::cout << std::endl << offsetStr << "name: " << oo->GetName() << ", class name: " << oo->ClassName();
str = oo->ClassName();
CheckClass(oo, str, offset);
}
}
//-----------------------------------------------------------------------
/**
* <p>Dump folder structure.
@ -343,7 +370,7 @@ void PMusrRoot2Xml::DumpEntry(TObject *obj, UInt_t offset)
offsetStr += " ";
TString nameTag(""), typeTag("");
switch (fFolderTag) {
switch (fNodeTag) {
case eDecayAnaModule:
nameTag = "HistoName";
typeTag = "HistoType";
@ -359,7 +386,7 @@ void PMusrRoot2Xml::DumpEntry(TObject *obj, UInt_t offset)
break;
}
if (fFolderTag == eDecayAnaModule)
if (fNodeTag == eDecayAnaModule)
fNoOfDecayHistos++;
TString str;
@ -389,34 +416,37 @@ void PMusrRoot2Xml::CheckClass(TObject *obj, TString str, UInt_t offset)
for (UInt_t i=0; i<offset; i++)
offsetStr += " ";
if (str == "TFolder") {
if ((str == "TFolder") || (str == "TDirectoryFile")) {
TString xmlTagName(TString(obj->GetName()));
// set folder tag
if (!xmlTagName.CompareTo("DecayAnaModule"))
fFolderTag = eDecayAnaModule;
fNodeTag = eDecayAnaModule;
else if (!xmlTagName.CompareTo("SCAnaModule"))
fFolderTag = eSlowControlAnaModule;
fNodeTag = eSlowControlAnaModule;
else if (!xmlTagName.CompareTo("SCAnaModule"))
fFolderTag = eSlowControlAnaModule;
fNodeTag = eSlowControlAnaModule;
else
fFolderTag = eUnkown;
fNodeTag = eUnkown;
offset += 2;
str = offsetStr + "<" + xmlTagName + ">";
fXmlData.push_back(str.Data());
TString sstr = offsetStr + "<" + xmlTagName + ">";
fXmlData.push_back(sstr.Data());
if (str == "TFolder")
DumpFolder(dynamic_cast<TFolder*>(obj), offset);
else
DumpDirectory(dynamic_cast<TDirectoryFile*>(obj), offset);
str = offsetStr + "</" + xmlTagName + ">";
fXmlData.push_back(str.Data());
sstr = offsetStr + "</" + xmlTagName + ">";
fXmlData.push_back(sstr.Data());
} else if (str == "TObjArray") {
offset += 2;
DumpObjArray(dynamic_cast<TObjArray*>(obj), offset);
} else {
// filter out the proper entry tag
TString entryTag("");
switch (fFolderTag) {
switch (fNodeTag) {
case eDecayAnaModule:
entryTag = TString("DecayHistoEntry");
break;

View File

@ -156,8 +156,12 @@ bool PmuppAdminXMLParser::startElement()
if (qName == "path_file_name") {
fKeyWord = eRecentFile;
} else if (qName == "dark_theme") {
fKeyWord = eDarkTheme;
} else if (qName == "ignore_theme_auto_detection") {
fKeyWord = eIgnoreThemeAutoDetection;
} else if (qName == "dark_theme_icon_menu") {
fKeyWord = eDarkThemeIconsMenu;
} else if (qName == "dark_theme_icon_toolbar") {
fKeyWord = eDarkThemeIconsToolbar;
} else if (qName == "marker") {
fKeyWord = eMarker;
} else if (qName == "color") {
@ -201,11 +205,23 @@ bool PmuppAdminXMLParser::characters()
case eRecentFile:
fAdmin->addRecentFile(QString(str.toLatin1()).trimmed());
break;
case eDarkTheme:
if ((str == "yes") || (str == "1") || (str == "true"))
fAdmin->setTheme(true);
case eIgnoreThemeAutoDetection:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setIgnoreThemeAutoDetection(true);
else
fAdmin->setTheme(false);
fAdmin->setIgnoreThemeAutoDetection(false);
break;
case eDarkThemeIconsMenu:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setThemeIconsMenu(true);
else
fAdmin->setThemeIconsMenu(false);
break;
case eDarkThemeIconsToolbar:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setThemeIconsToolbar(true);
else
fAdmin->setThemeIconsToolbar(false);
break;
case eMarker:
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
@ -280,7 +296,7 @@ bool PmuppAdminXMLParser::endDocument()
* <p>Initializes that PmuppAdmin object, and calls the XML parser which feeds
* the object variables.
*/
PmuppAdmin::PmuppAdmin() : QObject(), fDarkTheme(false)
PmuppAdmin::PmuppAdmin() : QObject()
{
// XML Parser part
// 1st: check local directory

View File

@ -102,7 +102,9 @@ class PmuppAdminXMLParser
virtual bool isValid() { return fValid; }
private:
enum EAdminKeyWords {eEmpty, eRecentFile, eDarkTheme, eMarker, eColor};
enum EAdminKeyWords {eEmpty, eRecentFile,
eIgnoreThemeAutoDetection, eDarkThemeIconsMenu, eDarkThemeIconsToolbar,
eMarker, eColor};
bool parse(QIODevice *device);
bool startDocument();
@ -145,18 +147,24 @@ class PmuppAdmin : public QObject
void getColor(QString name, int &r, int &g, int &b);
void getColor(int idx, int &r, int &g, int &b);
bool isDarkTheme() { return fDarkTheme; }
bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection; }
bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; }
bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; }
void setTheme(bool theme) { fDarkTheme = theme; }
void setMarker(int marker, double size);
void setColor(int r, int g, int b, QString name="");
void setIgnoreThemeAutoDetection(const bool theme) { fIgnoreThemeAutoDetection = theme; }
void setThemeIconsMenu(const bool theme) { fDarkThemeIconsMenu = theme; }
void setThemeIconsToolbar(const bool theme) { fDarkThemeIconsToolbar = theme; }
void setMarker(const int marker, const double size);
void setColor(const int r, const int g, const int b, QString name="");
private:
friend class PmuppAdminXMLParser;
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fDarkTheme;
bool fIgnoreThemeAutoDetection{false};
bool fDarkThemeIconsMenu{false};
bool fDarkThemeIconsToolbar{false};
QVector<PmuppMarker> fMarker;
QVector<PmuppColor> fColor;

View File

@ -250,6 +250,9 @@ PmuppGui::PmuppGui(QStringList fln)
readCmdHistory();
fAdmin = new PmuppAdmin();
fIgnoreThemeAutoDetection = fAdmin->getIgnoreThemeAutoDetection();
fDarkThemeIconsMenu = fAdmin->getDarkThemeIconsMenuFlag();
fDarkThemeIconsToolbar = fAdmin->getDarkThemeIconsToolbarFlag();
fParamDataHandler = new PParamDataHandler();
bool dataAtStartup = false;
@ -270,7 +273,7 @@ PmuppGui::PmuppGui(QStringList fln)
getTheme();
QString iconName("");
if (fDarkTheme)
if (fDarkThemeIconsMenu)
iconName = QString(":/icons/mupp-dark.svg");
else
iconName = QString(":/icons/mupp-plain.svg");
@ -514,7 +517,7 @@ void PmuppGui::setupFileActions()
QAction *a;
QString iconName("");
if (fDarkTheme)
if (fDarkThemeIconsMenu)
iconName = QString(":/icons/document-open-dark.svg");
else
iconName = QString(":/icons/document-open-plain.svg");
@ -523,7 +526,7 @@ void PmuppGui::setupFileActions()
a->setStatusTip( tr("Open a musrfit parameter file.") );
connect( a, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
menu->addAction(a);
if (!fDarkToolBarIcon) { // tool bar icon is not dark, even though the theme is (ubuntu)
if (!fDarkThemeIconsToolbar) { // tool bar icon is not dark, even though the theme is (ubuntu)
iconName = QString(":/icons/document-open-plain.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "&New..." ), this );
connect( a, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
@ -848,26 +851,32 @@ bool PmuppGui::eventFilter(QObject *o, QEvent *e)
*/
void PmuppGui::getTheme()
{
fDarkTheme = false; // true if theme is dark
fDarkToolBarIcon = false; // needed for ubuntu dark since there the menu icons
if (fIgnoreThemeAutoDetection)
return;
fDarkThemeIconsMenu = false; // true if theme is dark
fDarkThemeIconsToolbar = false; // needed for ubuntu dark since there the menu icons
// are dark, however the toolbar icons are plain!
QString str = QIcon::themeName();
if (str.isEmpty()) {
if (fAdmin->isDarkTheme()) {
fDarkTheme = true;
fDarkToolBarIcon = true;
if (fAdmin->getDarkThemeIconsMenuFlag()) {
fDarkThemeIconsMenu = true;
}
if (fAdmin->getDarkThemeIconsToolbarFlag()) {
fDarkThemeIconsToolbar = true;
}
return;
}
if (str.contains("dark", Qt::CaseInsensitive)) {
fDarkTheme = true;
if (str.contains("ubuntu", Qt::CaseInsensitive)) {
fDarkToolBarIcon = false;
fDarkThemeIconsMenu = true;
if (str.contains("ubuntu", Qt::CaseInsensitive) ||
str.contains("xfce", Qt::CaseInsensitive)) {
fDarkThemeIconsToolbar = false;
} else {
fDarkToolBarIcon = true;
fDarkThemeIconsToolbar = true;
}
}
}
@ -1316,7 +1325,7 @@ void PmuppGui::addVar()
// call variable dialog
fVarDlg.reset();
fVarDlg = std::make_unique<PVarDialog>(collection_list, fDarkTheme);
fVarDlg = std::make_unique<PVarDialog>(collection_list, fDarkThemeIconsMenu);
connect(fVarDlg.get(), SIGNAL(check_request(QString,QVector<int>)), this, SLOT(check(QString,QVector<int>)));
connect(fVarDlg.get(), SIGNAL(add_request(QString,QVector<int>)), this, SLOT(add(QString,QVector<int>)));
fVarDlg->show();

View File

@ -159,11 +159,12 @@ private:
enum EAxis {kXaxis, kYaxis};
PmuppAdmin *fAdmin;
bool fDarkTheme;
bool fDarkToolBarIcon;
bool fNormalize;
bool fIgnoreThemeAutoDetection{false};
bool fDarkThemeIconsMenu{false};
bool fDarkThemeIconsToolbar{false};
bool fNormalize{false};
uint fDatime;
qint64 fDatime;
uint fMuppInstance;
PParamDataHandler *fParamDataHandler;

View File

@ -5,7 +5,9 @@
</comment>
<recent_files>
</recent_files>
<dark_theme>no</dark_theme>
<ignore_theme_auto_detection>n</ignore_theme_auto_detection>
<dark_theme_icon_menu>n</dark_theme_icon_menu>
<dark_theme_icon_toolbar>n</dark_theme_icon_toolbar>
<root_settings>
<marker_list>
<!-- Root marker numbers -->

View File

@ -59,8 +59,12 @@ PAdminXMLParser::PAdminXMLParser(const QString& fln, PAdmin *admin) : fAdmin(adm
fFunc = false;
QFile file(fln);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
// warning and create default - STILL MISSING
if (!file.open(QFile::ReadOnly | QFile::Text) || (file.size()==0)) {
// warning and create default
QMessageBox::StandardButton ret = QMessageBox::warning(nullptr, "WARNING", "The musredit_startup.xml is corrupted. Create a default one?", QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
fAdmin->createMusreditStartupFile();
}
}
fValid = parse(&file);
@ -98,7 +102,7 @@ bool PAdminXMLParser::parse(QIODevice *device)
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(nullptr, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
@ -717,14 +721,14 @@ QString PAdminXMLParser::expandPath(const QString &str)
token.remove('$');
if (!procEnv.contains(token)) {
msg = QString("Couldn't find '%1'. Some things might not work properly").arg(token);
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::warning(nullptr, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
newStr = "";
break;
}
path = procEnv.value(token, "");
if (path.isEmpty()) {
msg = QString("Couldn't expand '%1'. Some things might not work properly").arg(token);
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::warning(nullptr, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
newStr = "";
break;
}
@ -769,13 +773,13 @@ PAdmin::PAdmin() : QObject()
// XML Parser part
// 1st: check local directory
QString path = QString("./");
QString path = QDir::currentPath();
QString fln = QString("musredit_startup.xml");
QString pathFln = path + fln;
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
if (!QFile::exists(pathFln)) {
// 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
path = procEnv.value("HOME", "");
path = QDir::homePath();
pathFln = path + "/.musrfit/musredit/" + fln;
if (!QFile::exists(pathFln)) {
// 3rd: check $MUSRFITPATH/musredit_startup.xml
@ -803,9 +807,9 @@ PAdmin::PAdmin() : QObject()
QFileInfo info(str);
if (info.exists()) {
if (!info.isExecutable())
QMessageBox::critical(0, "ERROR", "musrfit found but not recognized as executable.\nPlease check!");
QMessageBox::critical(nullptr, "ERROR", "musrfit found but not recognized as executable.\nPlease check!");
} else {
QMessageBox::critical(0, "ERROR", "musrfit not found.\nHave you set the necessary system variables properly?\nPlease check the manual.\nBefore you can use musrfit, this needs to be fixed.");
QMessageBox::critical(nullptr, "ERROR", "musrfit not found.\nHave you set the necessary system variables properly?\nPlease check the manual.\nBefore you can use musrfit, this needs to be fixed.");
}
// check if system variables are set properly
@ -823,19 +827,10 @@ PAdmin::PAdmin() : QObject()
}
if (sysVarMissing) {
msg += "Please set this/these system variables.";
QMessageBox::warning(0, "WARNING", msg);
QMessageBox::warning(nullptr, "WARNING", msg);
}
}
//--------------------------------------------------------------------------
/**
* <p>Destructor
*/
PAdmin::~PAdmin()
{
saveRecentFiles();
}
//--------------------------------------------------------------------------
/**
* <p>returns the help url corresponding the the tag.
@ -903,13 +898,13 @@ int PAdmin::loadPrefs(QString fln)
if (QFile::exists(fln)) { // administration file present
PAdminXMLParser handler(fln, this);
if (!handler.isValid()) {
QMessageBox::critical(0, "**ERROR**",
QMessageBox::critical(nullptr, "**ERROR**",
"Error parsing musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
}
} else {
QMessageBox::critical(0, "**ERROR**",
QMessageBox::critical(nullptr, "**ERROR**",
"Couldn't find the musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
QMessageBox::Ok, QMessageBox::NoButton);
return 0;
@ -1054,7 +1049,7 @@ int PAdmin::savePrefs(QString pref_fln)
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);
QMessageBox::warning(nullptr, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
}
return 1;
@ -1128,7 +1123,7 @@ void PAdmin::saveRecentFiles()
return;
}
i++;
for (int j=0; j<fRecentFile.size(); j++) {
for (int j=fRecentFile.size()-1; j>=0; j--) {
str = " <path_file_name>" + fRecentFile[j] + "</path_file_name>";
data.insert(i++, str);
}
@ -1148,7 +1143,7 @@ void PAdmin::saveRecentFiles()
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);
QMessageBox::warning(nullptr, "WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
}
}
@ -1177,13 +1172,13 @@ void PAdmin::createMusreditStartupFile()
QFile fres(":/musredit_startup.xml.in");
if (!fres.exists()) {
QString msg = QString("Neither couldn't find nor create musredit_startup.xml. Things are likely not to work.");
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(nullptr, "ERROR", msg);
return;
}
if (!fres.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString msg = QString("Couldn't open internal resource file musredit_startup.xml.in. Things are likely not to work.");
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(nullptr, "ERROR", msg);
return;
}
// text stream for fres

View File

@ -65,7 +65,6 @@ class PAdminXMLParser
{
public:
PAdminXMLParser(const QString &fln, PAdmin*);
virtual ~PAdminXMLParser() {}
virtual bool isValid() { return fValid; }
@ -113,7 +112,6 @@ class PAdmin : public QObject
{
public:
PAdmin();
virtual ~PAdmin();
int getTimeout() { return fTimeout; }
QString getFontName() { return fFontName; }
@ -173,6 +171,7 @@ class PAdmin : public QObject
int loadPrefs(QString fln);
int savePrefs(QString pref_fln);
void saveRecentFiles(); ///< save recent file list
protected:
void setExecPath(const QString str) { fExecPath = str; }
@ -228,7 +227,6 @@ class PAdmin : public QObject
QVector<PTheory> fTheory; ///< stores all known theories. Needed when generating theory blocks from within musredit.
void saveRecentFiles(); ///< save recent file list
void createMusreditStartupFile(); ///< create default musredit_startup.xml
};

View File

@ -155,6 +155,8 @@ PTextEdit::PTextEdit( QWidget *parent )
connect( fTabWidget.get(), SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
fLastDirInUse = fAdmin->getDefaultSavePath();
fStatusBar = this->statusBar();
}
//----------------------------------------------------------------------------------------------------
@ -294,6 +296,7 @@ void PTextEdit::setupFileActions()
// Save Prefs
a = new QAction( tr( "Save Prefs..." ), this );
a->setStatusTip( tr("Save the preferences") );
connect( a, SIGNAL( triggered() ), this, SLOT( fileSavePrefs() ) );
menu->addAction(a);
@ -696,7 +699,7 @@ void PTextEdit::setupMusrActions()
iconName = QString(":/icons/musrWiz-32x32.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "musr&Wiz" ), this );
a->setShortcut( tr("Alt+W") );
a->setStatusTip( tr("Call musrWiz which helps to create msr-files") );
a->setStatusTip( tr("Call musrWiz which helps to create msr-files - currently still very limited") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrWiz() ) );
menu->addAction(a);
fActions["musrWiz"] = a;
@ -838,7 +841,7 @@ void PTextEdit::setupMusrActions()
else
iconName = QString(":/icons/musrview2dat-plain.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "View2Dat" ), this );
a->setStatusTip( tr("export musrview data") );
a->setStatusTip( tr("Export musrview data from a collection of msr-files.") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrView2Dat() ) );
menu->addAction(a);
fActions["musrview2dat"] = a;
@ -1032,7 +1035,7 @@ void PTextEdit::load( const QString &f, const int index )
return;
// add file name to recent file names
fAdmin->addRecentFile(f); // keep it in admin
fAdmin->addRecentFile(QFileInfo(f).absoluteFilePath()); // keep it in admin
fillRecentFiles(); // update menu
// add the msr-file to the file system watchersssss
@ -1555,7 +1558,7 @@ void PTextEdit::fileClose(const bool check)
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close this file.\nChanges will be lost",
"Close", "Cancel");
if (result == 1) // Cancel
if (result == QMessageBox::Cancel) // Cancel
return;
}
@ -1585,7 +1588,7 @@ void PTextEdit::fileCloseAll()
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close all files.\nChanges of unsaved files will be lost",
"Close", "Cancel");
if (result == 1) // Cancel
if (result == QMessageBox::Cancel) // Cancel
return;
break;
}
@ -1622,7 +1625,7 @@ void PTextEdit::fileCloseAllOthers()
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close all files.\nChanges of unsaved files will be lost",
"Close", "Cancel");
if (result == 1) // Cancel
if (result == QMessageBox::Cancel) // Cancel
return;
break;
}
@ -1665,12 +1668,14 @@ void PTextEdit::fileExit()
int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to exit from the applcation.\nChanges will be lost",
"Exit", "Cancel");
if (result == 1) // Cancel
if (result == QMessageBox::Cancel) // Cancel
return;
break;
}
}
fAdmin->saveRecentFiles();
qApp->quit();
}
@ -3613,6 +3618,7 @@ void PTextEdit::switchMenuIcons()
fActions["musrStep"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32-dark.svg")));
fActions["msr2data"]->setIcon(QIcon(QPixmap(":/icons/msr2data-dark.svg")));
fActions["mupp"]->setIcon(QIcon(QPixmap(":/icons/mupp-dark.svg")));
fActions["musrview2dat"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-dark.svg")));
fActions["musrview"]->setIcon(QIcon(QPixmap(":/icons/musrview-dark.svg")));
fActions["musrt0"]->setIcon(QIcon(QPixmap(":/icons/musrt0-dark.svg")));
fActions["musrFT"]->setIcon(QIcon(QPixmap(":/icons/musrFT-dark.svg")));
@ -3639,6 +3645,7 @@ void PTextEdit::switchMenuIcons()
fActions["musrStep"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32.svg")));
fActions["msr2data"]->setIcon(QIcon(QPixmap(":/icons/msr2data-plain.svg")));
fActions["mupp"]->setIcon(QIcon(QPixmap(":/icons/mupp-plain.svg")));
fActions["musrview2dat"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-plain.svg")));
fActions["musrview"]->setIcon(QIcon(QPixmap(":/icons/musrview-plain.svg")));
fActions["musrt0"]->setIcon(QIcon(QPixmap(":/icons/musrt0-plain.svg")));
fActions["musrFT"]->setIcon(QIcon(QPixmap(":/icons/musrFT-plain.svg")));
@ -3674,6 +3681,7 @@ void PTextEdit::switchToolbarIcons()
fActions["musrStep-tb"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32-dark.svg")));
fActions["msr2data-tb"]->setIcon(QIcon(QPixmap(":/icons/msr2data-dark.svg")));
fActions["mupp-tb"]->setIcon(QIcon(QPixmap(":/icons/mupp-dark.svg")));
fActions["musrview2dat-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-dark.svg")));
fActions["musrview-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview-dark.svg")));
fActions["musrt0-tb"]->setIcon(QIcon(QPixmap(":/icons/musrt0-dark.svg")));
fActions["musrFT-tb"]->setIcon(QIcon(QPixmap(":/icons/musrFT-dark.svg")));
@ -3700,6 +3708,7 @@ void PTextEdit::switchToolbarIcons()
fActions["musrStep-tb"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32.svg")));
fActions["msr2data-tb"]->setIcon(QIcon(QPixmap(":/icons/msr2data-plain.svg")));
fActions["mupp-tb"]->setIcon(QIcon(QPixmap(":/icons/mupp-plain.svg")));
fActions["musrview2dat-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-plain.svg")));
fActions["musrview-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview-plain.svg")));
fActions["musrt0-tb"]->setIcon(QIcon(QPixmap(":/icons/musrt0-plain.svg")));
fActions["musrFT-tb"]->setIcon(QIcon(QPixmap(":/icons/musrFT-plain.svg")));

View File

@ -181,6 +181,7 @@ private:
QString fLastDirInUse{QString("")}; ///< string holding the path from where the last file was loaded.
QStringList fMusrFTPrevCmd;
int fEditW{900}, fEditH{800};
QStatusBar *fStatusBar{nullptr};
QMap<QString, QAction*> fActions;
std::unique_ptr<QAction> fMusrT0Action;

View File

@ -156,8 +156,12 @@ bool PmuppAdminXMLParser::startElement()
if (qName == "path_file_name") {
fKeyWord = eRecentFile;
} else if (qName == "dark_theme") {
fKeyWord = eDarkTheme;
} else if (qName == "ignore_theme_auto_detection") {
fKeyWord = eIgnoreThemeAutoDetection;
} else if (qName == "dark_theme_icon_menu") {
fKeyWord = eDarkThemeIconsMenu;
} else if (qName == "dark_theme_icon_toolbar") {
fKeyWord = eDarkThemeIconsToolbar;
} else if (qName == "marker") {
fKeyWord = eMarker;
} else if (qName == "color") {
@ -201,11 +205,23 @@ bool PmuppAdminXMLParser::characters()
case eRecentFile:
fAdmin->addRecentFile(QString(str.toLatin1()).trimmed());
break;
case eDarkTheme:
if ((str == "yes") || (str == "1") || (str == "true"))
fAdmin->setTheme(true);
case eIgnoreThemeAutoDetection:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setIgnoreThemeAutoDetection(true);
else
fAdmin->setTheme(false);
fAdmin->setIgnoreThemeAutoDetection(false);
break;
case eDarkThemeIconsMenu:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setThemeIconsMenu(true);
else
fAdmin->setThemeIconsMenu(false);
break;
case eDarkThemeIconsToolbar:
if ((str == "yes") || (str == "y") || (str == "1") || (str == "true"))
fAdmin->setThemeIconsToolbar(true);
else
fAdmin->setThemeIconsToolbar(false);
break;
case eMarker:
tok = str.split(",", Qt::SkipEmptyParts);
@ -272,7 +288,7 @@ bool PmuppAdminXMLParser::endDocument()
* <p>Initializes that PmuppAdmin object, and calls the XML parser which feeds
* the object variables.
*/
PmuppAdmin::PmuppAdmin() : QObject(), fDarkTheme(false)
PmuppAdmin::PmuppAdmin() : QObject()
{
// XML Parser part
// 1st: check local directory
@ -433,7 +449,7 @@ void PmuppAdmin::getColor(int idx, int &r, int &g, int &b)
* @param marker marker code
* @param size marker size
*/
void PmuppAdmin::setMarker(int marker, double size)
void PmuppAdmin::setMarker(const int marker, const double size)
{
PmuppMarker markerObj;
@ -456,7 +472,7 @@ void PmuppAdmin::setMarker(int marker, double size)
* @param b blue value (0..255)
* @param name color name
*/
void PmuppAdmin::setColor(int r, int g, int b, QString name)
void PmuppAdmin::setColor(const int r, const int g, const int b, QString name)
{
if (((r<0) || (r>255)) ||
((g<0) || (g>255)) ||

View File

@ -102,7 +102,9 @@ class PmuppAdminXMLParser
virtual bool isValid() { return fValid; }
private:
enum EAdminKeyWords {eEmpty, eRecentFile, eDarkTheme, eMarker, eColor};
enum EAdminKeyWords {eEmpty, eRecentFile,
eIgnoreThemeAutoDetection, eDarkThemeIconsMenu, eDarkThemeIconsToolbar,
eMarker, eColor};
bool parse(QIODevice *device);
bool startDocument();
@ -145,18 +147,24 @@ class PmuppAdmin : public QObject
void getColor(QString name, int &r, int &g, int &b);
void getColor(int idx, int &r, int &g, int &b);
bool isDarkTheme() { return fDarkTheme; }
bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection; }
bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; }
bool getDarkThemeIconsToolbarFlag() { return fDarkThemeIconsToolbar; }
void setTheme(bool theme) { fDarkTheme = theme; }
void setMarker(int marker, double size);
void setColor(int r, int g, int b, QString name="");
void setIgnoreThemeAutoDetection(const bool theme) { fIgnoreThemeAutoDetection = theme; }
void setThemeIconsMenu(const bool theme) { fDarkThemeIconsMenu = theme; }
void setThemeIconsToolbar(const bool theme) { fDarkThemeIconsToolbar = theme; }
void setMarker(const int marker, const double size);
void setColor(const int r, const int g, const int b, QString name="");
private:
friend class PmuppAdminXMLParser;
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fDarkTheme;
bool fIgnoreThemeAutoDetection{false};
bool fDarkThemeIconsMenu{false};
bool fDarkThemeIconsToolbar{false};
QVector<PmuppMarker> fMarker;
QVector<PmuppColor> fColor;

View File

@ -250,6 +250,9 @@ PmuppGui::PmuppGui(QStringList fln)
readCmdHistory();
fAdmin = new PmuppAdmin();
fIgnoreThemeAutoDetection = fAdmin->getIgnoreThemeAutoDetection();
fDarkThemeIconsMenu = fAdmin->getDarkThemeIconsMenuFlag();
fDarkThemeIconsToolbar = fAdmin->getDarkThemeIconsToolbarFlag();
fParamDataHandler = new PParamDataHandler();
bool dataAtStartup = false;
@ -270,7 +273,7 @@ PmuppGui::PmuppGui(QStringList fln)
getTheme();
QString iconName("");
if (fDarkTheme)
if (fDarkThemeIconsMenu)
iconName = QString(":/icons/mupp-dark.svg");
else
iconName = QString(":/icons/mupp-plain.svg");
@ -513,7 +516,7 @@ void PmuppGui::setupFileActions()
QAction *a;
QString iconName("");
if (fDarkTheme)
if (fDarkThemeIconsMenu)
iconName = QString(":/icons/document-open-dark.svg");
else
iconName = QString(":/icons/document-open-plain.svg");
@ -522,7 +525,7 @@ void PmuppGui::setupFileActions()
a->setStatusTip( tr("Open a musrfit parameter file.") );
connect( a, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
menu->addAction(a);
if (!fDarkToolBarIcon) { // tool bar icon is not dark, even though the theme is (ubuntu)
if (!fDarkThemeIconsToolbar) { // tool bar icon is not dark, even though the theme is (ubuntu, mx, xfce)
iconName = QString(":/icons/document-open-plain.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "&New..." ), this );
connect( a, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
@ -847,26 +850,32 @@ bool PmuppGui::eventFilter(QObject *o, QEvent *e)
*/
void PmuppGui::getTheme()
{
fDarkTheme = false; // true if theme is dark
fDarkToolBarIcon = false; // needed for ubuntu dark since there the menu icons
if (fIgnoreThemeAutoDetection)
return;
fDarkThemeIconsMenu = false; // true if theme is dark
fDarkThemeIconsToolbar = false; // needed for ubuntu dark since there the menu icons
// are dark, however the toolbar icons are plain!
QString str = QIcon::themeName();
if (str.isEmpty()) {
if (fAdmin->isDarkTheme()) {
fDarkTheme = true;
fDarkToolBarIcon = true;
if (fAdmin->getDarkThemeIconsMenuFlag()) {
fDarkThemeIconsMenu = true;
}
if (fAdmin->getDarkThemeIconsToolbarFlag()) {
fDarkThemeIconsToolbar = true;
}
return;
}
if (str.contains("dark", Qt::CaseInsensitive)) {
fDarkTheme = true;
if (str.contains("ubuntu", Qt::CaseInsensitive)) {
fDarkToolBarIcon = false;
fDarkThemeIconsMenu = true;
if (str.contains("ubuntu", Qt::CaseInsensitive) ||
str.contains("xfce", Qt::CaseInsensitive)) {
fDarkThemeIconsToolbar = false;
} else {
fDarkToolBarIcon = true;
fDarkThemeIconsToolbar = true;
}
}
}
@ -1304,7 +1313,7 @@ void PmuppGui::addVar()
// call variable dialog
fVarDlg.reset();
fVarDlg = std::make_unique<PVarDialog>(collection_list, fDarkTheme);
fVarDlg = std::make_unique<PVarDialog>(collection_list, fDarkThemeIconsMenu);
connect(fVarDlg.get(), SIGNAL(check_request(QString,QVector<int>)), this, SLOT(check(QString,QVector<int>)));
connect(fVarDlg.get(), SIGNAL(add_request(QString,QVector<int>)), this, SLOT(add(QString,QVector<int>)));
fVarDlg->show();

View File

@ -159,9 +159,10 @@ private:
enum EAxis {kXaxis, kYaxis};
PmuppAdmin *fAdmin;
bool fDarkTheme;
bool fDarkToolBarIcon;
bool fNormalize;
bool fIgnoreThemeAutoDetection{false};
bool fDarkThemeIconsMenu{false};
bool fDarkThemeIconsToolbar{false};
bool fNormalize{false};
qint64 fDatime;
uint fMuppInstance;

View File

@ -548,11 +548,11 @@ int main(int argc, char *argv[])
if (script.size() > 0) { // script
guiFlag = false;
}
QCoreApplication *app = createApplication(argc, argv, guiFlag);
QScopedPointer<QCoreApplication> app(createApplication(argc, argv, guiFlag));
std::unique_ptr<PmuppGui> gui;
std::unique_ptr<PmuppScript> mupp_script;
if (qobject_cast<QApplication *>(app)) { // GUI
if (qobject_cast<QApplication *>(app.get())) { // GUI
gui = std::make_unique<PmuppGui>(fln);
if (gui == nullptr) {
std::cerr << std::endl;
@ -565,8 +565,8 @@ int main(int argc, char *argv[])
gui->resize( 800, 500 );
gui->show();
app->connect( app, SIGNAL( lastWindowClosed() ), app, SLOT( quit() ) );
app->connect( app, SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) );
app.get()->connect( app.get(), SIGNAL( lastWindowClosed() ), app.get(), SLOT( quit() ) );
app.get()->connect( app.get(), SIGNAL( aboutToQuit() ), gui.get(), SLOT( aboutToQuit() ) );
} else { // scripting
mupp_script = std::make_unique<PmuppScript>(script);
if (mupp_script == nullptr) {
@ -578,7 +578,7 @@ int main(int argc, char *argv[])
}
// This will cause the application to exit when the task signals finished.
QObject::connect( mupp_script.get(), SIGNAL( finished() ), app, SLOT( quit() ) );
QObject::connect( mupp_script.get(), SIGNAL( finished() ), app.get(), SLOT( quit() ) );
// This will run the task from the application event loop.
QTimer::singleShot(0, mupp_script.get(), SLOT( executeScript() ) );

View File

@ -5,7 +5,9 @@
</comment>
<recent_files>
</recent_files>
<dark_theme>no</dark_theme>
<ignore_theme_auto_detection>n</ignore_theme_auto_detection>
<dark_theme_icon_menu>n</dark_theme_icon_menu>
<dark_theme_icon_toolbar>n</dark_theme_icon_toolbar>
<root_settings>
<marker_list>
<!-- Root marker numbers -->

View File

@ -775,13 +775,13 @@ PAdmin::PAdmin() : QObject()
// XML Parser part
// 1st: check local directory
QString path = QString("./");
QString path = QDir::currentPath();
QString fln = QString("musredit_startup.xml");
QString pathFln = path + fln;
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
if (!QFile::exists(pathFln)) {
// 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
path = procEnv.value("HOME", "");
path = QDir::homePath();
pathFln = path + "/.musrfit/musredit/" + fln;
if (!QFile::exists(pathFln)) {
// 3rd: check $MUSRFITPATH/musredit_startup.xml
@ -833,15 +833,6 @@ PAdmin::PAdmin() : QObject()
}
}
//--------------------------------------------------------------------------
/**
* <p>Destructor
*/
PAdmin::~PAdmin()
{
saveRecentFiles();
}
//--------------------------------------------------------------------------
/**
* <p>returns the help url corresponding the the tag.
@ -1130,7 +1121,7 @@ void PAdmin::saveRecentFiles()
return;
}
i++;
for (int j=0; j<fRecentFile.size(); j++) {
for (int j=fRecentFile.size()-1; j>=0; j--) {
str = " <path_file_name>" + fRecentFile[j] + "</path_file_name>";
data.insert(i++, str);
}

View File

@ -65,7 +65,6 @@ class PAdminXMLParser
{
public:
PAdminXMLParser(const QString &fln, PAdmin*);
virtual ~PAdminXMLParser() {}
virtual bool isValid() { return fValid; }
@ -113,7 +112,6 @@ class PAdmin : public QObject
{
public:
PAdmin();
virtual ~PAdmin();
int getTimeout() { return fTimeout; }
QString getFontName() { return fFontName; }
@ -173,6 +171,7 @@ class PAdmin : public QObject
int loadPrefs(QString fln);
int savePrefs(QString pref_fln);
void saveRecentFiles(); ///< save recent file list
protected:
void setExecPath(const QString str) { fExecPath = str; }
@ -228,7 +227,6 @@ class PAdmin : public QObject
QVector<PTheory> fTheory; ///< stores all known theories. Needed when generating theory blocks from within musredit.
void saveRecentFiles(); ///< save recent file list
void createMusreditStartupFile(); ///< create default musredit_startup.xml
};

View File

@ -155,6 +155,8 @@ PTextEdit::PTextEdit( QWidget *parent )
connect( fTabWidget.get(), SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
fLastDirInUse = fAdmin->getDefaultSavePath();
fStatusBar = this->statusBar();
}
//----------------------------------------------------------------------------------------------------
@ -294,6 +296,7 @@ void PTextEdit::setupFileActions()
// Save Prefs
a = new QAction( tr( "Save Prefs..." ), this );
a->setStatusTip( tr("Save the preferences") );
connect( a, SIGNAL( triggered() ), this, SLOT( fileSavePrefs() ) );
menu->addAction(a);
@ -695,7 +698,7 @@ void PTextEdit::setupMusrActions()
iconName = QString(":/icons/musrWiz-32x32.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "musr&Wiz" ), this );
a->setShortcut( tr("Alt+W") );
a->setStatusTip( tr("Call musrWiz which helps to create msr-files") );
a->setStatusTip( tr("Call musrWiz which helps to create msr-files - currently still very limited") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrWiz() ) );
menu->addAction(a);
fActions["musrWiz"] = a;
@ -837,7 +840,7 @@ void PTextEdit::setupMusrActions()
else
iconName = QString(":/icons/musrview2dat-plain.svg");
a = new QAction( QIcon( QPixmap(iconName) ), tr( "View2Dat" ), this );
a->setStatusTip( tr("export musrview data") );
a->setStatusTip( tr("Export musrview data from a collection of msr-files.") );
connect( a, SIGNAL( triggered() ), this, SLOT( musrView2Dat() ) );
menu->addAction(a);
fActions["musrview2dat"] = a;
@ -1031,7 +1034,7 @@ void PTextEdit::load( const QString &f, const int index )
return;
// add file name to recent file names
fAdmin->addRecentFile(f); // keep it in admin
fAdmin->addRecentFile(QFileInfo(f).absoluteFilePath()); // keep it in admin
fillRecentFiles(); // update menu
// add the msr-file to the file system watchersssss
@ -1670,6 +1673,8 @@ void PTextEdit::fileExit()
}
}
fAdmin->saveRecentFiles();
qApp->quit();
}
@ -3582,6 +3587,7 @@ void PTextEdit::switchMenuIcons()
fActions["musrStep"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32-dark.svg")));
fActions["msr2data"]->setIcon(QIcon(QPixmap(":/icons/msr2data-dark.svg")));
fActions["mupp"]->setIcon(QIcon(QPixmap(":/icons/mupp-dark.svg")));
fActions["musrview2dat"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-dark.svg")));
fActions["musrview"]->setIcon(QIcon(QPixmap(":/icons/musrview-dark.svg")));
fActions["musrt0"]->setIcon(QIcon(QPixmap(":/icons/musrt0-dark.svg")));
fActions["musrFT"]->setIcon(QIcon(QPixmap(":/icons/musrFT-dark.svg")));
@ -3608,6 +3614,7 @@ void PTextEdit::switchMenuIcons()
fActions["musrStep"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32.svg")));
fActions["msr2data"]->setIcon(QIcon(QPixmap(":/icons/msr2data-plain.svg")));
fActions["mupp"]->setIcon(QIcon(QPixmap(":/icons/mupp-plain.svg")));
fActions["musrview2dat"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-plain.svg")));
fActions["musrview"]->setIcon(QIcon(QPixmap(":/icons/musrview-plain.svg")));
fActions["musrt0"]->setIcon(QIcon(QPixmap(":/icons/musrt0-plain.svg")));
fActions["musrFT"]->setIcon(QIcon(QPixmap(":/icons/musrFT-plain.svg")));
@ -3643,6 +3650,7 @@ void PTextEdit::switchToolbarIcons()
fActions["musrStep-tb"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32-dark.svg")));
fActions["msr2data-tb"]->setIcon(QIcon(QPixmap(":/icons/msr2data-dark.svg")));
fActions["mupp-tb"]->setIcon(QIcon(QPixmap(":/icons/mupp-dark.svg")));
fActions["musrview2dat-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-dark.svg")));
fActions["musrview-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview-dark.svg")));
fActions["musrt0-tb"]->setIcon(QIcon(QPixmap(":/icons/musrt0-dark.svg")));
fActions["musrFT-tb"]->setIcon(QIcon(QPixmap(":/icons/musrFT-dark.svg")));
@ -3669,6 +3677,7 @@ void PTextEdit::switchToolbarIcons()
fActions["musrStep-tb"]->setIcon(QIcon(QPixmap(":/icons/musrStep-32x32.svg")));
fActions["msr2data-tb"]->setIcon(QIcon(QPixmap(":/icons/msr2data-plain.svg")));
fActions["mupp-tb"]->setIcon(QIcon(QPixmap(":/icons/mupp-plain.svg")));
fActions["musrview2dat-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview2dat-plain.svg")));
fActions["musrview-tb"]->setIcon(QIcon(QPixmap(":/icons/musrview-plain.svg")));
fActions["musrt0-tb"]->setIcon(QIcon(QPixmap(":/icons/musrt0-plain.svg")));
fActions["musrFT-tb"]->setIcon(QIcon(QPixmap(":/icons/musrFT-plain.svg")));

View File

@ -181,6 +181,7 @@ private:
QString fLastDirInUse{QString("")}; ///< string holding the path from where the last file was loaded.
QStringList fMusrFTPrevCmd;
int fEditW{900}, fEditH{800};
QStatusBar *fStatusBar{nullptr};
QMap<QString, QAction*> fActions;
std::unique_ptr<QAction> fMusrT0Action;