2
* Copyright 2006-2008 Aaron Seigo <aseigo@kde.org>
3
* Copyright 2009 Marco Martin <notmart@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 as
7
* published by the Free Software Foundation; either version 2, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details
15
* You should have received a copy of the GNU Library General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include "plasmaapp.h"
25
#include <QApplication>
26
#include <QPixmapCache>
28
#include <QVBoxLayout>
29
#include <QtDBus/QtDBus>
34
#include <KCmdLineArgs>
35
#include <KStandardAction>
36
#include <KWindowSystem>
38
#include <Plasma/Containment>
39
#include <Plasma/Theme>
40
#include <Plasma/Corona>
41
#include <Plasma/Applet>
43
#include "singleview.h"
46
PlasmaApp* PlasmaApp::self()
49
return new PlasmaApp();
52
return qobject_cast<PlasmaApp*>(kapp);
55
PlasmaApp::PlasmaApp()
56
: KUniqueApplication(),
59
KGlobal::locale()->insertCatalog("plasma-standaloneplasmoids");
60
KCrash::setFlags(KCrash::AutoRestart);
63
KConfigGroup cg(KGlobal::config(), "General");
64
Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", font()));
68
connect(this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
71
PlasmaApp::~PlasmaApp()
75
int PlasmaApp::newInstance()
77
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
80
if (args->count() > 0) {
81
pluginName = args->arg(0);
84
QVariantList appletArgs;
85
for (int i = 1; i < args->count(); ++i) {
86
appletArgs << args->arg(i);
91
SingleView *view = new SingleView(m_corona, pluginName, appletArgs);
97
void PlasmaApp::cleanup()
100
m_corona->saveLayout();
108
//TODO: This manual sync() should not be necessary?
112
void PlasmaApp::syncConfig()
114
KGlobal::config()->sync();
118
Plasma::Corona* PlasmaApp::corona()
121
m_corona = new Plasma::Corona(this);
122
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
125
m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
126
//m_corona->initializeLayout();
133
bool PlasmaApp::hasComposite()
135
return KWindowSystem::compositingActive();
139
bool PlasmaApp::eventFilter(QObject * watched, QEvent *event)
144
#include "plasmaapp.moc"