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 Plasma 00027 { 00028 class FrameSvg; 00029 } 00030 00031 namespace Kickoff 00032 { 00033 00034 class TabBar : public QTabBar 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 TabBar(QWidget *parent); 00040 00041 QSize sizeHint() const; 00045 void setCurrentIndexWithoutAnimation(int index); 00046 00048 void setSwitchTabsOnHover(bool switchOnHover); 00049 bool switchTabsOnHover() const; 00050 void setAnimateSwitch(bool animateSwitch); 00051 bool animateSwitch(); 00052 void setShape(Shape shape); 00053 00054 protected: 00055 int lastIndex() const; 00056 00057 // reimplemented from QTabBar 00058 virtual QSize tabSizeHint(int index) const; 00059 virtual void paintEvent(QPaintEvent *event); 00060 virtual void leaveEvent(QEvent *event); 00061 virtual void mouseMoveEvent(QMouseEvent *event); 00062 virtual void resizeEvent(QResizeEvent* event); 00063 00064 bool isHorizontal() const; 00065 bool isVertical() const; 00066 00067 protected slots: 00068 void switchToHoveredTab(); 00069 void animationFinished(); 00070 void startAnimation(); 00071 void onValueChanged(qreal val); 00072 00073 private: 00074 QPainterPath tabPath(const QRect &r); 00075 00076 static const int TAB_CONTENTS_MARGIN = 6; 00077 int m_hoveredTabIndex; 00078 QTimer m_tabSwitchTimer; 00079 bool m_switchOnHover; 00080 bool m_animateSwitch; 00081 QRect m_currentAnimRect; 00082 int m_lastIndex[2]; 00083 qreal m_animProgress; 00084 Plasma::FrameSvg *background; 00085 00086 QSize tabSize(int index) const; 00087 void storeLastIndex(); 00088 }; 00089 00090 } 00091 00092 #endif // TABBAR_H