really don't..
[quassel.git] / src / qtui / mainwin.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program 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) version 3.                                           *
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 program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef MAINWIN_H_
22 #define MAINWIN_H_
23
24 #ifdef HAVE_KDE
25 #  include <KMainWindow>
26 #else
27 #  include <QMainWindow>
28 #endif
29
30 #include <QSystemTrayIcon>
31
32 #include "qtui.h"
33 #include "sessionsettings.h"
34 #include "titlesetter.h"
35
36 class ActionCollection;
37 class BufferView;
38 class BufferViewConfig;
39 class ClientBufferViewConfig;
40 class BufferViewDock;
41 class BufferWidget;
42 class InputWidget;
43 class MsgProcessorStatusWidget;
44 class NickListWidget;
45 class SystemTray;
46
47 class QMenu;
48 class QLabel;
49 class QToolBar;
50
51 class KHelpMenu;
52
53 //!\brief The main window of Quassel's QtUi.
54 class MainWin
55 #ifdef HAVE_KDE
56 : public KMainWindow {
57 #else
58 : public QMainWindow {
59 #endif
60   Q_OBJECT
61
62   public:
63     MainWin(QWidget *parent = 0);
64     virtual ~MainWin();
65
66     void init();
67
68     void addBufferView(ClientBufferViewConfig *config);
69     BufferView *allBuffersView() const;
70
71     inline SystemTray *systemTray() const;
72
73     virtual bool event(QEvent *event);
74
75     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
76     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
77
78   public slots:
79     void saveStateToSession(const QString &sessionId);
80     void saveStateToSessionSettings(SessionSettings &s);
81     void showStatusBarMessage(const QString &message);
82
83   protected:
84     void closeEvent(QCloseEvent *event);
85     virtual void changeEvent(QEvent *event);
86
87   protected slots:
88     void connectedToCore();
89     void setConnectedState();
90     void updateLagIndicator(int lag = -1);
91     void disconnectedFromCore();
92     void setDisconnectedState();
93     void systrayActivated(QSystemTrayIcon::ActivationReason);
94
95   private slots:
96     void addBufferView(int bufferViewConfigId);
97     void awayLogDestroyed();
98     void removeBufferView(int bufferViewConfigId);
99     void messagesInserted(const QModelIndex &parent, int start, int end);
100     void showAboutDlg();
101     void showChannelList(NetworkId netId = NetworkId());
102     void startInternalCore();
103     void showCoreConnectionDlg(bool autoConnect = false);
104     void showCoreInfoDlg();
105     void showAwayLog();
106     void showSettingsDlg();
107     void showNotificationsDlg();
108 #ifdef HAVE_KDE
109     void showShortcutsDlg();
110 #endif
111     void on_actionConfigureNetworks_triggered();
112     void on_actionConfigureViews_triggered();
113     void on_actionLockLayout_toggled(bool lock);
114     void on_actionDebugNetworkModel_triggered();
115     void on_actionDebugMessageModel_triggered();
116     void on_actionDebugLog_triggered();
117
118     void clientNetworkCreated(NetworkId);
119     void clientNetworkRemoved(NetworkId);
120     void clientNetworkUpdated();
121     void connectOrDisconnectFromNet();
122
123     void saveStatusBarStatus(bool enabled);
124
125     void loadLayout();
126     void saveLayout();
127
128   signals:
129     void connectToCore(const QVariantMap &connInfo);
130     void disconnectFromCore();
131
132   private:
133 #ifdef HAVE_KDE
134     KHelpMenu *_kHelpMenu;
135 #endif
136
137     QLabel *coreLagLabel;
138     QLabel *sslLabel;
139     MsgProcessorStatusWidget *msgProcessorStatusWidget;
140
141     TitleSetter _titleSetter;
142
143     void setupActions();
144     void setupBufferWidget();
145     void setupMenus();
146     void setupNickWidget();
147     void setupChatMonitor();
148     void setupInputWidget();
149     void setupTopicWidget();
150     void setupStatusBar();
151     void setupSystray();
152     void setupTitleSetter();
153     void setupToolBars();
154
155     void updateIcon();
156     void hideToTray();
157     void toggleMinimizedToTray();
158     void enableMenus();
159
160     SystemTray *_systemTray;
161
162     QList<BufferViewDock *> _bufferViews;
163     BufferWidget *_bufferWidget;
164     NickListWidget *_nickListWidget;
165     InputWidget *_inputWidget;
166
167     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
168     QMenu *_toolbarMenu;
169     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
170
171     QWidget *_awayLog;
172     friend class QtUi;
173 };
174
175 SystemTray *MainWin::systemTray() const {
176   return _systemTray;
177 }
178
179 #endif