KVIrc  4.9.2
DeveloperAPIs
KviMainWindow.h
Go to the documentation of this file.
1 #ifndef _KVI_FRAME_H_
2 #define _KVI_FRAME_H_
3 //=============================================================================
4 //
5 // File : KviMainWindow.h
6 // Creation date : Sun Jun 18 2000 17:59:02 CEST by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 //=============================================================================
28 //
29 // KviMainWindow:
30 // The main window for the KVIrc application
31 //
32 //=============================================================================
33 
34 #include "kvi_settings.h"
35 
36 #include "KviTalMainWindow.h"
37 #include "KviQString.h"
38 #include "KviPointerList.h"
39 
40 class KviMenuBar;
41 class KviWindowStack;
42 class KviWindow;
43 class KviConsoleWindow;
44 class KviWindowListBase;
45 class QSplitter;
47 class KviMexToolBar;
48 class KviIrcContext;
49 class KviIrcConnection;
50 class KviStatusBar;
51 class QMenu;
52 class KviTrayIcon;
53 class QShortcut;
54 
55 #ifdef COMPILE_ON_WINDOWS
56 // MSVC has problems with KviPointerList<KviWindow> otherwise
57 #include "KviWindow.h"
58 #endif
59 
60 class KVIRC_API KviMainWindow : public KviTalMainWindow //, public KviIrcContextManager
61 {
62  friend class KviWindow;
63  friend class KviConsoleWindow;
64  friend class KviApplication;
65  friend class KviIrcServerParser;
66  friend class KviMexToolBar;
67  friend class KviWindowStack;
68  friend class KviIrcContext;
69  friend class KviIrcConnection;
70  friend class KviLagMeter;
71  friend class KviUserListView;
72  friend class KviUserListViewArea;
73  Q_OBJECT
74 public:
75  KviMainWindow(QWidget * pParent);
76  ~KviMainWindow();
77 
78 protected:
79  // subwindows
80  QSplitter * m_pSplitter; // the frame is splitted vertically and thus can host widgets
81  KviMenuBar * m_pMenuBar; // the main menu bar
82  KviWindowStack * m_pWindowStack; // the mdi manager widget (child of the splitter)
84  KviWindowListBase * m_pWindowList; // the WindowList
86  // the mdi workspace child windows
87  KviPointerList<KviWindow> * m_pWinList; // the main list of windows
88  KviIrcContext * m_pActiveContext; // the context of the m_pActiveWindow
89  // other
90  KviTrayIcon * m_pTrayIcon; // the frame's dock extension: this should be prolly moved ?
91  KviPointerList<QShortcut> * m_pAccellerators; // global application accellerators
92 public:
93  // the mdi manager: handles mdi children
94  KviWindowStack * windowStack() { return m_pWindowStack; };
95  // the splitter is the central widget for this frame
96  QSplitter * splitter() { return m_pSplitter; };
97  // KviWindowListBase is the base class for KviTreeWindowList and the KviClassicWindowList
98  KviWindowListBase * windowListWidget() { return m_pWindowList; };
99  // well.. the menu bar :D
100  KviMenuBar * mainMenuBar() { return m_pMenuBar; };
101  KviStatusBar * mainStatusBar() { return m_pStatusBar; };
102  // this function may return 0 if the active window has no irc context
103  KviIrcContext * activeContext() { return m_pActiveContext; };
104  // shortcut to a = activeContext(); return a ? a->connection() : 0
105  KviIrcConnection * activeConnection();
106  // The list of the windows belonging to this frame
107  // Note that the windows may be also undocked, but they are still owned by the frame
108  KviPointerList<KviWindow> * windowList() { return m_pWinList; };
109  // Sets the specified window to be the active one
110  // Raises it and focuses it
111  void setActiveWindow(KviWindow * wnd);
112  // Adds a new KviWindow to this frame
113  // This should be done just after the KviWindow constructor has returned
114  // If bShow is false then the window is not explicitly shown
115  // otherwise it is set as active window.
116  void addWindow(KviWindow * wnd, bool bShow = true); // public for modules
117  void closeWindow(KviWindow * wnd);
118  // Checks if a specified window is still existing in this frame child
119  // window list. This is useful for asynchronous functions
120  // that keep a window pointer and need to ensure that it is still
121  // valid after an uncontrolled delay. (Think of a /timer implementation)
122  bool windowExists(KviWindow * wnd) { return (m_pWinList->findRef(wnd) != -1); };
123  // The number of consoles in this frame
124  unsigned int consoleCount();
125  // Creates a new console window. DON'T use the KviConsoleWindow constructor directly.
126  // (The script creation events are triggered from here)
127  KviConsoleWindow * createNewConsole(bool bFirstInFrame = false, bool bShowIt = true);
128  // Returns the first available console.
129  // There is almost always an available console.
130  // Exceptions are the startup and the shutdown (see activeWindow())
131  KviConsoleWindow * firstConsole();
132  // Returns the first console that has no connection in progress
133  // This function CAN return 0 if all the consoles are connected
134  KviConsoleWindow * firstNotConnectedConsole();
135  // this is explicitly dedicated to the TrayIcon module
137  // returns the dockExtension applet. Useful for calling refresh() when
138  // some particular event happens
140  // helper for saving the window properties
141  void saveWindowProperties(KviWindow * wnd, const QString & szSection);
142  // finds the module extension toolbar with the specified identifier
143  // see KviModuleExtension.h and KviMexToolBar.h
144  KviMexToolBar * moduleExtensionToolBar(int extensionId);
145  // Helper to fill the toolbars popup
146  // it is used by KviToolBar and KviMenuBar
147  void fillToolBarsPopup(QMenu * p);
148  void fillIconSizePopup(QMenu * p);
149  // Set the size of the icons used by the whole app
150  // Allowed sizes are 16, 22, 32 and 48
151  void setIconSize(unsigned int uSize);
152  void setButtonStyle(unsigned int uStyle);
153  // allows scripts and actions to override builtin accellerators, avoiding ambiguous events
154  void freeAccelleratorKeySequence(QString & key);
155  // called by children windows when they have updated their titles.
156  void updateWindowTitle(KviWindow * wnd);
157 public slots:
158  void newConsole();
159  void executeInternalCommand(int index);
160  void toggleStatusBar();
161  void toggleMenuBar();
162  void customizeToolBars();
163 
164 protected:
165  void restoreModuleExtensionToolBars();
166  void saveModuleExtensionToolBars();
167  void registerModuleExtensionToolBar(KviMexToolBar * t);
168  void unregisterModuleExtensionToolBar(KviMexToolBar * t);
169 
170  void createWindowList();
171  void recreateWindowList();
172 
173  void dockWindow(KviWindow * wnd);
174  void undockWindow(KviWindow * wnd);
175 
176  // called by KviWindow
177  void childWindowCloseRequest(KviWindow * wnd);
178  void windowActivated(KviWindow * wnd, bool bForce = false);
179 
180  void childContextStateChange(KviIrcContext * c);
181  void childConnectionNickNameChange(KviIrcConnection * c);
182  void childConnectionAwayStateChange(KviIrcConnection * c);
183  void childConnectionUserModeChange(KviIrcConnection * c);
184  void childConnectionLagChange(KviIrcConnection * c);
185  void childConnectionServerInfoChange(KviIrcConnection * c);
186  void childWindowSelectionStateChange(KviWindow * pWnd, bool bGotSelectionNow);
187 
188  virtual void closeEvent(QCloseEvent * e);
189  virtual void hideEvent(QHideEvent * e);
190  virtual void resizeEvent(QResizeEvent * e);
191  virtual void moveEvent(QMoveEvent * e);
192  virtual bool focusNextPrevChild(bool next);
193  virtual void changeEvent(QEvent * event);
194  virtual void contextMenuEvent(QContextMenuEvent * event);
195 
196  void updatePseudoTransparency();
197  void installAccelerators();
198 protected slots:
199  void switchToNextWindow();
200  void switchToPrevWindow();
201  void switchToNextHighlightedWindow();
202  void switchToPrevHighlightedWindow();
203  void switchToNextWindowInContext();
204  void switchToPrevWindowInContext();
205  void closeActiveWindow();
206 
207  void accelActivated();
208  void toolbarsPopupSelected(QAction * pAction);
209  void iconSizePopupSelected(QAction * pAction);
210  void buttonStylePopupSelected(QAction * pAction);
211 signals:
212  void activeWindowChanged(); // almost never 0.. but may be
213  void activeContextChanged(); // may be 0!
214  void activeContextStateChanged(); // emitted only when the active context is non 0 and it changes state
215  void activeConnectionNickNameChanged();
216  void activeConnectionUserModeChanged();
217  void activeConnectionAwayStateChanged();
218  void activeConnectionServerInfoChanged();
219  void activeConnectionLagChanged();
220  void activeWindowSelectionStateChanged(bool bGotSelectionNow);
221 
222 protected:
223  void applyOptions();
224 
225 private:
226  void saveToolBarPositions();
227  void restoreToolBarPositions();
228 };
229 
230 #ifndef _KVI_FRAME_CPP_
232 #endif
233 
234 #endif //_KVI_FRAME_H_
KviIrcContext * m_pActiveContext
Definition: KviMainWindow.h:88
Definition: KviMainWindow.h:60
Definition: KviConsoleWindow.h:75
#define KVIRC_API
Definition: kvi_settings.h:128
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
KviTrayIcon * trayIcon()
Definition: KviMainWindow.h:139
An abstraction of a connection to an IRC server.
Definition: KviIrcConnection.h:95
Definition: KviConfigurationFile.h:48
KviWindowListBase * m_pWindowList
Definition: KviMainWindow.h:84
Definition: KviMexToolBar.h:32
KviStatusBar * m_pStatusBar
Definition: KviMainWindow.h:85
Status Bar class.
Definition: KviStatusBar.h:115
bool windowExists(KviWindow *wnd)
Definition: KviMainWindow.h:122
#define e
Definition: detector.cpp:69
QSplitter * splitter()
Definition: KviMainWindow.h:96
KviPointerList< KviWindow > * m_pWinList
Definition: KviMainWindow.h:87
virtual void resizeEvent(QResizeEvent *e)
Definition: KviUserListView.cpp:2063
QSplitter * m_pSplitter
Definition: KviMainWindow.h:80
Definition: KviMenuBar.h:44
User list area management.
Definition: KviUserListView.h:817
KviPointerList< KviWindow > * windowList()
Definition: KviMainWindow.h:108
KviTrayIcon * m_pTrayIcon
Definition: KviMainWindow.h:90
KVIRC_API KviMainWindow * g_pMainWindow
Definition: KviMainWindow.cpp:91
KviWindowStack * m_pWindowStack
Definition: KviMainWindow.h:82
Handles all docked KviWindow windows.
Definition: KviWindowStack.h:46
KviStatusBar * mainStatusBar()
Definition: KviMainWindow.h:101
KviIrcContext * activeContext()
Definition: KviMainWindow.h:103
void setTrayIcon(KviTrayIcon *e)
Definition: KviMainWindow.h:136
m_pTrayIcon
Definition: KvsObject_trayIcon.cpp:108
QHashIterator< int, QFile * > t(getDict)
KviPointerList< KviMexToolBar > * m_pModuleExtensionToolBarList
Definition: KviMainWindow.h:83
C++ Template based double linked pointer list class.
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
Definition: KviApplication.h:102
The KviTrayIcon class.
Definition: KviTrayIcon.h:37
Definition: KviWindowListBase.h:77
Definition: KviIrcServerParser.h:115
Contains the KviWindow class.
KviMenuBar * mainMenuBar()
Definition: KviMainWindow.h:100
Definition: KviLagMeter.h:45
KviPointerList< QShortcut > * m_pAccellerators
Definition: KviMainWindow.h:91
KviMenuBar * m_pMenuBar
Definition: KviMainWindow.h:81
This file contains compile time settings.
KviWindowListBase * windowListWidget()
Definition: KviMainWindow.h:98
User list view management class.
Definition: KviUserListView.h:226
Definition: KviIrcContext.h:58
#define p
Definition: detector.cpp:80
COMPILE_KDE_SUPPORT.
Definition: KviTalMainWindow.h:50
Toolkit Abstraction Layer class.
Helper functions for the QString class.
KviWindowStack * windowStack()
Definition: KviMainWindow.h:94