1
/***************************************************************************
2
* Copyright (C) 2009-2011 by Daniel Nicoletti *
4
* Copyright (C) 2011 Kevin Kofler <kevin.kofler@chello.at> *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, 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 General Public License *
17
* along with this program; see the file COPYING. If not, write to *
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
19
* Boston, MA 02110-1301, USA. *
20
***************************************************************************/
22
#include "PkInstallPlasmaResources.h"
24
#include "IntroDialog.h"
26
#include <PkStrings.h>
28
#include <QStandardItemModel>
33
PkInstallPlasmaResources::PkInstallPlasmaResources(uint xid,
34
const QStringList &resources,
35
const QString &interaction,
36
const QDBusMessage &message,
38
: SessionTask(xid, interaction, message, parent)
40
setWindowTitle(i18n("Install Plasma Resources"));
42
IntroDialog *introDialog = new IntroDialog(this);
43
QStandardItemModel *model = new QStandardItemModel(this);
44
introDialog->setModel(model);
45
connect(introDialog, SIGNAL(continueChanged(bool)),
46
this, SLOT(enableButtonOk(bool)));
47
setMainWidget(introDialog);
49
// Resources are strings like "dataengine-weather"
50
foreach (const QString &service, resources) {
51
QString prettyService = service;
52
if (service.startsWith(QLatin1String("dataengine-"))) {
53
prettyService = i18n("%1 data engine", service.mid(11));
54
} else if (service.startsWith(QLatin1String("scriptengine-"))) {
55
prettyService = i18n("%1 script engine", service.mid(13));
58
QStandardItem *item = new QStandardItem(prettyService);
59
item->setIcon(KIcon("application-x-plasma").pixmap(32, 32));
60
item->setFlags(Qt::ItemIsEnabled);
61
model->appendRow(item);
63
m_resources << service;
66
if (m_resources.isEmpty()) {
67
introDialog->setDescription(i18n("No supported resources were provided"));
69
QString description = i18np("The following service is required. "
70
"Do you want to search for this now?",
71
"The following services are required. "
72
"Do you want to search for these now?",
74
introDialog->setDescription(description);
78
QString title = i18np("Plasma requires an additional service for this operation",
79
"Plasma requires additional services for this operation",
85
PkInstallPlasmaResources::~PkInstallPlasmaResources()
89
void PkInstallPlasmaResources::search()
91
PkTransaction *transaction = new PkTransaction(this);
92
setTransaction(Transaction::RoleWhatProvides, transaction);
93
connect(transaction, SIGNAL(finished(PkTransaction::ExitStatus)),
94
this, SLOT(searchFinished(PkTransaction::ExitStatus)), Qt::UniqueConnection);
95
connect(transaction, SIGNAL(package(PackageKit::Transaction::Info,QString,QString)),
96
this, SLOT(addPackage(PackageKit::Transaction::Info,QString,QString)));
97
transaction->whatProvides(Transaction::ProvidesPlasmaService,
99
Transaction::FilterNotInstalled | Transaction::FilterArch | Transaction::FilterNewest);
100
if (transaction->error()) {
101
QString msg(i18n("Failed to search for provides"));
104
PkStrings::daemonError(transaction->error()));
106
sendErrorFinished(Failed, msg);
110
void PkInstallPlasmaResources::notFound()
112
QString msg = i18n("Failed to search for Plasma service");
115
i18n("Could not find service "
116
"in any configured software source"));
118
sendErrorFinished(NoPackagesFound, msg);
121
#include "PkInstallPlasmaResources.moc"