From e1045e1fa6d73a3f297aa7deb26f1f9fc810e6f0 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Thu, 12 Feb 2015 00:41:21 +0100 Subject: [PATCH] Hook maximum allowed rating into the configuration I wonder if max posts should be a setter in DanbooruService... --- src/mainwindow.cpp | 13 ++++++++++--- src/mainwindow.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 02e4c7b..eae2fc7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -45,6 +45,12 @@ namespace Danbooru { +QHash DanbooruMainWindow::ratingMap = { + {0, DanbooruPost::Safe}, + {1, DanbooruPost::Questionable}, + {2, DanbooruPost::Explicit} +}; + DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) : KXmlGuiWindow(parent), m_view(new QQuickWidget(this)), @@ -177,15 +183,16 @@ void DanbooruMainWindow::optionsPreferences() KConfigDialog* dialog = new KConfigDialog(this, "danboorusettings", DanbooruSettings::self()); - auto prefs = DanbooruSettings::self(); - qDebug() << prefs->boards() << "boards!"; - dialog->addPage(new GeneralPage(DanbooruSettings::self(), this), i18n("General")); + dialog->addPage(new GeneralPage(DanbooruSettings::self(), this), i18n("General"), + "table"); connect(dialog, &KConfigDialog::settingsChanged, [this](){ auto preferences = DanbooruSettings::self(); qDebug() << preferences->boards(); qDebug() << preferences->cacheSize(); qDebug() << preferences->maxPosts(); qDebug() << preferences->tagBlacklist(); + qDebug() << preferences->maxRating(); + m_service->setMaximumAllowedRating(ratingMap.value(preferences->maxRating())); }); dialog->show(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index b089ac9..3a8d362 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -27,6 +27,7 @@ #include #include +#include "libdanbooru/danboorupost.h" class QQuickWidget; @@ -75,6 +76,7 @@ private: DanbooruService *m_service; DanbooruConnectWidget *m_connectWidget; KImageCache *m_cache; + static QHash ratingMap; }; } // namespace Danbooru