2 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <KParts/Factory>
25 #include <KParts/Part>
26 #include <kde_terminal_interface.h>
38 class SessionController
;
43 * A factory which creates Konsole parts.
45 class PartFactory
: public KParts::Factory
48 /** Reimplemented to create Konsole parts. */
49 virtual KParts::Part
* createPartObject(QWidget
* parentWidget
= 0,
51 const char* classname
= "KParts::Part",
52 const QStringList
& args
= QStringList());
56 * A re-usable terminal emulator component using the KParts framework which can
57 * be used to embed terminal emulators into other applications.
59 class Part
: public KParts::ReadOnlyPart
, public TerminalInterface
62 Q_INTERFACES(TerminalInterface
)
64 /** Constructs a new Konsole part with the specified parent. */
65 explicit Part(QWidget
* parentWidget
, QObject
* parent
= 0);
68 /** Reimplemented from TerminalInterface. */
69 virtual void startProgram( const QString
& program
,
70 const QStringList
& arguments
);
71 /** Reimplemented from TerminalInterface. */
72 virtual void showShellInDir( const QString
& dir
);
73 /** Reimplemented from TerminalInterface. */
74 virtual void sendInput( const QString
& text
);
78 * Shows the dialog used to manage profiles in Konsole. The dialog
79 * will be non-modal and will delete itself when it is closed.
81 * This is experimental API and not guaranteed to be present in later
84 * @param parent The parent widget of the new dialog.
86 void showManageProfilesDialog(QWidget
* parent
);
88 * Shows the dialog used to edit the profile used by the active session. The
89 * dialog will be non-modal and will delete itself when it is closed.
91 * This is experimental API and not guaranteed to be present in later KDE 4
94 * @param parent The parent widget of the new dialog.
96 void showEditCurrentProfileDialog(QWidget
* parent
);
98 * Sends a profile change command to the active session. This is equivalent to using
99 * the konsoleprofile tool within the session to change its settings. The @p text string
100 * is a semi-colon separated list of property=value pairs, eg. "colors=Linux Colors"
102 * See the documentation for konsoleprofile for information on the format of @p text
104 * This is experimental API and not guaranteed to be present in later KDE 4 releases.
106 void changeSessionSettings(const QString
& text
);
109 * Connects to an existing pseudo-teletype. See Session::openTeletype().
110 * This must be called before the session is started by startProgram(),
111 * or showShellInDir()
113 * @param ptyMasterFd The file descriptor of the pseudo-teletype (pty) master
115 void openTeletype(int ptyMasterFd
);
119 * Emitted when the key sequence for a shortcut, which is also a valid terminal key sequence,
120 * is pressed while the terminal has focus. By responding to this signal, the
121 * controlling application can choose whether to execute the action associated with
122 * the shortcut or ignore the shortcut and send the key
123 * sequence to the terminal application.
125 * In the embedded terminal, shortcuts are overridden and sent to the terminal by default.
126 * Set @p override to false to prevent this happening and allow the shortcut to be triggered
129 * overrideShortcut() is not called for shortcuts which are not valid terminal key sequences,
130 * eg. shortcuts with two or more modifiers.
132 * @param event Describes the keys that were pressed.
133 * @param override Set this to false to prevent the terminal display from overriding the shortcut
135 void overrideShortcut(QKeyEvent
* event
, bool& override
);
138 /** Reimplemented from KParts::PartBase. */
139 virtual bool openFile();
140 virtual bool openUrl(const KUrl
& url
);
143 // creates a new session using the specified profile.
144 // call the run() method on the returned Session instance to begin the session
145 Session
* createSession(const Profile::Ptr profile
= Profile::Ptr());
146 void activeViewChanged(SessionController
* controller
);
147 void activeViewTitleChanged(ViewProperties
* properties
);
148 void showManageProfilesDialog();
149 void terminalExited();
151 void overrideTerminalShortcut(QKeyEvent
*,bool& override
);
154 Session
* activeSession() const;
155 void setupActionsForSession(SessionController
* session
);
156 void createGlobalActions();
157 bool transparencyAvailable();
160 ViewManager
* _viewManager
;
161 SessionController
* _pluggedController
;
162 QAction
* _manageProfilesAction
;