panelconfigview is a subclass of configview

This commit is contained in:
Marco Martin 2013-04-25 22:38:27 +02:00
parent d44f0973d3
commit 7301f6d8b7
3 changed files with 12 additions and 37 deletions

View File

@ -36,27 +36,13 @@
//////////////////////////////PanelConfigView
PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent)
: QQuickView(parent),
: ConfigView(containment, parent),
m_containment(containment),
m_panelView(panelView)
{
setFlags(Qt::FramelessWindowHint);
//FIXME: problem on nvidia, all windows should be transparent or won't show
setColor(Qt::transparent);
setTitle(i18n("%1 Settings", m_containment->title()));
if (!m_containment->corona()->package().isValid()) {
qWarning() << "Invalid home screen package";
}
setResizeMode(QQuickView::SizeViewToRootObject);
engine()->rootContext()->setContextProperty("panel", panelView);
engine()->rootContext()->setContextProperty("configDialog", this);
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
syncGeometry();
connect(containment, &Plasma::Containment::formFactorChanged,
this, &PanelConfigView::syncGeometry);
}
@ -65,6 +51,12 @@ PanelConfigView::~PanelConfigView()
{
}
void PanelConfigView::init()
{
setSource(QUrl::fromLocalFile(m_containment->corona()->package().filePath("panelconfigurationui")));
syncGeometry();
}
void PanelConfigView::syncGeometry()
{
if (!m_containment) {
@ -91,22 +83,5 @@ void PanelConfigView::syncGeometry()
}
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void PanelConfigView::hideEvent(QHideEvent *ev)
{
QQuickWindow::hideEvent(ev);
deleteLater();
}
void PanelConfigView::resizeEvent(QResizeEvent *re)
{
if (!rootObject()) {
return;
}
rootObject()->setWidth(re->size().width());
rootObject()->setHeight(re->size().height());
QQuickWindow::resizeEvent(re);
}
#include "moc_panelconfigview.cpp"

View File

@ -20,6 +20,7 @@
#ifndef PANELCONFIGVIEW_H
#define PANELCONFIGVIEW_H
#include "configview.h"
#include <QQuickItem>
#include <QQuickView>
#include <QJSValue>
@ -36,7 +37,7 @@ namespace Plasma {
//TODO: this should be a subclass of ConfigView currently in the scriptengine
//TODO: that class should be moved here
class PanelConfigView : public QQuickView
class PanelConfigView : public ConfigView
{
Q_OBJECT
@ -44,13 +45,11 @@ public:
PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0);
virtual ~PanelConfigView();
void init();
protected Q_SLOTS:
void syncGeometry();
protected:
void hideEvent(QHideEvent *ev);
void resizeEvent(QResizeEvent *re);
private:
Plasma::Containment *m_containment;
PanelView *m_panelView;

View File

@ -167,6 +167,7 @@ void PanelView::showPanelController()
{
if (!m_panelConfigView) {
m_panelConfigView = new PanelConfigView(containment(), this);
m_panelConfigView->init();
}
m_panelConfigView->show();
}