1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef FANCYTABWIDGET_H
35 #define FANCYTABWIDGET_H
37 #include <QtGui/QIcon>
38 #include <QtGui/QWidget>
40 #include <QtCore/QTimer>
41 #include <QtCore/QPropertyAnimation>
52 class FancyTab : public QObject
56 Q_PROPERTY(float fader READ fader WRITE setFader)
58 FancyTab(QWidget *tabbar) : enabled(false), tabbar(tabbar), m_fader(0) {
59 animator.setPropertyName("fader");
60 animator.setTargetObject(this);
62 float fader() { return m_fader; }
63 void setFader(float value);
74 QPropertyAnimation animator;
79 class FancyTabBar : public QWidget
84 FancyTabBar(QWidget *parent = 0);
87 bool event(QEvent *event);
89 void paintEvent(QPaintEvent *event);
90 void paintTab(QPainter *painter, int tabIndex) const;
91 void mousePressEvent(QMouseEvent *);
92 void mouseMoveEvent(QMouseEvent *);
93 void enterEvent(QEvent *);
94 void leaveEvent(QEvent *);
95 bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); }
97 QSize sizeHint() const;
98 QSize minimumSizeHint() const;
100 void setTabEnabled(int index, bool enable);
101 bool isTabEnabled(int index) const;
103 void insertTab(int index, const QIcon &icon, const QString &label) {
104 FancyTab *tab = new FancyTab(this);
107 m_tabs.insert(index, tab);
109 void setEnabled(int index, bool enabled);
110 void removeTab(int index) {
111 FancyTab *tab = m_tabs.takeAt(index);
114 void setCurrentIndex(int index);
115 int currentIndex() const { return m_currentIndex; }
117 void setTabToolTip(int index, QString toolTip) { m_tabs[index]->toolTip = toolTip; }
118 QString tabToolTip(int index) const { return m_tabs.at(index)->toolTip; }
120 QIcon tabIcon(int index) const { return m_tabs.at(index)->icon; }
121 QString tabText(int index) const { return m_tabs.at(index)->text; }
122 int count() const {return m_tabs.count(); }
123 QRect tabRect(int index) const;
126 void currentChanged(int);
129 void emitCurrentIndex();
132 static const int m_rounding;
133 static const int m_textPadding;
137 QList<FancyTab*> m_tabs;
138 QTimer m_triggerTimer;
139 QSize tabSizeHint(bool minimum = false) const;
143 class FancyTabWidget : public QWidget
148 FancyTabWidget(QWidget *parent = 0);
150 void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
151 void removeTab(int index);
152 void setBackgroundBrush(const QBrush &brush);
153 void addCornerWidget(QWidget *widget);
154 void insertCornerWidget(int pos, QWidget *widget);
155 int cornerWidgetCount() const;
156 void setTabToolTip(int index, const QString &toolTip);
158 void paintEvent(QPaintEvent *event);
160 int currentIndex() const;
161 QStatusBar *statusBar() const;
163 void setTabEnabled(int index, bool enable);
164 bool isTabEnabled(int index) const;
167 void currentAboutToShow(int index);
168 void currentChanged(int index);
171 void setCurrentIndex(int index);
174 void showWidget(int index);
177 FancyTabBar *m_tabBar;
178 QWidget *m_cornerWidgetContainer;
179 QStackedLayout *m_modesStack;
180 QWidget *m_selectionWidget;
181 QStatusBar *m_statusBar;
184 } // namespace Internal
187 #endif // FANCYTABWIDGET_H