1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* This file is part of unity-qt
*
* Copyright 2010 Canonical Ltd.
*
* Authors:
* - Aurélien Gâteau <aurelien.gateau@canonical.com>
*
* License: GPL v3
*/
// Self
#include "appnameapplet.h"
// Local
// Bamf
#include <bamf-application.h>
#include <bamf-matcher.h>
// Qt
#include <QHBoxLayout>
#include <QLabel>
namespace UnityQt
{
struct AppNameAppletPrivate
{
QLabel* m_label;
};
AppNameApplet::AppNameApplet()
: d(new AppNameAppletPrivate)
{
d->m_label = new QLabel;
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->addWidget(d->m_label);
connect(&BamfMatcher::get_default(), SIGNAL(ActiveApplicationChanged(BamfApplication*, BamfApplication*)), SLOT(updateLabel()));
updateLabel();
}
AppNameApplet::~AppNameApplet()
{
delete d;
}
void AppNameApplet::updateLabel()
{
BamfApplication* app = BamfMatcher::get_default().active_application();
if (app) {
d->m_label->setText(app->name());
} else {
d->m_label->setText(QString());
}
adjustSize();
}
} // namespace
APPLET_MAIN(UnityQt::AppNameApplet)
#include "appnameapplet.moc"
|