2
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
3
* Copyright 2010 Ryan Rix <ry@n.rix.si>
4
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Library General Public License as
8
* published by the Free Software Foundation; either version 2, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details
16
* You should have received a copy of the GNU Library General Public
17
* License along with this program; if not, write to the
18
* Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "plasmakpartcorona.h"
24
#include "plasmakpart.h"
28
#include <Plasma/Containment>
32
#include "scripting/scriptengine.h"
34
PlasmaKPartCorona::PlasmaKPartCorona(QObject* parent)
35
: Plasma::Corona(parent)
40
void PlasmaKPartCorona::init()
42
enableAction("Lock Widgets", false);
43
enableAction("Shortcut Settings", false);
46
void PlasmaKPartCorona::loadDefaultLayout()
48
// used to force a save into the config file
49
KConfigGroup invalidConfig;
50
Plasma::Containment* c = addContainment("newspaper");
53
// do some error reporting?
57
evaluateScripts(PlasmaKPartScripting::ScriptEngine::defaultLayoutScripts());
61
void PlasmaKPartCorona::evaluateScripts(const QStringList &scripts)
63
foreach (const QString &script, scripts) {
64
PlasmaKPartScripting::ScriptEngine scriptEngine(this);
65
connect(&scriptEngine, SIGNAL(printError(QString)), this, SLOT(printScriptError(QString)));
66
connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString)));
69
if (file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
70
QString code = file.readAll();
71
kDebug() << "evaluating startup script:" << script;
72
scriptEngine.evaluateScript(code);
77
void PlasmaKPartCorona::printScriptError(const QString &error)
79
kWarning() << "Startup script errror:" << error;
82
void PlasmaKPartCorona::printScriptMessage(const QString &error)
84
kDebug() << "Startup script: " << error;
87
Plasma::Containment* PlasmaKPartCorona::containment()
89
QList<Plasma::Containment*> list = containments();
91
return list.first(); // We only have one containment
94
#include "plasmakpartcorona.moc"