Index: dashboardview.cpp
===================================================================
--- dashboardview.cpp (Revision 0)
+++ dashboardview.cpp (Revision 0)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2007 Aaron Seigo <aseigo@kde.org>
+ * Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
+ * Copyright 2007 André Duffeck <duffeck@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License version 2 as
+ * published by the Free Software Foundation
+ *
+ * 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 Library 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 "dashboardview.h"
+
+#include "plasma/applet.h"
+#include "plasma/corona.h"
+#include "plasma/containment.h"
+#include "plasma/svg.h"
+
+#include "plasmaapp.h"
+
+DashBoardView::DashBoardView(QWidget *parent, int screen)
+ : QGraphicsView(parent),
+ m_screen(screen)
+{
+ kDebug();
+ setFrameShape(QFrame::NoFrame);
+ setAutoFillBackground(true);
+ setDragMode(QGraphicsView::RubberBandDrag);
+ setCacheMode(QGraphicsView::CacheBackground);
+ setInteractive(true);
+ setAcceptDrops(true);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setContextMenuPolicy(Qt::NoContextMenu);
+ setWindowFlags( Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint );
+ setWindowOpacity( 0.9 );
+
+ Plasma::Corona *corona = PlasmaApp::self()->corona();
+ setScene(corona);
+
+ Plasma::Containment * c = corona->containmentForScreen(screen);
+ kDebug() << "dashboard view on screen" << screen << "has containment" << (qint64)c;
+ if (c) {
+ setSceneRect(c->geometry());
+ connect(c, SIGNAL(geometryChanged()), this, SLOT(updateSceneRect()));
+ }
+
+ hide();
+}
+
+DashBoardView::~DashBoardView()
+{
+}
+
+void DashBoardView::toggleVisibility()
+{
+ if( isHidden() ) {
+ show();
+ raise();
+ } else {
+ hide();
+ }
+}
+
+int DashBoardView::screen() const
+{
+ return m_screen;
+}
+
+void DashBoardView::updateSceneRect()
+{
+ Plasma::Containment * c = PlasmaApp::self()->corona()->containmentForScreen(m_screen);
+ if (c) {
+ setSceneRect(c->geometry());
+ }
+}
+
+#include "dashboardview.moc"
Index: rootwidget.cpp
===================================================================
--- rootwidget.cpp (Revision 736605)
+++ rootwidget.cpp (Arbeitskopie)
@@ -24,17 +24,22 @@
#include <QVBoxLayout>
#include <KWindowSystem>
+#include <KAction>
+#include <KShortcut>
#include "plasma/corona.h"
#include "plasma/plasma.h"
#include "plasma/svg.h"
#include "desktopview.h"
+#include "dashboardview.h"
#include "plasmaapp.h"
+
RootWidget::RootWidget()
: QWidget(0)
{
+ kDebug();
setFocusPolicy(Qt::NoFocus);
QDesktopWidget *desktop = QApplication::desktop();
@@ -45,11 +50,31 @@
DesktopView *view = new DesktopView(this, i);
view->setGeometry(desktop->screenGeometry(i));
m_desktops.append(view);
+
+ DashBoardView *dashboard = new DashBoardView(desktop, i);
+ dashboard->setGeometry(desktop->screenGeometry(0));
+ m_dashboards.append(dashboard);
}
PlasmaApp::self()->corona();
+
+ //TODO: Make the shortcut configurable
+ KAction *showAction = new KAction( this );
+ showAction->setText( i18n( "Show Dashboard" ) );
+ showAction->setGlobalShortcut( KShortcut( Qt::Key_F6 ) );
+ connect( showAction, SIGNAL( activated() ), this, SLOT( toggleDashboard() ) );
+
}
+void RootWidget::toggleDashboard()
+{
+ int currentScreen = 0;
+ if (QApplication::desktop()->numScreens() > 1) {
+ currentScreen = QApplication::desktop()->screenNumber(QCursor::pos());
+ }
+ m_dashboards[currentScreen]->toggleVisibility();
+}
+
void RootWidget::setAsDesktop(bool setAsDesktop)
{
if (setAsDesktop) {
@@ -92,6 +117,9 @@
foreach (DesktopView *view, m_desktops) {
view->setGeometry(desktop->screenGeometry(view->screen()));
}
+ foreach (DashBoardView *view, m_dashboards) {
+ view->setGeometry(desktop->screenGeometry(view->screen()));
+ }
}
#include "rootwidget.moc"
Index: dashboardview.h
===================================================================
--- dashboardview.h (Revision 0)
+++ dashboardview.h (Revision 0)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007 Aaron Seigo <aseigo@kde.org>
+ * Copyright 2007 André Duffeck <duffeck@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,
+ * 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 Library 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 DASHBOARDVIEW_H
+#define DASHBOARDVIEW_H
+
+#include <QGraphicsView>
+
+#include "plasma/plasma.h"
+
+class QPixmap;
+
+namespace Plasma
+{
+ class Svg;
+ class Corona;
+}
+
+class DashBoardView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ DashBoardView(QWidget *parent, int screen = -1);
+ ~DashBoardView();
+
+ int screen() const;
+
+public slots:
+ void updateSceneRect();
+ void toggleVisibility();
+
+private:
+ int m_screen;
+};
+
+#endif // multiple inclusion guard
Index: rootwidget.h
===================================================================
--- rootwidget.h (Revision 736605)
+++ rootwidget.h (Arbeitskopie)
@@ -24,6 +24,7 @@
#include <QWidget>
class DesktopView;
+class DashBoardView;
/**
* @short The base widget that contains the desktop
@@ -56,9 +57,11 @@
protected slots:
void adjustSize();
+ void toggleDashboard();
private:
QList<DesktopView*> m_desktops;
+ QList<DashBoardView*> m_dashboards;
};
#endif
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (Revision 736605)
+++ CMakeLists.txt (Arbeitskopie)
@@ -6,6 +6,7 @@
plasmaapp.cpp
rootwidget.cpp
panelview.cpp
+ dashboardview.cpp
)
set(plasmaapp_dbusXML org.kde.plasma.App.xml)