diff --git a/src/BookmarkHandler.h b/src/BookmarkHandler.h index cfba07fe..7be535ed 100644 --- a/src/BookmarkHandler.h +++ b/src/BookmarkHandler.h @@ -1,128 +1,127 @@ /* This file was part of the KDE libraries Copyright 2002 Carsten Pfeiffer Copyright 2007-2008 Robert Knight library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation, version 2 or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Born as kdelibs/kio/kfile/kfilebookmarkhandler.h #ifndef BOOKMARKHANDLER_H #define BOOKMARKHANDLER_H // KDE #include -#include - // Konsole #include "konsoleprivate_export.h" class QMenu; +class QUrl; class KActionCollection; namespace Konsole { class ViewProperties; /** * This class handles the communication between the bookmark menu and the active session, * providing a suggested title and URL when the user clicks the "Add Bookmark" item in * the bookmarks menu. * * The bookmark handler is associated with a session controller, which is used to * determine the working URL of the current session. When the user changes the active * view, the bookmark handler's controller should be changed using setController() * * When the user selects a bookmark, the openUrl() signal is emitted. */ class KONSOLEPRIVATE_EXPORT BookmarkHandler : public QObject, public KBookmarkOwner { Q_OBJECT public: /** * Constructs a new bookmark handler for Konsole bookmarks. * * @param collection The collection which the bookmark menu's actions should be added to * @param menu The menu which the bookmark actions should be added to * @param toplevel TODO: Document me * @param parent The parent object */ BookmarkHandler(KActionCollection *collection, QMenu *menu, bool toplevel, QObject *parent); ~BookmarkHandler() Q_DECL_OVERRIDE; QUrl currentUrl() const Q_DECL_OVERRIDE; QString currentTitle() const Q_DECL_OVERRIDE; QString currentIcon() const Q_DECL_OVERRIDE; bool enableOption(BookmarkOption option) const Q_DECL_OVERRIDE; void openFolderinTabs(const KBookmarkGroup &group) Q_DECL_OVERRIDE; /** * Returns the menu which this bookmark handler inserts its actions into. */ QMenu *menu() const { return _menu; } QList views() const; ViewProperties *activeView() const; public Q_SLOTS: /** * */ void setViews(const QList &views); void setActiveView(ViewProperties *view); Q_SIGNALS: /** * Emitted when the user selects a bookmark from the bookmark menu. * * @param url The url of the bookmark which was selected by the user. */ void openUrl(const QUrl &url); /** * Emitted when the user selects 'Open Folder in Tabs' * from the bookmark menu. * * @param urls The urls of the bookmarks in the folder whose * 'Open Folder in Tabs' action was triggered */ void openUrls(const QList &urls); private Q_SLOTS: void openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(BookmarkHandler) QString titleForView(ViewProperties *view) const; QUrl urlForView(ViewProperties *view) const; QString iconForView(ViewProperties *view) const; QMenu *_menu; QString _file; bool _toplevel; ViewProperties *_activeView; QList _views; }; } #endif // BOOKMARKHANDLER_H diff --git a/src/MainWindow.h b/src/MainWindow.h index 1d5f505c..89958fc0 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -1,206 +1,204 @@ /* Copyright 2006-2008 by Robert Knight This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H // Qt #include #include // KDE #include // Konsole #include "Profile.h" #include "ViewSplitter.h" class QAction; class KActionMenu; class KToggleAction; namespace Konsole { -class IncrementalSearchBar; class ViewManager; class ViewProperties; class Session; class SessionController; class ProfileList; class BookmarkHandler; -class TabbedViewContainer; /** * The main window. This contains the menus and an area which contains the terminal displays. * * The main window does not create the views or the container widgets which hold the views. * This is done by the ViewManager class. When a MainWindow is instantiated, it creates * a new ViewManager. The ViewManager can then be used to create new terminal displays * inside the window. * * Do not construct new main windows directly, use Application's newMainWindow() method. */ class MainWindow : public KXmlGuiWindow { Q_OBJECT public: /** * Constructs a new main window. Do not create new main windows directly, use Application's * newMainWindow() method instead. */ MainWindow(); /** * Returns the view manager associated with this window. The view manager can be used to * create new views on particular session objects inside this window. */ ViewManager *viewManager() const; /** * Create a new session. * * @param profile The profile to use to create the new session. * @param directory Initial working directory for the new session or empty * if the default working directory associated with the profile should be used. */ Session *createSession(Profile::Ptr profile, const QString &directory); /** * create a new SSH session. * * @param profile The profile to use to create the new session. * @param url the URL representing the new SSH connection */ Session *createSSHSession(Profile::Ptr profile, const QUrl &url); /** * Helper method to make this window get input focus */ void setFocus(); /** * Set the initial visibility of the menubar. */ void setMenuBarInitialVisibility(bool visible); /** * @brief Set the frameless state * * @param frameless If true, no titlebar or frame is displayed. */ void setRemoveWindowTitleBarAndFrame(bool frameless); Q_SIGNALS: /** * Emitted by the main window to request the creation of a * new session in a new window. * * @param profile The profile to use to create the * first session in the new window. * @param directory Initial working directory for the new window or empty * if the default working directory associated with the profile should * be used. */ void newWindowRequest(const Profile::Ptr &profile, const QString &directory); /** * Emitted when a view for one session is detached from this window */ void terminalsDetached(ViewSplitter *splitter, QHash sessionsMap); protected: // Reimplemented for internal reasons. void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; // reimplemented from KMainWindow bool queryClose() Q_DECL_OVERRIDE; void saveProperties(KConfigGroup &group) Q_DECL_OVERRIDE; void readProperties(const KConfigGroup &group) Q_DECL_OVERRIDE; void saveGlobalProperties(KConfig *config) Q_DECL_OVERRIDE; void readGlobalProperties(KConfig *config) Q_DECL_OVERRIDE; // reimplemented from QWidget bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; private Q_SLOTS: void newTab(); void cloneTab(); void newWindow(); void showManageProfilesDialog(); void activateMenuBar(); void showSettingsDialog(bool showProfilePage = false); void showShortcutsDialog(); void newFromProfile(const Profile::Ptr &profile); void activeViewChanged(SessionController *controller); void disconnectController(SessionController *controller); void activeViewTitleChanged(ViewProperties *); void profileListChanged(const QList &sessionActions); void configureNotifications(); void setBlur(bool blur); void updateWindowIcon(); void updateWindowCaption(); void openUrls(const QList &urls); // Sets the list of profiles to be displayed under the "New Tab" action void setProfileList(ProfileList *list); void applyKonsoleSettings(); void updateUseTransparency(); public Q_SLOTS: void viewFullScreen(bool fullScreen); private: void correctStandardShortcuts(); void rememberMenuAccelerators(); void removeMenuAccelerators(); void restoreMenuAccelerators(); void setupActions(); QString activeSessionDir() const; void triggerAction(const QString &name) const; /** * Returns the bookmark handler associated with this window. */ BookmarkHandler *bookmarkHandler() const; // sets the active shortcuts of actions in 'dest' to the shortcuts of actions // with the same name in 'source' (see QAction::ActiveShortcut) static void syncActiveShortcuts(KActionCollection *dest, const KActionCollection *source); private: ViewManager *_viewManager; BookmarkHandler *_bookmarkHandler; KToggleAction *_toggleMenuBarAction; KActionMenu *_newTabMenuAction; QPointer _pluggedController; bool _menuBarInitialVisibility; bool _menuBarInitialVisibilityApplied; }; } #endif // MAINWINDOW_H diff --git a/src/Part.h b/src/Part.h index 41bce76a..7be16021 100644 --- a/src/Part.h +++ b/src/Part.h @@ -1,224 +1,223 @@ /* Copyright 2007-2008 by Robert Knight This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PART_H #define PART_H // KDE #include #include #include // Qt #include // Konsole #include "config-konsole.h" #include "Profile.h" -class QAction; class QStringList; class QKeyEvent; namespace Konsole { class Session; class SessionController; class ViewManager; class ViewProperties; /** * A re-usable terminal emulator component using the KParts framework which can * be used to embed terminal emulators into other applications. */ #ifdef USE_TERMINALINTERFACEV2 class Part : public KParts::ReadOnlyPart, public TerminalInterfaceV2 { Q_OBJECT Q_INTERFACES(TerminalInterface TerminalInterfaceV2) #else class TerminalInterfaceV2; class Part : public KParts::ReadOnlyPart, public TerminalInterface { Q_OBJECT Q_INTERFACES(TerminalInterface) #endif public: /** Constructs a new Konsole part with the specified parent. */ explicit Part(QWidget *parentWidget, QObject *parent, const QVariantList &); ~Part() Q_DECL_OVERRIDE; /** Reimplemented from TerminalInterface. */ void startProgram(const QString &program, const QStringList &arguments) override; /** Reimplemented from TerminalInterface. */ void showShellInDir(const QString &dir) override; /** Reimplemented from TerminalInterface. */ void sendInput(const QString &text) override; /** Reimplemented from TerminalInterface. */ int terminalProcessId() override; /** Reimplemented from TerminalInterface. */ int foregroundProcessId() override; /** Reimplemented from TerminalInterface. */ QString foregroundProcessName() override; /** Reimplemented from TerminalInterface. */ QString currentWorkingDirectory() const override; #ifdef USE_TERMINALINTERFACEV2 /** Reimplemented from TerminalInterfaceV2 */ QStringList availableProfiles() const override; /** Reimplemented from TerminalInterfaceV2 */ QString currentProfileName() const override; /** Reimplemented from TerminalInterfaceV2 */ bool setCurrentProfile(const QString &profileName) override; /** Reimplemented from TerminalInterfaceV2 */ QVariant profileProperty(const QString &profileProperty) const override; #endif public Q_SLOTS: /** * creates and run a session using the specified profile and directory * * @param profileName Specifies the name of the profile to create session * @param directory specifies The initial working directory of the created session * * This is highly experimental. Do not use it at the moment */ void createSession(const QString &profileName = QString(), const QString &directory = QString()); void showManageProfilesDialog(QWidget* parent); /** * Shows the dialog used to edit the profile used by the active session. The * dialog will be non-modal and will delete itself when it is closed. * * This is experimental API and not guaranteed to be present in later KDE 4 * releases. * * @param parent The parent widget of the new dialog. */ void showEditCurrentProfileDialog(QWidget *parent); /** * Sends a profile change command to the active session. This is equivalent to using * the konsoleprofile tool within the session to change its settings. The @p text string * is a semi-colon separated list of property=value pairs, eg. "colors=Linux Colors" * * See the documentation for konsoleprofile for information on the format of @p text * * This is experimental API and not guaranteed to be present in later KDE 4 releases. */ void changeSessionSettings(const QString &text); /** * Connects to an existing pseudo-teletype. See Session::openTeletype(). * This must be called before the session is started by startProgram(), * or showShellInDir() * * @param ptyMasterFd The file descriptor of the pseudo-teletype (pty) master */ void openTeletype(int ptyMasterFd); /** * Toggles monitoring for silence in the active session. If silence is detected, * the silenceDetected() signal is emitted. * * @param enabled Whether to enable or disable monitoring for silence. * */ void setMonitorSilenceEnabled(bool enabled); /** * Toggles monitoring for activity in the active session. If activity is detected, * the activityDetected() signal is emitted. * * @param enabled Whether to enable or disable monitoring for activity. * */ void setMonitorActivityEnabled(bool enabled); /** * Returns the status of the blur of the current profile. * * @return True if blur is enabled for the current active Konsole color profile. * */ bool isBlurEnabled(); Q_SIGNALS: /** * Emitted when the key sequence for a shortcut, which is also a valid terminal key sequence, * is pressed while the terminal has focus. By responding to this signal, the * controlling application can choose whether to execute the action associated with * the shortcut or ignore the shortcut and send the key * sequence to the terminal application. * * In the embedded terminal, shortcuts are overridden and sent to the terminal by default. * Set @p override to false to prevent this happening and allow the shortcut to be triggered * normally. * * overrideShortcut() is not called for shortcuts which are not valid terminal key sequences, * eg. shortcuts with two or more modifiers. * * @param event Describes the keys that were pressed. * @param override Set this to false to prevent the terminal display from overriding the shortcut */ void overrideShortcut(QKeyEvent *event, bool &override); /** * Emitted when silence has been detected in the active session. Monitoring * for silence has to be enabled first using setMonitorSilenceEnabled(). */ void silenceDetected(); /** * Emitted when activity has been detected in the active session. Monitoring * for activity has to be enabled first using setMonitorActivityEnabled(). */ void activityDetected(); /** * Emitted when the current working directory of the active session has changed. */ void currentDirectoryChanged(const QString &dir); protected: /** Reimplemented from KParts::PartBase. */ bool openFile() Q_DECL_OVERRIDE; bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; private Q_SLOTS: void activeViewChanged(SessionController *controller); void activeViewTitleChanged(ViewProperties *properties); void terminalExited(); void newTab(); void overrideTerminalShortcut(QKeyEvent *, bool &override); void sessionStateChanged(int state); private: Session *activeSession() const; private: ViewManager *_viewManager; SessionController *_pluggedController; }; } #endif // PART_H diff --git a/src/SessionController.h b/src/SessionController.h index 01d22662..43809a04 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -1,371 +1,370 @@ /* Copyright 2006-2008 by Robert Knight Copyright 2009 by Thomas Dreibholz This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef SESSIONCONTROLLER_H #define SESSIONCONTROLLER_H // Qt #include #include #include #include // KDE #include // Konsole #include "ViewProperties.h" #include "Profile.h" #include "Enumeration.h" namespace KIO { class Job; } class QAction; class QTextCodec; class QKeyEvent; class QTimer; class QUrl; class KCodecAction; -class KJob; class QAction; class KActionMenu; namespace Konsole { class Session; class SessionGroup; class ScreenWindow; class TerminalDisplay; class IncrementalSearchBar; class ProfileList; class RegExpFilter; class UrlFilter; class FileFilter; class EditProfileDialog; using SessionPtr = QPointer; /** * Provides the menu actions to manipulate a single terminal session and view pair. * The actions provided by this class are defined in the sessionui.rc XML file. * * SessionController monitors the session and provides access to basic information * about the session such as title(), icon() and currentDir(). SessionController * provides notifications of activity in the session via the activity() signal. * * When the controlled view receives the focus, the focused() signal is emitted * with a pointer to the controller. This can be used by main application window * which contains the view to plug the controller's actions into the menu when * the view is focused. */ class KONSOLEPRIVATE_EXPORT SessionController : public ViewProperties, public KXMLGUIClient { Q_OBJECT public: enum CopyInputToEnum { /** Copy keyboard input to all the other tabs in current window */ CopyInputToAllTabsMode = 0, /** Copy keyboard input to user selected tabs in current window */ CopyInputToSelectedTabsMode = 1, /** Do not copy keyboard input to other tabs */ CopyInputToNoneMode = 2 }; /** * Constructs a new SessionController which operates on @p session and @p view. */ SessionController(Session *session, TerminalDisplay *view, QObject *parent); ~SessionController() Q_DECL_OVERRIDE; /** Returns the session associated with this controller */ QPointer session() { return _session; } /** Returns the view associated with this controller */ QPointer view() { return _view; } /** * Returns the "window title" of the associated session. */ QString userTitle() const; /** * Returns true if the controller is valid. * A valid controller is one which has a non-null session() and view(). * * Equivalent to "!session().isNull() && !view().isNull()" */ bool isValid() const; /** Set the start line from which the next search will be done **/ void setSearchStartTo(int line); /** set start line to the first or last line (depending on the reverse search * setting) in the terminal display **/ void setSearchStartToWindowCurrentLine(); /** * Sets the action displayed in the session's context menu to hide or * show the menu bar. */ void setShowMenuAction(QAction *action); EditProfileDialog *profileDialogPointer(); // reimplemented QUrl url() const Q_DECL_OVERRIDE; QString currentDir() const Q_DECL_OVERRIDE; void rename() Q_DECL_OVERRIDE; bool confirmClose() const Q_DECL_OVERRIDE; virtual bool confirmForceClose() const; // Reimplemented to watch for events happening to the view bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; /** Returns the set of all controllers that exist. */ static QSet allControllers() { return _allControllers; } /* Returns true if called within a KPart; false if called within Konsole. */ bool isKonsolePart() const; bool isReadOnly() const; Q_SIGNALS: /** * Emitted when the view associated with the controller is focused. * This can be used by other classes to plug the controller's actions into a window's * menus. */ void focused(SessionController *controller); void rawTitleChanged(); /** * Emitted when the current working directory of the session associated with * the controller is changed. */ void currentDirectoryChanged(const QString &dir); /** * Emitted when the user changes the tab title. */ void tabRenamedByUser(bool renamed) const; public Q_SLOTS: /** * Issues a command to the session to navigate to the specified URL. * This may not succeed if the foreground program does not understand * the command sent to it ( 'cd path' for local URLs ) or is not * responding to input. * * openUrl() currently supports urls for local paths and those * using the 'ssh' protocol ( eg. "ssh://joebloggs@hostname" ) */ void openUrl(const QUrl &url); /** * update actions which are meaningful only when primary screen is in use. */ void setupPrimaryScreenSpecificActions(bool use); /** * update actions which are closely related with the selected text. */ void selectionChanged(const QString &selectedText); /** * close the associated session. This might involve user interaction for * confirmation. */ void closeSession(); /** Increase font size */ void increaseFontSize(); /** Decrease font size */ void decreaseFontSize(); /** Reset font size */ void resetFontSize(); /** Close the incremental search */ void searchClosed(); // called when the user clicks on the private Q_SLOTS: // menu item handlers void openBrowser(); void copy(); void paste(); void selectAll(); void selectLine(); void pasteFromX11Selection(); // shortcut only void copyInputActionsTriggered(QAction *action); void copyInputToAllTabs(); void copyInputToSelectedTabs(); void copyInputToNone(); void editCurrentProfile(); void changeCodec(QTextCodec *codec); void enableSearchBar(bool showSearchBar); void searchHistory(bool showSearchBar); void searchBarEvent(); void searchFrom(); void findNextInHistory(); void findPreviousInHistory(); void changeSearchMatch(); void print_screen(); void saveHistory(); void showHistoryOptions(); void clearHistory(); void clearHistoryAndReset(); void monitorActivity(bool monitor); void monitorSilence(bool monitor); void renameSession(); void switchProfile(const Profile::Ptr &profile); void handleWebShortcutAction(); void configureWebShortcuts(); void sendSignal(QAction *action); void sendBackgroundColor(); void toggleReadOnly(); // other void setupSearchBar(); void prepareSwitchProfileMenu(); void updateCodecAction(); void showDisplayContextMenu(const QPoint &position); void movementKeyFromSearchBarReceived(QKeyEvent *event); void sessionStateChanged(int state); void sessionAttributeChanged(); void sessionReadOnlyChanged(); void searchTextChanged(const QString &text); void searchCompleted(bool success); void updateFilterList(Profile::Ptr profile); // Called when the profile has changed, so we might need to change the list of filters void interactionHandler(); void snapshot(); // called periodically as the user types // to take a snapshot of the state of the // foreground process in the terminal void highlightMatches(bool highlight); void scrollBackOptionsChanged(int mode, int lines); void sessionResizeRequest(const QSize &size); void trackOutput(QKeyEvent *event); // move view to end of current output // when a key press occurs in the // display area void updateSearchFilter(); void zmodemDownload(); void zmodemUpload(); // update actions related with selected text void updateCopyAction(const QString &selectedText); void updateWebSearchMenu(); private: Q_DISABLE_COPY(SessionController) // begins the search // text - pattern to search for // direction - value from SearchHistoryTask::SearchDirection enum to specify // the search direction void beginSearch(const QString &text, Enum::SearchDirection direction); QRegularExpression regexpFromSearchBarOptions() const; bool reverseSearchChecked() const; void setupCommonActions(); void setupExtraActions(); void removeSearchFilter(); // remove and delete the current search filter if set void setFindNextPrevEnabled(bool enabled); void listenForScreenWindowUpdates(); private: void updateSessionIcon(); void updateReadOnlyActionStates(); QPointer _session; QPointer _view; SessionGroup *_copyToGroup; ProfileList *_profileList; QIcon _sessionIcon; QString _sessionIconName; int _previousState; RegExpFilter *_searchFilter; UrlFilter *_urlFilter; FileFilter *_fileFilter; QAction *_copyInputToAllTabsAction; QAction *_findAction; QAction *_findNextAction; QAction *_findPreviousAction; QTimer *_interactionTimer; int _searchStartLine; int _prevSearchResultLine; KCodecAction *_codecAction; KActionMenu *_switchProfileMenu; KActionMenu *_webSearchMenu; bool _listenForScreenWindowUpdates; bool _preventClose; bool _keepIconUntilInteraction; QString _selectedText; QAction *_showMenuAction; static QSet _allControllers; static int _lastControllerId; QStringList _bookmarkValidProgramsToClear; bool _isSearchBarEnabled; QPointer _editProfileDialog; QString _searchText; QPointer _searchBar; }; inline bool SessionController::isValid() const { return !_session.isNull() && !_view.isNull(); } } #endif //SESSIONCONTROLLER_H diff --git a/src/ViewContainer.h b/src/ViewContainer.h index f66c737a..5932f3bc 100644 --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -1,226 +1,223 @@ /* This file is part of the Konsole Terminal. Copyright 2006-2008 Robert Knight This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef VIEWCONTAINER_H #define VIEWCONTAINER_H // Qt #include #include // Konsole #include "Profile.h" #include "ViewManager.h" // Qt class QPoint; class QToolButton; class QMenu; -class QDropEvent; -class QDragEnterEvent; namespace Konsole { -class IncrementalSearchBar; class ViewProperties; class ViewManager; class TabbedViewContainer; /** * An interface for container widgets which can hold one or more views. * * The container widget typically displays a list of the views which * it has and provides a means of switching between them. * * Subclasses should reimplement the addViewWidget() and removeViewWidget() functions * to actually add or remove view widgets from the container widget, as well * as updating any navigation aids. */ class KONSOLEPRIVATE_EXPORT TabbedViewContainer : public QTabWidget { Q_OBJECT public: /** * Constructs a new view container with the specified parent. * * @param connectedViewManager Connect the new view to this manager * @param parent The parent object of the container */ TabbedViewContainer(ViewManager *connectedViewManager, QWidget *parent); /** * Called when the ViewContainer is destroyed. When reimplementing this in * subclasses, use object->deleteLater() to delete any widgets or other objects * instead of 'delete object'. */ ~TabbedViewContainer() Q_DECL_OVERRIDE; /** Adds a new view to the container widget */ void addView(TerminalDisplay *view); void addSplitter(ViewSplitter *splitter, int index = -1); /** splits the currently focused Splitter */ void splitView(TerminalDisplay *view, Qt::Orientation orientation); void setTabActivity(int index, bool activity); void updateTitle(ViewProperties *item); void updateIcon(ViewProperties *item); void updateActivity(ViewProperties *item); /** Changes the active view to the next view */ void activateNextView(); /** Changes the active view to the previous view */ void activatePreviousView(); /** Changes the active view to the last view */ void activateLastView(); void setCss(const QString& styleSheet = QString()); void setCssFromFile(const QUrl& url); ViewSplitter *activeViewSplitter(); /** * This enum describes the directions * in which views can be re-arranged within the container * using the moveActiveView() method. */ enum MoveDirection { /** Moves the view to the left. */ MoveViewLeft, /** Moves the view to the right. */ MoveViewRight }; /** * Moves the active view within the container and * updates the order in which the views are shown * in the container's navigation widget. * * The default implementation does nothing. */ void moveActiveView(MoveDirection direction); /** Sets the menu to be shown when the new view button is clicked. * Only valid if the QuickNewView feature is enabled. * The default implementation does nothing. */ // TODO: Reenable this later. // void setNewViewMenu(QMenu *menu); void renameTab(int index); ViewManager *connectedViewManager(); void currentTabChanged(int index); void closeCurrentTab(); void wheelScrolled(int delta); void currentSessionControllerChanged(SessionController *controller); void tabDoubleClicked(int index); void openTabContextMenu(const QPoint &point); void setNavigationVisibility(ViewManager::NavigationVisibility navigationVisibility); void moveTabToWindow(int index, QWidget *window); void toggleMaximizeCurrentTerminal(); /* return the widget(int index) casted to TerminalDisplay* * * The only thing that this class holds are TerminalDisplays, so * this is the only thing that should be used to retrieve widgets. */ ViewSplitter *viewSplitterAt(int index); void connectTerminalDisplay(TerminalDisplay *view); void disconnectTerminalDisplay(TerminalDisplay *view); void moveTabLeft(); void moveTabRight(); /** * This enum describes where newly created tab should be placed. */ enum NewTabBehavior { /** Put newly created tab at the end. */ PutNewTabAtTheEnd = 0, /** Put newly created tab right after current tab. */ PutNewTabAfterCurrentTab = 1 }; void setNavigationBehavior(int behavior); void terminalDisplayDropped(TerminalDisplay* terminalDisplay); QSize sizeHint() const override; Q_SIGNALS: /** Emitted when the container has no more children */ void empty(TabbedViewContainer *container); /** Emitted when the user requests to open a new view */ void newViewRequest(); /** Requests creation of a new view, with the selected profile. */ void newViewWithProfileRequest(const Profile::Ptr&); /** a terminalDisplay was dropped in a child Splitter */ /** * Emitted when the user requests to move a view from another container * into this container. If 'success' is set to true by a connected slot * then the original view will be removed. * * @param index Index at which to insert the new view in the container * or -1 to append it. This index should be passed to addView() when * the new view has been created. * @param sessionControllerId The identifier of the view. */ void moveViewRequest(int index, int sessionControllerId); /** Emitted when the active view changes */ void activeViewChanged(TerminalDisplay *view); /** Emitted when a view is added to the container. */ void viewAdded(TerminalDisplay *view); /** Emitted when a view is removed from the container. */ void viewRemoved(TerminalDisplay *view); /** detach the specific tab */ void detachTab(int tabIdx); protected: // close tabs and unregister void closeTerminalTab(int idx); void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; private Q_SLOTS: void viewDestroyed(QObject *view); void konsoleConfigChanged(); private: void forgetView(ViewSplitter *view); ViewManager *_connectedViewManager; QMenu *_contextPopupMenu; QToolButton *_newTabButton; QToolButton *_closeTabButton; int _contextMenuTabIndex; ViewManager::NavigationVisibility _navigationVisibility; NewTabBehavior _newTabBehavior; }; } #endif //VIEWCONTAINER_H diff --git a/src/ViewSplitter.h b/src/ViewSplitter.h index e13b3fb9..81169a0a 100644 --- a/src/ViewSplitter.h +++ b/src/ViewSplitter.h @@ -1,147 +1,146 @@ /* This file is part of the Konsole Terminal. Copyright 2006-2008 Robert Knight This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef VIEWSPLITTER_H #define VIEWSPLITTER_H // Qt #include // Konsole #include "konsoleprivate_export.h" -class QFocusEvent; class QDragMoveEvent; class QDragEnterEvent; class QDropEvent; class QDragLeaveEvent; namespace Konsole { class TerminalDisplay; /** * A splitter which holds a number of ViewContainer objects and allows * the user to control the size of each view container by dragging a splitter * bar between them. * * Each splitter can also contain child ViewSplitter widgets, allowing * for a hierarchy of view splitters and containers. * * The addContainer() method is used to split the existing view and * insert a new view container. * Containers can only be removed from the hierarchy by deleting them. */ class KONSOLEPRIVATE_EXPORT ViewSplitter : public QSplitter { Q_OBJECT public: explicit ViewSplitter(QWidget *parent = nullptr); enum class AddBehavior {AddBefore, AddAfter}; /** * Locates the child ViewSplitter widget which currently has the focus * and inserts the container into it. * * @param terminalDisplay The container to insert * @param containerOrientation Specifies whether the view should be split * horizontally or vertically. If the orientation * is the same as the ViewSplitter into which the * container is to be inserted, or if the splitter * has fewer than two child widgets then the container * will be added to that splitter. If the orientation * is different, then a new child splitter * will be created, into which the container will * be inserted. * @param behavior Specifies whether to add new terminal after current * tab or at end. */ void addTerminalDisplay(TerminalDisplay* terminalDisplay, Qt::Orientation containerOrientation, AddBehavior behavior = AddBehavior::AddAfter); /** Returns the child ViewSplitter widget which currently has the focus */ ViewSplitter *activeSplitter(); /** * Returns the container which currently has the focus or 0 if none * of the immediate child containers have the focus. This does not * search through child splitters. activeSplitter() can be used * to search recursively through child splitters for the splitter * which currently has the focus. * * To find the currently active container, use * mySplitter->activeSplitter()->activeContainer() where mySplitter * is the ViewSplitter widget at the top of the hierarchy. */ TerminalDisplay *activeTerminalDisplay() const; /** Makes the current TerminalDisplay expanded to 100% of the view */ void toggleMaximizeCurrentTerminal(); void handleMinimizeMaximize(bool maximize); /** returns the splitter that has no splitter as a parent. */ ViewSplitter *getToplevelSplitter(); /** * Changes the size of the specified @p container by a given @p percentage. * @p percentage may be positive ( in which case the size of the container * is increased ) or negative ( in which case the size of the container * is decreased ). * * The sizes of the remaining containers are increased or decreased * uniformly to maintain the width of the splitter. */ void adjustActiveTerminalDisplaySize(int percentage); void focusUp(); void focusDown(); void focusLeft(); void focusRight(); void handleFocusDirection(Qt::Orientation orientation, int direction); void childEvent(QChildEvent* event) override; bool terminalMaximized() const { return m_terminalMaximized; } protected: void dragEnterEvent(QDragEnterEvent *ev) override; void dragMoveEvent(QDragMoveEvent *ev) override; void dragLeaveEvent(QDragLeaveEvent * event) override; void dropEvent(QDropEvent *ev) override; Q_SIGNALS: void terminalDisplayDropped(TerminalDisplay *terminalDisplay); private: /** recursively walks the object tree looking for Splitters and * TerminalDisplays, hidding the ones that should be hidden. * If a terminal display is not hidden in a subtree, we cannot * hide the whole tree. * * @p currentTerminalDisplay the only terminal display that will still be visible. */ bool hideRecurse(TerminalDisplay *currentTerminalDisplay); void updateSizes(); bool m_terminalMaximized = false; }; } #endif //VIEWSPLITTER_H diff --git a/src/ZModemDialog.h b/src/ZModemDialog.h index 3bb0f6a8..bdfd2258 100644 --- a/src/ZModemDialog.h +++ b/src/ZModemDialog.h @@ -1,66 +1,65 @@ /* This file is part of the KDE libraries * Copyright 2002 Waldo Bastian * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation; * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. **/ #ifndef ZMODEM_DIALOG_H #define ZMODEM_DIALOG_H #include class KTextEdit; class QDialogButtonBox; -class QPushButton; namespace Konsole { class ZModemDialog : public QDialog { Q_OBJECT public: ZModemDialog(QWidget *parent, bool modal, const QString &caption); /** * Adds a line of text to the progress window */ void addText(const QString &); /** * Adds a line of text without a new line to the progress window */ void addProgressText(const QString &); /** * To indicate the process is finished. */ void transferDone(); Q_SIGNALS: void zmodemCancel(); private Q_SLOTS: void slotClose(); void slotCancel(); private: Q_DISABLE_COPY(ZModemDialog) void delayedDestruct(); KTextEdit *_textEdit; QDialogButtonBox *mButtonBox; }; } #endif diff --git a/src/settings/ProfileSettings.h b/src/settings/ProfileSettings.h index 10fd59d0..66b09366 100644 --- a/src/settings/ProfileSettings.h +++ b/src/settings/ProfileSettings.h @@ -1,164 +1,163 @@ /* Copyright 2007-2008 by Robert Knight This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PROFILESETTINGS_H #define PROFILESETTINGS_H // Qt #include #include #include // KDE // Konsole #include "Profile.h" #include "ui_ProfileSettings.h" class QItemSelection; -class QShowEvent; class QStandardItem; class QStandardItemModel; namespace Konsole { /** * A dialog which lists the available types of profiles and allows * the user to add new profiles, and remove or edit existing * profile types. */ class ProfileSettings : public QWidget, private Ui::ProfileSettings { Q_OBJECT friend class ShortcutItemDelegate; public: /** Constructs a new profile type with the specified parent. */ explicit ProfileSettings(QWidget *parent = nullptr); ~ProfileSettings() Q_DECL_OVERRIDE; /** * Specifies whether the shortcut editor should be show. * The shortcut editor allows shortcuts to be associated with * profiles. When a shortcut is changed, the dialog will call * SessionManager::instance()->setShortcut() to update the shortcut * associated with the profile. * * By default the editor is visible. */ void setShortcutEditorVisible(bool visible); protected: private Q_SLOTS: void slotAccepted(); void deleteSelected(); void setSelectedAsDefault(); void createProfile(); void editSelected(); void itemDataChanged(QStandardItem *item); // enables or disables Edit/Delete/Set as Default buttons when the // selection changes void tableSelectionChanged(const QItemSelection &); void updateFavoriteStatus(const Profile::Ptr &profile, bool favorite); void addItems(const Profile::Ptr&); void updateItems(const Profile::Ptr&); void removeItems(const Profile::Ptr&); // double clicking the profile name opens the edit profile dialog void doubleClicked(const QModelIndex &index); private: Profile::Ptr currentProfile() const; QList selectedProfiles() const; bool isProfileDeletable(Profile::Ptr profile) const; // updates the font of the items to match // their default / non-default profile status void updateDefaultItem(); void updateItemsForProfile(const Profile::Ptr &profile,const QList &items) const; void updateShortcutField(QStandardItem *item, bool isFavorite) const; // updates the profile table to be in sync with the // session manager void populateTable(); int rowForProfile(const Profile::Ptr &profile) const; QStandardItemModel *_sessionModel; enum Column { FavoriteStatusColumn = 0, ProfileNameColumn = 1, ShortcutColumn = 2, ProfileColumn = 3, }; enum Role { ProfilePtrRole = Qt::UserRole + 1, ShortcutRole, }; }; class StyledBackgroundPainter { public: static void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); }; class FilteredKeySequenceEdit: public QKeySequenceEdit { Q_OBJECT public: explicit FilteredKeySequenceEdit(QWidget *parent = nullptr): QKeySequenceEdit(parent) {} protected: void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; }; class ShortcutItemDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit ShortcutItemDelegate(QObject *parent = nullptr); void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; void destroyEditor(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE; private Q_SLOTS: void editorModified(); private: mutable QSet _modifiedEditors; mutable QSet _itemsBeingEdited; }; } #endif // MANAGEPROFILESDIALOG_H