diff --git a/src/scriptengines/qml/CMakeLists.txt b/src/scriptengines/qml/CMakeLists.txt index b7cc580da..0e86966e5 100644 --- a/src/scriptengines/qml/CMakeLists.txt +++ b/src/scriptengines/qml/CMakeLists.txt @@ -18,6 +18,7 @@ set(declarative_appletscript_SRCS declarative/packageaccessmanagerfactory.cpp declarative/qmlobject.cpp plasmoid/appletinterface.cpp + plasmoid/configview.cpp plasmoid/containmentinterface.cpp plasmoid/declarativeappletscript.cpp ) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 86cee345d..b2f752fe9 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -45,6 +45,7 @@ #include #include "containmentinterface.h" +#include "configview.h" #include "declarative/configpropertymap.h" #include "declarative/qmlobject.h" #include "declarative/packageaccessmanagerfactory.h" @@ -611,29 +612,12 @@ void AppletInterface::setConfigurationInterfaceShown(bool show) } if (show) { - if (m_configView) { - m_configView.data()->show(); - return; - } else { - m_configView = new QQuickView(); - //FIXME: problem on nvidia, all windows should be transparent or won't show - m_configView.data()->setColor(Qt::transparent); - m_configView.data()->setTitle(i18n("%1 Settings", applet()->title())); - } - - if (!applet()->containment()->corona()->package().isValid()) { - qWarning() << "Invalid home screen package"; - } - - m_configView.data()->setResizeMode(QQuickView::SizeRootObjectToView); - m_configView.data()->setSource(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "Configuration.qml"))); - - if (m_configView.data()->rootObject()) { - m_configView.data()->engine()->rootContext()->setContextProperty("plasmoid", this); - m_configView.data()->rootObject()->metaObject()->invokeMethod(m_configView.data()->rootObject(), "addConfigPage", Q_ARG(QVariant, QUrl::fromLocalFile(m_appletScriptEngine->package().filePath("ui", "ConfigGeneral.qml")))); + if (!m_configView) { + m_configView = new ConfigView(this); } m_configView.data()->show(); + } else { if (m_configView) { m_configView.data()->hide(); diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 16585c7db..a62f140da 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -37,6 +37,7 @@ class QSignalMapper; class QSizeF; class ConfigPropertyMap; +class ConfigView; class QmlObject; @@ -251,7 +252,7 @@ private: //UI-specific members ------------------ QmlObject *m_qmlObject; QWeakPointer m_compactUiObject; - QWeakPointer m_configView; + QWeakPointer m_configView; QTimer *m_creationTimer; diff --git a/src/scriptengines/qml/plasmoid/configview.cpp b/src/scriptengines/qml/plasmoid/configview.cpp new file mode 100644 index 000000000..117076785 --- /dev/null +++ b/src/scriptengines/qml/plasmoid/configview.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library 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 "configview.h" +#include "plasmoid/appletinterface.h" + +#include +#include +#include +#include + +#include + +#include + +ConfigView::ConfigView(AppletInterface *interface, QWindow *parent) + : QQuickView(parent), + m_appletInterface(interface) +{ + //FIXME: problem on nvidia, all windows should be transparent or won't show + setColor(Qt::transparent); + setTitle(i18n("%1 Settings", m_appletInterface->applet()->title())); + + + if (!m_appletInterface->applet()->containment()->corona()->package().isValid()) { + qWarning() << "Invalid home screen package"; + } + + setResizeMode(QQuickView::SizeRootObjectToView); + setSource(QUrl::fromLocalFile(m_appletInterface->applet()->containment()->corona()->package().filePath("ui", "Configuration.qml"))); + + if (rootObject()) { + engine()->rootContext()->setContextProperty("plasmoid", interface); + rootObject()->metaObject()->invokeMethod(rootObject(), "addConfigPage", Q_ARG(QVariant, QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "ConfigGeneral.qml")))); + } +} + +ConfigView::~ConfigView() +{ +} + +#include "moc_configview.cpp" diff --git a/src/scriptengines/qml/plasmoid/configview.h b/src/scriptengines/qml/plasmoid/configview.h new file mode 100644 index 000000000..462d67d7b --- /dev/null +++ b/src/scriptengines/qml/plasmoid/configview.h @@ -0,0 +1,40 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library 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. + */ + +#ifndef CONFIGUILOADER_H +#define CONFIGUILOADER_H + + +#include + +class AppletInterface; + +class ConfigView : public QQuickView +{ + Q_OBJECT + +public: + ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0); + virtual ~ConfigView(); + +private: + AppletInterface *m_appletInterface; +}; + +#endif // multiple inclusion guard