create config uis always from the same point

This commit is contained in:
Marco Martin 2013-04-26 13:00:07 +02:00
parent f6765fda8c
commit b0b03f4a8f
5 changed files with 38 additions and 28 deletions

View File

@ -269,8 +269,6 @@ void DesktopCorona::handleContainmentAdded(Plasma::Containment* c)
{
connect(c, &Plasma::Containment::showAddWidgetsInterface,
this, &DesktopCorona::showWidgetExplorer);
connect(c, &Plasma::Containment::configureRequested,
this, &DesktopCorona::showConfigurationInterface);
}
void DesktopCorona::showWidgetExplorer()
@ -304,28 +302,5 @@ 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;
}
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"

View File

@ -85,8 +85,6 @@ 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();
@ -97,7 +95,6 @@ private:
WidgetExplorerView *m_widgetExplorerView;
QHash<Plasma::Containment *, PanelView *> m_panelViews;
KConfigGroup m_desktopDefaultsConfig;
QWeakPointer<ConfigView> m_configView;
};
#endif

View File

@ -21,6 +21,7 @@
#define PANELCONFIGVIEW_H
#include "configview.h"
#include <QQuickItem>
#include <QQuickView>
#include <QJSValue>

View File

@ -17,6 +17,10 @@
*/
#include "view.h"
#include "containmentconfigview.h"
#include "panelconfigview.h"
#include "panelview.h"
#include <QDebug>
#include <QQuickItem>
@ -99,6 +103,8 @@ void View::setContainment(Plasma::Containment *cont)
this, &View::locationChanged);
connect(cont, &Plasma::Containment::formFactorChanged,
this, &View::formFactorChanged);
connect(cont, &Plasma::Containment::configureRequested,
this, &View::showConfigurationInterface);
} else {
return;
}
@ -152,4 +158,30 @@ QRectF View::screenGeometry()
return screen()->geometry();
}
void View::showConfigurationInterface(Plasma::Applet *applet)
{
if (m_configView) {
m_configView.data()->hide();
m_configView.data()->deleteLater();
}
if (!applet || !applet->containment()) {
return;
}
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
PanelView *pv = qobject_cast< PanelView* >(this);
if (cont && pv) {
m_configView = new PanelConfigView(cont, pv);
} else if (cont) {
m_configView = new ContainmentConfigView(cont);
} else {
m_configView = new ConfigView(applet);
}
m_configView.data()->init();
m_configView.data()->show();
}
#include "moc_view.cpp"

View File

@ -25,6 +25,7 @@
#include "plasma/corona.h"
#include "plasma/containment.h"
#include "configview.h"
class View : public QQuickView
{
@ -54,6 +55,9 @@ public:
QRectF screenGeometry();
protected Q_SLOTS:
void showConfigurationInterface(Plasma::Applet *applet);
Q_SIGNALS:
void locationChanged(Plasma::Location location);
void formFactorChanged(Plasma::FormFactor formFactor);
@ -63,6 +67,7 @@ Q_SIGNALS:
private:
Plasma::Corona *m_corona;
QWeakPointer<Plasma::Containment> m_containment;
QWeakPointer<ConfigView> m_configView;
};
#endif // VIEW_H