move the config view in a separate file

This commit is contained in:
Marco Martin 2013-02-22 18:23:35 +01:00
parent 459b49fff9
commit 949d114eec
5 changed files with 105 additions and 21 deletions

View File

@ -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
)

View File

@ -45,6 +45,7 @@
#include <Plasma/PluginLoader>
#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();

View File

@ -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<QObject> m_compactUiObject;
QWeakPointer<QQuickView> m_configView;
QWeakPointer<ConfigView> m_configView;
QTimer *m_creationTimer;

View File

@ -0,0 +1,58 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* 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 <QDebug>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQmlContext>
#include <KLocalizedString>
#include <Plasma/Corona>
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"

View File

@ -0,0 +1,40 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* 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 <QQuickView>
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