Skip to content
Snippets Groups Projects
Commit f098a08a authored by Matthias Puchner's avatar Matthias Puchner
Browse files

refactor

parent f2e780ac
No related branches found
No related tags found
1 merge request!304Add instrument library
Pipeline #44233 passed
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "GUI/utils/hostosinfo.h" #include "GUI/utils/hostosinfo.h"
#include <QFile> #include <QFile>
#include <QIcon> #include <QIcon>
#include <QStandardPaths>
Application::Application(int& argc, char** argv) Application::Application(int& argc, char** argv)
: QApplication(argc, argv), m_currentStyle(ApplicationSettings::Style::native) : QApplication(argc, argv), m_currentStyle(ApplicationSettings::Style::native)
...@@ -100,3 +101,13 @@ InstrumentLibrary& Application::instrumentLibrary() ...@@ -100,3 +101,13 @@ InstrumentLibrary& Application::instrumentLibrary()
{ {
return m_instrumentLibrary; return m_instrumentLibrary;
} }
QString Application::instrumentLibraryFilePath() const
{
return appDataFolder() + "/BornAgainInstrumentLibrary.balib";
}
QString Application::appDataFolder() const
{
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
...@@ -40,6 +40,13 @@ public: ...@@ -40,6 +40,13 @@ public:
InstrumentLibrary& instrumentLibrary(); InstrumentLibrary& instrumentLibrary();
QString instrumentLibraryFilePath() const;
//! The folder where persistent application data shall be stored. E.g. in Windows this is the
//! AppData/Roaming location.
//! Used e.g. for storing the instrument library.
QString appDataFolder() const;
private: private:
ApplicationSettings m_settings; ApplicationSettings m_settings;
InstrumentLibrary m_instrumentLibrary; InstrumentLibrary m_instrumentLibrary;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <QDir> #include <QDir>
#include <QLocale> #include <QLocale>
#include <QMetaType> #include <QMetaType>
#include <QStandardPaths>
void messageHandler(QtMsgType, const QMessageLogContext&, const QString&) {} void messageHandler(QtMsgType, const QMessageLogContext&, const QString&) {}
...@@ -44,15 +43,10 @@ int main(int argc, char* argv[]) ...@@ -44,15 +43,10 @@ int main(int argc, char* argv[])
app.loadStyle(app.settings().styleToUse()); app.loadStyle(app.settings().styleToUse());
const QString folderForInstrumentLibrary = if (!QDir().exists(app.appDataFolder()))
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); QDir().mkpath(app.appDataFolder());
const QString filePathForInstrumentLibrary =
folderForInstrumentLibrary + "/BornAgainInstrumentLibrary.balib";
if (!QDir().exists(folderForInstrumentLibrary)) app.instrumentLibrary().load(app.instrumentLibraryFilePath());
QDir().mkpath(folderForInstrumentLibrary);
app.instrumentLibrary().load(filePathForInstrumentLibrary);
MainWindow win; MainWindow win;
if (options.find("geometry")) if (options.find("geometry"))
...@@ -62,7 +56,7 @@ int main(int argc, char* argv[]) ...@@ -62,7 +56,7 @@ int main(int argc, char* argv[])
int ret = QApplication::exec(); int ret = QApplication::exec();
app.instrumentLibrary().saveIfModified(filePathForInstrumentLibrary); app.instrumentLibrary().saveIfModified(app.instrumentLibraryFilePath());
return ret; return ret;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment