Removing core related items from menu and statusbar
[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 #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 BufferViewDock;
40 class BufferWidget;
41 class MsgProcessorStatusWidget;
42 class NickListWidget;
43 class SystemTrayIcon;
44
45 class QMenu;
46 class QLabel;
47
48 class KHelpMenu;
49
50 //!\brief The main window of Quassel's QtUi.
51 class MainWin
52 #ifdef HAVE_KDE
53 : public KMainWindow {
54 #else
55 : public QMainWindow {
56 #endif
57   Q_OBJECT
58
59   public:
60     MainWin(QWidget *parent = 0);
61     virtual ~MainWin();
62
63     void init();
64
65     void addBufferView(BufferViewConfig *config = 0);
66     BufferView *allBuffersView() const;
67
68     inline QSystemTrayIcon *systemTrayIcon() const;
69
70     virtual bool event(QEvent *event);
71
72     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
73     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
74
75   public slots:
76     void saveStateToSession(const QString &sessionId);
77     void saveStateToSessionSettings(SessionSettings &s);
78     void showStatusBarMessage(const QString &message);
79
80   protected:
81     void closeEvent(QCloseEvent *event);
82     virtual void changeEvent(QEvent *event);
83
84   protected slots:
85     void connectedToCore();
86     void setConnectedState();
87     void updateLagIndicator(int lag);
88     void securedConnection();
89     void disconnectedFromCore();
90     void setDisconnectedState();
91     void systrayActivated(QSystemTrayIcon::ActivationReason);
92
93   private slots:
94     void addBufferView(int bufferViewConfigId);
95     void removeBufferView(int bufferViewConfigId);
96     void messagesInserted(const QModelIndex &parent, int start, int end);
97     void showAboutDlg();
98     void showChannelList(NetworkId netId = NetworkId());
99     void showCoreConnectionDlg(bool autoConnect = false);
100     void showCoreInfoDlg();
101     void showSettingsDlg();
102     void showNotificationsDlg();
103 #ifdef HAVE_KDE
104     void showShortcutsDlg();
105 #endif
106     void on_actionConfigureNetworks_triggered();
107     void on_actionConfigureViews_triggered();
108     void on_actionLockDockPositions_toggled(bool lock);
109     void on_actionDebugNetworkModel_triggered();
110     void on_actionDebugMessageModel_triggered();
111     void on_actionDebugLog_triggered();
112
113     void clientNetworkCreated(NetworkId);
114     void clientNetworkRemoved(NetworkId);
115     void clientNetworkUpdated();
116     void connectOrDisconnectFromNet();
117
118     void saveStatusBarStatus(bool enabled);
119
120     void loadLayout();
121     void saveLayout();
122
123   signals:
124     void connectToCore(const QVariantMap &connInfo);
125     void disconnectFromCore();
126
127   private:
128 #ifdef HAVE_KDE
129     KHelpMenu *_kHelpMenu;
130 #endif
131
132     QMenu *systrayMenu;
133     QLabel *coreLagLabel;
134     QLabel *sslLabel;
135     MsgProcessorStatusWidget *msgProcessorStatusWidget;
136
137     TitleSetter _titleSetter;
138
139     void setupActions();
140     void setupBufferWidget();
141     void setupMenus();
142     void setupViews();
143     void setupNickWidget();
144     void setupChatMonitor();
145     void setupInputWidget();
146     void setupTopicWidget();
147     void setupStatusBar();
148     void setupSystray();
149     void setupTitleSetter();
150
151     void updateIcon();
152     void toggleVisibility();
153     void enableMenus();
154
155     QSystemTrayIcon *_trayIcon;
156
157     QList<BufferViewDock *> _bufferViews;
158     BufferWidget *_bufferWidget;
159     NickListWidget *_nickListWidget;
160
161     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
162
163     friend class QtUi;
164 };
165
166 QSystemTrayIcon *MainWin::systemTrayIcon() const {
167   return _trayIcon;
168 }
169
170 #endif