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

« back to all changes in this revision

Viewing changes to src/ViewManager.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:
27
27
 
28
28
// Konsole
29
29
#include "Profile.h"
 
30
#include "ViewContainer.h"
30
31
 
31
32
class QSignalMapper;
32
 
class QMenu;
33
33
class KActionCollection;
34
34
class KConfigGroup;
35
35
 
36
36
namespace Konsole
37
37
{
38
 
 
39
38
class ColorScheme;
40
39
class IncrementalSearchBar;
41
40
class Session;
43
42
 
44
43
class SessionController;
45
44
class ViewProperties;
46
 
class ViewContainer;
47
45
class ViewSplitter;
48
46
 
49
47
/**
67
65
 */
68
66
class KONSOLEPRIVATE_EXPORT ViewManager : public QObject
69
67
{
70
 
Q_OBJECT
71
 
Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Konsole")
 
68
    Q_OBJECT
 
69
    Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Window")
72
70
 
73
71
public:
74
72
    /**
92
90
    void applyProfileToView(TerminalDisplay* view , const Profile::Ptr profile);
93
91
 
94
92
    /**
95
 
     * Applies the container-specific settings associated with specified @p
96
 
     * profile to the view container @p container.
97
 
     */
98
 
    void applyProfileToContainer(ViewContainer* container , const Profile::Ptr profile);
99
 
 
100
 
    /**
101
93
     * Return the main widget for the view manager which
102
94
     * holds all of the views managed by this ViewManager instance.
103
95
     */
122
114
     * which newly created containers can provide to allow navigation
123
115
     * between open sessions.
124
116
     */
125
 
    enum NavigationMethod
126
 
    {
 
117
    enum NavigationMethod {
127
118
        /**
128
119
         * Each container has a row of tabs (one per session) which the user
129
120
         * can click on to navigate between open sessions.
134
125
    };
135
126
 
136
127
    /**
 
128
     * This enum describes where newly created tab should be placed.
 
129
     */
 
130
    enum NewTabBehavior {
 
131
        /** Put newly created tab at the end. */
 
132
        PutNewTabAtTheEnd = 0,
 
133
        /** Put newly created tab right after current tab. */
 
134
        PutNewTabAfterCurrentTab = 1
 
135
    };
 
136
 
 
137
    /**
137
138
     * Sets the type of widget provided to navigate between open sessions
138
139
     * in a container.  The changes will only apply to newly created containers.
139
140
     *
165
166
    void saveSessions(KConfigGroup& group);
166
167
    void restoreSessions(const KConfigGroup& group);
167
168
 
 
169
    void setNavigationVisibility(int visibility);
 
170
    void setNavigationPosition(int position);
 
171
    void setNavigationBehavior(int behavior);
 
172
    void setNavigationStyleSheet(const QString& styleSheet);
 
173
    void setShowQuickButtons(bool show);
 
174
 
 
175
    int managerId() const;
 
176
 
168
177
signals:
169
178
    /** Emitted when the last view is removed from the view manager */
170
179
    void empty();
216
225
 
217
226
public slots:
218
227
    /** DBus slot that returns the number of sessions in the current view. */
219
 
    int sessionCount();
 
228
    Q_SCRIPTABLE int sessionCount();
220
229
 
221
230
    /** DBus slot that returns the current (active) session window */
222
 
    int currentSession();
 
231
    Q_SCRIPTABLE int currentSession();
223
232
 
224
233
    /** DBus slot that creates a new session in the current view.
225
234
     * @param profile the name of the profile to be used
226
235
     * @param directory the working directory where the session is
227
236
     * started.
228
237
     */
229
 
    int newSession(QString profile, QString directory);
230
 
 
 
238
    Q_SCRIPTABLE int newSession(QString profile, QString directory);
 
239
 
 
240
    // TODO: its semantic is application-wide. Move it to more appropriate place
 
241
    // DBus slot that returns the name of default profile
 
242
    Q_SCRIPTABLE QString defaultProfile();
 
243
 
 
244
    // TODO: its semantic is application-wide. Move it to more appropriate place
231
245
    // DBus slot that returns a string list of defined (known) profiles
232
 
    QStringList profileList();
 
246
    Q_SCRIPTABLE QStringList profileList();
233
247
 
234
248
    /** DBus slot that creates a new session in the current view with the associated
235
249
      * default profile and the default working directory
236
250
      */
237
 
    int newSession();
 
251
    Q_SCRIPTABLE int newSession();
238
252
 
239
253
    /** DBus slot that changes the view port to the next session */
240
 
    void nextSession();
 
254
    Q_SCRIPTABLE void nextSession();
241
255
 
242
256
    /** DBus slot that changes the view port to the previous session */
243
 
    void prevSession();
 
257
    Q_SCRIPTABLE void prevSession();
244
258
 
245
259
    /** DBus slot that switches the current session (as returned by
246
260
      * currentSession()) with the left (or previous) one in the
247
261
      * navigation tab.
248
262
      */
249
 
    void moveSessionLeft();
 
263
    Q_SCRIPTABLE void moveSessionLeft();
250
264
 
251
265
    /** DBus slot that Switches the current session (as returned by
252
266
      * currentSession()) with the right (or next) one in the navigation
253
267
      * tab.
254
268
      */
255
 
    void moveSessionRight();
 
269
    Q_SCRIPTABLE void moveSessionRight();
256
270
 
257
271
    /** DBus slot that sets ALL tabs' width to match their text */
258
 
    void setTabWidthToText(bool);
 
272
    Q_SCRIPTABLE void setTabWidthToText(bool);
259
273
 
260
274
private slots:
261
275
    // called when the "Split View Left/Right" menu item is selected
262
276
    void splitLeftRight();
263
277
    void splitTopBottom();
264
 
    void closeActiveView();
265
 
    void closeOtherViews();
266
 
    void expandActiveView();
267
 
    void shrinkActiveView();
 
278
    void closeActiveContainer();
 
279
    void closeOtherContainers();
 
280
    void expandActiveContainer();
 
281
    void shrinkActiveContainer();
268
282
 
269
283
    // called when the "Detach View" menu item is selected
270
284
    void detachActiveView();
273
287
    // called when a session terminates - the view manager will delete any
274
288
    // views associated with the session
275
289
    void sessionFinished();
276
 
    // called when the container requests to close a particular view
277
 
    void viewCloseRequest(QWidget* widget);
 
290
    // called when one view has been destroyed
 
291
    void viewDestroyed(QWidget* widget);
278
292
 
279
293
    // controller detects when an associated view is given the focus
280
294
    // and emits a signal.  ViewManager listens for that signal
283
297
 
284
298
    // called when the active view in a ViewContainer changes, so
285
299
    // that we can plug the appropriate actions into the UI
286
 
    void viewActivated( QWidget* view );
 
300
    void viewActivated(QWidget* view);
287
301
 
288
302
    // called when "Next View" shortcut is activated
289
303
    void nextView();
327
341
 
328
342
private:
329
343
    void createView(Session* session, ViewContainer* container, int index);
330
 
    const ColorScheme* colorSchemeForProfile(const Profile::Ptr profile) const;
 
344
    static const ColorScheme* colorSchemeForProfile(const Profile::Ptr profile);
331
345
 
332
346
    void setupActions();
333
347
    void focusActiveView();
334
 
    void registerView(TerminalDisplay* view);
335
 
    void unregisterView(TerminalDisplay* view);
336
348
 
337
349
    // takes a view from a view container owned by a different manager and places it in
338
350
    // newContainer owned by this manager
339
 
    void takeView(ViewManager* otherManager , ViewContainer* otherContainer, ViewContainer* newContainer, TerminalDisplay* view); 
 
351
    void takeView(ViewManager* otherManager , ViewContainer* otherContainer, ViewContainer* newContainer, TerminalDisplay* view);
340
352
    void splitView(Qt::Orientation orientation);
341
353
 
342
354
    // creates a new container which can hold terminal displays
343
 
    // 'profile' specifies the profile to use to get initial
344
 
    // settings (eg. navigation position) for the container
345
 
    ViewContainer* createContainer(const Profile::Ptr profile);
 
355
    ViewContainer* createContainer();
346
356
    // removes a container and emits appropriate signals
347
357
    void removeContainer(ViewContainer* container);
348
358
 
356
366
    // about the session ( such as title and associated icon ) to the display.
357
367
    SessionController* createController(Session* session , TerminalDisplay* display);
358
368
 
359
 
    // create menu for 'new tab' button
360
 
    QMenu* createNewViewMenu();
361
369
private:
362
370
    QPointer<ViewSplitter>          _viewSplitter;
363
371
    QPointer<SessionController>     _pluggedController;
364
372
 
365
 
    QHash<TerminalDisplay*,Session*> _sessionMap;
 
373
    QHash<TerminalDisplay*, Session*> _sessionMap;
366
374
 
367
375
    KActionCollection*                  _actionCollection;
368
376
    QSignalMapper*                      _containerSignalMapper;
369
 
    NavigationMethod                _navigationMethod;
370
 
 
371
 
    QMenu* _newViewMenu;
 
377
 
 
378
    NavigationMethod  _navigationMethod;
 
379
 
 
380
    ViewContainer::NavigationVisibility _navigationVisibility;
 
381
    ViewContainer::NavigationPosition _navigationPosition;
 
382
    bool _showQuickButtons;
 
383
    NewTabBehavior _newTabBehavior;
 
384
    QString _navigationStyleSheet;
 
385
 
 
386
    int _managerId;
 
387
    static int lastManagerId;
372
388
};
373
 
 
374
389
}
375
390
 
376
391
#endif