mirror of https://github.com/KDE/kasts.git
Change to singleton AlligatorSettings class
This commit is contained in:
parent
81c2ad90d1
commit
436e66542a
|
@ -4,4 +4,5 @@ Mutators=true
|
||||||
DefaultValueGetters=true
|
DefaultValueGetters=true
|
||||||
GenerateProperties=true
|
GenerateProperties=true
|
||||||
ParentInConstructor=true
|
ParentInConstructor=true
|
||||||
|
Singleton=true
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,8 @@ int Database::version()
|
||||||
|
|
||||||
void Database::cleanup()
|
void Database::cleanup()
|
||||||
{
|
{
|
||||||
AlligatorSettings settings;
|
int count = AlligatorSettings::self()->deleteAfterCount();
|
||||||
int count = settings.deleteAfterCount();
|
int type = AlligatorSettings::self()->deleteAfterType();
|
||||||
int type = settings.deleteAfterType();
|
|
||||||
|
|
||||||
if (type == 0) { // Never delete Entries
|
if (type == 0) { // Never delete Entries
|
||||||
return;
|
return;
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -63,6 +63,10 @@ int main(int argc, char *argv[])
|
||||||
engine->setObjectOwnership(&DataManager::instance(), QQmlEngine::CppOwnership);
|
engine->setObjectOwnership(&DataManager::instance(), QQmlEngine::CppOwnership);
|
||||||
return &DataManager::instance();
|
return &DataManager::instance();
|
||||||
});
|
});
|
||||||
|
qmlRegisterSingletonType<AlligatorSettings>("org.kde.alligator", 1, 0, "AlligatorSettings", [](QQmlEngine *engine, QJSEngine *) -> QObject * {
|
||||||
|
engine->setObjectOwnership(AlligatorSettings::self(), QQmlEngine::CppOwnership);
|
||||||
|
return AlligatorSettings::self();
|
||||||
|
});
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||||
|
@ -81,11 +85,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty(QStringLiteral("_aboutData"), QVariant::fromValue(about));
|
engine.rootContext()->setContextProperty(QStringLiteral("_aboutData"), QVariant::fromValue(about));
|
||||||
|
|
||||||
AlligatorSettings settings;
|
// Make sure that settings are saved before the application exits
|
||||||
|
QObject::connect(&app, &QCoreApplication::aboutToQuit, AlligatorSettings::self(), &AlligatorSettings::save);
|
||||||
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
|
|
||||||
|
|
||||||
QObject::connect(&app, &QCoreApplication::aboutToQuit, &settings, &AlligatorSettings::save);
|
|
||||||
|
|
||||||
Database::instance();
|
Database::instance();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import QtQuick.Controls 2.14 as Controls
|
||||||
import QtQuick.Layouts 1.14
|
import QtQuick.Layouts 1.14
|
||||||
|
|
||||||
import org.kde.kirigami 2.12 as Kirigami
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
import org.kde.alligator 1.0
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
Kirigami.ScrollablePage {
|
||||||
title: i18n("Settings")
|
title: i18n("Settings")
|
||||||
|
@ -27,25 +28,25 @@ Kirigami.ScrollablePage {
|
||||||
id: numberNewEpisodes
|
id: numberNewEpisodes
|
||||||
|
|
||||||
Kirigami.FormData.label: i18n("# of episodes to label as new when adding a new subscription:")
|
Kirigami.FormData.label: i18n("# of episodes to label as new when adding a new subscription:")
|
||||||
value: _settings.numberNewEpisodes
|
value: AlligatorSettings.numberNewEpisodes
|
||||||
|
|
||||||
onValueModified: _settings.numberNewEpisodes = value
|
onValueModified: AlligatorSettings.numberNewEpisodes = value
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.CheckBox {
|
Controls.CheckBox {
|
||||||
id: autoDownload
|
id: autoDownload
|
||||||
checked: _settings.autoDownload
|
checked: AlligatorSettings.autoDownload
|
||||||
text: i18n("Automatically download new episodes")
|
text: i18n("Automatically download new episodes")
|
||||||
|
|
||||||
onToggled: _settings.autoDownload = checked
|
onToggled: AlligatorSettings.autoDownload = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.CheckBox {
|
Controls.CheckBox {
|
||||||
id: allowStreaming
|
id: allowStreaming
|
||||||
checked: _settings.allowStreaming
|
checked: AlligatorSettings.allowStreaming
|
||||||
text: i18n("Allow streaming of audio")
|
text: i18n("Allow streaming of audio")
|
||||||
|
|
||||||
onToggled: _settings.allowStreaming = checked
|
onToggled: AlligatorSettings.allowStreaming = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue