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 @@
#include "GUI/utils/hostosinfo.h"
#include <QFile>
#include <QIcon>
#include <QStandardPaths>
Application::Application(int& argc, char** argv)
: QApplication(argc, argv), m_currentStyle(ApplicationSettings::Style::native)
......@@ -100,3 +101,13 @@ InstrumentLibrary& Application::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:
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:
ApplicationSettings m_settings;
InstrumentLibrary m_instrumentLibrary;
......
......@@ -20,7 +20,6 @@
#include <QDir>
#include <QLocale>
#include <QMetaType>
#include <QStandardPaths>
void messageHandler(QtMsgType, const QMessageLogContext&, const QString&) {}
......@@ -44,15 +43,10 @@ int main(int argc, char* argv[])
app.loadStyle(app.settings().styleToUse());
const QString folderForInstrumentLibrary =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const QString filePathForInstrumentLibrary =
folderForInstrumentLibrary + "/BornAgainInstrumentLibrary.balib";
if (!QDir().exists(app.appDataFolder()))
QDir().mkpath(app.appDataFolder());
if (!QDir().exists(folderForInstrumentLibrary))
QDir().mkpath(folderForInstrumentLibrary);
app.instrumentLibrary().load(filePathForInstrumentLibrary);
app.instrumentLibrary().load(app.instrumentLibraryFilePath());
MainWindow win;
if (options.find("geometry"))
......@@ -62,7 +56,7 @@ int main(int argc, char* argv[])
int ret = QApplication::exec();
app.instrumentLibrary().saveIfModified(filePathForInstrumentLibrary);
app.instrumentLibrary().saveIfModified(app.instrumentLibraryFilePath());
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