~ubuntu-branches/ubuntu/trusty/networkmanagement/trusty

« back to all changes in this revision

Viewing changes to .pc/fix-and-workaround-graphical-artifacts.diff/applet/interfaceitem.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-02-11 20:44:55 UTC
  • Revision ID: package-import@ubuntu.com-20120211204455-se2bx8iwlyhnp89u
Tags: 0.9.0~rc4-0ubuntu2
Cherry pick upstream commit 6a5e30e94ee539b7765eb5ad054bf9e1a6785703
as fix-and-workaround-graphical-artifacts.diff
to fix graphical artifacts in buttons with the default plasma theme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008,2009 Will Stephenson <wstephenson@kde.org>
 
3
Copyright 2008, 2009 Sebastian Kügler <sebas@kde.org>
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License as
 
7
published by the Free Software Foundation; either version 2 of
 
8
the License or (at your option) version 3 or any later version
 
9
accepted by the membership of KDE e.V. (or its successor approved
 
10
by the membership of KDE e.V.), which shall act as a proxy
 
11
defined in Section 14 of version 3 of the license.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
#ifndef APPLET_INTERFACEITEM_H
 
23
#define APPLET_INTERFACEITEM_H
 
24
 
 
25
#include <QDBusObjectPath>
 
26
#include <QGraphicsWidget>
 
27
 
 
28
#include <solid/control/networkinterface.h>
 
29
 
 
30
#include "interfaceconnection.h"
 
31
#include "remoteactivatable.h"
 
32
#include "types.h"
 
33
 
 
34
#include <Plasma/Frame>
 
35
#include <Plasma/IconWidget>
 
36
#include <Plasma/Label>
 
37
#include <Plasma/Meter>
 
38
#include <Plasma/CheckBox>
 
39
#include <Plasma/PushButton>
 
40
 
 
41
class QGraphicsGridLayout;
 
42
class QGraphicsLinearLayout;
 
43
namespace Solid
 
44
{
 
45
    namespace Control
 
46
    {
 
47
        class NetworkInterface;
 
48
    }
 
49
}
 
50
 
 
51
class RemoteInterfaceConnection;
 
52
class RemoteActivatableList;
 
53
 
 
54
 
 
55
/**
 
56
 * Represents a single network interface
 
57
 * Displays status, updates itself
 
58
 * Allows deactivating any active connection
 
59
 */
 
60
class InterfaceItem : public Plasma::IconWidget
 
61
{
 
62
Q_OBJECT
 
63
public:
 
64
    enum NameDisplayMode {InterfaceName, HardwareName};
 
65
    InterfaceItem(Solid::Control::NetworkInterfaceNm09* iface, RemoteActivatableList* activatables, NameDisplayMode mode = InterfaceName,  QGraphicsWidget* parent = 0);
 
66
    virtual ~InterfaceItem();
 
67
 
 
68
    void setNameDisplayMode(NameDisplayMode);
 
69
    NameDisplayMode nameDisplayMode() const;
 
70
    Solid::Control::NetworkInterfaceNm09* interface();
 
71
    virtual QString connectionName();
 
72
    QString label();
 
73
    virtual void setActivatableList(RemoteActivatableList* activatables);
 
74
    virtual QString currentIpAddress();
 
75
    void disappear();
 
76
 
 
77
public Q_SLOTS:
 
78
    void activeConnectionsChanged();
 
79
    virtual void connectionStateChanged(Solid::Control::NetworkInterfaceNm09::ConnectionState, bool updateConnection = true);
 
80
    virtual void setEnabled(bool enable);
 
81
    // also updates the connection info
 
82
    virtual void setActive(bool active);
 
83
 
 
84
Q_SIGNALS:
 
85
    void disappearAnimationFinished();
 
86
 
 
87
protected Q_SLOTS:
 
88
    /**
 
89
     * Remove any connections that were provided by this service
 
90
     * from our active connection list
 
91
     */
 
92
    void handleConnectionStateChange(int new_state);
 
93
    void handleConnectionStateChange(int new_state, int old_state, int reason);
 
94
    void handleHasDefaultRouteChanged(bool);
 
95
    void pppStats(uint in, uint out);
 
96
    void slotClicked();
 
97
    virtual void setConnectionInfo();
 
98
 
 
99
Q_SIGNALS:
 
100
    void stateChanged();
 
101
    void disconnectInterfaceRequested(const QString& deviceUni);
 
102
    void clicked(Solid::Control::NetworkInterfaceNm09*);
 
103
    void hoverEnter(const QString& uni = QString());
 
104
    void hoverLeave(const QString& uni = QString());
 
105
 
 
106
protected:
 
107
    /**
 
108
     * Fill in interface type connection info
 
109
     */
 
110
    /**
 
111
     * Give us a pixmap for an icon
 
112
     */
 
113
    virtual QPixmap interfacePixmap(const QString &icon = QString());
 
114
 
 
115
    /**
 
116
    * The current IP address when the connection is active.
 
117
    */
 
118
   //----- virtual QString currentIpAddress();
 
119
    virtual RemoteInterfaceConnection* currentConnection();
 
120
    void showItem(QGraphicsWidget* widget, bool show = true);
 
121
 
 
122
    RemoteInterfaceConnection* m_currentConnection;
 
123
 
 
124
    QWeakPointer<Solid::Control::NetworkInterfaceNm09> m_iface;
 
125
    RemoteActivatableList* m_activatables;
 
126
 
 
127
    QGraphicsGridLayout* m_layout;
 
128
    QGraphicsLinearLayout* m_infoLayout;
 
129
    Plasma::Label* m_icon;
 
130
    QPixmap* m_pixmap;
 
131
    Plasma::PushButton* m_disconnectButton;
 
132
    Plasma::Label* m_ifaceNameLabel;
 
133
    Plasma::Label* m_connectionNameLabel;
 
134
    QGraphicsLinearLayout* m_connectionInfoLayout;
 
135
    Plasma::Label* m_connectionInfoLabel;
 
136
    Plasma::Label* m_connectionInfoStrengthLabel;
 
137
    Plasma::Label* m_connectionInfoIcon;
 
138
    NameDisplayMode m_nameMode;
 
139
    bool m_enabled;
 
140
    Solid::Control::NetworkInterfaceNm09::ConnectionState m_state;
 
141
    QString m_interfaceName;
 
142
    bool m_disconnect;
 
143
    bool m_hasDefaultRoute;
 
144
    QSize m_pixmapSize;
 
145
    bool m_starting;
 
146
 
 
147
    virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
 
148
    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
 
149
 
 
150
protected Q_SLOTS:
 
151
    virtual void currentConnectionChanged();
 
152
 
 
153
private Q_SLOTS:
 
154
    void emitDisconnectInterfaceRequest();
 
155
    void serviceDisappeared();
 
156
    void activatableAdded(RemoteActivatable*);
 
157
    void activatableRemoved(RemoteActivatable*);
 
158
    void updateCurrentConnection(RemoteInterfaceConnection *);
 
159
};
 
160
#endif // APPLET_INTERFACEWIDGET_H