~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to plasma/plasma/rootwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
 
3
 *   Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
 
4
 *
 
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
 
8
 *
 
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
 
13
 *
 
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.
 
18
 */
 
19
 
 
20
#include "rootwidget.h"
 
21
 
 
22
#include <QApplication>
 
23
#include <QDesktopWidget>
 
24
#include <QVBoxLayout>
 
25
 
 
26
#include <KWindowSystem>
 
27
 
 
28
#include "plasma/corona.h"
 
29
#include "plasma/plasma.h"
 
30
#include "plasma/svg.h"
 
31
 
 
32
#include "controlbox.h"
 
33
#include "desktopview.h"
 
34
#include "plasmaapp.h"
 
35
 
 
36
//#define ICON_DEMO
 
37
//#define SUPERKARAMBA_DEMO
 
38
//#define CONFIGXML_DEMO
 
39
 
 
40
#ifdef CONFIGXML_DEMO
 
41
#include <QFile>
 
42
#include <KStandardDirs>
 
43
#include "plasma/configxml.h"
 
44
#endif
 
45
 
 
46
#ifdef ICON_DEMO
 
47
#include "plasma/widgets/icon.h"
 
48
#endif
 
49
 
 
50
RootWidget::RootWidget()
 
51
    : QWidget(0)
 
52
{
 
53
    setFocusPolicy( Qt::NoFocus );
 
54
 
 
55
    QVBoxLayout* rootLayout = new QVBoxLayout(this);
 
56
    rootLayout->setMargin(0);
 
57
    rootLayout->setSpacing(0);
 
58
 
 
59
    m_desktop = new DesktopView(this);
 
60
    Plasma::Corona* corona = PlasmaApp::self()->corona();
 
61
    //FIXME: form factors need to move out of Corona
 
62
 
 
63
    corona->setFormFactor(Plasma::Planar);
 
64
    corona->setLocation(Plasma::Desktop);
 
65
    rootLayout->addWidget(m_desktop);
 
66
 
 
67
    m_controlBox = new ControlBox(this);
 
68
 
 
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)));
 
74
 
 
75
#ifdef ICON_DEMO
 
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);
 
81
 
 
82
    icon = new Plasma::Icon(icon);
 
83
    icon->setIcon("plasmagik");
 
84
//    icon->setFlags(QGraphicsItem::ItemIsMovable);
 
85
    corona->addItem(icon);
 
86
 
 
87
#endif
 
88
 
 
89
#ifdef SUPERKARAMBA_DEMO
 
90
    corona->addKaramba(KUrl("~/themes/aero_aio.skz"));
 
91
#endif
 
92
 
 
93
#ifdef CONFIGXML_DEMO
 
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();
 
98
    }
 
99
#endif
 
100
}
 
101
 
 
102
void RootWidget::setAsDesktop(bool setAsDesktop)
 
103
{
 
104
    if (setAsDesktop) {
 
105
        setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
 
106
 
 
107
        KWindowSystem::setOnAllDesktops(winId(), true);
 
108
        KWindowSystem::setType(winId(), NET::Desktop);
 
109
        lower();
 
110
 
 
111
        QRect desktopGeometry = QApplication::desktop()->geometry();
 
112
 
 
113
        if (geometry() != desktopGeometry) {
 
114
            setGeometry(desktopGeometry);
 
115
        }
 
116
 
 
117
        connect(QApplication::desktop(), SIGNAL(resized(int)), SLOT(adjustSize()));
 
118
    } else {
 
119
        setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
 
120
 
 
121
        KWindowSystem::setOnAllDesktops(winId(),false);
 
122
        KWindowSystem::setType(winId() , NET::Normal); 
 
123
 
 
124
        disconnect(QApplication::desktop(),SIGNAL(resized(int)),this,SLOT(adjustSize()));
 
125
    }
 
126
}
 
127
 
 
128
bool RootWidget::isDesktop() const
 
129
{
 
130
    return KWindowInfo(winId(),NET::WMWindowType).windowType(NET::Desktop);
 
131
}
 
132
 
 
133
RootWidget::~RootWidget()
 
134
{
 
135
}
 
136
 
 
137
DesktopView* RootWidget::desktop()
 
138
{
 
139
    return m_desktop;
 
140
}
 
141
 
 
142
void RootWidget::adjustSize()
 
143
{
 
144
    setGeometry(QApplication::desktop()->geometry());
 
145
}
 
146
 
 
147
#include "rootwidget.moc"
 
148