2
This is the new kwindecoration kcontrol module
4
Copyright (c) 2009, Urs Wolfer <uwolfer @ kde.org>
5
Copyright (c) 2004, Sandro Giessl <sandro@giessl.com>
7
Karol Szwed <gallium@kde.org>
10
Supports new kwin configuration plugins, and titlebar button position
11
modification via dnd interface.
13
Based on original "kwintheme" (Window Borders)
14
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
16
This program is free software; you can redistribute it and/or modify
17
it under the terms of the GNU General Public License as published by
18
the Free Software Foundation; either version 2 of the License, or
19
(at your option) any later version.
21
This program is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
GNU General Public License for more details.
26
You should have received a copy of the GNU General Public License
27
along with this program; if not, write to the Free Software
28
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36
#include <QListWidget>
39
class KDecorationFactory;
45
* This class holds the button data.
51
Button(const QString& name, const QBitmap& icon, QChar type, bool duplicate, bool supported);
61
class ButtonDrag : public QMimeData
64
ButtonDrag(Button btn);
67
static bool canDecode(QDropEvent* e);
68
static bool decode(QDropEvent* e, Button& btn);
72
* This is plugged into ButtonDropSite
74
class ButtonDropSiteItem
77
ButtonDropSiteItem(const Button& btn);
78
~ButtonDropSiteItem();
86
void draw(QPainter *p, const QPalette& cg, const QRect &rect);
93
* This is plugged into ButtonSource
95
class ButtonSourceItem : public QListWidgetItem
98
ButtonSourceItem(QListWidget * parent, const Button& btn);
99
virtual ~ButtonSourceItem();
101
void setButton(const Button& btn);
102
Button button() const;
108
* Implements the button drag source list view
110
class ButtonSource : public QListWidget
115
ButtonSource(QWidget *parent = 0);
116
virtual ~ButtonSource();
118
QSize sizeHint() const;
120
void hideAllButtons();
121
void showAllButtons();
123
void dragMoveEvent(QDragMoveEvent *e);
124
void dragEnterEvent(QDragEnterEvent *e);
125
void dropEvent(QDropEvent *e);
126
void mousePressEvent(QMouseEvent *e);
132
void hideButton(QChar btn);
133
void showButton(QChar btn);
136
typedef QList<ButtonDropSiteItem*> ButtonList;
139
* This class renders and handles the demo titlebar dropsite
141
class ButtonDropSite: public QFrame
146
explicit ButtonDropSite(QWidget* parent = 0);
149
// Allow external classes access our buttons - ensure buttons are
150
// not duplicated however.
151
ButtonList buttonsLeft;
152
ButtonList buttonsRight;
156
void resizeEvent(QResizeEvent* e);
157
void dragEnterEvent(QDragEnterEvent* e);
158
void dragMoveEvent(QDragMoveEvent* e);
159
void dragLeaveEvent(QDragLeaveEvent* e);
160
void dropEvent(QDropEvent* e);
161
void mousePressEvent(QMouseEvent* e); ///< Starts dragging a button...
162
void paintEvent(QPaintEvent* p);
165
void buttonAdded(QChar btn);
166
void buttonRemoved(QChar btn);
170
bool removeSelectedButton(); ///< This slot is called after we drop on the item listbox...
171
void recalcItemGeometry(); ///< Call this whenever the item list changes... updates the items' rect property
174
ButtonDropSiteItem *buttonAt(QPoint p);
175
bool removeButton(ButtonDropSiteItem *item);
176
int calcButtonListWidth(const ButtonList& buttons); ///< Computes the total space the buttons will take in the titlebar
177
void drawButtonList(QPainter *p, const ButtonList& buttons, int offset);
179
QRect leftDropArea();
180
QRect rightDropArea();
184
* Try to find the item. If found, set its list and index and return true, else return false
186
bool getItemPos(ButtonDropSiteItem *item, ButtonList* &list, int &pos);
188
void cleanDropVisualizer();
189
QRect m_oldDropVisualizer;
191
ButtonDropSiteItem *m_selected;
194
class ButtonPositionWidget : public QWidget
199
explicit ButtonPositionWidget(QWidget *parent = 0);
200
~ButtonPositionWidget();
202
QString buttonsLeft() const;
203
QString buttonsRight() const;
204
void setButtonsLeft(const QString &buttons);
205
void setButtonsRight(const QString &buttons);
211
void clearButtonList(const ButtonList& btns);
212
Button getButton(QChar type, bool& success);
214
ButtonDropSite* m_dropSite;
215
ButtonSource *m_buttonSource;
217
KDecorationFactory *m_factory;
218
QString m_supportedButtons;
225
// kate: space-indent off; tab-width 4;