~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/MainWindow.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    02110-1301  USA.
18
18
*/
19
19
 
20
 
#ifndef KONSOLEMAINWINDOW_H
21
 
#define KONSOLEMAINWINDOW_H
 
20
#ifndef MAINWINDOW_H
 
21
#define MAINWINDOW_H
22
22
 
23
23
// Qt
24
24
#include <QtCore/QPointer>
36
36
 
37
37
namespace Konsole
38
38
{
39
 
 
40
39
class IncrementalSearchBar;
41
40
class ViewManager;
42
41
class ViewProperties;
 
42
class Session;
43
43
class SessionController;
44
44
class ProfileList;
45
45
class BookmarkHandler;
58
58
{
59
59
    Q_OBJECT
60
60
 
61
 
    public:
62
 
        /**
63
 
         * Constructs a new main window.  Do not create new main windows directly, use Application's
64
 
         * newMainWindow() method instead.
65
 
         */
66
 
        MainWindow();
67
 
 
68
 
        /**
69
 
         * Returns the view manager associated with this window.  The view manager can be used to
70
 
         * create new views on particular session objects inside this window.
71
 
         */
72
 
        ViewManager* viewManager() const;
73
 
 
74
 
        /**
75
 
         * Returns the search bar.
76
 
         *
77
 
         * This is a convenience method. The search bar is actually owned by
78
 
         * ViewManager, or more precisely, by ViewContainer.
79
 
         */
80
 
        IncrementalSearchBar* searchBar() const;
81
 
 
82
 
        /** Sets the list of sessions to be displayed in the File menu */
83
 
        void setSessionList(ProfileList* list);
84
 
 
85
 
        /**
86
 
         * Returns the bookmark handler associated with this window.
87
 
         */
88
 
        BookmarkHandler* bookmarkHandler() const;
89
 
 
90
 
        /**
91
 
         * Sets the default profile for this window.
92
 
         * This is the default value for the profile argument
93
 
         * when the newSessionRequest() and newWindow() signals
94
 
         * are emitted.
95
 
         */
96
 
        void setDefaultProfile(Profile::Ptr profile);
97
 
 
98
 
        /**
99
 
         * Returns the default profile for this window.
100
 
         * See setDefaultProfile()
101
 
         */
102
 
        Profile::Ptr defaultProfile() const;
103
 
 
104
 
    signals:
105
 
        /**
106
 
         * Emitted by the main window to request the creation of a new session.
107
 
         *
108
 
         * @param profile The profile to use to create the new session.
109
 
         * @param directory Initial working directory for the new session or empty
110
 
         * if the default working directory associated with the profile should be used.
111
 
         * @param view The view manager owned by this main window
112
 
         */
113
 
        void newSessionRequest(Profile::Ptr profile,
114
 
                               const QString& directory,
115
 
                               ViewManager* view);
116
 
 
117
 
        /**
118
 
         * Emitted by the main window to request the creation of a new SSH session.
119
 
         *
120
 
         * @param profile The profile to use to create the new session.
121
 
         * @param url URL for the new session
122
 
         * @param view The view manager owned by this main window
123
 
         */
124
 
        void newSSHSessionRequest(Profile::Ptr profile,
125
 
                                  const KUrl& url,
126
 
                                  ViewManager* view);
127
 
 
128
 
        /**
129
 
         * Emitted by the main window to request the creation of a
130
 
         * new session in a new window.
131
 
         *
132
 
         * @param profile The profile to use to create the
133
 
         * first session in the new window.
134
 
         * @param directory Initial working directory for the new window or empty
135
 
         * if the default working directory associated with the profile should
136
 
         * be used.
137
 
         */
138
 
        void newWindowRequest(Profile::Ptr profile,
139
 
                              const QString& directory);
140
 
 
141
 
        /**
142
 
         * Emitted by the main window to request the current session to close.
143
 
         */
144
 
        void closeActiveSessionRequest();
145
 
 
146
 
    protected:
147
 
        // Reimplemented for internal reasons.
148
 
        virtual void showEvent(QShowEvent* event);
149
 
 
150
 
        // reimplemented from KMainWindow
151
 
        virtual bool queryClose();
152
 
        virtual void saveProperties(KConfigGroup& group);
153
 
        virtual void readProperties(const KConfigGroup& group);
154
 
        virtual void saveGlobalProperties(KConfig* config);
155
 
        virtual void readGlobalProperties(KConfig* config);
156
 
 
157
 
        // reimplemented from QWidget
158
 
        virtual bool focusNextPrevChild( bool next );
159
 
 
160
 
    private slots:
161
 
        void newTab();
162
 
        void newWindow();
163
 
        void showManageProfilesDialog();
164
 
        void activateMenuBar();
165
 
        void showShortcutsDialog();
166
 
        void newFromProfile(Profile::Ptr profile);
167
 
        void activeViewChanged(SessionController* controller);
168
 
        void disconnectController(SessionController* controller);
169
 
        void activeViewTitleChanged(ViewProperties*);
170
 
 
171
 
        void sessionListChanged(const QList<QAction*>& actions);
172
 
        void viewFullScreen(bool fullScreen);
173
 
        void configureNotifications();
174
 
 
175
 
        // single shot call to set the initial visibility of the menu bar.
176
 
        // Has no effect if the menu bar is a MacOS-style top-level menu
177
 
        void setMenuBarInitialVisibility(bool visible);
178
 
 
179
 
        void setSaveGeometryOnExit(bool visible);
180
 
 
181
 
        void updateWindowIcon();
182
 
 
183
 
        void openUrls(const QList<KUrl>& urls);
184
 
 
185
 
    private:
186
 
        void correctShortcuts();
187
 
        void removeMenuAccelerators();
188
 
        void setupActions();
189
 
        void setupWidgets();
190
 
        QString activeSessionDir() const;
191
 
 
192
 
        // sets the active shortcuts of actions in 'dest' to the shortcuts of actions
193
 
        // with the same name in 'source' (see KAction::ActiveShortcut)
194
 
        static void syncActiveShortcuts(KActionCollection* dest, const KActionCollection* source);
195
 
 
196
 
    private:
197
 
        ViewManager*  _viewManager;
198
 
        BookmarkHandler* _bookmarkHandler;
199
 
        KToggleAction* _toggleMenuBarAction;
200
 
        KActionMenu* _newTabMenuAction;
201
 
 
202
 
        QPointer<SessionController> _pluggedController;
203
 
 
204
 
        Profile::Ptr _defaultProfile;
205
 
 
206
 
        bool _menuBarInitialVisibility;
207
 
        bool _menuBarInitialVisibilitySet;
208
 
        bool _menuBarInitialVisibilityApplied;
 
61
public:
 
62
    /**
 
63
     * Constructs a new main window.  Do not create new main windows directly, use Application's
 
64
     * newMainWindow() method instead.
 
65
     */
 
66
    MainWindow();
 
67
 
 
68
    /**
 
69
     * Returns the view manager associated with this window.  The view manager can be used to
 
70
     * create new views on particular session objects inside this window.
 
71
     */
 
72
    ViewManager* viewManager() const;
 
73
 
 
74
    /**
 
75
     * Create a new session.
 
76
     *
 
77
     * @param profile The profile to use to create the new session.
 
78
     * @param directory Initial working directory for the new session or empty
 
79
     * if the default working directory associated with the profile should be used.
 
80
     */
 
81
    Session* createSession(Profile::Ptr profile, const QString& directory);
 
82
 
 
83
    /**
 
84
     * create a new SSH session.
 
85
     *
 
86
     * @param profile The profile to use to create the new session.
 
87
     * @param url the URL representing the new SSH connection
 
88
     */
 
89
    Session* createSSHSession(Profile::Ptr profile, const KUrl& url);
 
90
 
 
91
    /**
 
92
     * create view for the specified session
 
93
     */
 
94
    void createView(Session* session);
 
95
 
 
96
    /**
 
97
     * Helper method to make this window get input focus
 
98
     */
 
99
    void setFocus();
 
100
 
 
101
    /**
 
102
     * Set the initial visibility of the menubar.
 
103
     */
 
104
    void setMenuBarInitialVisibility(bool visible);
 
105
 
 
106
    void setNavigationVisibility(int visibility);
 
107
    void setNavigationPosition(int position);
 
108
    void setNavigationStyleSheet(const QString& stylesheet);
 
109
    void setNavigationBehavior(int behavior);
 
110
    void setShowQuickButtons(bool show);
 
111
 
 
112
signals:
 
113
 
 
114
    /**
 
115
     * Emitted by the main window to request the creation of a
 
116
     * new session in a new window.
 
117
     *
 
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.
 
123
     */
 
124
    void newWindowRequest(Profile::Ptr profile,
 
125
                          const QString& directory);
 
126
 
 
127
    /**
 
128
     * Emitted when a view for one session is detached from this window
 
129
     */
 
130
    void viewDetached(Session* session);
 
131
 
 
132
protected:
 
133
    // Reimplemented for internal reasons.
 
134
    virtual void showEvent(QShowEvent* event);
 
135
 
 
136
    // reimplemented from KMainWindow
 
137
    virtual bool queryClose();
 
138
    virtual void saveProperties(KConfigGroup& group);
 
139
    virtual void readProperties(const KConfigGroup& group);
 
140
    virtual void saveGlobalProperties(KConfig* config);
 
141
    virtual void readGlobalProperties(KConfig* config);
 
142
 
 
143
    // reimplemented from QWidget
 
144
    virtual bool focusNextPrevChild(bool next);
 
145
 
 
146
private slots:
 
147
    void newTab();
 
148
    void cloneTab();
 
149
    void newWindow();
 
150
    void showManageProfilesDialog();
 
151
    void activateMenuBar();
 
152
    void showSettingsDialog();
 
153
    void showShortcutsDialog();
 
154
    void newFromProfile(Profile::Ptr profile);
 
155
    void activeViewChanged(SessionController* controller);
 
156
    void disconnectController(SessionController* controller);
 
157
    void activeViewTitleChanged(ViewProperties*);
 
158
 
 
159
    void profileListChanged(const QList<QAction*>& actions);
 
160
    void viewFullScreen(bool fullScreen);
 
161
    void configureNotifications();
 
162
 
 
163
    void setSaveGeometryOnExit(bool visible);
 
164
 
 
165
    void updateWindowIcon();
 
166
    void updateWindowCaption();
 
167
 
 
168
    void openUrls(const QList<KUrl>& urls);
 
169
 
 
170
    // Sets the list of profiles to be displayed under the "New Tab" action
 
171
    void setProfileList(ProfileList* list);
 
172
 
 
173
    void applyKonsoleSettings();
 
174
 
 
175
private:
 
176
    void correctStandardShortcuts();
 
177
    void rememberMenuAccelerators();
 
178
    void removeMenuAccelerators();
 
179
    void restoreMenuAccelerators();
 
180
    void setupActions();
 
181
    void setupMainWidget();
 
182
    QString activeSessionDir() const;
 
183
 
 
184
    /**
 
185
     * Returns the search bar.
 
186
     *
 
187
     * This is a convenience method. The search bar is actually owned by
 
188
     * ViewManager, or more precisely, by ViewContainer.
 
189
     */
 
190
    IncrementalSearchBar* searchBar() const;
 
191
 
 
192
    /**
 
193
     * Returns the bookmark handler associated with this window.
 
194
     */
 
195
    BookmarkHandler* bookmarkHandler() const;
 
196
 
 
197
    // sets the active shortcuts of actions in 'dest' to the shortcuts of actions
 
198
    // with the same name in 'source' (see KAction::ActiveShortcut)
 
199
    static void syncActiveShortcuts(KActionCollection* dest, const KActionCollection* source);
 
200
 
 
201
private:
 
202
    ViewManager*  _viewManager;
 
203
    BookmarkHandler* _bookmarkHandler;
 
204
    KToggleAction* _toggleMenuBarAction;
 
205
    KActionMenu* _newTabMenuAction;
 
206
 
 
207
    QPointer<SessionController> _pluggedController;
 
208
 
 
209
    bool _menuBarInitialVisibility;
 
210
    bool _menuBarInitialVisibilityApplied;
209
211
};
210
 
 
211
212
}
212
213
 
213
 
#endif // KONSOLEMAINWINDOW_H
 
214
#endif // MAINWINDOW_H