From f3a4607d6a722a862af0eb9747a15dcdf624b6fb Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 3 Nov 2019 00:18:10 +0200 Subject: Drop boost dependency - wrote not-invented-here config file parser and conf class - spent obscene amount of time plugging in said conf class --- lib/webprofile/webprofilemanager.cpp | 8 ++++---- lib/webprofile/webprofilemanager.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/webprofile') diff --git a/lib/webprofile/webprofilemanager.cpp b/lib/webprofile/webprofilemanager.cpp index b0eff93..05808ab 100644 --- a/lib/webprofile/webprofilemanager.cpp +++ b/lib/webprofile/webprofilemanager.cpp @@ -11,7 +11,7 @@ #include #include -WebProfileManager::WebProfileManager(const QHash &profileSection, QObject *parent) +WebProfileManager::WebProfileManager(const ProfileDefault_t &profileSection, QObject *parent) : QObject(parent) , defaults(profileSection) { @@ -62,17 +62,17 @@ WebProfile *WebProfileManager::profile(const QString &id, const QString &path, b profile.settings->setValue("name", name); }); - profile.ptr->setSearch(profile.value("search", defaults.value("profile.search")).toString()); + profile.ptr->setSearch(profile.value("search", defaults.search).toString()); connect(profile.ptr, &WebProfile::searchChanged, profile.settings, [profile](const QString &url) { profile.settings->setValue("search", url); }); - profile.ptr->setHomepage(profile.value("homepage", defaults.value("profile.homepage")).toUrl()); + profile.ptr->setHomepage(profile.value("homepage", defaults.homepage).toUrl()); connect(profile.ptr, &WebProfile::homepageChanged, profile.settings, [profile](const QUrl &url) { profile.settings->setValue("homepage", url); }); - profile.ptr->setNewtab(profile.value("newtab", defaults.value("profile.newtab")).toUrl()); + profile.ptr->setNewtab(profile.value("newtab", defaults.newtab).toUrl()); connect(profile.ptr, &WebProfile::newtabChanged, profile.settings, [profile](const QUrl &url) { profile.settings->setValue("newtab", url); }); diff --git a/lib/webprofile/webprofilemanager.h b/lib/webprofile/webprofilemanager.h index f7bf52a..3d86def 100644 --- a/lib/webprofile/webprofilemanager.h +++ b/lib/webprofile/webprofilemanager.h @@ -18,11 +18,18 @@ #include #include +struct ProfileDefault_t +{ + QString search; + QString homepage; + QString newtab; +}; + class WebProfileManager : public QObject { Q_OBJECT public: - explicit WebProfileManager(const QHash &profileSection, QObject *parent); + explicit WebProfileManager(const ProfileDefault_t &profileSection, QObject *parent); ~WebProfileManager(); /** Create a profile with specified id @@ -72,7 +79,7 @@ private: }; QMap profiles; - const QHash defaults; + const ProfileDefault_t defaults; }; #endif // SMOLBOTE_PROFILEMANAGER_H -- cgit v1.2.1