close window on ok/cancel pressed

delete window on close
This commit is contained in:
Marco Martin 2013-02-26 12:47:08 +01:00
parent 45147081e7
commit 3a5e5f931b
5 changed files with 16 additions and 5 deletions

View File

@ -37,6 +37,7 @@
#include <kcoreauthorized.h> #include <kcoreauthorized.h>
#include <kcolorscheme.h> #include <kcolorscheme.h>
#include <kdesktopfile.h> #include <kdesktopfile.h>
#include <kdebug.h>
#include <kplugininfo.h> #include <kplugininfo.h>
#include <klocalizedstring.h> #include <klocalizedstring.h>
#include <kservice.h> #include <kservice.h>

View File

@ -63,8 +63,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
{ {
qmlRegisterType<AppletInterface>(); qmlRegisterType<AppletInterface>();
m_configuration = new ConfigPropertyMap(applet()->configScheme(), this);
connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus())); connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus()));
connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving())); connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving()));
connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged())); connect(applet(), SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SIGNAL(immutableChanged()));
@ -97,6 +95,8 @@ void AppletInterface::init()
return; return;
} }
m_configuration = new ConfigPropertyMap(applet()->configScheme(), this);
//use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled //use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled
QQmlEngine *engine = m_qmlObject->engine(); QQmlEngine *engine = m_qmlObject->engine();
QQmlNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory(); QQmlNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory();

View File

@ -74,4 +74,11 @@ QVariantList ConfigView::configPages() const
return m_configPages; return m_configPages;
} }
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void ConfigView::hideEvent(QHideEvent *ev)
{
QQuickWindow::hideEvent(ev);
deleteLater();
}
#include "moc_configview.cpp" #include "moc_configview.cpp"

View File

@ -37,6 +37,9 @@ public:
QVariantList configPages() const; QVariantList configPages() const;
protected:
void hideEvent(QHideEvent *ev);
private: private:
AppletInterface *m_appletInterface; AppletInterface *m_appletInterface;
QVariantList m_configPages; QVariantList m_configPages;

View File

@ -133,18 +133,18 @@ Rectangle {
text: "Ok" text: "Ok"
onClicked: { onClicked: {
root.saveConfig() root.saveConfig()
configDialog.close()
} }
} }
PlasmaComponents.Button { PlasmaComponents.Button {
iconSource: "dialog-ok-apply" iconSource: "dialog-ok-apply"
text: "Apply" text: "Apply"
onClicked: { onClicked: root.saveConfig()
root.saveConfig()
}
} }
PlasmaComponents.Button { PlasmaComponents.Button {
iconSource: "dialog-cancel" iconSource: "dialog-cancel"
text: "Cancel" text: "Cancel"
onClicked: configDialog.close()
} }
} }
} }