Rename AlligatorSettings to SettingsManager

This commit is contained in:
Bart De Vries 2021-04-10 08:46:14 +02:00
parent 7468c35b9a
commit 65ef16017b
8 changed files with 28 additions and 26 deletions

View File

@ -14,7 +14,7 @@ add_executable(alligator
resources.qrc
)
kconfig_add_kcfg_files(alligator alligatorsettings.kcfgc GENERATE_MOC)
kconfig_add_kcfg_files(alligator settingsmanager.kcfgc GENERATE_MOC)
target_include_directories(alligator PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Sql Qt5::Multimedia KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n)

View File

@ -14,7 +14,7 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "alligatorsettings.h"
#include "settingsmanager.h"
#include "database.h"
#include "fetcher.h"
@ -93,8 +93,8 @@ int Database::version()
void Database::cleanup()
{
int count = AlligatorSettings::self()->deleteAfterCount();
int type = AlligatorSettings::self()->deleteAfterType();
int count = SettingsManager::self()->deleteAfterCount();
int type = SettingsManager::self()->deleteAfterType();
if (type == 0) { // Never delete Entries
return;

View File

@ -15,7 +15,7 @@
#include "datamanager.h"
#include "fetcher.h"
#include "database.h"
#include "alligatorsettings.h"
#include "settingsmanager.h"
DataManager::DataManager()
{
@ -56,7 +56,7 @@ DataManager::DataManager()
}
// Check for "new" entries
if (AlligatorSettings::self()->autoQueue()) {
if (SettingsManager::self()->autoQueue()) {
query.prepare(QStringLiteral("SELECT id FROM Entries WHERE feed=:feed AND new=:new;"));
query.bindValue(QStringLiteral(":feed"), feedurl);
query.bindValue(QStringLiteral(":new"), true);
@ -64,9 +64,11 @@ DataManager::DataManager()
while (query.next()) {
QString const id = query.value(QStringLiteral("id")).toString();
addtoQueue(feedurl, id);
if (AlligatorSettings::self()->autoDownload()) {
if (getEntry(id)->hasEnclosure())
if (SettingsManager::self()->autoDownload()) {
if (getEntry(id)->hasEnclosure()) {
qDebug() << "Start downloading" << getEntry(id)->title();
getEntry(id)->enclosure()->download();
}
}
}

View File

@ -22,7 +22,7 @@
#include "database.h"
#include "fetcher.h"
#include "alligatorsettings.h"
#include "settingsmanager.h"
Fetcher::Fetcher()
{
@ -144,7 +144,7 @@ void Fetcher::processFeed(Syndication::FeedPtr feed, const QString &url)
if (isNewFeed) {
query.prepare(QStringLiteral("SELECT * FROM Entries WHERE feed=:feed ORDER BY updated DESC LIMIT :recentNew;"));
query.bindValue(QStringLiteral(":feed"), url);
query.bindValue(QStringLiteral(":recentNew"), AlligatorSettings::self()->numberNewEpisodes());
query.bindValue(QStringLiteral(":recentNew"), SettingsManager::self()->numberNewEpisodes());
Database::instance().execute(query);
QSqlQuery updateQuery;
while (query.next()) {

View File

@ -23,7 +23,7 @@
#include <KLocalizedString>
#include "alligator-version.h"
#include "alligatorsettings.h"
#include "settingsmanager.h"
#include "database.h"
#include "entriesmodel.h"
#include "feedsmodel.h"
@ -63,9 +63,9 @@ int main(int argc, char *argv[])
engine->setObjectOwnership(&DataManager::instance(), QQmlEngine::CppOwnership);
return &DataManager::instance();
});
qmlRegisterSingletonType<AlligatorSettings>("org.kde.alligator", 1, 0, "AlligatorSettings", [](QQmlEngine *engine, QJSEngine *) -> QObject * {
engine->setObjectOwnership(AlligatorSettings::self(), QQmlEngine::CppOwnership);
return AlligatorSettings::self();
qmlRegisterSingletonType<SettingsManager>("org.kde.alligator", 1, 0, "SettingsManager", [](QQmlEngine *engine, QJSEngine *) -> QObject * {
engine->setObjectOwnership(SettingsManager::self(), QQmlEngine::CppOwnership);
return SettingsManager::self();
});
QQmlApplicationEngine engine;
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("_aboutData"), QVariant::fromValue(about));
// Make sure that settings are saved before the application exits
QObject::connect(&app, &QCoreApplication::aboutToQuit, AlligatorSettings::self(), &AlligatorSettings::save);
QObject::connect(&app, &QCoreApplication::aboutToQuit, SettingsManager::self(), &SettingsManager::save);
Database::instance();

View File

@ -28,40 +28,40 @@ Kirigami.ScrollablePage {
id: numberNewEpisodes
Kirigami.FormData.label: i18n("# of episodes to label as new when adding a new subscription:")
value: AlligatorSettings.numberNewEpisodes
value: SettingsManager.numberNewEpisodes
onValueModified: AlligatorSettings.numberNewEpisodes = value
onValueModified: SettingsManager.numberNewEpisodes = value
}
Controls.CheckBox {
id: autoQueue
checked: AlligatorSettings.autoQueue
checked: SettingsManager.autoQueue
text: i18n("Automatically queue new episodes")
onToggled: {
AlligatorSettings.autoQueue = checked
SettingsManager.autoQueue = checked
if (!checked) {
autoDownload.checked = false
AlligatorSettings.autoDownload = false
SettingsManager.autoDownload = false
}
}
}
Controls.CheckBox {
id: autoDownload
checked: AlligatorSettings.autoDownload
checked: SettingsManager.autoDownload
text: i18n("Automatically download new episodes")
enabled: autoQueue.checked
onToggled: AlligatorSettings.autoDownload = checked
onToggled: SettingsManager.autoDownload = checked
}
Controls.CheckBox {
id: allowStreaming
checked: AlligatorSettings.allowStreaming
checked: SettingsManager.allowStreaming
text: i18n("Allow streaming of audio")
onToggled: AlligatorSettings.allowStreaming = checked
onToggled: SettingsManager.allowStreaming = checked
}
}

View File

@ -1,5 +1,5 @@
File=alligatorsettings.kcfg
ClassName=AlligatorSettings
File=settingsmanager.kcfg
ClassName=SettingsManager
Mutators=true
DefaultValueGetters=true
GenerateProperties=true