basic panelView separed from the desktop view
This commit is contained in:
parent
b2d1493e74
commit
99df361ebb
@ -35,6 +35,7 @@ set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||
add_executable(testplasma2
|
||||
main.cpp
|
||||
desktopcorona.cpp
|
||||
panelview.cpp
|
||||
view.cpp
|
||||
)
|
||||
|
||||
|
@ -22,8 +22,11 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#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,6 +207,24 @@ void DesktopCorona::checkViews()
|
||||
void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment)
|
||||
{
|
||||
qDebug() << "Was screen" << wasScreen << "Is screen" << isScreen <<"Containment" << containment;
|
||||
|
||||
if (containment->formFactor() == Plasma::Horizontal ||
|
||||
containment->formFactor() == Plasma::Vertical) {
|
||||
|
||||
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;
|
||||
@ -210,6 +232,7 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
|
||||
|
||||
m_views[isScreen]->setContainment(containment);
|
||||
}
|
||||
}
|
||||
|
||||
#include "desktopcorona.moc"
|
||||
|
||||
|
@ -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 <View *> m_views;
|
||||
QHash<Plasma::Containment *, PanelView *> m_panelViews;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
38
shell/panelview.cpp
Normal file
38
shell/panelview.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* 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"
|
38
shell/panelview.h
Normal file
38
shell/panelview.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* 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
|
@ -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<QObject *>();
|
||||
if (oldGraphicObject) {
|
||||
//make sure the graphic object won't die with us
|
||||
oldGraphicObject->setParent(cont);
|
||||
}
|
||||
}
|
||||
|
||||
m_containment = cont;
|
||||
|
Loading…
Reference in New Issue
Block a user