Verified Commit 59cecb58 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Port away from context properties

parent ed550ebd
Pipeline #29776 passed with stage
in 10 minutes and 8 seconds
......@@ -28,7 +28,7 @@ import org.kde.plasma.settings 0.1
Kirigami.ApplicationWindow {
id: rootItem
pageStack.initialPage: singleModule ? null : modulesList
pageStack.initialPage: SettingsApp.singleModule ? null : modulesList
pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.Breadcrumb
contextDrawer: Kirigami.ContextDrawer {
......@@ -45,13 +45,13 @@ Kirigami.ApplicationWindow {
}
Component.onCompleted: {
if (startModule.length > 0) {
openModule(startModule)
if (SettingsApp.startModule.length > 0) {
openModule(SettingsApp.startModule)
}
}
Connections {
target: settingsApp
target: SettingsApp
onModuleRequested: {
openModule(moduleName)
}
......
......@@ -164,14 +164,14 @@ int main(int argc, char **argv)
package.setPath(ui);
auto *settingsApp = new SettingsApp(parser);
settingsApp->setStartModule(module);
settingsApp->setSingleModule(singleModule);
qmlRegisterType<ModulesModel>("org.kde.plasma.settings", 0, 1, "ModulesModel");
qmlRegisterType<Module>("org.kde.plasma.settings", 0, 1, "Module");
qmlRegisterSingletonInstance<SettingsApp>("org.kde.plasma.settings", 0, 1, "SettingsApp", settingsApp);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("settingsApp", settingsApp);
engine.rootContext()->setContextProperty("startModule", module);
engine.rootContext()->setContextProperty("singleModule", singleModule);
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(package.filePath("mainscript"));
......
......@@ -57,3 +57,12 @@ void SettingsApp::setupKDBus()
} );
}
void SettingsApp::setStartModule(const QString &startModule)
{
m_startModule = startModule;
}
void SettingsApp::setSingleModule(const bool singleModule)
{
m_singleModule = singleModule;
}
......@@ -28,19 +28,29 @@
class SettingsApp : public QObject
{
Q_OBJECT
Q_PROPERTY(QString startModule MEMBER m_startModule WRITE setStartModule NOTIFY startModuleChanged)
Q_PROPERTY(bool singleModule MEMBER m_singleModule WRITE setSingleModule NOTIFY singleModuleChanged)
public:
explicit SettingsApp(QCommandLineParser &parser, QObject *parent = nullptr );
~SettingsApp() override;
void setSingleModule(const bool singleModule);
void setStartModule(const QString &startModule);
Q_SIGNALS:
void moduleRequested(const QString &moduleName);
void activateRequested();
void startModuleChanged();
void singleModuleChanged();
private:
void setupKDBus();
QCommandLineParser *m_parser;
QString m_startModule;
bool m_singleModule;
};
#endif // SettingsApp_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment