diff --git a/doc/manual/index.docbook b/doc/manual/index.docbook
index 3509ef38..7a09e860 100644
--- a/doc/manual/index.docbook
+++ b/doc/manual/index.docbook
@@ -1040,6 +1040,12 @@ For more information, please visit
+
+
+Start &konsole; in the background and bring to the front when &Ctrl;&Shift;F12 (by default) is pressed.
+
+
+
Create a new tab in an existing window rather than creating a new window.
diff --git a/src/Application.cpp b/src/Application.cpp
index a1a68383..efd43ae2 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -46,6 +46,8 @@ Application::Application() : KUniqueApplication()
void Application::init()
{
+ _backgroundInstance = 0;
+
#if defined(Q_WS_MAC)
// this ensures that Ctrl and Meta are not swapped, so CTRL-C and friends
// will work correctly in the terminal
@@ -125,22 +127,28 @@ int Application::newInstance()
}
}
- // Qt constrains top-level windows which have not been manually
- // resized (via QWidget::resize()) to a maximum of 2/3rds of the
- // screen size.
- //
- // This means that the terminal display might not get the width/
- // height it asks for. To work around this, the widget must be
- // manually resized to its sizeHint().
- //
- // This problem only affects the first time the application is run.
- // run. After that KMainWindow will have manually resized the
- // window to its saved size at this point (so the Qt::WA_Resized
- // attribute will be set)
- if (!window->testAttribute(Qt::WA_Resized))
- window->resize(window->sizeHint());
-
- window->show();
+ // if the background-mode argument is supplied, start the background
+ // session ( or bring to the front if it already exists )
+ if (args->isSet("background-mode")) {
+ startBackgroundMode(window);
+ } else {
+ // Qt constrains top-level windows which have not been manually
+ // resized (via QWidget::resize()) to a maximum of 2/3rds of the
+ // screen size.
+ //
+ // This means that the terminal display might not get the width/
+ // height it asks for. To work around this, the widget must be
+ // manually resized to its sizeHint().
+ //
+ // This problem only affects the first time the application is run.
+ // run. After that KMainWindow will have manually resized the
+ // window to its saved size at this point (so the Qt::WA_Resized
+ // attribute will be set)
+ if (!window->testAttribute(Qt::WA_Resized))
+ window->resize(window->sizeHint());
+
+ window->show();
+ }
}
firstInstance = false;
@@ -425,5 +433,37 @@ Profile::Ptr Application::processProfileChangeArgs(KCmdLineArgs* args, Profile::
}
}
+void Application::startBackgroundMode(MainWindow* window)
+{
+ if (_backgroundInstance) {
+ return;
+ }
+
+ KAction* action = window->actionCollection()->addAction("toggle-background-window");
+ action->setObjectName(QLatin1String("Konsole Background Mode"));
+ action->setText(i18n("Toggle Background Window"));
+ action->setGlobalShortcut(KShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F12)));
+
+ connect(action, SIGNAL(triggered()),
+ this, SLOT(toggleBackgroundInstance()));
+
+ _backgroundInstance = window;
+}
+
+void Application::toggleBackgroundInstance()
+{
+ Q_ASSERT(_backgroundInstance);
+
+ if (!_backgroundInstance->isVisible()) {
+ _backgroundInstance->show();
+ // ensure that the active terminal display has the focus. Without
+ // this, an odd problem occurred where the focus widget would change
+ // each time the background instance was shown
+ _backgroundInstance->setFocus();
+ } else {
+ _backgroundInstance->hide();
+ }
+}
+
#include "Application.moc"
diff --git a/src/Application.h b/src/Application.h
index c1d37b4a..ae9b1fe5 100644
--- a/src/Application.h
+++ b/src/Application.h
@@ -69,10 +69,13 @@ private slots:
void createWindow(Profile::Ptr profile , const QString& directory);
void detachView(Session* session);
+ void toggleBackgroundInstance();
+
private:
void init();
void listAvailableProfiles();
void listProfilePropertyInfo();
+ void startBackgroundMode(MainWindow* window);
bool processHelpArgs(KCmdLineArgs* args);
MainWindow* processWindowArgs(KCmdLineArgs* args);
Profile::Ptr processProfileSelectArgs(KCmdLineArgs* args);
@@ -80,6 +83,8 @@ private:
void processTabsFromFileArgs(KCmdLineArgs* args, MainWindow* window);
void createTabFromArgs(KCmdLineArgs* args, MainWindow* window,
const QHash&);
+
+ MainWindow* _backgroundInstance;
};
}
#endif // APPLICATION_H
diff --git a/src/main.cpp b/src/main.cpp
index 7544a81b..9674e719 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -170,6 +170,9 @@ void fillCommandLineOptions(KCmdLineOptions& options)
options.add("tabs-from-file ",
ki18nc("@info:shell", "Create tabs as specified in given tabs configuration"
" file"));
+ options.add("background-mode",
+ ki18nc("@info:shell", "Start Konsole in the background and bring to the front"
+ " when Ctrl+Shift+F12 (by default) is pressed"));
options.add("show-menubar", ki18nc("@info:shell", "Show the menubar, overriding the default setting"));
options.add("hide-menubar", ki18nc("@info:shell", "Hide the menubar, overriding the default setting"));
options.add("show-tabbar", ki18nc("@info:shell", "Show the tabbar, overriding the default setting"));