~unity-team/unity8/slim-greeter

« back to all changes in this revision

Viewing changes to plugins/Greeter/Unity/Launcher/launcheritem.cpp

  • Committer: Michael Terry
  • Date: 2015-02-12 15:45:21 UTC
  • mfrom: (1432.1.178 unity8)
  • Revision ID: michael.terry@canonical.com-20150212154521-1qpg3t501ljj88lj
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014-2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include "launcheritem.h"
 
18
#include "quicklistmodel.h"
 
19
 
 
20
#include <libintl.h>
 
21
 
 
22
LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
 
23
    LauncherItemInterface(parent),
 
24
    m_appId(appId),
 
25
    m_name(name),
 
26
    m_icon(icon),
 
27
    m_pinned(false),
 
28
    m_running(false),
 
29
    m_recent(false),
 
30
    m_progress(-1),
 
31
    m_count(0),
 
32
    m_countVisible(false),
 
33
    m_focused(false),
 
34
    m_quickList(new QuickListModel(this))
 
35
{
 
36
    QuickListEntry nameAction;
 
37
    nameAction.setActionId("launch_item");
 
38
    nameAction.setText(m_name);
 
39
    m_quickList->appendAction(nameAction);
 
40
}
 
41
 
 
42
QString LauncherItem::appId() const
 
43
{
 
44
    return m_appId;
 
45
}
 
46
 
 
47
QString LauncherItem::name() const
 
48
{
 
49
    return m_name;
 
50
}
 
51
 
 
52
void LauncherItem::setName(const QString &name)
 
53
{
 
54
    if (m_name != name) {
 
55
        m_name = name;
 
56
        QuickListEntry entry;
 
57
        entry.setActionId("launch_item");
 
58
        entry.setText(m_name);
 
59
        m_quickList->updateAction(entry);
 
60
        Q_EMIT nameChanged(name);
 
61
    }
 
62
}
 
63
 
 
64
QString LauncherItem::icon() const
 
65
{
 
66
    return m_icon;
 
67
}
 
68
 
 
69
void LauncherItem::setIcon(const QString &icon)
 
70
{
 
71
    if (m_icon != icon) {
 
72
        m_icon = icon;
 
73
        Q_EMIT iconChanged(icon);
 
74
    }
 
75
}
 
76
 
 
77
bool LauncherItem::pinned() const
 
78
{
 
79
    return m_pinned;
 
80
}
 
81
 
 
82
void LauncherItem::setPinned(bool pinned)
 
83
{
 
84
    if (m_pinned != pinned) {
 
85
        m_pinned = pinned;
 
86
        Q_EMIT pinnedChanged(pinned);
 
87
    }
 
88
}
 
89
 
 
90
bool LauncherItem::running() const
 
91
{
 
92
    return m_running;
 
93
}
 
94
 
 
95
void LauncherItem::setRunning(bool running)
 
96
{
 
97
    if (m_running != running) {
 
98
        m_running = running;
 
99
        Q_EMIT runningChanged(running);
 
100
    }
 
101
}
 
102
 
 
103
bool LauncherItem::recent() const
 
104
{
 
105
    return m_recent;
 
106
}
 
107
 
 
108
void LauncherItem::setRecent(bool recent)
 
109
{
 
110
    if (m_recent != recent) {
 
111
        m_recent = recent;
 
112
        Q_EMIT recentChanged(recent);
 
113
    }
 
114
}
 
115
 
 
116
int LauncherItem::progress() const
 
117
{
 
118
    return m_progress;
 
119
}
 
120
 
 
121
void LauncherItem::setProgress(int progress)
 
122
{
 
123
    if (m_progress != progress) {
 
124
        m_progress = progress;
 
125
        Q_EMIT progressChanged(progress);
 
126
    }
 
127
}
 
128
 
 
129
int LauncherItem::count() const
 
130
{
 
131
    return m_count;
 
132
}
 
133
 
 
134
void LauncherItem::setCount(int count)
 
135
{
 
136
    if (m_count != count) {
 
137
        m_count = count;
 
138
        Q_EMIT countChanged(count);
 
139
    }
 
140
}
 
141
 
 
142
bool LauncherItem::countVisible() const
 
143
{
 
144
    return m_countVisible;
 
145
}
 
146
 
 
147
void LauncherItem::setCountVisible(bool countVisible)
 
148
{
 
149
    if (m_countVisible != countVisible) {
 
150
        m_countVisible = countVisible;
 
151
        Q_EMIT countVisibleChanged(countVisible);
 
152
    }
 
153
}
 
154
 
 
155
bool LauncherItem::focused() const
 
156
{
 
157
    return m_focused;
 
158
}
 
159
 
 
160
void LauncherItem::setFocused(bool focused)
 
161
{
 
162
    if (m_focused != focused) {
 
163
        m_focused = focused;
 
164
        Q_EMIT focusedChanged(focused);
 
165
    }
 
166
}
 
167
 
 
168
unity::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
 
169
{
 
170
    return m_quickList;
 
171
}