Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
mainwin.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 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  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #pragma once
22 
23 #ifdef HAVE_KDE4
24 # include <KMainWindow>
25 #elif defined HAVE_KF5
26 # include <KXmlGui/KMainWindow>
27 #else
28 # include <QMainWindow>
29 #endif
30 
31 #include "qtui.h"
32 #include "titlesetter.h"
33 #include "uisettings.h"
34 
35 class ActionCollection;
37 class BufferView;
38 class BufferViewConfig;
40 class ClientTransfer;
41 class CoreAccount;
43 class BufferViewDock;
44 class BufferWidget;
45 class InputWidget;
47 class NickListWidget;
48 class SystemTray;
49 class ChatMonitorView;
50 class TopicWidget;
51 
52 class QMenu;
53 class QLabel;
54 class QToolBar;
55 
56 class KHelpMenu;
57 
59 class MainWin
60 #ifdef HAVE_KDE
61  : public KMainWindow {
62 #else
63  : public QMainWindow {
64 #endif
65  Q_OBJECT
66 
67 public:
68  MainWin(QWidget *parent = 0);
69  virtual ~MainWin();
70 
71  void init();
72 
74  BufferView *allBuffersView() const;
76 
77  inline BufferWidget *bufferWidget() const { return _bufferWidget; }
78  inline SystemTray *systemTray() const { return _systemTray; }
79 
80  bool event(QEvent *event);
81 
82  static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
83  static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
84 
87 
88 public slots:
89  void showStatusBarMessage(const QString &message);
90  void hideCurrentBuffer();
91  void nextBufferView();
92  void previousBufferView();
93  void nextBuffer();
94  void previousBuffer();
95 
97  void quit();
98 
99 protected:
100  void closeEvent(QCloseEvent *event);
101  void moveEvent(QMoveEvent *event);
102  void resizeEvent(QResizeEvent *event);
103 
104 protected slots:
105  void connectedToCore();
106  void setConnectedState();
107  void disconnectedFromCore();
108  void setDisconnectedState();
109 
110 private slots:
111  void addBufferView(int bufferViewConfigId);
112  void awayLogDestroyed();
113  void removeBufferView(int bufferViewConfigId);
115  void messagesInserted(const QModelIndex &parent, int start, int end);
116  void showAboutDlg();
117  void showChannelList(NetworkId netId = NetworkId());
118  void showCoreConnectionDlg();
119  void showCoreConfigWizard(const QVariantList &);
120  void showCoreInfoDlg();
121  void showAwayLog();
122  void showSettingsDlg();
123  void showNotificationsDlg();
124  void showIgnoreList(QString newRule = QString());
125  void showShortcutsDlg();
126  void showPasswordChangeDlg();
127  void showNewTransferDlg(const ClientTransfer *transfer);
128  void onFullScreenToggled();
129 
130  void handleCoreConnectionError(const QString &errorMsg);
131  void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
132  void handleNoSslInClient(bool *accepted);
133  void handleNoSslInCore(bool *accepted);
134 #ifdef HAVE_SSL
135  void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
136 #endif
137 
140  void on_actionLockLayout_toggled(bool lock);
147 
148  void bindJumpKey();
149  void onJumpKey();
150 
153  void clientNetworkUpdated();
155 
156  void saveMenuBarStatus(bool enabled);
157  void saveStatusBarStatus(bool enabled);
158  void saveMainToolBarStatus(bool enabled);
159 
160  void loadLayout();
161  void saveLayout();
162 
163  void bufferViewToggled(bool enabled);
164  void bufferViewVisibilityChanged(bool visible);
165  void changeActiveBufferView(bool backwards);
166  void changeActiveBufferView(int bufferViewId);
167 
168 signals:
169  void connectToCore(const QVariantMap &connInfo);
170  void disconnectFromCore();
171 
172 private:
173 #ifdef HAVE_KDE
174  KHelpMenu *_kHelpMenu;
175 #endif
176 
180 
182 
183  void setupActions();
184  void setupBufferWidget();
185  void setupMenus();
186  void setupNickWidget();
187  void setupChatMonitor();
188  void setupInputWidget();
189  void setupTopicWidget();
190  void setupViewMenuTail();
191  void setupStatusBar();
192  void setupSystray();
193  void setupTitleSetter();
194  void setupToolBars();
195  void setupHotList();
196 
197  void updateIcon();
198  void enableMenus();
199 
200  QList<BufferViewDock *> _bufferViews;
206 
209  QMenu *_toolbarMenu;
211 
212  QWidget *_awayLog;
213 
215 
216  QSize _normalSize;
217  QPoint _normalPos;
218 
220  QHash<int, BufferId> _jumpKeyMap;
222 
223  friend class QtUi;
224 };