1
/***************************************************************************
5
copyright : (C) 2005 by Dominik Haumann
8
Copyright (C) 2007 Flavio Castelli <flavio.castelli@gmail.com>
9
***************************************************************************/
11
/***************************************************************************
12
This program is free software; you can redistribute it and/or
13
modify it under the terms of the GNU General Public License
14
as published by the Free Software Foundation; either version 2
15
of the License, or (at your option) any later version.
17
This program is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
GNU General Public License for more details.
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
***************************************************************************/
27
#ifndef TINYTABBUTTON_H
28
#define TINYTABBUTTON_H
30
#include <QPushButton>
31
#include "ktinytabbar.h"
35
* A \p KTinyTabButton represents a button on the tab bar. It can either be
36
* \e activated or \e deactivated. If the state is \e deactivated it will
37
* be @e activated when the mouse is pressed. It then emits the signal
38
* @p activated(). The \p KTinyTabButton's caption can be set with \p setText()
39
* and an additional pixmap can be shown with \p setPixmap().
41
* @author Dominik Haumann
43
class KTinyTabButton : public QPushButton
49
* Constructs a new tab bar button with \a caption and \a parent. If
50
* \e blockContextMenu is \e false the context menu will be blocked, i.e.
51
* hidden. If the @p docurl is unknown, pass QString().
53
KTinyTabButton( const QString& docurl, const QString& caption, int button_id,
54
bool blockContextMenu = true, QWidget *parent = 0 );
56
virtual ~KTinyTabButton();
59
* Activate or deactivate the button. If the button is already down
60
* and \a active is \e true nothing happens, otherwise the state toggles.
61
* \note The signal \p activated is \e not emitted.
63
void setActivated( bool active );
66
* Check the button status. The return value is \e true, if the button is
69
bool isActivated() const;
72
* Set a unique button id number.
74
void setButtonID( int button_id );
77
* Get the unique id number.
82
* Set the document's url to @p docurl. If unknown, pass QString().
84
void setURL( const QString& docurl );
87
* Get the document's url.
92
* Set the highlighted state. If @p color.isValid() is \e false the
93
* button is not highlighted. This does \e not emit the signal
94
* @p highlightChanged().
95
* @param color the color
97
void setHighlightColor( const QColor& color );
100
* Get the highlight color. If the button is not highlighted then the color
101
* is invalid, i.e. \p QColor::isValid() returns \e flase.
103
QColor highlightColor() const;
106
* Set the highlight opacity to @p value.
107
* @param value opacity between 0..100
109
void setHighlightOpacity( int value );
112
* Get the highlight opacity
115
int highlightOpacity() const;
118
* Set whether the tab was previously selected.
119
* @param previous truth vlaue
121
void setPreviousTab( bool previous );
124
* Check whether the tab is the previously selected tab.
125
* @return true, if tab was active before the current active tab
127
bool previousTab() const;
130
* Set the tabbutton style.
131
* @param tabStyle button style
133
void setTabButtonStyle( KTinyTabBar::ButtonStyle tabStyle );
136
* Get the tabbutton style
137
* @return button style
139
KTinyTabBar::ButtonStyle tabButtonStyle() const;
142
* Set whether an active tab should be highlighted.
144
void setHighlightActiveTab( bool value );
146
* Get whether an active tab should be highlighted.
148
bool highlightActiveTab();
151
* Set whether a previous tab should be highlighted.
153
void setHighlightPreviousTab( bool value );
155
* Get whether a previous tab is highlighted.
157
bool highlightPreviousTab();
159
void setPreviousTabColor( const QColor& color );
160
QColor previousTabColor() const;
162
void setActiveTabColor( const QColor& color );
163
QColor activeTabColor() const;
165
void setHighlightModifiedTabs( bool highlight );
166
bool highlightModifiedTabs() const;
168
void setModifiedTabsColor( const QColor& color );
169
QColor modifiedTabsColor() const;
171
void setModified( bool modified );
172
bool isModified() const;
176
* Emitted whenever the button changes state from deactivated to activated.
177
* @param tabbutton the pressed button (this)
179
void activated( KTinyTabButton* tabbutton );
182
* Emitted whenever the user changes the highlighted state. This can be
183
* done only via the context menu.
184
* @param tabbutton the changed button (this)
186
void highlightChanged( KTinyTabButton* tabbutton );
189
* Emitted whenever the user wants to close the tab button.
190
* @param tabbutton the button that emitted this signal
192
void closeRequest( KTinyTabButton* tabbutton );
195
* Emitted whenever the user wants to close all the tab button except the
197
* @param tabbutton the button that emitted this signal
199
void closeOtherTabsRequest( KTinyTabButton* tabbutton );
202
* Emitted whenever the user wants to close all the tabs.
204
void closeAllTabsRequest();
207
void buttonClicked();
210
/** paint eyecandy rectangles around the button */
211
virtual void paintEvent( QPaintEvent* ev );
212
/** support for context menu */
213
virtual void contextMenuEvent( QContextMenuEvent* ev );
214
/** middle mouse button changes color */
215
virtual void mousePressEvent( QMouseEvent* ev );
222
bool m_highlightModifiedTab;
223
bool m_highlightActiveTab;
224
bool m_highlightPreviousTab;
225
bool m_isPreviousTab;
227
QColor m_colorModifiedTab;
228
QColor m_colorActiveTab;
229
QColor m_colorPreviousTab;
231
QColor m_highlightColor;
232
KTinyTabBar::ButtonStyle m_tabButtonStyle;
233
int m_highlightOpacity;
235
static QColor s_predefinedColors[6];
236
static const int s_colorCount;
237
static int s_currentColor;
242
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;