Put setting loading in a slot so it can be used at startup and when

preferences change
This commit is contained in:
Luca Beltrame 2015-02-13 07:48:12 +01:00
parent 929a099760
commit 1b9c0adaa8
2 changed files with 33 additions and 22 deletions

View file

@ -68,6 +68,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
qmlRegisterType<Danbooru::DanbooruService>("DanbooruClient", 1, 0, "DanbooruService");
qRegisterMetaType<DanbooruPost::Rating>();
loadSettings();
// TODO Configurable
m_cache = new KImageCache(qApp->applicationName(), DanbooruSettings::self()->cacheSize());
m_service->setImageCache(m_cache);
@ -129,6 +131,17 @@ DanbooruMainWindow::~DanbooruMainWindow()
{
}
void DanbooruMainWindow::loadSettings()
{
m_service->setBlacklist(DanbooruSettings::self()->tagBlacklist());
m_service->setMaxPosts(DanbooruSettings::self()->maxPosts());
m_service->setMaximumAllowedRating(ratingMap.value(DanbooruSettings::self()->maxRating()));
m_service->setMaxPosts(DanbooruSettings::self()->maxPosts());
}
void DanbooruMainWindow::setupActions()
{
@ -174,7 +187,7 @@ void DanbooruMainWindow::downloadPosts()
}
// TODO Pick from configuration
m_service->getPostList(1, QStringList(), 10);
m_service->getPostList();
}
@ -185,15 +198,7 @@ void DanbooruMainWindow::optionsPreferences()
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()));
});
connect(dialog, &KConfigDialog::settingsChanged, this, &DanbooruMainWindow::loadSettings);
dialog->show();
}