Lock Dock Positions has been replaced by Lock Layout
[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 SystemTrayIcon;
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 QSystemTrayIcon *systemTrayIcon() 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     QMenu *systrayMenu;
138     QLabel *coreLagLabel;
139     QLabel *sslLabel;
140     MsgProcessorStatusWidget *msgProcessorStatusWidget;
141
142     TitleSetter _titleSetter;
143
144     void setupActions();
145     void setupBufferWidget();
146     void setupMenus();
147     void setupNickWidget();
148     void setupChatMonitor();
149     void setupInputWidget();
150     void setupTopicWidget();
151     void setupStatusBar();
152     void setupSystray();
153     void setupTitleSetter();
154     void setupToolBars();
155
156     void updateIcon();
157     void hideToTray();
158     void toggleMinimizedToTray();
159     void enableMenus();
160
161     QSystemTrayIcon *_trayIcon;
162
163     QList<BufferViewDock *> _bufferViews;
164     BufferWidget *_bufferWidget;
165     NickListWidget *_nickListWidget;
166     InputWidget *_inputWidget;
167
168     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
169     QMenu *_toolbarMenu;
170     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
171
172     QWidget *_awayLog;
173     friend class QtUi;
174 };
175
176 QSystemTrayIcon *MainWin::systemTrayIcon() const {
177   return _trayIcon;
178 }
179
180 #endif