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