[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps/konsole/src
From: Robert Knight <robertknight () gmail ! com>
Date: 2007-11-07 1:32:34
Message-ID: 1194399154.503270.18339.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 733659 by knight:
Change the 'workdir' argument to set a property on the default profile rather than \
changing the directory argument for the first new session in the new window or tab. \
Refactor the command-line argument processing, split the processing of groups of \
commands into their own functions.
M +45 -23 Application.cpp
M +3 -0 Application.h
--- trunk/KDE/kdebase/apps/konsole/src/Application.cpp #733658:733659
@@ -113,16 +113,38 @@
int Application::newInstance()
{
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
-
- if ( args->isSet("list-profiles") )
- {
- listAvailableProfiles();
+
+ // check for arguments to print help or other information to the terminal,
+ // quit if such an argument was found
+ if ( processHelpArgs(args) )
return 0;
- }
// create a new window or use an existing one
+ MainWindow* window = processWindowArgs(args);
+
+ // select profile to use
+ processProfileSelectArgs(args,window);
+
+ // process various command-line options which cause a property of the
+ // default profile to be changed
+ processProfileChangeArgs(args);
+
+ // create new session
+ createSession( window->defaultProfile() , QString() , window->viewManager() );
+
+ // 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
+ window->show();
+
+ return 0;
+}
+
+MainWindow* Application::processWindowArgs(KCmdLineArgs* args)
+{
MainWindow* window = 0;
-
if ( args->isSet("new-tab") )
{
QListIterator<QWidget*> iter(topLevelWidgets());
@@ -139,32 +161,27 @@
{
window = newMainWindow();
}
+ return window;
+}
+void Application::processProfileSelectArgs(KCmdLineArgs* args,MainWindow* window)
+{
if ( args->isSet("profile") )
{
QString key = \
SessionManager::instance()->loadProfile(args->getOption("profile")); \
window->setDefaultProfile(key); }
- QString workdir;
- if( args->isSet("workdir") )
+}
+
+bool Application::processHelpArgs(KCmdLineArgs* args)
+{
+ if ( args->isSet("list-profiles") )
{
- workdir = args->getOption("workdir");
+ listAvailableProfiles();
+ return true;
}
- processProfileChangeArgs(args);
-
- // create new session
- createSession( window->defaultProfile() , workdir , window->viewManager() );
-
- // 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
- window->show();
-
- return 0;
+ return false;
}
-
void Application::processProfileChangeArgs(KCmdLineArgs* args)
{
Profile* const defaultProfile = SessionManager::instance()->defaultProfile();
@@ -181,6 +198,11 @@
defaultProfile->setProperty(Profile::Arguments,arguments);
}
+ // change the initial working directory
+ if( args->isSet("workdir") )
+ {
+ defaultProfile->setProperty(Profile::Directory,args->getOption("workdir"));
+ }
// temporary changes to profile options specified on the command line
foreach( QString value , args->getOptionList("p") )
--- trunk/KDE/kdebase/apps/konsole/src/Application.h #733658:733659
@@ -84,6 +84,9 @@
void init();
void listAvailableProfiles();
void startBackgroundMode(MainWindow* window);
+ bool processHelpArgs(KCmdLineArgs* args);
+ MainWindow* processWindowArgs(KCmdLineArgs* args);
+ void processProfileSelectArgs(KCmdLineArgs* args,MainWindow* window);
void processProfileChangeArgs(KCmdLineArgs* args);
KCmdLineArgs* _arguments;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic