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); | ||||
200 | 194 | | |||
201 | Q_SIGNALS: | 195 | Q_SIGNALS: | ||
202 | /** Emitted when the last view is removed from the view manager */ | 196 | /** Emitted when the last view is removed from the view manager */ | ||
203 | void empty(); | 197 | void empty(); | ||
204 | 198 | | |||
205 | /** Emitted when a session is detached from a view owned by this ViewManager */ | 199 | /** Emitted when a session is detached from a view owned by this ViewManager */ | ||
206 | void viewDetached(Session *session); | 200 | void viewDetached(Session *session); | ||
207 | 201 | | |||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 245 | public Q_SLOTS: | |||
311 | 305 | | |||
312 | /** DBus slot that sets ALL tabs' width to match their text */ | 306 | /** DBus slot that sets ALL tabs' width to match their text */ | ||
313 | Q_SCRIPTABLE void setTabWidthToText(bool); | 307 | Q_SCRIPTABLE void setTabWidthToText(bool); | ||
314 | 308 | | |||
315 | private Q_SLOTS: | 309 | private Q_SLOTS: | ||
316 | // called when the "Split View Left/Right" menu item is selected | 310 | // called when the "Split View Left/Right" menu item is selected | ||
317 | void splitLeftRight(); | 311 | void splitLeftRight(); | ||
318 | void splitTopBottom(); | 312 | void splitTopBottom(); | ||
319 | void closeActiveContainer(); | | |||
320 | void closeOtherContainers(); | | |||
321 | void expandActiveContainer(); | 313 | void expandActiveContainer(); | ||
322 | void shrinkActiveContainer(); | 314 | void shrinkActiveContainer(); | ||
323 | 315 | | |||
324 | // called when the "Detach View" menu item is selected | 316 | // called when the "Detach View" menu item is selected | ||
325 | void detachActiveView(); | 317 | void detachActiveView(); | ||
326 | void updateDetachViewState(); | 318 | void updateDetachViewState(); | ||
327 | 319 | | |||
328 | // called when a session terminates - the view manager will delete any | 320 | // called when a session terminates - the view manager will delete any | ||
329 | // views associated with the session | 321 | // views associated with the session | ||
330 | void sessionFinished(); | 322 | void sessionFinished(); | ||
331 | // called when one view has been destroyed | 323 | // called when one view has been destroyed | ||
332 | void viewDestroyed(QWidget *view); | 324 | void viewDestroyed(QWidget *view); | ||
333 | 325 | | |||
334 | // controller detects when an associated view is given the focus | 326 | // controller detects when an associated view is given the focus | ||
335 | // and emits a signal. ViewManager listens for that signal | 327 | // and emits a signal. ViewManager listens for that signal | ||
336 | // and then plugs the action into the UI | 328 | // and then plugs the action into the UI | ||
337 | //void viewFocused( SessionController* controller ); | 329 | //void viewFocused( SessionController* controller ); | ||
338 | 330 | | |||
339 | // called when the active view in a ViewContainer changes, so | 331 | // called when the active view in a ViewContainer changes, so | ||
340 | // that we can plug the appropriate actions into the UI | 332 | // that we can plug the appropriate actions into the UI | ||
341 | void viewActivated(QWidget *view); | 333 | void viewActivated(QWidget *view); | ||
342 | 334 | | |||
335 | void focusUp(); | ||||
336 | void focusDown(); | ||||
337 | void focusLeft(); | ||||
338 | void focusRight(); | ||||
339 | | ||||
343 | // called when "Next View" shortcut is activated | 340 | // called when "Next View" shortcut is activated | ||
344 | void nextView(); | 341 | void nextView(); | ||
345 | 342 | | |||
346 | // called when "Previous View" shortcut is activated | 343 | // called when "Previous View" shortcut is activated | ||
347 | void previousView(); | 344 | void previousView(); | ||
348 | 345 | | |||
349 | // called when "Switch to last tab" shortcut is activated | 346 | // called when "Switch to last tab" shortcut is activated | ||
350 | void lastView(); | 347 | void lastView(); | ||
Show All 31 Lines | |||||
382 | // moved | 379 | // moved | ||
383 | void containerMoveViewRequest(int index, int sessionControllerId); | 380 | void containerMoveViewRequest(int index, int sessionControllerId); | ||
384 | 381 | | |||
385 | void detachView(TabbedViewContainer *container, QWidget *view); | 382 | void detachView(TabbedViewContainer *container, QWidget *view); | ||
386 | 383 | | |||
387 | private: | 384 | private: | ||
388 | Q_DISABLE_COPY(ViewManager) | 385 | Q_DISABLE_COPY(ViewManager) | ||
389 | 386 | | |||
390 | void createView(Session *session, TabbedViewContainer *container, int index); | | |||
391 | static const ColorScheme *colorSchemeForProfile(const Profile::Ptr profile); | 387 | static const ColorScheme *colorSchemeForProfile(const Profile::Ptr profile); | ||
392 | 388 | | |||
393 | void setupActions(); | 389 | void setupActions(); | ||
394 | 390 | | |||
395 | // takes a view from a view container owned by a different manager and places it in | 391 | // takes a view from a view container owned by a different manager and places it in | ||
396 | // newContainer owned by this manager | 392 | // newContainer owned by this manager | ||
397 | void takeView(ViewManager *otherManager, TabbedViewContainer *otherContainer, | 393 | void takeView(ViewManager *otherManager, TabbedViewContainer *otherContainer, | ||
398 | TabbedViewContainer *newContainer, TerminalDisplay *view); | 394 | TabbedViewContainer *newContainer, TerminalDisplay *view); | ||
Show All 9 Lines | |||||
408 | // can be set to something which depends uniquely on that session | 404 | // can be set to something which depends uniquely on that session | ||
409 | TerminalDisplay *createTerminalDisplay(Session *session = nullptr); | 405 | TerminalDisplay *createTerminalDisplay(Session *session = nullptr); | ||
410 | 406 | | |||
411 | // creates a new controller for a session/display pair which provides the menu | 407 | // creates a new controller for a session/display pair which provides the menu | ||
412 | // actions associated with that view, and exposes basic information | 408 | // actions associated with that view, and exposes basic information | ||
413 | // about the session ( such as title and associated icon ) to the display. | 409 | // about the session ( such as title and associated icon ) to the display. | ||
414 | SessionController *createController(Session *session, TerminalDisplay *view); | 410 | SessionController *createController(Session *session, TerminalDisplay *view); | ||
415 | 411 | | |||
412 | // Activates a different terminal than the one passed by | ||||
413 | // that lives in the same tab. this is used when the TerminalDisplay | ||||
414 | // closes and another one should be focused. | ||||
415 | void focusAnotherTerminal(TerminalDisplay *lostFocus); | ||||
416 | | ||||
416 | private: | 417 | private: | ||
417 | QPointer<ViewSplitter> _viewSplitter; | 418 | QPointer<TabbedViewContainer> _viewContainer; | ||
418 | QPointer<SessionController> _pluggedController; | 419 | QPointer<SessionController> _pluggedController; | ||
419 | 420 | | |||
420 | QHash<TerminalDisplay *, Session *> _sessionMap; | 421 | QHash<TerminalDisplay *, Session *> _sessionMap; | ||
421 | 422 | | |||
422 | KActionCollection *_actionCollection; | 423 | KActionCollection *_actionCollection; | ||
423 | 424 | | |||
424 | NavigationMethod _navigationMethod; | 425 | NavigationMethod _navigationMethod; | ||
425 | NavigationVisibility _navigationVisibility; | 426 | NavigationVisibility _navigationVisibility; | ||
426 | NewTabBehavior _newTabBehavior; | 427 | NewTabBehavior _newTabBehavior; | ||
427 | int _managerId; | 428 | int _managerId; | ||
428 | static int lastManagerId; | 429 | static int lastManagerId; | ||
429 | }; | 430 | }; | ||
430 | } | 431 | } | ||
431 | 432 | | |||
432 | #endif | 433 | #endif |