~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/applets/systemtray/protocols/fdo/fdotask.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   fdotask.cpp                                                           *
 
3
 *                                                                         *
 
4
 *   Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com>              *
 
5
 *                                                                         *
 
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.                                   *
 
10
 *                                                                         *
 
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.                          *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU General Public License     *
 
17
 *   along with this program; if not, write to the                         *
 
18
 *   Free Software Foundation, Inc.,                                       *
 
19
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
 
20
 ***************************************************************************/
 
21
 
 
22
#include "fdographicswidget.h"
 
23
#include "fdotask.h"
 
24
 
 
25
#include <KWindowSystem>
 
26
#include <Plasma/Applet>
 
27
 
 
28
namespace SystemTray
 
29
{
 
30
 
 
31
class FdoTask::Private
 
32
{
 
33
public:
 
34
    Private(WId winId)
 
35
        : winId(winId),
 
36
          widget(0)
 
37
    {
 
38
        KWindowInfo info = KWindowSystem::windowInfo(winId, NET::WMName, NET::WM2WindowClass);
 
39
 
 
40
        // FIXME: This isn't unique
 
41
        typeId = info.windowClassName();
 
42
 
 
43
        name = info.name();
 
44
        if (name.isEmpty()) {
 
45
            name = typeId;
 
46
        }
 
47
 
 
48
        icon = KWindowSystem::icon(winId);
 
49
    }
 
50
 
 
51
    WId winId;
 
52
    QString name;
 
53
    QString typeId;
 
54
    QIcon icon;
 
55
    FdoGraphicsWidget *widget;
 
56
};
 
57
 
 
58
 
 
59
FdoTask::FdoTask(WId winId, QObject *parent)
 
60
    : Task(parent),
 
61
      d(new Private(winId))
 
62
{
 
63
    setCategory(ApplicationStatus);
 
64
}
 
65
 
 
66
FdoTask::~FdoTask()
 
67
{
 
68
    emit taskDeleted(d->winId);
 
69
    delete d;
 
70
}
 
71
 
 
72
bool FdoTask::isEmbeddable() const
 
73
{
 
74
    return !isUsed();
 
75
}
 
76
 
 
77
QString FdoTask::name() const
 
78
{
 
79
    return d->name;
 
80
}
 
81
 
 
82
QString FdoTask::typeId() const
 
83
{
 
84
    return d->typeId;
 
85
}
 
86
 
 
87
QIcon FdoTask::icon() const
 
88
{
 
89
    return d->icon;
 
90
}
 
91
 
 
92
void FdoTask::abandon(Plasma::Applet *host)
 
93
{
 
94
    forget(host);
 
95
    if (d->widget) {
 
96
        d->widget->hide();
 
97
    }
 
98
}
 
99
 
 
100
QGraphicsWidget* FdoTask::createWidget(Plasma::Applet *applet)
 
101
{
 
102
    if (!d->widget) {
 
103
        d->widget = new FdoGraphicsWidget(d->winId, applet);
 
104
        connect(d->widget, SIGNAL(clientClosed()), this, SLOT(deleteLater()));
 
105
    }
 
106
 
 
107
    return d->widget;
 
108
}
 
109
 
 
110
}
 
111
 
 
112
#include "fdotask.moc"