Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.h
Show All 38 Lines | |||||
39 | class SessionController; | 39 | class SessionController; | ||
40 | class ViewProperties; | 40 | class ViewProperties; | ||
41 | class ViewSplitter; | 41 | class ViewSplitter; | ||
42 | class TabbedViewContainer; | 42 | class TabbedViewContainer; | ||
43 | 43 | | |||
44 | /** | 44 | /** | ||
45 | * Manages the terminal display widgets in a Konsole window or part. | 45 | * Manages the terminal display widgets in a Konsole window or part. | ||
46 | * | 46 | * | ||
47 | * When a view manager is created, it constructs a splitter widget ( accessed via | 47 | * When a view manager is created, it constructs a tab widget ( accessed via | ||
48 | * widget() ) to hold one or more view containers. Each view container holds | 48 | * widget() ) to hold one or more view splitters. Each view splitter holds | ||
49 | * one or more terminal displays and a navigation widget ( eg. tabs or a list ) | 49 | * one or more terminal displays and splitters. | ||
50 | * to allow the user to navigate between the displays in that container. | | |||
51 | * | 50 | * | ||
52 | * The view manager provides menu actions ( defined in the 'konsoleui.rc' XML file ) | 51 | * The view manager provides menu actions ( defined in the 'konsoleui.rc' XML file ) | ||
53 | * to manipulate the views and view containers - for example, actions to split the view | 52 | * to manipulate the views and view containers - for example, actions to split the view | ||
54 | * left/right or top/bottom, detach a view from the current window and navigate between | 53 | * left/right or top/bottom, detach a view from the current window and navigate between | ||
55 | * views and containers. These actions are added to the collection specified in the | 54 | * views and containers. These actions are added to the collection specified in the | ||
56 | * ViewManager's constructor. | 55 | * ViewManager's constructor. | ||
57 | * | 56 | * | ||
58 | * The view manager provides facilities to construct display widgets for a terminal | 57 | * The view manager provides facilities to construct display widgets for a terminal | ||
Show All 11 Lines | 67 | public: | |||
70 | * Constructs a new view manager with the specified @p parent. | 69 | * Constructs a new view manager with the specified @p parent. | ||
71 | * View-related actions defined in 'konsoleui.rc' are created | 70 | * View-related actions defined in 'konsoleui.rc' are created | ||
72 | * and added to the specified @p collection. | 71 | * and added to the specified @p collection. | ||
73 | */ | 72 | */ | ||
74 | ViewManager(QObject *parent, KActionCollection *collection); | 73 | ViewManager(QObject *parent, KActionCollection *collection); | ||
75 | ~ViewManager() Q_DECL_OVERRIDE; | 74 | ~ViewManager() Q_DECL_OVERRIDE; | ||
76 | 75 | | |||
77 | /** | 76 | /** | ||
78 | * Creates a new view to display the output from and deliver input to @p session. | | |||
79 | * Constructs a new container to hold the views if no container has yet been created. | | |||
80 | */ | | |||
81 | void createView(TabbedViewContainer *tabWidget, Session *session); | | |||
82 | | ||||
83 | /** | | |||
84 | * Applies the view-specific settings associated with specified @p profile | 77 | * Applies the view-specific settings associated with specified @p profile | ||
85 | * to the terminal display @p view. | 78 | * to the terminal display @p view. | ||
86 | */ | 79 | */ | ||
87 | void applyProfileToView(TerminalDisplay *view, const Profile::Ptr &profile); | 80 | void applyProfileToView(TerminalDisplay *view, const Profile::Ptr &profile); | ||
88 | 81 | | |||
89 | /** | 82 | /** | ||
90 | * Return the main widget for the view manager which | 83 | * Return the main widget for the view manager which | ||
91 | * holds all of the views managed by this ViewManager instance. | 84 | * holds all of the views managed by this ViewManager instance. | ||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | |||||
192 | /** | 185 | /** | ||
193 | * Returns whether the @p profile has the blur setting enabled | 186 | * Returns whether the @p profile has the blur setting enabled | ||
194 | */ | 187 | */ | ||
195 | static bool profileHasBlurEnabled(const Profile::Ptr &profile); | 188 | static bool profileHasBlurEnabled(const Profile::Ptr &profile); | ||
196 | 189 | | |||
197 | /** returns the active tab from the view | 190 | /** returns the active tab from the view | ||
198 | */ | 191 | */ | ||
199 | TabbedViewContainer *activeContainer(); | 192 | TabbedViewContainer *activeContainer(); | ||
193 | TerminalDisplay *createView(Session *session); | ||||
194 | void attachView(TerminalDisplay *terminal, Session *session); | ||||
195 | | ||||
196 | /** Reorder the terminal display history list */ | ||||
197 | void updateTerminalDisplayHistory(TerminalDisplay *terminalDisplay = nullptr, bool remove = false); | ||||
200 | 198 | | |||
201 | Q_SIGNALS: | 199 | Q_SIGNALS: | ||
202 | /** Emitted when the last view is removed from the view manager */ | 200 | /** Emitted when the last view is removed from the view manager */ | ||
203 | void empty(); | 201 | void empty(); | ||
204 | 202 | | |||
205 | /** Emitted when a session is detached from a view owned by this ViewManager */ | 203 | /** Emitted when a session is detached from a view owned by this ViewManager */ | ||
206 | void viewDetached(Session *session); | 204 | void viewDetached(Session *session); | ||
205 | void tabDetached(ViewSplitter *splitter, QHash<TerminalDisplay*, Session*> sessionsMap); | ||||
207 | 206 | | |||
208 | /** | 207 | /** | ||
209 | * Emitted when the active view changes. | 208 | * Emitted when the active view changes. | ||
210 | * @param controller The controller associated with the active view | 209 | * @param controller The controller associated with the active view | ||
211 | */ | 210 | */ | ||
212 | void activeViewChanged(SessionController *controller); | 211 | void activeViewChanged(SessionController *controller); | ||
213 | 212 | | |||
214 | /** | 213 | /** | ||
Show All 24 Lines | |||||
239 | * activated. | 238 | * activated. | ||
240 | */ | 239 | */ | ||
241 | void setMenuBarVisibleRequest(bool); | 240 | void setMenuBarVisibleRequest(bool); | ||
242 | void updateWindowIcon(); | 241 | void updateWindowIcon(); | ||
243 | 242 | | |||
244 | void blurSettingChanged(bool); | 243 | void blurSettingChanged(bool); | ||
245 | 244 | | |||
246 | /** Requests creation of a new view with the default profile. */ | 245 | /** Requests creation of a new view with the default profile. */ | ||
247 | void newViewRequest(TabbedViewContainer *tabWidget); | 246 | void newViewRequest(); | ||
248 | /** Requests creation of a new view, with the selected profile. */ | 247 | /** Requests creation of a new view, with the selected profile. */ | ||
249 | void newViewWithProfileRequest(TabbedViewContainer *tabWidget, const Profile::Ptr&); | 248 | void newViewWithProfileRequest(const Profile::Ptr&); | ||
250 | 249 | | |||
251 | public Q_SLOTS: | 250 | public Q_SLOTS: | ||
252 | /** DBus slot that returns the number of sessions in the current view. */ | 251 | /** DBus slot that returns the number of sessions in the current view. */ | ||
253 | Q_SCRIPTABLE int sessionCount(); | 252 | Q_SCRIPTABLE int sessionCount(); | ||
254 | 253 | | |||
255 | /** | 254 | /** | ||
256 | * DBus slot that returns the unique ids of the sessions in the | 255 | * DBus slot that returns the unique ids of the sessions in the | ||
257 | * current view. The returned list is not sorted. | 256 | * current view. The returned list is not sorted. | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
311 | 310 | | |||
312 | /** DBus slot that sets ALL tabs' width to match their text */ | 311 | /** DBus slot that sets ALL tabs' width to match their text */ | ||
313 | Q_SCRIPTABLE void setTabWidthToText(bool); | 312 | Q_SCRIPTABLE void setTabWidthToText(bool); | ||
314 | 313 | | |||
315 | private Q_SLOTS: | 314 | private Q_SLOTS: | ||
316 | // called when the "Split View Left/Right" menu item is selected | 315 | // called when the "Split View Left/Right" menu item is selected | ||
317 | void splitLeftRight(); | 316 | void splitLeftRight(); | ||
318 | void splitTopBottom(); | 317 | void splitTopBottom(); | ||
319 | void closeActiveContainer(); | | |||
320 | void closeOtherContainers(); | | |||
321 | void expandActiveContainer(); | 318 | void expandActiveContainer(); | ||
322 | void shrinkActiveContainer(); | 319 | void shrinkActiveContainer(); | ||
323 | 320 | | |||
324 | // called when the "Detach View" menu item is selected | 321 | // called when the "Detach View" menu item is selected | ||
325 | void detachActiveView(); | 322 | void detachActiveView(); | ||
323 | void detachActiveTab(); | ||||
326 | void updateDetachViewState(); | 324 | void updateDetachViewState(); | ||
327 | 325 | | |||
328 | // called when a session terminates - the view manager will delete any | 326 | // called when a session terminates - the view manager will delete any | ||
329 | // views associated with the session | 327 | // views associated with the session | ||
330 | void sessionFinished(); | 328 | void sessionFinished(); | ||
331 | // called when one view has been destroyed | 329 | // called when one view has been destroyed | ||
332 | void viewDestroyed(QWidget *view); | 330 | void viewDestroyed(QWidget *view); | ||
333 | 331 | | |||
334 | // controller detects when an associated view is given the focus | 332 | // controller detects when an associated view is given the focus | ||
335 | // and emits a signal. ViewManager listens for that signal | 333 | // and emits a signal. ViewManager listens for that signal | ||
336 | // and then plugs the action into the UI | 334 | // and then plugs the action into the UI | ||
337 | //void viewFocused( SessionController* controller ); | 335 | //void viewFocused( SessionController* controller ); | ||
338 | 336 | | |||
339 | // called when the active view in a ViewContainer changes, so | 337 | // called when the active view in a ViewContainer changes, so | ||
340 | // that we can plug the appropriate actions into the UI | 338 | // that we can plug the appropriate actions into the UI | ||
341 | void viewActivated(QWidget *view); | 339 | void viewActivated(TerminalDisplay *view); | ||
340 | | ||||
341 | void focusUp(); | ||||
342 | void focusDown(); | ||||
343 | void focusLeft(); | ||||
344 | void focusRight(); | ||||
342 | 345 | | |||
343 | // called when "Next View" shortcut is activated | 346 | // called when "Next View" shortcut is activated | ||
344 | void nextView(); | 347 | void nextView(); | ||
345 | 348 | | |||
346 | // called when "Previous View" shortcut is activated | 349 | // called when "Previous View" shortcut is activated | ||
347 | void previousView(); | 350 | void previousView(); | ||
348 | 351 | | |||
349 | // called when "Switch to last tab" shortcut is activated | 352 | // called when "Switch to last tab" shortcut is activated | ||
Show All 22 Lines | |||||
372 | 375 | | |||
373 | // moves active view to the left | 376 | // moves active view to the left | ||
374 | void moveActiveViewLeft(); | 377 | void moveActiveViewLeft(); | ||
375 | // moves active view to the right | 378 | // moves active view to the right | ||
376 | void moveActiveViewRight(); | 379 | void moveActiveViewRight(); | ||
377 | // switches to the view at visual position 'index' | 380 | // switches to the view at visual position 'index' | ||
378 | // in the current container | 381 | // in the current container | ||
379 | void switchToView(int index); | 382 | void switchToView(int index); | ||
383 | // gives focus and switches the terminal display, changing tab if needed | ||||
384 | void switchToTerminalDisplay(TerminalDisplay *terminalDisplay); | ||||
380 | 385 | | |||
381 | // called when a SessionController gains focus | 386 | // called when a SessionController gains focus | ||
382 | void controllerChanged(SessionController *controller); | 387 | void controllerChanged(SessionController *controller); | ||
383 | 388 | | |||
384 | // called when a ViewContainer requests a view be | 389 | // called when a ViewContainer requests a view be | ||
385 | // moved | 390 | // moved | ||
386 | void containerMoveViewRequest(int index, int sessionControllerId); | 391 | void containerMoveViewRequest(int index, int sessionControllerId); | ||
387 | 392 | | |||
388 | void detachView(TabbedViewContainer *container, QWidget *view); | 393 | void detachView(TabbedViewContainer *container, QWidget *view); | ||
389 | 394 | | |||
395 | /* Detaches the tab at index tabIdx */ | ||||
396 | void detachTab(int tabIdx); | ||||
397 | | ||||
390 | private: | 398 | private: | ||
391 | Q_DISABLE_COPY(ViewManager) | 399 | Q_DISABLE_COPY(ViewManager) | ||
392 | 400 | | |||
393 | void createView(Session *session, TabbedViewContainer *container, int index); | | |||
394 | static const ColorScheme *colorSchemeForProfile(const Profile::Ptr &profile); | 401 | static const ColorScheme *colorSchemeForProfile(const Profile::Ptr &profile); | ||
395 | 402 | | |||
396 | void setupActions(); | 403 | void setupActions(); | ||
397 | 404 | | |||
398 | // takes a view from a view container owned by a different manager and places it in | 405 | // takes a view from a view container owned by a different manager and places it in | ||
399 | // newContainer owned by this manager | 406 | // newContainer owned by this manager | ||
400 | void takeView(ViewManager *otherManager, TabbedViewContainer *otherContainer, | 407 | void takeView(ViewManager *otherManager, TabbedViewContainer *otherContainer, | ||
401 | TabbedViewContainer *newContainer, TerminalDisplay *view); | 408 | TabbedViewContainer *newContainer, TerminalDisplay *view); | ||
402 | void splitView(Qt::Orientation orientation); | 409 | void splitView(Qt::Orientation orientation); | ||
403 | 410 | | |||
404 | // creates a new container which can hold terminal displays | 411 | // creates a new container which can hold terminal displays | ||
405 | TabbedViewContainer *createContainer(); | 412 | TabbedViewContainer *createContainer(); | ||
406 | // removes a container and emits appropriate signals | | |||
407 | void removeContainer(TabbedViewContainer *container); | | |||
408 | 413 | | |||
409 | // creates a new terminal display | 414 | // creates a new terminal display | ||
410 | // the 'session' is used so that the terminal display's random seed | 415 | // the 'session' is used so that the terminal display's random seed | ||
411 | // can be set to something which depends uniquely on that session | 416 | // can be set to something which depends uniquely on that session | ||
412 | TerminalDisplay *createTerminalDisplay(Session *session = nullptr); | 417 | TerminalDisplay *createTerminalDisplay(Session *session = nullptr); | ||
413 | 418 | | |||
414 | // creates a new controller for a session/display pair which provides the menu | 419 | // creates a new controller for a session/display pair which provides the menu | ||
415 | // actions associated with that view, and exposes basic information | 420 | // actions associated with that view, and exposes basic information | ||
416 | // about the session ( such as title and associated icon ) to the display. | 421 | // about the session ( such as title and associated icon ) to the display. | ||
417 | SessionController *createController(Session *session, TerminalDisplay *view); | 422 | SessionController *createController(Session *session, TerminalDisplay *view); | ||
418 | 423 | | |||
424 | // Activates a different terminal when the TerminalDisplay | ||||
425 | // closes or is detached and another one should be focused. | ||||
426 | // It will activate the last used terminal within the same splitView | ||||
427 | // if possible otherwise it will focus the last used tab | ||||
428 | void focusAnotherTerminal(ViewSplitter *toplevelSplitter); | ||||
429 | | ||||
430 | void activateLastUsedView(bool reverse); | ||||
431 | | ||||
419 | private: | 432 | private: | ||
420 | QPointer<ViewSplitter> _viewSplitter; | 433 | QPointer<TabbedViewContainer> _viewContainer; | ||
421 | QPointer<SessionController> _pluggedController; | 434 | QPointer<SessionController> _pluggedController; | ||
422 | 435 | | |||
423 | QHash<TerminalDisplay *, Session *> _sessionMap; | 436 | QHash<TerminalDisplay *, Session *> _sessionMap; | ||
424 | 437 | | |||
425 | KActionCollection *_actionCollection; | 438 | KActionCollection *_actionCollection; | ||
426 | 439 | | |||
427 | NavigationMethod _navigationMethod; | 440 | NavigationMethod _navigationMethod; | ||
428 | NavigationVisibility _navigationVisibility; | 441 | NavigationVisibility _navigationVisibility; | ||
429 | NewTabBehavior _newTabBehavior; | 442 | NewTabBehavior _newTabBehavior; | ||
430 | int _managerId; | 443 | int _managerId; | ||
431 | static int lastManagerId; | 444 | static int lastManagerId; | ||
445 | QList<TerminalDisplay *> _terminalDisplayHistory; | ||||
446 | int _terminalDisplayHistoryIndex; | ||||
432 | }; | 447 | }; | ||
433 | } | 448 | } | ||
434 | 449 | | |||
435 | #endif | 450 | #endif |