diff --git a/App/main.cpp b/App/main.cpp index b19d25779b70e767bc135ff59aae832053dde948..5881ab0e7f9e356d9b456871f8022099be16fd25 100644 --- a/App/main.cpp +++ b/App/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) auto style = applicationSettings.styleToUse(); applicationSettings.loadStyle(style); - QString dir = SessionData::appDataFolder(); + QString dir = GUI::Util::Path::appDataFolder(); if (!QDir().exists(dir)) QDir().mkpath(dir); diff --git a/GUI/Application/ApplicationSettings.cpp b/GUI/Application/ApplicationSettings.cpp index 8dbbf3a980029a13870b639cc6cd67b2453f51a3..2b5d2ed868f565382c95fe1755a2b968c3e8f062 100644 --- a/GUI/Application/ApplicationSettings.cpp +++ b/GUI/Application/ApplicationSettings.cpp @@ -190,8 +190,3 @@ const ApplicationSettings::Palette& ApplicationSettings::styleSheetPalette() con { return m_styleSheetPalette; } - -QString ApplicationSettings::appDataFolder() const -{ - return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); -} diff --git a/GUI/Application/ApplicationSettings.h b/GUI/Application/ApplicationSettings.h index 1c0671e7217fca3dd645de3782258a918527fca3..95e8379e945621786b53af575ff34575de25b49b 100644 --- a/GUI/Application/ApplicationSettings.h +++ b/GUI/Application/ApplicationSettings.h @@ -61,12 +61,6 @@ public: const Palette& styleSheetPalette() 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::Style m_currentStyle; Palette m_styleSheetPalette; diff --git a/GUI/Model/Instrument/InstrumentLibrary.cpp b/GUI/Model/Instrument/InstrumentLibrary.cpp index 4212341b5b86a19c56d5e12bdeedce75786be377..769dcd66f7c23db42fa3ccbf85d3326e2eeeebf0 100644 --- a/GUI/Model/Instrument/InstrumentLibrary.cpp +++ b/GUI/Model/Instrument/InstrumentLibrary.cpp @@ -15,7 +15,7 @@ #include "GUI/Model/Instrument/InstrumentLibrary.h" #include "GUI/Model/Instrument/InstrumentItems.h" #include "GUI/Model/Instrument/InstrumentsTreeModel.h" -#include "GUI/Model/State/SessionData.h" +#include "GUI/Util/Path.h" #include <QFile> #include <QXmlStreamWriter> @@ -26,7 +26,7 @@ const QString XML_VERSION_TAG = "Version"; QString instrumentLibraryFilePath() { - return SessionData::appDataFolder() + "/BornAgainInstrumentLibrary.balib"; + return GUI::Util::Path::appDataFolder() + "/BornAgainInstrumentLibrary.balib"; } } // namespace diff --git a/GUI/Model/State/SessionData.cpp b/GUI/Model/State/SessionData.cpp index cb62dce1383ec35129398ec2d4e1f88f5cc429b9..35039aa84b06297bac0f9492c0c40bfd57d78ad7 100644 --- a/GUI/Model/State/SessionData.cpp +++ b/GUI/Model/State/SessionData.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/Model/State/SessionData.h" -#include <QStandardPaths> SessionData* gSessionData; //!< global pointer to the single instance @@ -21,8 +20,3 @@ SessionData::SessionData() { gSessionData = this; } - -QString SessionData::appDataFolder() -{ - return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); -} diff --git a/GUI/Model/State/SessionData.h b/GUI/Model/State/SessionData.h index 7e8a962843c3e6871c21089a57b7eb463c8e923c..7ee81d4658ee81ebfc8312991e55a89bf8dccf66 100644 --- a/GUI/Model/State/SessionData.h +++ b/GUI/Model/State/SessionData.h @@ -24,11 +24,6 @@ struct SessionData { InstrumentLibrary instrumentLibrary; ProjectDocument* projectDocument{nullptr}; - - //! 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. - static QString appDataFolder(); }; extern SessionData* gSessionData; //!< global pointer to the single instance diff --git a/GUI/Util/Path.cpp b/GUI/Util/Path.cpp index 4a6359147ef2577838e3cfcaf56604327b920454..37e0ac9eb3b41d51669782d647bb79a5afb77b4b 100644 --- a/GUI/Util/Path.cpp +++ b/GUI/Util/Path.cpp @@ -19,6 +19,7 @@ #include <QDir> #include <QFileInfo> #include <QMap> +#include <QStandardPaths> #include <QVector> namespace { @@ -133,3 +134,9 @@ QString GUI::Util::Path::baseName(const QString& fileName) QFileInfo info(fileName); return info.baseName(); } + + +QString GUI::Util::Path::appDataFolder() +{ + return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); +} diff --git a/GUI/Util/Path.h b/GUI/Util/Path.h index 2612704d79c70efa1e7b44689527bf17e471287f..ba84471fc272c14b4dcccde08545a9f95e4e941a 100644 --- a/GUI/Util/Path.h +++ b/GUI/Util/Path.h @@ -34,6 +34,11 @@ int versionCode(const QString& version); bool isVersionMatchMinimal(const QString& version, const QString& minimal_version); +//! The folder where persistent application data shall be stored. +//! Under Windows this is the AppData/Roaming location. +//! Used e.g. for storing the instrument library. +QString appDataFolder(); + } // namespace GUI::Util::Path #endif // BORNAGAIN_GUI_UTIL_PATH_H