~ubuntu-branches/ubuntu/saucy/kate/saucy

« back to all changes in this revision

Viewing changes to addons/kate/tabbarextension/ktinytabbutton.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, Rohan Garg, Jonathan Riddell
  • Date: 2013-06-21 00:48:29 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20130621004829-y2ui02eg0j47h94y
Tags: 4:4.10.80-0ubuntu1
[ Rohan Garg ]
* New upstream release
  - Update and sort install files
  - Drop kubuntu_pate_find_python.diff, kubuntu_kate_initial_preference.patch,
    kubuntu_find_python.diff from debian/patches , not required

[ Jonathan Riddell ]
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                           ktinytabbutton.h
 
3
                           -------------------
 
4
    begin                : 2005-06-15
 
5
    copyright            : (C) 2005 by Dominik Haumann
 
6
    email                : dhdev@gmx.de
 
7
 
 
8
    Copyright (C) 2007 Flavio Castelli <flavio.castelli@gmail.com>
 
9
 ***************************************************************************/
 
10
 
 
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.
 
16
 
 
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.
 
21
 
 
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
 ***************************************************************************/
 
26
 
 
27
#ifndef TINYTABBUTTON_H
 
28
#define TINYTABBUTTON_H
 
29
 
 
30
#include <QPushButton>
 
31
#include "ktinytabbar.h"
 
32
 
 
33
 
 
34
/**
 
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().
 
40
 *
 
41
 * @author Dominik Haumann
 
42
 */
 
43
class KTinyTabButton : public QPushButton
 
44
{
 
45
Q_OBJECT
 
46
 
 
47
public:
 
48
    /**
 
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().
 
52
     */
 
53
    KTinyTabButton( const QString& docurl, const QString& caption, int button_id,
 
54
                    bool blockContextMenu = true, QWidget *parent = 0 );
 
55
 
 
56
    virtual ~KTinyTabButton();
 
57
 
 
58
    /**
 
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.
 
62
     */
 
63
    void setActivated( bool active );
 
64
 
 
65
    /**
 
66
     * Check the button status. The return value is \e true, if the button is
 
67
     * down.
 
68
     */
 
69
    bool isActivated() const;
 
70
 
 
71
    /**
 
72
     * Set a unique button id number.
 
73
     */
 
74
    void setButtonID( int button_id );
 
75
 
 
76
    /**
 
77
     * Get the unique id number.
 
78
     */
 
79
    int buttonID() const;
 
80
 
 
81
    /**
 
82
     * Set the document's url to @p docurl. If unknown, pass QString().
 
83
     */
 
84
    void setURL( const QString& docurl );
 
85
 
 
86
    /**
 
87
     * Get the document's url.
 
88
     */
 
89
    QString url() const;
 
90
 
 
91
    /**
 
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
 
96
     */
 
97
    void setHighlightColor( const QColor& color );
 
98
 
 
99
    /**
 
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.
 
102
     */
 
103
    QColor highlightColor() const;
 
104
 
 
105
    /**
 
106
     * Set the highlight opacity to @p value.
 
107
     * @param value opacity between 0..100
 
108
     */
 
109
    void setHighlightOpacity( int value );
 
110
 
 
111
    /**
 
112
     * Get the highlight opacity
 
113
     * @return opacity
 
114
     */
 
115
    int highlightOpacity() const;
 
116
 
 
117
    /**
 
118
     * Set whether the tab was previously selected.
 
119
     * @param previous truth vlaue
 
120
     */
 
121
    void setPreviousTab( bool previous );
 
122
 
 
123
    /**
 
124
     * Check whether the tab is the previously selected tab.
 
125
     * @return true, if tab was active before the current active tab
 
126
     */
 
127
    bool previousTab() const;
 
128
 
 
129
    /**
 
130
     * Set the tabbutton style.
 
131
     * @param tabStyle button style
 
132
     */
 
133
    void setTabButtonStyle( KTinyTabBar::ButtonStyle tabStyle );
 
134
 
 
135
    /**
 
136
     * Get the tabbutton style
 
137
     * @return button style
 
138
     */
 
139
    KTinyTabBar::ButtonStyle tabButtonStyle() const;
 
140
 
 
141
    /**
 
142
     * Set whether an active tab should be highlighted.
 
143
     */
 
144
    void setHighlightActiveTab( bool value );
 
145
    /**
 
146
     * Get whether an active tab should be highlighted.
 
147
     */
 
148
    bool highlightActiveTab();
 
149
 
 
150
    /**
 
151
     * Set whether a previous tab should be highlighted.
 
152
     */
 
153
    void setHighlightPreviousTab( bool value );
 
154
    /**
 
155
     * Get whether a previous tab is highlighted.
 
156
     */
 
157
    bool highlightPreviousTab();
 
158
 
 
159
    void setPreviousTabColor( const QColor& color );
 
160
    QColor previousTabColor() const;
 
161
 
 
162
    void setActiveTabColor( const QColor& color );
 
163
    QColor activeTabColor() const;
 
164
 
 
165
    void setHighlightModifiedTabs( bool highlight );
 
166
    bool highlightModifiedTabs() const;
 
167
 
 
168
    void setModifiedTabsColor( const QColor& color );
 
169
    QColor modifiedTabsColor() const;
 
170
 
 
171
    void setModified( bool modified );
 
172
    bool isModified() const;
 
173
 
 
174
signals:
 
175
    /**
 
176
     * Emitted whenever the button changes state from deactivated to activated.
 
177
     * @param tabbutton the pressed button (this)
 
178
     */
 
179
    void activated( KTinyTabButton* tabbutton );
 
180
 
 
181
    /**
 
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)
 
185
     */
 
186
    void highlightChanged( KTinyTabButton* tabbutton );
 
187
 
 
188
    /**
 
189
     * Emitted whenever the user wants to close the tab button.
 
190
     * @param tabbutton the button that emitted this signal
 
191
     */
 
192
    void closeRequest( KTinyTabButton* tabbutton );
 
193
 
 
194
    /**
 
195
     * Emitted whenever the user wants to close all the tab button except the
 
196
     * selected one.
 
197
     * @param tabbutton the button that emitted this signal
 
198
     */
 
199
    void closeOtherTabsRequest( KTinyTabButton* tabbutton );
 
200
 
 
201
    /**
 
202
     * Emitted whenever the user wants to close all the tabs.
 
203
     */
 
204
    void closeAllTabsRequest();
 
205
 
 
206
protected slots:
 
207
    void buttonClicked();
 
208
 
 
209
protected:
 
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 );
 
216
 
 
217
 
 
218
private:
 
219
    QString m_url;
 
220
    int m_buttonId;
 
221
    bool m_modified;
 
222
    bool m_highlightModifiedTab;
 
223
    bool m_highlightActiveTab;
 
224
    bool m_highlightPreviousTab;
 
225
    bool m_isPreviousTab;
 
226
 
 
227
    QColor m_colorModifiedTab;
 
228
    QColor m_colorActiveTab;
 
229
    QColor m_colorPreviousTab;
 
230
 
 
231
    QColor m_highlightColor;
 
232
    KTinyTabBar::ButtonStyle m_tabButtonStyle;
 
233
    int m_highlightOpacity;
 
234
 
 
235
    static QColor s_predefinedColors[6];
 
236
    static const int s_colorCount;
 
237
    static int s_currentColor;
 
238
};
 
239
 
 
240
#endif
 
241
 
 
242
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; eol unix;