LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / plugins / config / fancytabwidget.h
bloba9604169f13495df7bd3ae17b398d84083e97780
1 /**
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
8 * @{
9 * @addtogroup CorePlugin Core Plugin
10 * @{
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
22 * for more details.
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>
33 #include <QTabBar>
34 #include <QStyleOptionTabV2>
35 #include <QtCore/QTimeLine>
37 QT_BEGIN_NAMESPACE
38 class QPainter;
39 class QStackedLayout;
40 class QStatusBar;
41 QT_END_NAMESPACE
43 struct FancyTab {
44 QIcon icon;
45 QString text;
46 QString toolTip;
49 class FancyTabBar : public QWidget {
50 Q_OBJECT
52 public:
53 FancyTabBar(QWidget *parent = 0, bool isVertical = false);
54 ~FancyTabBar();
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)
70 FancyTab tab;
72 tab.icon = icon;
73 tab.text = 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)
98 iconSize = 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;
108 int count() const
110 return m_tabs.count();
112 QRect tabRect(int index) const;
115 signals:
116 void currentChanged(int);
117 void aboutToChange(bool *);
119 public slots:
120 void updateHover();
122 private:
123 static const int m_rounding;
124 static const int m_textPadding;
125 QTimeLine m_hoverControl;
126 QRect m_hoverRect;
127 int m_hoverIndex;
128 int m_currentIndex;
129 int iconSize;
130 QList<FancyTab> m_tabs;
131 bool verticalTabs;
133 QSize tabSizeHint(bool minimum = false) const;
136 class FancyTabWidget : public QWidget {
137 Q_OBJECT
139 public:
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();
161 signals:
162 void currentAboutToShow(int index);
163 void currentChanged(int index);
165 public slots:
166 void setCurrentIndex(int index);
168 private slots:
169 void showWidget(int index);
171 private:
172 QWidget *m_cornerWidgetContainer;
173 QStackedLayout *m_modesStack;
174 QWidget *m_selectionWidget;
175 QStatusBar *m_statusBar;
179 #endif // FANCYTABWIDGET_H