Applets
tabbar.h
Go to the documentation of this file.00001 /* 00002 Copyright 2007 Robert Knight <robertknight@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef TABBAR_H 00021 #define TABBAR_H 00022 00023 #include <QTabBar> 00024 #include <QTimer> 00025 00026 namespace Kickoff 00027 { 00028 00029 class TabBar : public QTabBar 00030 { 00031 Q_OBJECT 00032 00033 public: 00034 TabBar(QWidget *parent); 00035 00039 void setCurrentIndexWithoutAnimation(int index); 00040 00042 void setSwitchTabsOnHover(bool switchOnHover); 00043 bool switchTabsOnHover() const; 00044 void setAnimateSwitch(bool animateSwitch); 00045 bool animateSwitch(); 00046 void setShape( Shape shape ); 00047 00048 protected: 00049 int lastIndex() const; 00050 00051 // reimplemented from QTabBar 00052 virtual QSize tabSizeHint(int index) const; 00053 virtual void paintEvent(QPaintEvent *event); 00054 virtual void leaveEvent(QEvent *event); 00055 virtual void mouseMoveEvent(QMouseEvent *event); 00056 virtual void resizeEvent(QResizeEvent* event); 00057 00058 bool isHorizontal() const; 00059 bool isVertical() const; 00060 00061 protected slots: 00062 void switchToHoveredTab(); 00063 void animationFinished(); 00064 void startAnimation(); 00065 void onValueChanged(qreal val); 00066 00067 private: 00068 QPainterPath tabPath(const QRect &r); 00069 00070 static const int TAB_CONTENTS_MARGIN = 6; 00071 int m_hoveredTabIndex; 00072 QTimer m_tabSwitchTimer; 00073 bool m_switchOnHover; 00074 bool m_animateSwitch; 00075 QRect m_currentAnimRect; 00076 int m_lastIndex[2]; 00077 qreal m_animProgress; 00078 00079 QSize tabSize(int index) const; 00080 void storeLastIndex(); 00081 }; 00082 00083 } 00084 00085 #endif // TABBAR_H