From ec72a6d51ded6d4e8dafd28dbb225d0c902f4cc2 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Thu, 16 Aug 2007 05:48:46 +0000 Subject: [PATCH] Add --new-tab command line option which starts new instance in a new tab rather than creating a new window. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=700656 --- src/Application.cpp | 21 +++++++++++++++++++-- src/main.cpp | 36 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index a07f7c31e..e386cf1a4 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -120,8 +120,25 @@ int Application::newInstance() return 0; } - // create a new window and session to run in it - MainWindow* window = newMainWindow(); + // create a new window or use an existing one + MainWindow* window = 0; + + if ( args->isSet("new-tab") ) + { + QListIterator iter(topLevelWidgets()); + iter.toBack(); + while ( iter.hasPrevious() ) + { + window = qobject_cast(iter.previous()); + if ( window != 0 ) + break; + } + } + + if ( window == 0 ) + { + window = newMainWindow(); + } if ( args->isSet("profile") ) { diff --git a/src/main.cpp b/src/main.cpp index 083f2e862..425c13264 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,12 +40,7 @@ using namespace Konsole; // fills the KAboutData structure with information about contributors to // Konsole void fillAboutData(KAboutData& aboutData); - -#if 0 -#ifdef Q_WS_X11 -void getDisplayInformation(Display*& display , Visual*& visual , Colormap& colormap); -#endif -#endif +void fillCommandLineOptions(KCmdLineOptions& options); // *** // @@ -67,19 +62,8 @@ extern "C" int KDE_EXPORT kdemain(int argc,char** argv) fillAboutData(about); KCmdLineArgs::init(argc,argv,&about); - KCmdLineOptions options; - options.add("profile \\", ki18n("Name of profile to use for new Konsole instance")); - options.add("list-profiles", ki18n("List the available profiles")); - // TODO - Update this when F12 is no longer hard coded - options.add("background-mode", ki18n("Start Konsole in the background" - " and bring to the front when the F12" - " key is pressed")); - // TODO - Document this option more clearly - options.add("p \\",ki18n("Change the value of a profile property.")); - options.add("!e \\",ki18n("Command to execute")); - options.add("+[args]",ki18n("Arguments passed to command")); - + fillCommandLineOptions(options); KCmdLineArgs::addCmdLineOptions(options); KUniqueApplication::addCmdLineOptions(); @@ -96,6 +80,22 @@ extern "C" int KDE_EXPORT kdemain(int argc,char** argv) return app.exec(); } +void fillCommandLineOptions(KCmdLineOptions& options) +{ + options.add("profile \\", ki18n("Name of profile to use for new Konsole instance")); + options.add("list-profiles", ki18n("List the available profiles")); + // TODO - Update this when F12 is no longer hard coded + options.add("background-mode", ki18n("Start Konsole in the background" + " and bring to the front when the F12" + " key is pressed")); + options.add("new-tab",ki18n("Create a new tab in an existing window rather than creating a new window")); + // TODO - Document this option more clearly + options.add("p \\",ki18n("Change the value of a profile property.")); + options.add("!e \\",ki18n("Command to execute")); + options.add("+[args]",ki18n("Arguments passed to command")); + +} + void fillAboutData(KAboutData& aboutData) { aboutData.addAuthor(ki18n("Robert Knight"),ki18n("Maintainer"), "robertknight@gmail.com");