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 <kcolorscheme.h>
#include <kdesktopfile.h>
#include <kdebug.h>
#include <kplugininfo.h>
#include <klocalizedstring.h>
#include <kservice.h>

View File

@ -62,8 +62,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
m_expanded(false)
{
qmlRegisterType<AppletInterface>();
m_configuration = new ConfigPropertyMap(applet()->configScheme(), this);
connect(this, SIGNAL(releaseVisualFocus()), applet(), SIGNAL(releaseVisualFocus()));
connect(this, SIGNAL(configNeedsSaving()), applet(), SIGNAL(configNeedsSaving()));
@ -97,6 +95,8 @@ void AppletInterface::init()
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
QQmlEngine *engine = m_qmlObject->engine();
QQmlNetworkAccessManagerFactory *factory = engine->networkAccessManagerFactory();

View File

@ -74,4 +74,11 @@ QVariantList ConfigView::configPages() const
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"

View File

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

View File

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