move the config dialog in the shell
it still doesn't successfully load
This commit is contained in:
parent
db5ef57480
commit
e7ca00e534
@ -73,8 +73,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
} else if (appletId > s_maxAppletId) {
|
||||
s_maxAppletId = appletId;
|
||||
}
|
||||
QObject::connect(actions->action("configure"), SIGNAL(QAction::triggered()),
|
||||
q, SLOT(Applet::requestConfiguration));
|
||||
QObject::connect(actions->action("configure"), SIGNAL(triggered()),
|
||||
q, SLOT(requestConfiguration()));
|
||||
}
|
||||
|
||||
AppletPrivate::~AppletPrivate()
|
||||
|
@ -18,8 +18,6 @@ set(declarative_appletscript_SRCS
|
||||
declarative/packageaccessmanagerfactory.cpp
|
||||
declarative/qmlobject.cpp
|
||||
plasmoid/appletinterface.cpp
|
||||
plasmoid/configview.cpp
|
||||
plasmoid/containmentconfigview.cpp
|
||||
plasmoid/containmentinterface.cpp
|
||||
plasmoid/declarativeappletscript.cpp
|
||||
plasmoid/wallpaperinterface.cpp
|
||||
|
@ -46,8 +46,6 @@
|
||||
#include <Plasma/PluginLoader>
|
||||
|
||||
#include "containmentinterface.h"
|
||||
#include "configview.h"
|
||||
#include "containmentconfigview.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include "declarative/qmlobject.h"
|
||||
#include "declarative/packageaccessmanagerfactory.h"
|
||||
@ -76,9 +74,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
|
||||
connect(m_appletScriptEngine, SIGNAL(contextChanged()),
|
||||
this, SIGNAL(contextChanged()));
|
||||
|
||||
connect(applet()->actions()->action("configure"), &QAction::triggered,
|
||||
this, &AppletInterface::configureTriggered);
|
||||
|
||||
m_qmlObject = new QmlObject(this);
|
||||
m_qmlObject->setInitializationDelayed(true);
|
||||
|
||||
@ -457,7 +452,8 @@ bool AppletInterface::immutable() const
|
||||
|
||||
bool AppletInterface::userConfiguring() const
|
||||
{
|
||||
return m_configView.data()->isVisible();
|
||||
//FIXME
|
||||
return false;
|
||||
}
|
||||
|
||||
int AppletInterface::apiVersion() const
|
||||
@ -620,37 +616,4 @@ QmlObject *AppletInterface::qmlObject()
|
||||
return m_qmlObject;
|
||||
}
|
||||
|
||||
void AppletInterface::configureTriggered()
|
||||
{
|
||||
setConfigurationInterfaceShown(true);
|
||||
}
|
||||
|
||||
void AppletInterface::setConfigurationInterfaceShown(bool show)
|
||||
{
|
||||
if (!applet()->containment() || !applet()->containment()->corona()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
if (!m_configView) {
|
||||
ContainmentInterface *ci = qobject_cast<ContainmentInterface *>(this);
|
||||
|
||||
if (ci) {
|
||||
m_configView = new ContainmentConfigView(ci);
|
||||
} else {
|
||||
m_configView = new ConfigView(this);
|
||||
}
|
||||
m_configView.data()->init();
|
||||
}
|
||||
|
||||
m_configView.data()->show();
|
||||
|
||||
} else {
|
||||
if (m_configView) {
|
||||
m_configView.data()->hide();
|
||||
m_configView.data()->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_appletinterface.cpp"
|
||||
|
@ -231,15 +231,10 @@ Q_SIGNALS:
|
||||
void busyChanged();
|
||||
void expandedChanged();
|
||||
|
||||
//it's important those slots are private because must not be invokable by qml
|
||||
private Q_SLOTS:
|
||||
void configureTriggered();
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
|
||||
void itemChange(ItemChange change, const ItemChangeData &value);
|
||||
void setConfigurationInterfaceShown(bool show);
|
||||
|
||||
DeclarativeAppletScript *m_appletScriptEngine;
|
||||
|
||||
@ -255,7 +250,6 @@ private:
|
||||
//UI-specific members ------------------
|
||||
QmlObject *m_qmlObject;
|
||||
QWeakPointer<QObject> m_compactUiObject;
|
||||
QWeakPointer<ConfigView> m_configView;
|
||||
|
||||
QTimer *m_creationTimer;
|
||||
|
||||
|
@ -56,6 +56,8 @@ set(widgetexplorer_SRC
|
||||
|
||||
add_executable(plasma-shell
|
||||
main.cpp
|
||||
configview.cpp
|
||||
containmentconfigview.cpp
|
||||
desktopcorona.cpp
|
||||
panelview.cpp
|
||||
shellpluginloader.cpp
|
||||
|
@ -18,16 +18,17 @@
|
||||
*/
|
||||
|
||||
#include "configview.h"
|
||||
#include "plasmoid/appletinterface.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
#include "plasmoid/wallpaperinterface.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include "Plasma/Applet"
|
||||
#include "Plasma/Containment"
|
||||
//#include "plasmoid/wallpaperinterface.h"
|
||||
#include "kdeclarative/configpropertymap.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KLocalizedString>
|
||||
@ -146,7 +147,7 @@ QVariant ConfigModel::data(const QModelIndex& index, int role) const
|
||||
return m_categories.at(index.row())->icon();
|
||||
case SourceRole:
|
||||
if (m_appletInterface) {
|
||||
return QUrl::fromLocalFile(m_appletInterface.data()->applet()->package().filePath("ui", m_categories.at(index.row())->source()));
|
||||
return QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(index.row())->source()));
|
||||
} else {
|
||||
return m_categories.at(index.row())->source();
|
||||
}
|
||||
@ -167,7 +168,7 @@ QVariant ConfigModel::get(int row) const
|
||||
value["name"] = m_categories.at(row)->name();
|
||||
value["icon"] = m_categories.at(row)->icon();
|
||||
if (m_appletInterface) {
|
||||
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->applet()->package().filePath("components", m_categories.at(row)->source()));
|
||||
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("components", m_categories.at(row)->source()));
|
||||
} else {
|
||||
value["source"] = m_categories.at(row)->source();
|
||||
}
|
||||
@ -193,12 +194,12 @@ void ConfigModel::clear()
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void ConfigModel::setAppletInterface(AppletInterface *interface)
|
||||
void ConfigModel::setApplet(Plasma::Applet *interface)
|
||||
{
|
||||
m_appletInterface = interface;
|
||||
}
|
||||
|
||||
AppletInterface *ConfigModel::appletInterface() const
|
||||
Plasma::Applet *ConfigModel::applet() const
|
||||
{
|
||||
return m_appletInterface.data();
|
||||
}
|
||||
@ -259,19 +260,19 @@ void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
||||
|
||||
|
||||
//////////////////////////////ConfigView
|
||||
ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
|
||||
ConfigView::ConfigView(Plasma::Applet *interface, QWindow *parent)
|
||||
: QQuickView(parent),
|
||||
m_appletInterface(interface)
|
||||
m_applet(interface)
|
||||
{
|
||||
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
|
||||
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
|
||||
|
||||
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
||||
setColor(Qt::transparent);
|
||||
setTitle(i18n("%1 Settings", m_appletInterface->applet()->title()));
|
||||
setTitle(i18n("%1 Settings", m_applet->title()));
|
||||
|
||||
|
||||
if (!m_appletInterface->applet()->containment()->corona()->package().isValid()) {
|
||||
if (!m_applet->containment()->corona()->package().isValid()) {
|
||||
qWarning() << "Invalid home screen package";
|
||||
}
|
||||
|
||||
@ -279,17 +280,17 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
|
||||
|
||||
|
||||
//config model local of the applet
|
||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("configmodel")), this);
|
||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_applet->package().filePath("configmodel")), this);
|
||||
QObject *object = component->create(engine()->rootContext());
|
||||
m_configModel = qobject_cast<ConfigModel *>(object);
|
||||
if (m_configModel) {
|
||||
m_configModel->setAppletInterface(m_appletInterface);
|
||||
m_configModel->setApplet(m_applet);
|
||||
} else {
|
||||
delete object;
|
||||
}
|
||||
delete component;
|
||||
|
||||
ContainmentInterface *cont = qobject_cast<ContainmentInterface *>(m_appletInterface);
|
||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(m_applet);
|
||||
|
||||
engine()->rootContext()->setContextProperty("plasmoid", interface);
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
@ -301,7 +302,7 @@ ConfigView::~ConfigView()
|
||||
|
||||
void ConfigView::init()
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(m_appletInterface->applet()->containment()->corona()->package().filePath("configurationui")));
|
||||
setSource(QUrl::fromLocalFile(m_applet->containment()->corona()->package().filePath("configurationui")));
|
||||
}
|
||||
|
||||
ConfigModel *ConfigView::configModel() const
|
@ -26,7 +26,10 @@
|
||||
#include <QQmlListProperty>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class AppletInterface;
|
||||
namespace Plasma {
|
||||
class Applet;
|
||||
}
|
||||
|
||||
class ConfigPropertyMap;
|
||||
|
||||
|
||||
@ -87,8 +90,8 @@ public:
|
||||
void appendCategory(ConfigCategory *c);
|
||||
void clear();
|
||||
|
||||
void setAppletInterface(AppletInterface *interface);
|
||||
AppletInterface *appletInterface() const;
|
||||
void setApplet(Plasma::Applet *interface);
|
||||
Plasma::Applet *applet() const;
|
||||
|
||||
int count() {return rowCount();}
|
||||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||||
@ -107,7 +110,7 @@ Q_SIGNALS:
|
||||
|
||||
private:
|
||||
QList<ConfigCategory*>m_categories;
|
||||
QWeakPointer<AppletInterface> m_appletInterface;
|
||||
QWeakPointer<Plasma::Applet> m_appletInterface;
|
||||
};
|
||||
|
||||
|
||||
@ -119,7 +122,7 @@ class ConfigView : public QQuickView
|
||||
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
||||
|
||||
public:
|
||||
ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0);
|
||||
ConfigView(Plasma::Applet *applet, QWindow *parent = 0);
|
||||
virtual ~ConfigView();
|
||||
|
||||
void init();
|
||||
@ -131,7 +134,7 @@ protected:
|
||||
void resizeEvent(QResizeEvent *re);
|
||||
|
||||
private:
|
||||
AppletInterface *m_appletInterface;
|
||||
Plasma::Applet *m_applet;
|
||||
ConfigModel *m_configModel;
|
||||
};
|
||||
|
@ -18,13 +18,14 @@
|
||||
*/
|
||||
|
||||
#include "containmentconfigview.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
#include "plasmoid/wallpaperinterface.h"
|
||||
#include "declarative/configpropertymap.h"
|
||||
#include <Plasma/Containment>
|
||||
//#include "plasmoid/wallpaperinterface.h"
|
||||
#include <kdeclarative/configpropertymap.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
|
||||
|
||||
#include <KLocalizedString>
|
||||
@ -33,14 +34,14 @@
|
||||
|
||||
|
||||
//////////////////////////////ContainmentConfigView
|
||||
ContainmentConfigView::ContainmentConfigView(ContainmentInterface *interface, QWindow *parent)
|
||||
: ConfigView(interface, parent),
|
||||
m_containmentInterface(interface),
|
||||
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent)
|
||||
: ConfigView(cont, parent),
|
||||
m_containment(cont),
|
||||
m_wallpaperConfigModel(0),
|
||||
m_currentWallpaperConfig(0)
|
||||
{
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
setCurrentWallpaper(interface->containment()->wallpaper());
|
||||
setCurrentWallpaper(cont->containment()->wallpaper());
|
||||
}
|
||||
|
||||
ContainmentConfigView::~ContainmentConfigView()
|
||||
@ -94,17 +95,17 @@ QString ContainmentConfigView::currentWallpaper() const
|
||||
|
||||
void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
{
|
||||
if (m_currentWallpaper == wallpaper) {
|
||||
/*if (m_currentWallpaper == wallpaper) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_containmentInterface->containment()->wallpaper() == wallpaper) {
|
||||
if (m_containment->containment()->wallpaper() == wallpaper) {
|
||||
delete m_currentWallpaperConfig;
|
||||
if (m_containmentInterface->wallpaperInterface()) {
|
||||
m_currentWallpaperConfig = m_containmentInterface->wallpaperInterface()->configuration();
|
||||
if (m_containment->wallpaperInterface()) {
|
||||
m_currentWallpaperConfig = m_containment->wallpaperInterface()->configuration();
|
||||
}
|
||||
} else {
|
||||
if (m_containmentInterface->containment()->wallpaper() != m_currentWallpaper) {
|
||||
if (m_containment->containment()->wallpaper() != m_currentWallpaper) {
|
||||
delete m_currentWallpaperConfig;
|
||||
}
|
||||
|
||||
@ -113,10 +114,10 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
pkg.setDefaultPackageRoot("plasma/wallpapers");
|
||||
pkg.setPath(wallpaper);
|
||||
QFile file(pkg.filePath("config", "main.xml"));
|
||||
KConfigGroup cfg = m_containmentInterface->containment()->config();
|
||||
KConfigGroup cfg = m_containment->containment()->config();
|
||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||
m_currentWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this);
|
||||
}
|
||||
}*/
|
||||
|
||||
m_currentWallpaper = wallpaper;
|
||||
emit currentWallpaperChanged();
|
||||
@ -125,13 +126,13 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
||||
|
||||
void ContainmentConfigView::applyWallpaper()
|
||||
{
|
||||
m_containmentInterface->containment()->setWallpaper(m_currentWallpaper);
|
||||
/*m_containment->containment()->setWallpaper(m_currentWallpaper);
|
||||
|
||||
if (m_currentWallpaperConfig != m_containmentInterface->wallpaperInterface()->configuration()) {
|
||||
if (m_currentWallpaperConfig != m_containment->wallpaperInterface()->configuration()) {
|
||||
delete m_currentWallpaperConfig;
|
||||
m_currentWallpaperConfig = m_containmentInterface->wallpaperInterface()->configuration();
|
||||
m_currentWallpaperConfig = m_containment->wallpaperInterface()->configuration();
|
||||
emit wallpaperConfigurationChanged();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#include "moc_containmentconfigview.cpp"
|
@ -23,7 +23,9 @@
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
class ContainmentInterface;
|
||||
namespace Plasma {
|
||||
class Containment;
|
||||
}
|
||||
class ConfigPropertyMap;
|
||||
|
||||
|
||||
@ -36,7 +38,7 @@ class ContainmentConfigView : public ConfigView
|
||||
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
|
||||
|
||||
public:
|
||||
ContainmentConfigView(ContainmentInterface *interface, QWindow *parent = 0);
|
||||
ContainmentConfigView(Plasma::Containment *interface, QWindow *parent = 0);
|
||||
virtual ~ContainmentConfigView();
|
||||
|
||||
ConfigModel *wallpaperConfigModel();
|
||||
@ -51,7 +53,7 @@ Q_SIGNALS:
|
||||
void wallpaperConfigurationChanged();
|
||||
|
||||
private:
|
||||
ContainmentInterface *m_containmentInterface;
|
||||
Plasma::Containment *m_containment;
|
||||
ConfigModel *m_wallpaperConfigModel;
|
||||
QString m_currentWallpaper;
|
||||
ConfigPropertyMap *m_currentWallpaperConfig;
|
@ -29,6 +29,7 @@
|
||||
#include <KLocalizedString>
|
||||
#include <Plasma/Package>
|
||||
|
||||
#include "containmentconfigview.h"
|
||||
#include "panelview.h"
|
||||
#include "view.h"
|
||||
#include "scripting/desktopscriptengine.h"
|
||||
@ -266,7 +267,10 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
|
||||
|
||||
void DesktopCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
{
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface, this, &DesktopCorona::showWidgetExplorer);
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface,
|
||||
this, &DesktopCorona::showWidgetExplorer);
|
||||
connect(c, &Plasma::Containment::configureRequested,
|
||||
this, &DesktopCorona::showConfigurationInterface);
|
||||
}
|
||||
|
||||
void DesktopCorona::showWidgetExplorer()
|
||||
@ -300,5 +304,30 @@ void DesktopCorona::printScriptMessage(const QString &message)
|
||||
qDebug() << message;
|
||||
}
|
||||
|
||||
void DesktopCorona::showConfigurationInterface(Plasma::Applet *applet)
|
||||
{
|
||||
if (m_configView) {
|
||||
m_configView.data()->hide();
|
||||
m_configView.data()->deleteLater();
|
||||
}
|
||||
|
||||
if (!applet || !applet->containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_configView) {
|
||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
|
||||
|
||||
if (cont) {
|
||||
m_configView = new ContainmentConfigView(cont);
|
||||
} else {
|
||||
m_configView = new ConfigView(applet);
|
||||
}
|
||||
m_configView.data()->init();
|
||||
}
|
||||
|
||||
m_configView.data()->show();
|
||||
}
|
||||
|
||||
#include "desktopcorona.moc"
|
||||
|
||||
|
@ -23,6 +23,8 @@ class * Free Software Foundation, Inc.,
|
||||
|
||||
#include "plasma/corona.h"
|
||||
|
||||
#include "configview.h"
|
||||
|
||||
class QDesktopWidget;
|
||||
class QQuickView;
|
||||
class PanelView;
|
||||
@ -83,6 +85,8 @@ protected Q_SLOTS:
|
||||
void printScriptError(const QString &error);
|
||||
void printScriptMessage(const QString &message);
|
||||
|
||||
void showConfigurationInterface(Plasma::Applet *applet);
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleContainmentAdded(Plasma::Containment *c);
|
||||
void showWidgetExplorer();
|
||||
@ -93,6 +97,7 @@ private:
|
||||
WidgetExplorerView *m_widgetExplorerView;
|
||||
QHash<Plasma::Containment *, PanelView *> m_panelViews;
|
||||
KConfigGroup m_desktopDefaultsConfig;
|
||||
QWeakPointer<ConfigView> m_configView;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user