Commit 95d479b6 authored by Robert Knight's avatar Robert Knight

Support for -e command line argument to specify a custom command to run when...

Support for -e command line argument to specify a custom command to run when starting Konsole.  Also added a -p command line argument which can be used to change almost any other option for that Konsole instance using the same syntax as the konsoleprofile tool.  Update TODO.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=700451
parent 348c46f8
......@@ -36,12 +36,7 @@ The KDE 4.0 TODO List:
- Support for common terminal command line options
Essential:
-e : Execute command with arguments
Nice to have:
- Ability to pass string for profile options on
command line (same syntax as for konsoleprofile)
-fg : Specify foreground color
-bg : Specify background color
......@@ -212,6 +207,14 @@ do not always behave well with lots of successive image size changes.
=== DONE ===
- Support for common terminal command line options
Essential:
-e : Execute command with arguments
Nice To Have:
- Ability to pass string for profile options on
command line (same syntax as for konsoleprofile)
- Pressing a keyboard scroll key combination causes the view to scroll
to the bottom of the output
......
......@@ -26,6 +26,7 @@
#include "kdebug.h"
// Qt
#include <QHashIterator>
#include <QFileInfo>
// KDE
......@@ -128,6 +129,9 @@ int Application::newInstance()
window->setDefaultProfile(key);
}
processProfileChangeArgs(args);
// create new session
createSession( window->defaultProfile() , QString() , window->viewManager() );
// if the background-mode argument is supplied, start the background session
......@@ -140,6 +144,37 @@ int Application::newInstance()
return 0;
}
void Application::processProfileChangeArgs(KCmdLineArgs* args)
{
Profile* const defaultProfile = SessionManager::instance()->defaultProfile();
// run a custom command
if ( args->isSet("e") )
{
QStringList arguments;
arguments << args->getOption("e");
for ( int i = 0 ; i < args->count() ; i++ )
arguments << args->arg(i);
defaultProfile->setProperty(Profile::Command,args->getOption("e"));
defaultProfile->setProperty(Profile::Arguments,arguments);
}
// temporary changes to profile options specified on the command line
foreach( QString value , args->getOptionList("p") )
{
ProfileCommandParser parser;
QHashIterator<Profile::Property,QVariant> iter(parser.parse(value));
while ( iter.hasNext() )
{
iter.next();
defaultProfile->setProperty(iter.key(),iter.value());
}
}
}
void Application::startBackgroundMode(MainWindow* window)
{
if ( _backgroundInstance )
......
......@@ -84,6 +84,7 @@ private:
void init();
void listAvailableProfiles();
void startBackgroundMode(MainWindow* window);
void processProfileChangeArgs(KCmdLineArgs* args);
KCmdLineArgs* _arguments;
ProfileList* _sessionList;
......
......@@ -33,7 +33,7 @@
#include <KWindowSystem>
// bump the version to 2.0 before the KDE 4 release
#define KONSOLE_VERSION "1.9"
#define KONSOLE_VERSION "1.9.2"
using namespace Konsole;
......@@ -69,13 +69,17 @@ extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
KCmdLineArgs::init(argc,argv,&about);
KCmdLineOptions options;
/* { "command" , I18N_NOOP("Command to run in new Konsole instance") , 0 },*/
options.add("profile \\<file>", 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 \\<property=value>",ki18n("Change the value of a profile property."));
options.add("!e \\<cmd>",ki18n("Command to execute"));
options.add("+[args]",ki18n("Arguments passed to command"));
KCmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
......@@ -86,24 +90,7 @@ extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
exit(0);
}
#if 0
#ifdef Q_WS_X11
//Display* display = 0;
Display* display = XOpenDisplay(0);
Visual* visual = 0;
Colormap colormap = 0;
bool transparencyAvailable = KWindowSystem::compositingActive();
if ( transparencyAvailable )
getDisplayInformation(display,visual,colormap);
qDebug() << "Transparency available: " << transparencyAvailable;
Application app(display,Qt::HANDLE(visual),Qt::HANDLE(colormap));
#else
Application app;
#endif
#endif
qDebug() << "Have compositing: " << KWindowSystem::compositingActive();
Application app;
return app.exec();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment