diff --git a/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.cpp b/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.cpp index 62f74e17..573f7b95 100644 --- a/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.cpp +++ b/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.cpp @@ -1,25 +1,31 @@ #include "QSettingsStore.hpp" +#include using namespace MellowPlayer::Domain; using namespace MellowPlayer::Domain; using namespace MellowPlayer::Infrastructure; using namespace std; -QSettingsStore::QSettingsStore(const QString& orgName) : qSettings_(orgName, "3") +QSettingsStore::QSettingsStore() : qSettings_(make_unique("MellowPlayer", "3")) { } +void QSettingsStore::setOrganizationName(const QString &orgName) +{ + qSettings_ = make_unique(orgName, "3"); +} + void QSettingsStore::clear() { - qSettings_.clear(); + qSettings_->clear(); } QVariant QSettingsStore::value(const QString& key, const QVariant& defaultValue) const { - return qSettings_.value(key, defaultValue); + return qSettings_->value(key, defaultValue); } void QSettingsStore::setValue(const QString& key, const QVariant& value) { - qSettings_.setValue(key, value); + qSettings_->setValue(key, value); } diff --git a/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.hpp b/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.hpp index 09fed625..4b246847 100644 --- a/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.hpp +++ b/src/lib/MellowPlayer/Infrastructure/Settings/QSettingsStore.hpp @@ -8,7 +8,9 @@ namespace MellowPlayer::Infrastructure class QSettingsStore : public Domain::ISettingsStore { public: - QSettingsStore(const QString& orgName="MellowPlayer"); + QSettingsStore(); + + void setOrganizationName(const QString& orgName); void clear() override; @@ -16,6 +18,6 @@ namespace MellowPlayer::Infrastructure void setValue(const QString& key, const QVariant& value) override; private: - QSettings qSettings_; + std::unique_ptr qSettings_; }; } diff --git a/tests/UnitTests/Infrastructure/Settings/QSettingsProviderTests.cpp b/tests/UnitTests/Infrastructure/Settings/QSettingsProviderTests.cpp index 70bb464c..fd5d680e 100644 --- a/tests/UnitTests/Infrastructure/Settings/QSettingsProviderTests.cpp +++ b/tests/UnitTests/Infrastructure/Settings/QSettingsProviderTests.cpp @@ -8,7 +8,8 @@ using namespace MellowPlayer::Infrastructure; TEST_CASE("QSettingsStoreTests") { - QSettingsStore qSettingsStore("MellowPlayer.Tests"); + QSettingsStore qSettingsStore(); + qSettingsStore.setOrganizationName("MellowPlayer.Tests"); SECTION("defaultValue") {