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
32 #include <QPushButton>
34 #include <QStyleOptionTabV2>
35 #include <QtCore/QTimeLine>
49 class FancyTabBar
: public QWidget
{
53 FancyTabBar(QWidget
*parent
= 0, bool isVertical
= false);
56 bool event(QEvent
*event
);
58 void paintEvent(QPaintEvent
*event
);
59 void paintTab(QPainter
*painter
, int tabIndex
) const;
60 void mousePressEvent(QMouseEvent
*);
61 void mouseMoveEvent(QMouseEvent
*);
62 void enterEvent(QEvent
*);
63 void leaveEvent(QEvent
*);
65 QSize
sizeHint() const;
66 QSize
minimumSizeHint() const;
68 void insertTab(int index
, const QIcon
&icon
, const QString
&label
)
74 m_tabs
.insert(index
, tab
);
76 void removeTab(int index
)
78 m_tabs
.removeAt(index
);
80 void updateTabNameIcon(int index
, const QIcon
&icon
, const QString
&label
);
81 void setCurrentIndex(int index
);
82 int currentIndex() const
84 return m_currentIndex
;
87 void setTabToolTip(int index
, QString toolTip
)
89 m_tabs
[index
].toolTip
= toolTip
;
91 QString
tabToolTip(int index
) const
93 return m_tabs
.at(index
).toolTip
;
96 void setIconSize(int s
)
100 QIcon
tabIcon(int index
) const
102 return m_tabs
.at(index
).icon
;
104 QString
tabText(int index
) const
106 return m_tabs
.at(index
).text
;
110 return m_tabs
.count();
112 QRect
tabRect(int index
) const;
116 void currentChanged(int);
117 void aboutToChange(bool *);
123 static const int m_rounding
;
124 static const int m_textPadding
;
125 QTimeLine m_hoverControl
;
130 QList
<FancyTab
> m_tabs
;
133 QSize
tabSizeHint(bool minimum
= false) const;
136 class FancyTabWidget
: public QWidget
{
140 FancyTabWidget(QWidget
*parent
= 0, bool isVertical
= false);
141 FancyTabBar
*m_tabBar
;
142 void insertTab(int index
, QWidget
*tab
, const QIcon
&icon
, const QString
&label
);
143 void removeTab(int index
);
144 void setBackgroundBrush(const QBrush
&brush
);
145 void addCornerWidget(QWidget
*widget
);
146 void insertCornerWidget(int pos
, QWidget
*widget
);
147 int cornerWidgetCount() const;
148 void setTabToolTip(int index
, const QString
&toolTip
);
149 void updateTabNameIcon(int index
, const QIcon
&icon
, const QString
&label
);
150 void setIconSize(int s
)
152 m_tabBar
->setIconSize(s
);
155 void paintEvent(QPaintEvent
*event
);
157 int currentIndex() const;
158 QStatusBar
*statusBar() const;
160 QWidget
*currentWidget();
162 void currentAboutToShow(int index
);
163 void currentChanged(int index
);
166 void setCurrentIndex(int index
);
169 void showWidget(int index
);
172 QWidget
*m_cornerWidgetContainer
;
173 QStackedLayout
*m_modesStack
;
174 QWidget
*m_selectionWidget
;
175 QStatusBar
*m_statusBar
;
179 #endif // FANCYTABWIDGET_H