not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / shells / screensaver / savercorona.cpp
blobce37e7e7f9d7765e9396662c6d423eabc85a4b7a
1 /*
2 * Copyright 2008 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
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 "savercorona.h"
22 #include <QApplication>
23 #include <QDesktopWidget>
24 #include <QGraphicsLayout>
26 #include <KDebug>
27 #include <KDialog>
28 #include <KStandardDirs>
30 #include <Plasma/Containment>
32 SaverCorona::SaverCorona(QObject *parent)
33 : Plasma::Corona(parent)
35 init();
38 void SaverCorona::init()
40 QDesktopWidget *desktop = QApplication::desktop();
41 m_numScreens = desktop->numScreens();
42 if (m_numScreens > 1) {
43 kDebug() << "maybe someone should implement multiple screen support";
47 void SaverCorona::loadDefaultLayout()
49 kDebug();
50 QString defaultConfig = KStandardDirs::locate("appdata", "plasma-overlay-default-layoutrc");
51 if (!defaultConfig.isEmpty()) {
52 kDebug() << "attempting to load the default layout from:" << defaultConfig;
53 loadLayout(defaultConfig);
54 return;
57 QDesktopWidget *desktop = QApplication::desktop();
59 // create a containment for the screen
60 QRect g = desktop->screenGeometry(0);
61 kDebug() << " screen geometry is" << g;
62 Plasma::Containment *c = addContainment("saverdesktop");
63 c->setScreen(0);
64 c->setFormFactor(Plasma::Planar);
65 c->flushPendingConstraintsEvents();
67 // a default clock
68 Plasma::Applet *clock = Plasma::Applet::load("clock", c->id() + 1);
69 c->addApplet(clock, QPointF(KDialog::spacingHint(), KDialog::spacingHint()), true);
70 clock->init();
71 clock->flushPendingConstraintsEvents();
73 emit containmentAdded(c);
77 int SaverCorona::numScreens() const
79 return QApplication::desktop()->numScreens();
82 QRect SaverCorona::screenGeometry(int id) const
84 return QApplication::desktop()->screenGeometry(id);
87 #include "savercorona.moc"