From 3dee256411d4181a253043907b46fcd778d549ad Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 5 Mar 2013 17:22:00 +0100 Subject: [PATCH] get default containments and toolbox from package --- .../qml/plasmoid/appletinterface.cpp | 9 ++++++++- src/shell/desktopcorona.cpp | 6 +++++- src/shell/desktopcorona.h | 1 + src/shell/qmlpackages/desktop/contents/defaults | 15 +++++++++++++++ src/shell/shellpackage.cpp | 2 +- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/shell/qmlpackages/desktop/contents/defaults diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 25353fe85..a76f8f1dd 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -137,8 +137,15 @@ void AppletInterface::init() //Create the ToolBox Plasma::Containment *pc = qobject_cast(applet()); if (pc) { + KConfigGroup defaults; + if (pc->containmentType() == Plasma::DesktopContainment) { + defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Desktop"); + } else if (pc->containmentType() == Plasma::PanelContainment) { + defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Panel"); + } + Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); - pkg.setPath("org.kde.toolbox"); + pkg.setPath(defaults.readEntry("ToolBox", "org.kde.toolbox")); if (pkg.isValid()) { QObject *toolBoxObject = m_qmlObject->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript"))); diff --git a/src/shell/desktopcorona.cpp b/src/shell/desktopcorona.cpp index 8882c4945..895212361 100644 --- a/src/shell/desktopcorona.cpp +++ b/src/shell/desktopcorona.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "panelview.h" #include "view.h" @@ -33,6 +34,8 @@ DesktopCorona::DesktopCorona(QObject *parent) : Plasma::Corona(parent), m_desktopWidget(QApplication::desktop()) { + m_desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop"); + connect(m_desktopWidget, SIGNAL(resized(int)), this, SLOT(screenResized(int))); connect(m_desktopWidget, SIGNAL(screenCountChanged(int)), @@ -53,6 +56,7 @@ DesktopCorona::~DesktopCorona() void DesktopCorona::loadDefaultLayout() { + //TODO: use Javascript here Plasma::Containment *cont = createContainment("org.kde.testcontainment"); cont->setScreen(0); qDebug() << containmentForScreen(0); @@ -118,7 +122,7 @@ void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists, //TODO: remove following when activities are restored if (!c) { - c = createContainment("desktop"); + c = createContainment(m_desktopDefaultsConfig.readEntry("Containment", "org.kde.testcontainment")); } if (!c) { diff --git a/src/shell/desktopcorona.h b/src/shell/desktopcorona.h index 983a63a9f..adacae450 100644 --- a/src/shell/desktopcorona.h +++ b/src/shell/desktopcorona.h @@ -76,6 +76,7 @@ private: QDesktopWidget *m_desktopWidget; QList m_views; QHash m_panelViews; + KConfigGroup m_desktopDefaultsConfig; }; #endif diff --git a/src/shell/qmlpackages/desktop/contents/defaults b/src/shell/qmlpackages/desktop/contents/defaults new file mode 100644 index 000000000..147d0ec4e --- /dev/null +++ b/src/shell/qmlpackages/desktop/contents/defaults @@ -0,0 +1,15 @@ +[Desktop] +Containment=org.kde.desktop +ToolBox=org.kde.toolbox +[Desktop][ContainmentActions] +Ctrl;LeftButton=org.kde.standardmenu +MiddleButton=org.kde.paste + +[Panel] +Containment=org.kde.panel +ToolBox=org.kde.toolbox +[Panel][ContainmentActions] +Ctrl;LeftButton=org.kde.standardmenu + +[Theme] +Theme=default \ No newline at end of file diff --git a/src/shell/shellpackage.cpp b/src/shell/shellpackage.cpp index b370027c6..7703e1b7e 100644 --- a/src/shell/shellpackage.cpp +++ b/src/shell/shellpackage.cpp @@ -40,7 +40,7 @@ void ShellPackageStructure::initPackage(Plasma::Package *package) package->addFileDefinition("defaults", "defaults", i18n("Default plugins for containments, containmentActions etc")); package->setMimeTypes("layout", QStringList() << "application/javascript"); - package->setMimeTypes("layout", QStringList() << "text/plain"); + package->setMimeTypes("defaults", QStringList() << "text/plain"); package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails loading")); package->addFileDefinition("compactapplet", "components/CompactApplet.qml", i18n("QML component that shows an applet in a popup"));