Commit f2be403e authored by Nicolas Fella's avatar Nicolas Fella Committed by Jonah Brüchert

Fix starting with -m argument

parent 127b0a83
Pipeline #7675 passed with stage
in 12 minutes and 16 seconds
import QtQuick 2.6
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.5 as Kirigami
import org.kde.plasma.settings 0.1
Kirigami.Page {
id: container
title: internalPage.title
property QtObject kcm
property Item internalPage
topPadding: 0
leftPadding: 0
rightPadding: 0
bottomPadding: 0
flickable: internalPage.flickable
actions.main: internalPage.actions.main
actions.contextualActions: internalPage.contextualActions
onInternalPageChanged: {
internalPage.parent = contentItem;
internalPage.anchors.fill = contentItem;
}
data: [
Connections {
target: kcm
onPagePushed: {
pageStack.push(kcmContainer.createObject(pageStack, {"internalPage": page}));
}
onPageRemoved: pageStack.pop();
},
Connections {
target: pageStack
onPageRemoved: {
if (page == container) {
page.destroy();
}
}
}
]
}
......@@ -93,43 +93,10 @@ Kirigami.ScrollablePage {
// This is pretty much a placeholder of what will be the sandboxing mechanism: this element will be a wayland compositor that will contain off-process kcm pages
Component {
id: kcmContainer
Kirigami.Page {
id: container
title: internalPage.title
property QtObject kcm
property Item internalPage
topPadding: 0
leftPadding: 0
rightPadding: 0
bottomPadding: 0
flickable: internalPage.flickable
actions.main: internalPage.actions.main
actions.contextualActions: internalPage.contextualActions
onInternalPageChanged: {
internalPage.parent = contentItem;
internalPage.anchors.fill = contentItem;
}
data: [
Connections {
target: kcm
onPagePushed: {
pageStack.push(kcmContainer.createObject(pageStack, {"internalPage": page}));
}
onPageRemoved: pageStack.pop();
},
Connections {
target: pageStack
onPageRemoved: {
if (page == container) {
page.destroy();
}
}
}
]
}
KCMContainer {}
}
ListView {
id: listView
model: ModulesModel{}
......
......@@ -28,8 +28,6 @@ import org.kde.plasma.settings 0.1
Kirigami.ApplicationWindow {
id: rootItem
property Item currentModule
pageStack.initialPage: modulesList
pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.Breadcrumb
......@@ -37,27 +35,25 @@ Kirigami.ApplicationWindow {
id: contextDrawer
}
Connections {
target: settingsApp
onActivateRequested: rootItem.requestActivate();
onModuleRequested: {
pageStack.currentIndex = 0;
rootItem.currentModule = module;
}
}
onCurrentModuleChanged: {
if (currentModule.length > 0) {
pageStack.push(moduleItem);
}
pageStack.currentIndex = 1;
}
Component.onCompleted: {
if (startModule.length > 0) {
rootItem.currentModule = startModule;
module.name = startModule
var container = kcmContainer.createObject(pageStack, {"kcm": module.kcm, "internalPage": module.kcm.mainUi});
pageStack.push(container);
}
}
Module {
id: module
}
ModulesList {
id: modulesList
}
Component {
id: kcmContainer
KCMContainer {}
}
}
......@@ -5,6 +5,7 @@ set(plasma-settings_SRCS
main.cpp
settingsapp.cpp
modulesmodel.cpp
module.cpp
)
add_executable(plasma-settings ${plasma-settings_SRCS})
......
......@@ -25,6 +25,7 @@
//own
#include "settingsapp.h"
#include "modulesmodel.h"
#include "module.h"
// Qt
#include <QApplication>
......@@ -154,6 +155,7 @@ int main(int argc, char **argv)
auto *settingsApp = new SettingsApp(parser);
qmlRegisterType<ModulesModel>("org.kde.plasma.settings", 0, 1, "ModulesModel");
qmlRegisterType<Module>("org.kde.plasma.settings", 0, 1, "Module");
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("settingsApp", settingsApp);
......
/***************************************************************************
* *
* Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "module.h"
#include <KPluginLoader>
#include <KPluginFactory>
KQuickAddons::ConfigModule *Module::kcm() const
{
return m_kcm;
}
QString Module::name() const
{
return m_name;
}
void Module::setName(const QString& name)
{
if (m_name == name) {
return;
}
m_name = name;
Q_EMIT nameChanged();
const QString pluginPath = KPluginLoader::findPlugin(QLatin1String("kcms/") + name);
KPluginLoader loader(pluginPath);
KPluginFactory* factory = loader.factory();
if (!factory) {
qWarning() << "Error loading KCM plugin:" << loader.errorString();
} else {
m_kcm = factory->create<KQuickAddons::ConfigModule >();
if (!m_kcm) {
qWarning() << "Error creating object from plugin" << loader.fileName();
}
}
Q_EMIT kcmChanged();
}
/***************************************************************************
* *
* Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#pragma once
#include <QObject>
#include <KQuickAddons/ConfigModule>
class Module : public QObject
{
Q_OBJECT
Q_PROPERTY(KQuickAddons::ConfigModule* kcm READ kcm NOTIFY kcmChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
KQuickAddons::ConfigModule *kcm() const;
QString name() const;
void setName(const QString &name);
Q_SIGNALS:
void kcmChanged();
void nameChanged();
private:
KQuickAddons::ConfigModule *m_kcm = nullptr;
QString m_name;
};
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