1bff138b491863f4ae3879e0c6bafacfd8588f87
[quassel.git] / src / qtui / mainwin.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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 #include <QMainWindow>
25 #include <QSystemTrayIcon>
26
27 #include "qtui.h"
28 #include "sessionsettings.h"
29 #include "titlesetter.h"
30
31 class ActionCollection;
32 class BufferViewConfig;
33 class BufferWidget;
34 class MsgProcessorStatusWidget;
35 class NickListWidget;
36 class SystemTrayIcon;
37
38 class QMenu;
39 class QLabel;
40
41 //!\brief The main window of Quassel's QtUi.
42 class MainWin : public QMainWindow {
43   Q_OBJECT
44
45   public:
46     MainWin(QWidget *parent = 0);
47     virtual ~MainWin();
48
49     void init();
50
51     void addBufferView(BufferViewConfig *config = 0);
52
53     inline QSystemTrayIcon *systemTrayIcon() const;
54
55     virtual bool event(QEvent *event);
56   public slots:
57     void saveStateToSession(const QString &sessionId);
58     void saveStateToSessionSettings(SessionSettings &s);
59
60   protected:
61     void closeEvent(QCloseEvent *event);
62     virtual void changeEvent(QEvent *event);
63
64   protected slots:
65     void connectedToCore();
66     void setConnectedState();
67     void updateLagIndicator(int lag);
68     void securedConnection();
69     void disconnectedFromCore();
70     void setDisconnectedState();
71     void systrayActivated(QSystemTrayIcon::ActivationReason);
72
73   private slots:
74     void addBufferView(int bufferViewConfigId);
75     void removeBufferView(int bufferViewConfigId);
76     void messagesInserted(const QModelIndex &parent, int start, int end);
77     void showAboutDlg();
78     void showChannelList(NetworkId netId = NetworkId());
79     void showCoreConnectionDlg(bool autoConnect = false);
80     void showCoreInfoDlg();
81     void showSettingsDlg();
82     void on_actionEditNetworks_triggered();
83     void on_actionManageViews_triggered();
84     void on_actionLockDockPositions_toggled(bool lock);
85     void on_actionDebugNetworkModel_triggered();
86
87     void clientNetworkCreated(NetworkId);
88     void clientNetworkRemoved(NetworkId);
89     void clientNetworkUpdated();
90     void connectOrDisconnectFromNet();
91
92     void saveStatusBarStatus(bool enabled);
93
94     void loadLayout();
95     void saveLayout();
96
97   signals:
98     void connectToCore(const QVariantMap &connInfo);
99     void disconnectFromCore();
100
101   private:
102
103     QMenu *systrayMenu;
104     QLabel *coreLagLabel;
105     QLabel *sslLabel;
106     MsgProcessorStatusWidget *msgProcessorStatusWidget;
107
108     TitleSetter _titleSetter;
109
110     void setupActions();
111     void setupBufferWidget();
112     void setupMenus();
113     void setupViews();
114     void setupNickWidget();
115     void setupChatMonitor();
116     void setupInputWidget();
117     void setupTopicWidget();
118     void setupStatusBar();
119     void setupSystray();
120     void setupTitleSetter();
121
122     void updateIcon();
123     void toggleVisibility();
124     void enableMenus();
125
126     QSystemTrayIcon *_trayIcon;
127
128     QList<QDockWidget *> _netViews;
129     BufferWidget *_bufferWidget;
130     NickListWidget *_nickListWidget;
131
132     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
133
134     friend class QtUi;
135 };
136
137 QSystemTrayIcon *MainWin::systemTrayIcon() const {
138   return _trayIcon;
139 }
140
141 #endif