2
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
3
* Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Library General Public License version 2 as
7
* published by the Free Software Foundation
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU Library General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include "rootwidget.h"
22
#include <QApplication>
23
#include <QDesktopWidget>
24
#include <QVBoxLayout>
26
#include <KWindowSystem>
28
#include "plasma/corona.h"
29
#include "plasma/plasma.h"
30
#include "plasma/svg.h"
32
#include "controlbox.h"
33
#include "desktopview.h"
34
#include "plasmaapp.h"
37
//#define SUPERKARAMBA_DEMO
38
//#define CONFIGXML_DEMO
42
#include <KStandardDirs>
43
#include "plasma/configxml.h"
47
#include "plasma/widgets/icon.h"
50
RootWidget::RootWidget()
53
setFocusPolicy( Qt::NoFocus );
55
QVBoxLayout* rootLayout = new QVBoxLayout(this);
56
rootLayout->setMargin(0);
57
rootLayout->setSpacing(0);
59
m_desktop = new DesktopView(this);
60
Plasma::Corona* corona = PlasmaApp::self()->corona();
61
//FIXME: form factors need to move out of Corona
63
corona->setFormFactor(Plasma::Planar);
64
corona->setLocation(Plasma::Desktop);
65
rootLayout->addWidget(m_desktop);
67
m_controlBox = new ControlBox(this);
69
connect(m_controlBox, SIGNAL(zoomIn()), m_desktop, SLOT(zoomIn()));
70
connect(m_controlBox, SIGNAL(zoomOut()), m_desktop, SLOT(zoomOut()));
71
connect(m_controlBox, SIGNAL(addApplet(const QString&)), corona, SLOT(addApplet(const QString&)));
72
connect(m_controlBox, SIGNAL(setFormFactor(Plasma::FormFactor)), corona, SLOT(setFormFactor(Plasma::FormFactor)));
73
connect(m_controlBox, SIGNAL(lockInterface(bool)), corona, SLOT(setImmutable(bool)));
76
Plasma::Icon* icon = new Plasma::Icon();
77
icon->setIcon("user-home");
78
icon->setIconSize(64, 64);
79
// icon->setFlags(QGraphicsItem::ItemIsMovable);
80
corona->addItem(icon);
82
icon = new Plasma::Icon(icon);
83
icon->setIcon("plasmagik");
84
// icon->setFlags(QGraphicsItem::ItemIsMovable);
85
corona->addItem(icon);
89
#ifdef SUPERKARAMBA_DEMO
90
corona->addKaramba(KUrl("~/themes/aero_aio.skz"));
94
QFile file(KStandardDirs::locate("kcfg", "kickerSettings.kcfg"));
95
Plasma::ConfigXml appletConfig(KStandardDirs::locateLocal("config", "kickerrc"), &file);
96
foreach (KConfigSkeletonItem* item, appletConfig.items()) {
97
kDebug() << "item " << item->name() << " in " << item->group();
102
void RootWidget::setAsDesktop(bool setAsDesktop)
105
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
107
KWindowSystem::setOnAllDesktops(winId(), true);
108
KWindowSystem::setType(winId(), NET::Desktop);
111
QRect desktopGeometry = QApplication::desktop()->geometry();
113
if (geometry() != desktopGeometry) {
114
setGeometry(desktopGeometry);
117
connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(adjustSize()));
119
setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
121
KWindowSystem::setOnAllDesktops(winId(),false);
122
KWindowSystem::setType(winId() , NET::Normal);
124
disconnect(QApplication::desktop(),SIGNAL(resized(int)),this,SLOT(adjustSize()));
128
bool RootWidget::isDesktop() const
130
return KWindowInfo(winId(),NET::WMWindowType).windowType(NET::Desktop);
133
RootWidget::~RootWidget()
137
DesktopView* RootWidget::desktop()
142
void RootWidget::adjustSize()
144
setGeometry(QApplication::desktop()->geometry());
147
#include "rootwidget.moc"