2 Copyright (c) 2009 Volker Krause <vkrause@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <kassistantdialog.h>
24 #include <kconfiggroup.h>
25 #include <kross/core/action.h>
27 #include <KLocalizedString>
29 LoadPage::LoadPage(KAssistantDialog
*parent
) :
37 void LoadPage::enterPageNext()
40 // FIXME: deletion seems to delete the exported objects as well, killing the entire wizard...
43 Q_EMIT
aboutToStart();
45 const KConfig
f(Global::assistant());
46 KConfigGroup
grp(&f
, "Wizard");
47 const QString scriptFile
= grp
.readEntry("Script", QString());
48 if (scriptFile
.isEmpty()) {
49 ui
.statusLabel
->setText(i18n("No script specified in '%1'.", Global::assistant()));
52 if (!QFile::exists(Global::assistantBasePath() + scriptFile
)) {
53 ui
.statusLabel
->setText(i18n("Unable to load assistant: File '%1' does not exist.", Global::assistantBasePath() + scriptFile
));
56 ui
.statusLabel
->setText(i18n("Loading script '%1'...", Global::assistantBasePath() + scriptFile
));
58 m_action
= new Kross::Action(this, QStringLiteral("AccountWizard"));
59 typedef QPair
<QObject
*, QString
> ObjectStringPair
;
60 foreach (const ObjectStringPair
&exportedObject
, m_exportedObjects
) {
61 m_action
->addQObject(exportedObject
.first
, exportedObject
.second
);
64 if (!m_action
->setFile(Global::assistantBasePath() + scriptFile
)) {
65 ui
.statusLabel
->setText(i18n("Failed to load script: '%1'.", m_action
->errorMessage()));
69 KConfigGroup
grpTranslate(&f
, "Translate");
70 const QString poFileName
= grpTranslate
.readEntry("Filename");
72 if (!poFileName
.isEmpty()) {
73 Global::setPoFileName(poFileName
);
80 void LoadPage::enterPageBack()
82 // TODO: if we are the first page, call enterPageNext(), hm, can we get here then at all?
86 void LoadPage::exportObject(QObject
*object
, const QString
&name
)
88 m_exportedObjects
.push_back(qMakePair(object
, name
));