SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / accountwizard / loadpage.cpp
blobbd321ad3d60bc04134cd2a3bee0972955287a3cc
1 /*
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
17 02110-1301, USA.
20 #include "loadpage.h"
21 #include "global.h"
22 #include <kassistantdialog.h>
23 #include <kconfig.h>
24 #include <kconfiggroup.h>
25 #include <kross/core/action.h>
26 #include <qfile.h>
27 #include <KLocalizedString>
29 LoadPage::LoadPage(KAssistantDialog *parent) :
30 Page(parent),
31 m_action(0)
33 ui.setupUi(this);
34 setValid(false);
37 void LoadPage::enterPageNext()
39 setValid(false);
40 // FIXME: deletion seems to delete the exported objects as well, killing the entire wizard...
41 //delete m_action;
42 m_action = 0;
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()));
50 return;
52 if (!QFile::exists(Global::assistantBasePath() + scriptFile)) {
53 ui.statusLabel->setText(i18n("Unable to load assistant: File '%1' does not exist.", Global::assistantBasePath() + scriptFile));
54 return;
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()));
66 return;
69 KConfigGroup grpTranslate(&f, "Translate");
70 const QString poFileName = grpTranslate.readEntry("Filename");
72 if (!poFileName.isEmpty()) {
73 Global::setPoFileName(poFileName);
74 m_action->trigger();
77 m_parent->next();
80 void LoadPage::enterPageBack()
82 // TODO: if we are the first page, call enterPageNext(), hm, can we get here then at all?
83 m_parent->back();
86 void LoadPage::exportObject(QObject *object, const QString &name)
88 m_exportedObjects.push_back(qMakePair(object, name));