2 ******************************************************************************
4 * @file fancytabwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup CorePlugin Core Plugin
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef FANCYTABWIDGET_H
30 #define FANCYTABWIDGET_H
36 #include <QPropertyAnimation>
46 class FancyTab
: public QObject
{
47 Q_OBJECT
Q_PROPERTY(float fader READ fader WRITE setFader
)
49 FancyTab(QWidget
*tabbar
) : enabled(false), tabbar(tabbar
), m_fader(0)
51 animator
.setPropertyName("fader");
52 animator
.setTargetObject(this);
58 void setFader(float value
);
69 QPropertyAnimation animator
;
74 class FancyTabBar
: public QWidget
{
78 FancyTabBar(QWidget
*parent
= 0);
81 bool event(QEvent
*event
);
83 void paintEvent(QPaintEvent
*event
);
84 void paintTab(QPainter
*painter
, int tabIndex
) const;
85 void mousePressEvent(QMouseEvent
*);
86 void mouseMoveEvent(QMouseEvent
*);
87 void enterEvent(QEvent
*);
88 void leaveEvent(QEvent
*);
89 bool validIndex(int index
) const
91 return index
>= 0 && index
< m_tabs
.count();
94 QSize
sizeHint() const;
95 QSize
minimumSizeHint() const;
97 void setTabEnabled(int index
, bool enable
);
98 bool isTabEnabled(int index
) const;
100 void insertTab(int index
, const QIcon
&icon
, const QString
&label
)
102 FancyTab
*tab
= new FancyTab(this);
106 m_tabs
.insert(index
, tab
);
109 void setEnabled(int index
, bool enabled
);
110 void removeTab(int index
)
112 FancyTab
*tab
= m_tabs
.takeAt(index
);
117 void setCurrentIndex(int index
);
118 int currentIndex() const
120 return m_currentIndex
;
123 void setTabToolTip(int index
, QString toolTip
)
125 m_tabs
[index
]->toolTip
= toolTip
;
127 QString
tabToolTip(int index
) const
129 return m_tabs
.at(index
)->toolTip
;
132 QIcon
tabIcon(int index
) const
134 return m_tabs
.at(index
)->icon
;
136 QString
tabText(int index
) const
138 return m_tabs
.at(index
)->text
;
142 return m_tabs
.count();
144 QRect
tabRect(int index
) const;
147 void currentChanged(int);
150 void emitCurrentIndex();
153 static const int m_rounding
;
154 static const int m_textPadding
;
158 QList
<FancyTab
*> m_tabs
;
159 QTimer m_triggerTimer
;
160 QSize
tabSizeHint(bool minimum
= false) const;
163 class FancyTabWidget
: public QWidget
{
167 FancyTabWidget(QWidget
*parent
= 0);
169 void insertTab(int index
, QWidget
*tab
, const QIcon
&icon
, const QString
&label
);
170 void removeTab(int index
);
171 void setBackgroundBrush(const QBrush
&brush
);
172 void addCornerWidget(QWidget
*widget
);
173 void insertCornerWidget(int pos
, QWidget
*widget
);
174 int cornerWidgetCount() const;
175 void setTabToolTip(int index
, const QString
&toolTip
);
177 void paintEvent(QPaintEvent
*event
);
179 int currentIndex() const;
180 QStatusBar
*statusBar() const;
182 void setTabEnabled(int index
, bool enable
);
183 bool isTabEnabled(int index
) const;
185 bool isSelectionWidgetVisible() const;
188 void currentAboutToShow(int index
);
189 void currentChanged(int index
);
192 void setCurrentIndex(int index
);
193 void setSelectionWidgetVisible(bool visible
);
196 void showWidget(int index
);
199 FancyTabBar
*m_tabBar
;
200 QWidget
*m_cornerWidgetContainer
;
201 QStackedLayout
*m_modesStack
;
202 QWidget
*m_selectionWidget
;
203 QStatusBar
*m_statusBar
;
205 } // namespace Internal
208 #endif // FANCYTABWIDGET_H