~ubuntu-branches/ubuntu/vivid/muon/vivid-proposed

« back to all changes in this revision

Viewing changes to installer/ApplicationLauncher.cpp

Tags: upstream-1.3.65
ImportĀ upstreamĀ versionĀ 1.3.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 ***************************************************************************/
20
20
 
21
21
#include "ApplicationLauncher.h"
 
22
#include <ApplicationModel/LaunchListModel.h>
 
23
#include <Application.h>
 
24
#include <ApplicationBackend.h>
22
25
 
23
26
#include <QtCore/QStringBuilder>
24
27
#include <QtGui/QLabel>
32
35
#include <KLocale>
33
36
#include <KService>
34
37
#include <KStandardGuiItem>
35
 
#include <KToolInvocation>
36
38
 
37
 
ApplicationLauncher::ApplicationLauncher(const QVector<KService*> &applications, QWidget *parent)
 
39
ApplicationLauncher::ApplicationLauncher(ApplicationBackend* backend, QWidget* parent)
38
40
    : QDialog(parent)
39
41
{
40
42
    QVBoxLayout *layout = new QVBoxLayout(this);
43
45
    QLabel *label = new QLabel(this);
44
46
    label->setText(i18np("The following application was just installed, click on it to launch:",
45
47
                         "The following applications were just installed, click on them to launch:",
46
 
                         applications.size()));
 
48
                         backend->launchList().size()));
47
49
 
48
50
    QListView *appView = new QListView(this);
49
51
    appView->setIconSize(QSize(32, 32));
68
70
    bottomLayout->addWidget(bottomSpacer);
69
71
    bottomLayout->addWidget(closeButton);
70
72
 
71
 
    m_model = new QStandardItemModel(this);
72
 
    addApplications(applications);
 
73
    m_model = new LaunchListModel(this);
 
74
    m_model->setBackend(backend);
73
75
    appView->setModel(m_model);
74
76
 
75
77
    layout->addWidget(label);
81
83
{
82
84
}
83
85
 
84
 
void ApplicationLauncher::addApplications(const QVector<KService*> &applications)
85
 
{
86
 
    QStandardItem *item = 0;
87
 
    foreach (const KService *service, applications) {
88
 
        QString name = service->genericName().isEmpty() ?
89
 
                       service->property("Name").toString() :
90
 
                       service->property("Name").toString() % QLatin1Literal(" - ") % service->genericName();
91
 
        item = new QStandardItem(name);
92
 
        item->setIcon(KIcon(service->icon()));
93
 
        item->setData(service->desktopEntryPath(), Qt::UserRole);
94
 
        m_model->appendRow(item);
95
 
    }
96
 
}
97
 
 
98
86
void ApplicationLauncher::onAppClicked(const QModelIndex &index)
99
87
{
100
 
    KToolInvocation::startServiceByDesktopPath(index.data(Qt::UserRole).toString());
 
88
    m_model->invokeApplication(index.row());
101
89
}
102
90
 
103
91
#include "ApplicationLauncher.moc"