not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / kickoff / ui / tabbar.h
blob857fb5af08831f349391ae63a1dd647c3aba82c3
1 /*
2 Copyright 2007 Robert Knight <robertknight@gmail.com>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef TABBAR_H
21 #define TABBAR_H
23 #include <QTabBar>
24 #include <QTimer>
26 namespace Plasma
28 class FrameSvg;
31 namespace Kickoff
34 class TabBar : public QTabBar
36 Q_OBJECT
38 public:
39 TabBar(QWidget *parent);
41 QSize sizeHint() const;
42 /** Like the setCurrentIndex() method but switches the tab without using any
43 animation. This is used e.g. within Launcher::reset() to switch back to the
44 favorite tab before Kickoff got shown. */
45 void setCurrentIndexWithoutAnimation(int index);
47 /** Specifies whether hovering switches between tabs or if a click is required to switch the tabs. */
48 void setSwitchTabsOnHover(bool switchOnHover);
49 bool switchTabsOnHover() const;
50 void setAnimateSwitch(bool animateSwitch);
51 bool animateSwitch();
52 void setShape(Shape shape);
54 protected:
55 int lastIndex() const;
57 // reimplemented from QTabBar
58 virtual QSize tabSizeHint(int index) const;
59 virtual void paintEvent(QPaintEvent *event);
60 virtual void leaveEvent(QEvent *event);
61 virtual void mouseMoveEvent(QMouseEvent *event);
62 virtual void resizeEvent(QResizeEvent* event);
64 bool isHorizontal() const;
65 bool isVertical() const;
67 protected slots:
68 void switchToHoveredTab();
69 void animationFinished();
70 void startAnimation();
71 void onValueChanged(qreal val);
73 private:
74 QPainterPath tabPath(const QRect &r);
76 static const int TAB_CONTENTS_MARGIN = 6;
77 int m_hoveredTabIndex;
78 QTimer m_tabSwitchTimer;
79 bool m_switchOnHover;
80 bool m_animateSwitch;
81 QRect m_currentAnimRect;
82 int m_lastIndex[2];
83 qreal m_animProgress;
84 Plasma::FrameSvg *background;
86 QSize tabSize(int index) const;
87 void storeLastIndex();
92 #endif // TABBAR_H