diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt index 503e9a256..e609bcb26 100644 --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -35,6 +35,7 @@ set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") add_executable(testplasma2 main.cpp desktopcorona.cpp + panelview.cpp view.cpp ) diff --git a/shell/desktopcorona.cpp b/shell/desktopcorona.cpp index 46ff04dc4..42a7cb28b 100644 --- a/shell/desktopcorona.cpp +++ b/shell/desktopcorona.cpp @@ -22,8 +22,11 @@ #include #include #include + +#include "panelview.h" #include "view.h" + static const QString s_panelTemplatesPath("plasma-layout-templates/panels/*"); DesktopCorona::DesktopCorona(QObject *parent) @@ -183,6 +186,7 @@ void DesktopCorona::checkViews() } else if (m_views.count() < m_desktopWidget->screenCount()) { for (int i = m_views.count(); i < m_desktopWidget->screenCount(); ++i) { View *view = new View(this); + view->show(); m_views << view; } @@ -203,12 +207,31 @@ void DesktopCorona::checkViews() void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment) { qDebug() << "Was screen" << wasScreen << "Is screen" << isScreen <<"Containment" << containment; - if (isScreen < 0 || m_views.count() < isScreen + 1) { - qWarning() << "Invalid screen"; - return; - } + + if (containment->formFactor() == Plasma::Horizontal || + containment->formFactor() == Plasma::Vertical) { - m_views[isScreen]->setContainment(containment); + if (isScreen >= 0) { + m_panelViews[containment] = new PanelView(this); + m_panelViews[containment]->show(); + } else { + if (m_panelViews.contains(containment)) { + m_panelViews[containment]->setContainment(0); + m_panelViews[containment]->deleteLater(); + m_panelViews.remove(containment); + } + } + + //Desktop view + } else { + + if (isScreen < 0 || m_views.count() < isScreen + 1) { + qWarning() << "Invalid screen"; + return; + } + + m_views[isScreen]->setContainment(containment); + } } #include "desktopcorona.moc" diff --git a/shell/desktopcorona.h b/shell/desktopcorona.h index 1c5e1f119..e7a3ba095 100644 --- a/shell/desktopcorona.h +++ b/shell/desktopcorona.h @@ -24,6 +24,7 @@ class * Free Software Foundation, Inc., #include "plasma/corona.h" class QDesktopWidget; +class PanelView; class View; namespace Plasma @@ -74,6 +75,7 @@ protected Q_SLOTS: private: QDesktopWidget *m_desktopWidget; QList m_views; + QHash m_panelViews; }; #endif diff --git a/shell/panelview.cpp b/shell/panelview.cpp new file mode 100644 index 000000000..168a2c0a9 --- /dev/null +++ b/shell/panelview.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "panelview.h" + + + +PanelView::PanelView(Plasma::Corona *corona, QWindow *parent) + : View(corona, parent) +{ + QSurfaceFormat format; + format.setAlphaBufferSize(8); + setFormat(format); +} + +PanelView::~PanelView() +{ + +} + + + +#include "moc_panelview.cpp" diff --git a/shell/panelview.h b/shell/panelview.h new file mode 100644 index 000000000..8883b2a6f --- /dev/null +++ b/shell/panelview.h @@ -0,0 +1,38 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef PANELVIEW_H +#define PANELVIEW_H + + +#include "view.h" + + +class PanelView : public View +{ + Q_OBJECT + +public: + PanelView(Plasma::Corona *corona, QWindow *parent = 0); + virtual ~PanelView(); + +private: + +}; + +#endif // PANELVIEW_H diff --git a/shell/view.cpp b/shell/view.cpp index bc35907f9..d2c0f44e5 100644 --- a/shell/view.cpp +++ b/shell/view.cpp @@ -34,7 +34,6 @@ View::View(Plasma::Corona *corona, QWindow *parent) setResizeMode(View::SizeRootObjectToView); setSource(QUrl::fromLocalFile(m_corona->package().filePath("mainscript"))); - show(); } View::~View() @@ -48,6 +47,11 @@ void View::setContainment(Plasma::Containment *cont) { if (m_containment) { disconnect(m_containment.data(), 0, this, 0); + QObject *oldGraphicObject = m_containment.data()->property("graphicObject").value(); + if (oldGraphicObject) { + //make sure the graphic object won't die with us + oldGraphicObject->setParent(cont); + } } m_containment = cont;