1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2006-2009 Licq developers
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef TABWIDGET_H
21 #define TABWIDGET_H
22 
23 #include "config.h"
24 
25 #ifdef USE_KDE
26 # include <KDE/KTabWidget>
27 # define TABWIDGET_BASE KTabWidget
28 #else
29 # include <QTabBar>
30 # include <QTabWidget>
31 # define TABWIDGET_BASE QTabWidget
32 #endif
33 
34 namespace LicqQtGui
35 {
36 
37 #ifndef USE_KDE
38 class TabBar : public QTabBar
39 {
40   Q_OBJECT
41 
42 public:
43   TabBar(QWidget* parent = NULL);
44 
45   void setPreviousTab();
46   void setNextTab();
47 
48 signals:
49   void mouseMiddleClick(int t);
50 
51 private:
52   virtual void wheelEvent(QWheelEvent* e);
53   virtual void mousePressEvent(QMouseEvent* e);
54   virtual void mouseReleaseEvent(QMouseEvent* e);
55 
56   int myClickedTab;
57 };
58 #endif
59 
60 
61 class TabWidget : public TABWIDGET_BASE
62 {
63   Q_OBJECT
64 
65 public:
66   TabWidget(QWidget* parent = NULL);
67   void setTabColor(QWidget* tab, const QColor& color);
68 
69   void setPreviousPage();
70   void setNextPage();
71 
72 #ifdef USE_KDE
73   /**
74    * Overloaded to fix tab shortcuts
75    */
76   void setTabText(int index, const QString& label);
77 
78 protected:
79   /**
80    * Overloaded to fix tab shortcuts
81    */
82   virtual void resizeEvent(QResizeEvent* event);
83 
84 private:
85   /**
86    * Restore tab shortcuts after KTabWidget has broken them
87    */
88   void restoreShortcuts();
89 #else
90 signals:
91   void mouseMiddleClick(QWidget* p);
92 
93 private slots:
94   void slot_middleClick(int t);
95 
96 private:
97   virtual void wheelEvent(QWheelEvent* e);
98 #endif
99 };
100 
101 } // namespace LicqQtGui
102 
103 #endif
104