1 /* 2 * tabdlg.h - dialog for handling tabbed chats 3 * Copyright (C) 2005 Kevin Smith 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program 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 this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef TABDLG_H 22 #define TABDLG_H 23 24 #include <QWidget> 25 #include <QSize> 26 #include <QMap> 27 #include <QPointer> 28 29 #include "advwidget.h" 30 31 #include "tabbablewidget.h" 32 33 class PsiCon; 34 class ChatTabs; 35 class ChatDlg; 36 class QPushButton; 37 class QMenu; 38 class QString; 39 class QContextMenuEvent; 40 class QAction; 41 class QActionGroup; 42 class QSignalMapper; 43 class PsiTabWidget; 44 class TabManager; 45 46 class TabDlg; 47 48 class TabDlgDelegate : public QObject 49 { 50 Q_OBJECT 51 public: 52 TabDlgDelegate(QObject *parent = 0); 53 ~TabDlgDelegate(); 54 55 virtual Qt::WindowFlags initWindowFlags() const; 56 virtual void create(QWidget *widget); 57 virtual void destroy(QWidget *widget); 58 virtual void tabWidgetCreated(QWidget *widget, PsiTabWidget *tabWidget); 59 virtual bool paintEvent(QWidget *widget, QPaintEvent *event); 60 virtual bool resizeEvent(QWidget *widget, QResizeEvent *event); 61 virtual bool mousePressEvent(QWidget *widget, QMouseEvent *event); 62 virtual bool mouseMoveEvent(QWidget *widget, QMouseEvent *event); 63 virtual bool mouseReleaseEvent(QWidget *widget, QMouseEvent *event); 64 virtual bool changeEvent(QWidget *widget, QEvent *event); 65 virtual bool tabEvent(QWidget *widget, QEvent *event); 66 virtual bool tabEventFilter(QWidget *widget, QObject *obj, QEvent *event); 67 }; 68 69 class TabDlg : public AdvancedWidget<QWidget> 70 { 71 Q_OBJECT 72 public: 73 TabDlg(TabManager* tabManager, const QString& geometryOption, TabDlgDelegate *delegate = 0); 74 ~TabDlg(); 75 bool managesTab(const TabbableWidget*) const; 76 bool tabOnTop(const TabbableWidget*) const; 77 TabbableWidget *getTab(int i) const; 78 void removeTabWithNoChecks(TabbableWidget *tab); 79 80 TabbableWidget* getTabPointer(PsiAccount* account, QString fullJid); 81 82 virtual QString desiredCaption() const; 83 QString captionForTab(TabbableWidget* tab) const; 84 85 int tabCount() const; 86 void setUserManagementEnabled(bool enabled); // default enabled 87 void setTabBarShownForSingles(bool enabled); // default enabled 88 void setSimplifiedCaptionEnabled(bool enabled); // default disabled 89 void setTabIcon(QWidget *,const QIcon &); 90 TabbableWidget* getCurrentTab() const; 91 92 protected: 93 void setShortcuts(); 94 95 // reimplemented 96 void closeEvent(QCloseEvent*); 97 void changeEvent(QEvent *event); 98 void resizeEvent(QResizeEvent *); 99 void dragEnterEvent(QDragEnterEvent *event); 100 void dropEvent(QDropEvent *event); 101 102 // delegate-only 103 virtual void paintEvent(QPaintEvent *event); 104 virtual void mousePressEvent(QMouseEvent *event); 105 virtual void mouseMoveEvent(QMouseEvent *event); 106 virtual void mouseReleaseEvent(QMouseEvent *event); 107 virtual bool event(QEvent *event); 108 virtual bool eventFilter(QObject *obj, QEvent *event); 109 110 protected slots: 111 void detachCurrentTab(); 112 void mouseDoubleClickTab(QWidget*); 113 void mouseMiddleClickTab(QWidget*); 114 115 public slots: 116 void addTab(TabbableWidget *tab); 117 void setLooks(); 118 void closeCurrentTab(); 119 void closeTab(TabbableWidget*, bool doclose = true); 120 void selectTab(TabbableWidget*); 121 void activated(); 122 void optionsUpdate(); 123 void detachTab(TabbableWidget*); 124 void sendTabTo(TabbableWidget*, TabDlg *); 125 void tabCloseRequested(int i); 126 void hideTab(TabbableWidget*); 127 void hideCurrentTab(); 128 void hideAllTab(); 129 130 signals: 131 void resized(QSize size); 132 133 private slots: 134 void updateFlashState(); 135 void tabSelected(QWidget* selected); 136 void checkHasChats(); 137 void updateTab(); 138 void updateTab(TabbableWidget*); 139 void showTabWithoutActivation(); 140 void nextTab(); 141 void previousTab(); 142 void tab_aboutToShowMenu(QMenu *menu); 143 void setAsDefaultForChat(); 144 void setAsDefaultForMuc(); 145 void menu_sendTabTo(QAction *act); 146 void queuedSendTabTo(TabbableWidget* chat, TabDlg *dest); 147 void showTabMenu(int tab, QPoint pos, QContextMenuEvent * event); 148 149 private: 150 TabDlgDelegate *delegate_; 151 QList<TabbableWidget*> tabs_; 152 PsiTabWidget *tabWidget_; 153 QPushButton *detachButton_; 154 QPushButton *closeButton_; 155 QPushButton *closeCross_; 156 QMenu *tabMenu_; 157 QAction *act_close_; 158 QAction *act_next_; 159 QAction *act_prev_; 160 TabManager *tabManager_; 161 QPointer<TabbableWidget> selectedTab_; 162 bool userManagement_; 163 bool tabBarSingles_; 164 bool simplifiedCaption_; 165 QSignalMapper *activateTabMapper_; 166 QList<QAction*> tabMapperActions_; 167 168 QSize chatSize_; 169 170 void extinguishFlashingTabs(); 171 void updateCaption(); 172 void updateTabBar(); 173 }; 174 175 #endif 176