add more spacing
[personal-kdebase.git] / apps / konsole / src / MainWindow.h
blobc55ae551ac8bba21c69455f15d3749a6c1456696
1 /*
2 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301 USA.
20 #ifndef KONSOLEMAINWINDOW_H
21 #define KONSOLEMAINWINDOW_H
23 // Qt
24 #include <QtCore/QPointer>
26 // KDE
27 #include <KXmlGuiWindow>
28 #include <KUrl>
30 // Local
31 #include "Profile.h"
33 class KToggleAction;
35 namespace Konsole
38 class IncrementalSearchBar;
39 class ViewManager;
40 class ViewProperties;
41 class SessionController;
42 class ProfileList;
43 class BookmarkHandler;
45 /**
46 * The main window. This contains the menus and an area which contains the terminal displays.
48 * The main window does not create the views or the container widgets which hold the views.
49 * This is done by the ViewManager class. When a MainWindow is instantiated, it creates
50 * a new ViewManager. The ViewManager can then be used to create new terminal displays
51 * inside the window.
53 * Do not construct new main windows directly, use Application's newMainWindow() method.
55 class MainWindow : public KXmlGuiWindow
57 Q_OBJECT
59 public:
60 /**
61 * Constructs a new main window. Do not create new main windows directly, use Application's
62 * newMainWindow() method instead.
64 MainWindow();
66 /**
67 * Returns the view manager associated with this window. The view manager can be used to
68 * create new views on particular session objects inside this window.
70 ViewManager* viewManager() const;
72 /**
73 * Returns the search bar.
74 * TODO - More documentation
76 IncrementalSearchBar* searchBar() const;
78 /** Sets the list of sessions to be displayed in the File menu */
79 void setSessionList(ProfileList* list);
81 /**
82 * Returns the bookmark handler associated with this window.
84 BookmarkHandler* bookmarkHandler() const;
86 /**
87 * Sets the default profile for this window.
88 * This is the default value for the profile argument
89 * when the newSessionRequest() and newWindow() signals
90 * are emitted.
92 void setDefaultProfile(Profile::Ptr profile);
94 /**
95 * Returns the default profile for this window.
96 * See setDefaultProfile()
98 Profile::Ptr defaultProfile() const;
101 signals:
102 /**
103 * Emitted by the main window to request the creation of a new session.
105 * @param profile The profile to use to create the new session.
106 * @param directory Initial working directory for the new session or empty
107 * if the default working directory associated with the profile should be used.
108 * @param view The view manager owned by this main window
110 void newSessionRequest(Profile::Ptr profile,
111 const QString& directory,
112 ViewManager* view);
115 * Emitted by the main window to request the creation of a
116 * new session in a new window.
118 * @param profile The profile to use to create the
119 * first session in the new window.
120 * @param directory Initial working directory for the new window or empty
121 * if the default working directory associated with the profile should
122 * be used.
124 void newWindowRequest(Profile::Ptr profile,
125 const QString& directory);
128 * Emitted by the main window to request the current session to close.
130 void closeActiveSessionRequest();
132 protected:
133 // reimplemented from KMainWindow
134 virtual bool queryClose();
135 virtual void saveProperties(KConfigGroup& group);
136 virtual void readProperties(const KConfigGroup& group);
137 virtual void saveGlobalProperties(KConfig* config);
138 virtual void readGlobalProperties(KConfig* config);
140 private slots:
141 void newTab();
142 void newWindow();
143 void showManageProfilesDialog();
144 void showRemoteConnectionDialog();
145 void showShortcutsDialog();
146 void newFromProfile(Profile::Ptr profile);
147 void activeViewChanged(SessionController* controller);
148 void activeViewTitleChanged(ViewProperties*);
150 void sessionListChanged(const QList<QAction*>& actions);
151 void viewFullScreen(bool fullScreen);
152 void configureNotifications();
154 // single shot call to set the visibility of the menu bar. Has no
155 // effect if the menu bar is a MacOS-style top-level menu
156 void setMenuBarVisibleOnce(bool visible);
158 void openUrls(const QList<KUrl>& urls);
160 private:
161 void correctShortcuts();
162 void removeMenuAccelerators();
163 void setupActions();
164 void setupWidgets();
165 QString activeSessionDir() const;
166 void disconnectController(SessionController* controller);
168 // sets the active shortcuts of actions in 'dest' to the shortcuts of actions
169 // with the same name in 'source' (see KAction::ActiveShortcut)
170 static void syncActiveShortcuts(KActionCollection* dest, const KActionCollection* source);
172 private:
173 ViewManager* _viewManager;
174 BookmarkHandler* _bookmarkHandler;
175 KToggleAction* _toggleMenuBarAction;
177 QPointer<SessionController> _pluggedController;
179 Profile::Ptr _defaultProfile;
180 bool _menuBarVisibilitySet;
185 #endif // KONSOLEMAINWINDOW_H
188 Local Variables:
189 mode: c++
190 c-file-style: "stroustrup"
191 indent-tabs-mode: nil
192 tab-width: 4
193 End: