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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*****************************************************************
Copyright (c) 2000 Bill Nagel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
#ifndef __quickbutton_h__
#define __quickbutton_h__
#include <qbutton.h>
#include <qpoint.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qcursor.h>
#include <kickertip.h>
#include <kicontheme.h>
#include <kmimetype.h>
#include <kpanelapplet.h>
#include <kservice.h>
#include <kurl.h>
#include "simplebutton.h"
class QPopupMenu;
class KAction;
class KToggleAction;
class QuickURL {
public:
QuickURL(const QString &u);
KURL kurl() const {return _kurl;};
QString url() const {return _kurl.url();};
QString menuId() const {return _menuId;};
QString genericName() const { return m_genericName; }
QString name() const { return m_name; }
KService::Ptr service() const {return _service;};
void run() const;
QPixmap pixmap(mode_t _mode = 0, KIcon::Group _group = KIcon::Desktop,
int _force_size = 0, int _state = 0, QString * _path = 0L) const;
private:
KURL _kurl;
QString _menuId;
QString m_genericName;
QString m_name;
KService::Ptr _service;
};
class QuickButton: public SimpleButton, public KickerTip::Client {
Q_OBJECT
public:
enum { DEFAULT_ICON_DIM = 16 };
enum { ICON_MARGIN = 1 };
QuickButton(const QString &u, KAction* configAction,
QWidget *parent=0, const char *name=0);
~QuickButton();
QString url() const;
QString menuId() const;
QPixmap icon() const{ return _icon;}
bool sticky() { return m_sticky; }
void setSticky(bool bSticky);
void setPopupDirection(KPanelApplet::Direction d);
void setDragging(bool drag);
void setEnableDrag(bool enable);
void setDynamicModeEnabled(bool enabled);
void flash();
signals:
void removeApp(QuickButton *);
void executed(QString serviceStorageID);
void stickyToggled(bool isSticky);
protected:
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void resizeEvent(QResizeEvent *rsevent);
void loadIcon();
void updateKickerTip(KickerTip::Data &data);
protected slots:
void slotIconChanged(int);
void launch();
void removeApp();
void slotFlash();
void slotStickyToggled(bool isSticky);
private:
int m_flashCounter;
QuickURL *_qurl;
QPoint _dragPos;
QPopupMenu *_popup;
QPixmap _icon, _iconh;
QCursor _oldCursor;
bool _highlight, _changeCursorOverItem, _dragEnabled;
int _iconDim;
bool m_sticky;
KToggleAction *m_stickyAction;
int m_stickyId;
KPanelApplet::Direction m_popupDirection;
};
#endif
|