2 // Copyright (C) 1998 Matthias Hoelzer <hoelzer@kde.org>
3 // Copyright (C) 2002 David Faure <faure@kde.org>
4 // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net>
5 // Copyright (C) 2008 by Dmitry Suzdalev <dimsuz@gmail.com>
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the7 implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <kmessagebox.h>
27 #include <kapplication.h>
28 #include <kpassivepopup.h>
29 #include <krecentdocument.h>
30 #include <kcmdlineargs.h>
31 #include <kaboutdata.h>
32 #include <kfiledialog.h>
33 #include <kicondialog.h>
34 #include <kdirselectdialog.h>
35 #include <kcolordialog.h>
36 #include <kwindowsystem.h>
38 #include <QtCore/QTimer>
39 #include <QtGui/QDesktopWidget>
43 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
47 #include "../config-apps.h"
48 #ifdef QT_QTDBUS_FOUND
49 #include <QtDBus/QDBusConnection>
50 #include <QtDBus/QDBusConnectionInterface>
54 #include <QtGui/QFileDialog>
60 // this class hooks into the eventloop and outputs the id
61 // of shown dialogs or makes the dialog transient for other winids.
62 // Will destroy itself on app exit.
63 class WinIdEmbedder
: public QObject
66 WinIdEmbedder(bool printID
, WId winId
):
67 QObject(kapp
), print(printID
), id(winId
)
70 kapp
->installEventFilter(this);
73 bool eventFilter(QObject
*o
, QEvent
*e
);
79 bool WinIdEmbedder::eventFilter(QObject
*o
, QEvent
*e
)
81 if (e
->type() == QEvent::Show
&& o
->isWidgetType()
82 && o
->inherits("KDialog"))
84 QWidget
*w
= static_cast<QWidget
*>(o
);
86 cout
<< "winId: " << w
->winId() << endl
;
88 KWindowSystem::setMainWindow(w
, id
);
89 deleteLater(); // WinIdEmbedder is not needed anymore after the first dialog was shown
92 return QObject::eventFilter(o
, e
);
96 * Display a passive notification popup using the D-Bus interface, if possible.
97 * @return true if the notification was successfully sent, false otherwise.
99 bool sendVisualNotification(QString text
, QString title
, int timeout
)
101 #ifdef QT_QTDBUS_FOUND
102 const QString dbusServiceName
= "org.kde.VisualNotifications";
103 const QString dbusInterfaceName
= "org.kde.VisualNotifications";
104 const QString dbusPath
= "/VisualNotifications";
106 // check if service already exists on plugin instantiation
107 QDBusConnectionInterface
* interface
= QDBusConnection::sessionBus().interface();
109 if (!interface
|| !interface
->isServiceRegistered(dbusServiceName
)) {
110 //kDebug() << dbusServiceName << "D-Bus service not registered";
117 QDBusMessage m
= QDBusMessage::createMethodCall(dbusServiceName
, dbusPath
, dbusInterfaceName
, "Notify");
118 QList
<QVariant
> args
;
120 args
.append("kdialog"); // app_name
121 args
.append(0U); // replaces_id
122 args
.append("kdialogPassivePopup"); // event_id
123 args
.append("dialog-information"); // app_icon
124 args
.append(title
); // summary
125 args
.append(text
); // body
126 args
.append(QStringList()); // actions - unused for plain passive popups
127 args
.append(QVariantMap()); // hints - unused atm
128 args
.append(timeout
); // expire timout
130 m
.setArguments(args
);
132 QDBusMessage replyMsg
= QDBusConnection::sessionBus().call(m
);
133 if(replyMsg
.type() == QDBusMessage::ReplyMessage
) {
134 if (!replyMsg
.arguments().isEmpty()) {
137 // Not displaying any error messages as this is optional for kdialog
138 // and KPassivePopup is a perfectly valid fallback.
140 // kDebug() << "Error: received reply with no arguments.";
142 } else if (replyMsg
.type() == QDBusMessage::ErrorMessage
) {
143 //kDebug() << "Error: failed to send D-Bus message";
144 //kDebug() << replyMsg;
146 //kDebug() << "Unexpected reply type";
152 static void outputStringList(const QStringList
&list
, bool separateOutput
)
154 if ( separateOutput
) {
155 for ( QStringList::ConstIterator it
= list
.begin(); it
!= list
.end(); ++it
) {
156 cout
<< (*it
).toLocal8Bit().data() << endl
;
159 for ( QStringList::ConstIterator it
= list
.begin(); it
!= list
.end(); ++it
) {
160 cout
<< (*it
).toLocal8Bit().data() << " ";
166 static int directCommand(KCmdLineArgs
*args
)
169 bool separateOutput
= false;
170 bool printWId
= args
->isSet("print-winid");
171 QString defaultEntry
;
174 KCmdLineArgs
*qtargs
= KCmdLineArgs::parsedArgs("qt"); // --title is a qt option
175 if(qtargs
->isSet("title")) {
176 title
= qtargs
->getOption("title");
180 if (args
->isSet("separate-output"))
182 separateOutput
= true;
186 bool attach
= args
->isSet("attach");
189 winid
= reinterpret_cast<WId
>(args
->getOption("attach").toLong(&attach
, 0)); //C style parsing. If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.
191 winid
= args
->getOption("attach").toLong(&attach
, 0); //C style parsing. If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.
193 } else if(args
->isSet("embed")) {
194 /* KDialog originally used --embed for attaching the dialog box. However this is misleading and so we changed to --attach.
195 * For consistancy, we silently map --embed to --attach */
198 winid
= reinterpret_cast<WId
>(args
->getOption("embed").toLong(&attach
, 0)); //C style parsing. If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.
200 winid
= args
->getOption("embed").toLong(&attach
, 0); //C style parsing. If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.
204 if (printWId
|| attach
)
206 (void)new WinIdEmbedder(printWId
, winid
);
209 // --yesno and other message boxes
210 KMessageBox::DialogType type
= (KMessageBox::DialogType
) 0;
212 if (args
->isSet("yesno")) {
214 type
= KMessageBox::QuestionYesNo
;
216 else if (args
->isSet("yesnocancel")) {
217 option
= "yesnocancel";
218 type
= KMessageBox::QuestionYesNoCancel
;
220 else if (args
->isSet("warningyesno")) {
221 option
= "warningyesno";
222 type
= KMessageBox::WarningYesNo
;
224 else if (args
->isSet("warningcontinuecancel")) {
225 option
= "warningcontinuecancel";
226 type
= KMessageBox::WarningContinueCancel
;
228 else if (args
->isSet("warningyesnocancel")) {
229 option
= "warningyesnocancel";
230 type
= KMessageBox::WarningYesNoCancel
;
232 else if (args
->isSet("sorry")) {
234 type
= KMessageBox::Sorry
;
236 else if (args
->isSet("error")) {
238 type
= KMessageBox::Error
;
240 else if (args
->isSet("msgbox")) {
242 type
= KMessageBox::Information
;
245 if ( !option
.isEmpty() )
247 KConfig
* dontagaincfg
= NULL
;
249 QString dontagain
; // QString()
250 if (args
->isSet("dontagain"))
252 QString value
= args
->getOption("dontagain");
253 QStringList values
= value
.split( ':', QString::SkipEmptyParts
);
254 if( values
.count() == 2 )
256 dontagaincfg
= new KConfig( values
[ 0 ] );
257 KMessageBox::setDontShowAskAgainConfig( dontagaincfg
);
258 dontagain
= values
[ 1 ];
261 qDebug( "Incorrect --dontagain!" );
265 QString text
= args
->getOption( option
);
267 while ((pos
= text
.indexOf( QLatin1String("\\n") )) >= 0)
269 text
.replace(pos
, 2, QLatin1String("\n"));
272 if ( type
== KMessageBox::WarningContinueCancel
) {
273 /* TODO configurable button texts*/
274 ret
= KMessageBox::messageBox( 0, type
, text
, title
, KStandardGuiItem::cont(),
275 KStandardGuiItem::no(), KStandardGuiItem::cancel(), dontagain
);
277 ret
= KMessageBox::messageBox( 0, type
, text
, title
/*, TODO configurable button texts*/,
278 KStandardGuiItem::yes(), KStandardGuiItem::no(), KStandardGuiItem::cancel(), dontagain
);
281 // ret is 1 for Ok, 2 for Cancel, 3 for Yes, 4 for No and 5 for Continue.
282 // We want to return 0 for ok, yes and continue, 1 for no and 2 for cancel
283 return (ret
== KMessageBox::Ok
|| ret
== KMessageBox::Yes
|| ret
== KMessageBox::Continue
) ? 0
284 : ( ret
== KMessageBox::No
? 1 : 2 );
287 // --inputbox text [init]
288 if (args
->isSet("inputbox"))
293 if (args
->count() > 0)
296 bool retcode
= Widgets::inputBox(0, title
, args
->getOption("inputbox"), init
, result
);
297 cout
<< result
.toLocal8Bit().data() << endl
;
298 return retcode
? 0 : 1;
303 if (args
->isSet("password"))
306 bool retcode
= Widgets::passwordBox(0, title
, args
->getOption("password"), result
);
307 cout
<< qPrintable(result
) << endl
;
308 return retcode
? 0 : 1;
312 if (args
->isSet("passivepopup"))
315 if (args
->count() > 0)
316 duration
= 1000 * args
->arg(0).toInt();
320 // try to use more stylish notifications
321 if (sendVisualNotification(args
->getOption("passivepopup"), title
, duration
))
324 // ...did not work, use KPassivePopup as fallback
325 KPassivePopup
*popup
= KPassivePopup::message( KPassivePopup::Boxed
, // style
327 args
->getOption("passivepopup"),
328 QPixmap() /* do not crash 0*/, // icon
329 (QWidget
*)0UL, // parent
331 KDialog::centerOnScreen( popup
);
332 QTimer
*timer
= new QTimer();
333 QObject::connect( timer
, SIGNAL( timeout() ), kapp
, SLOT( quit() ) );
334 QObject::connect( popup
, SIGNAL( clicked() ), kapp
, SLOT( quit() ) );
335 timer
->setSingleShot( true );
336 timer
->start( duration
);
340 KCmdLineArgs
*args
= KCmdLineArgs::parsedArgs("kde");
341 if (args
&& args
->isSet("geometry"))
342 geometry
= args
->getOption("geometry");
343 if ( !geometry
.isEmpty()) {
346 int m
= XParseGeometry( geometry
.toLatin1(), &x
, &y
, (unsigned int*)&w
, (unsigned int*)&h
);
347 if ( (m
& XNegative
) )
348 x
= KApplication::desktop()->width() + x
- w
;
349 if ( (m
& YNegative
) )
350 y
= KApplication::desktop()->height() + y
- h
;
351 popup
->setAnchor( QPoint(x
, y
) );
358 // --textbox file [width] [height]
359 if (args
->isSet("textbox"))
364 if (args
->count() == 2) {
365 w
= args
->arg(0).toInt();
366 h
= args
->arg(1).toInt();
369 return Widgets::textBox(0, w
, h
, title
, args
->getOption("textbox"));
372 // --textinputbox file [width] [height]
373 if (args
->isSet("textinputbox"))
378 if (args
->count() == 4) {
379 w
= args
->arg(2).toInt();
380 h
= args
->arg(3).toInt();
384 list
.append(args
->getOption("textinputbox"));
386 if (args
->count() >= 1) {
387 for (int i
= 0; i
< args
->count(); i
++)
388 list
.append(args
->arg(i
));
392 int ret
= Widgets::textInputBox(0, w
, h
, title
, list
, result
);
393 cout
<< qPrintable(result
) << endl
;
397 // --combobox <text> [tag item] [tag item] ..."
398 if (args
->isSet("combobox")) {
400 if (args
->count() >= 2) {
401 for (int i
= 0; i
< args
->count(); i
++) {
402 list
.append(args
->arg(i
));
404 QString text
= args
->getOption("combobox");
405 if (args
->isSet("default")) {
406 defaultEntry
= args
->getOption("default");
409 bool retcode
= Widgets::comboBox(0, title
, text
, list
, defaultEntry
, result
);
410 cout
<< result
.toLocal8Bit().data() << endl
;
411 return retcode
? 0 : 1;
416 // --menu text [tag item] [tag item] ...
417 if (args
->isSet("menu")) {
419 if (args
->count() >= 2) {
420 for (int i
= 0; i
< args
->count(); i
++) {
421 list
.append(args
->arg(i
));
423 QString text
= args
->getOption("menu");
424 if (args
->isSet("default")) {
425 defaultEntry
= args
->getOption("default");
428 bool retcode
= Widgets::listBox(0, title
, text
, list
, defaultEntry
, result
);
429 if (1 == retcode
) { // OK was selected
430 cout
<< result
.toLocal8Bit().data() << endl
;
432 return retcode
? 0 : 1;
437 // --checklist text [tag item status] [tag item status] ...
438 if (args
->isSet("checklist")) {
440 if (args
->count() >= 3) {
441 for (int i
= 0; i
< args
->count(); i
++) {
442 list
.append(args
->arg(i
));
445 QString text
= args
->getOption("checklist");
448 bool retcode
= Widgets::checkList(0, title
, text
, list
, separateOutput
, result
);
450 for (int i
=0; i
<result
.count(); i
++)
451 if (!result
.at(i
).toLocal8Bit().isEmpty()) {
452 cout
<< result
.at(i
).toLocal8Bit().data() << endl
;
454 exit( retcode
? 0 : 1 );
459 // --radiolist text width height menuheight [tag item status]
460 if (args
->isSet("radiolist")) {
462 if (args
->count() >= 3) {
463 for (int i
= 0; i
< args
->count(); i
++) {
464 list
.append(args
->arg(i
));
467 QString text
= args
->getOption("radiolist");
469 bool retcode
= Widgets::radioBox(0, title
, text
, list
, result
);
470 cout
<< result
.toLocal8Bit().data() << endl
;
471 exit( retcode
? 0 : 1 );
476 // getopenfilename [startDir] [filter]
477 if (args
->isSet("getopenfilename")) {
480 startDir
= args
->getOption("getopenfilename");
481 if (args
->count() >= 1) {
482 filter
= args
->arg(0);
484 KFileDialog
dlg( startDir
, filter
, 0 );
485 dlg
.setOperationMode( KFileDialog::Opening
);
487 if (args
->isSet("multiple")) {
488 dlg
.setMode(KFile::Files
| KFile::LocalOnly
);
490 dlg
.setMode(KFile::File
| KFile::LocalOnly
);
492 Widgets::handleXGeometry(&dlg
);
493 kapp
->setTopWidget( &dlg
);
494 dlg
.setCaption(title
.isNull() ? i18n("Open") : title
);
497 if (args
->isSet("multiple")) {
498 QStringList result
= dlg
.selectedFiles();
499 if ( !result
.isEmpty() ) {
500 outputStringList( result
, separateOutput
);
504 QString result
= dlg
.selectedFile();
505 if (!result
.isEmpty()) {
506 cout
<< result
.toLocal8Bit().data() << endl
;
510 return 1; // canceled
514 // getsaveurl [startDir] [filter]
515 // getsavefilename [startDir] [filter]
516 if ( (args
->isSet("getsavefilename") ) || (args
->isSet("getsaveurl") ) ) {
519 if ( args
->isSet("getsavefilename") ) {
520 startDir
= args
->getOption("getsavefilename");
522 startDir
= args
->getOption("getsaveurl");
524 if (args
->count() >= 1) {
525 filter
= args
->arg(0);
527 // copied from KFileDialog::getSaveFileName(), so we can add geometry
528 bool specialDir
= ( startDir
.at(0) == ':' );
529 KFileDialog
dlg( specialDir
? startDir
: QString(), filter
, 0 );
531 dlg
.setSelection( startDir
);
532 dlg
.setOperationMode( KFileDialog::Saving
);
533 Widgets::handleXGeometry(&dlg
);
534 kapp
->setTopWidget( &dlg
);
535 dlg
.setCaption(title
.isNull() ? i18n("Save As") : title
);
538 if ( args
->isSet("getsaveurl") ) {
539 KUrl result
= dlg
.selectedUrl();
540 if ( result
.isValid()) {
542 cout
<< result
.url().toLocal8Bit().data() << endl
;
545 } else { // getsavefilename
546 QString result
= dlg
.selectedFile();
547 if (!result
.isEmpty()) {
548 KRecentDocument::add(result
);
549 cout
<< result
.toLocal8Bit().data() << endl
;
553 return 1; // canceled
556 // getexistingdirectory [startDir]
557 if (args
->isSet("getexistingdirectory")) {
559 startDir
= args
->getOption("getexistingdirectory");
562 result
= QFileDialog::getExistingDirectory( 0, title
, startDir
,
563 QFileDialog::DontResolveSymlinks
|
564 QFileDialog::ShowDirsOnly
);
567 KDirSelectDialog
myDialog( startDir
, true, 0 );
569 kapp
->setTopWidget( &myDialog
);
571 Widgets::handleXGeometry(&myDialog
);
572 if ( !title
.isNull() )
573 myDialog
.setCaption( title
);
575 if ( myDialog
.exec() == QDialog::Accepted
)
576 url
= myDialog
.url();
581 if (!result
.isEmpty()) {
582 cout
<< result
.toLocal8Bit().data() << endl
;
585 return 1; // canceled
588 // getopenurl [startDir] [filter]
589 if (args
->isSet("getopenurl")) {
592 startDir
= args
->getOption("getopenurl");
593 if (args
->count() >= 1) {
594 filter
= args
->arg(0);
596 KFileDialog
dlg( startDir
, filter
, 0 );
597 dlg
.setOperationMode( KFileDialog::Opening
);
599 if (args
->isSet("multiple")) {
600 dlg
.setMode(KFile::Files
);
602 dlg
.setMode(KFile::File
);
604 Widgets::handleXGeometry(&dlg
);
605 kapp
->setTopWidget( &dlg
);
606 dlg
.setCaption(title
.isNull() ? i18n("Open") : title
);
609 if (args
->isSet("multiple")) {
610 KUrl::List result
= dlg
.selectedUrls();
611 if ( !result
.isEmpty() ) {
612 outputStringList( result
.toStringList(), separateOutput
);
616 KUrl result
= dlg
.selectedUrl();
617 if (!result
.isEmpty()) {
618 cout
<< result
.url().toLocal8Bit().data() << endl
;
622 return 1; // canceled
625 // geticon [group] [context]
626 if (args
->isSet("geticon")) {
627 QString groupStr
, contextStr
;
628 groupStr
= args
->getOption("geticon");
629 if (args
->count() >= 1) {
630 contextStr
= args
->arg(0);
632 KIconLoader::Group group
= KIconLoader::NoGroup
;
633 if ( groupStr
== QLatin1String( "Desktop" ) )
634 group
= KIconLoader::Desktop
;
635 else if ( groupStr
== QLatin1String( "Toolbar" ) )
636 group
= KIconLoader::Toolbar
;
637 else if ( groupStr
== QLatin1String( "MainToolbar" ) )
638 group
= KIconLoader::MainToolbar
;
639 else if ( groupStr
== QLatin1String( "Small" ) )
640 group
= KIconLoader::Small
;
641 else if ( groupStr
== QLatin1String( "Panel" ) )
642 group
= KIconLoader::Panel
;
643 else if ( groupStr
== QLatin1String( "User" ) )
644 group
= KIconLoader::User
;
645 KIconLoader::Context context
= KIconLoader::Any
;
646 // From kicontheme.cpp
647 if ( contextStr
== QLatin1String( "Devices" ) )
648 context
= KIconLoader::Device
;
649 else if ( contextStr
== QLatin1String( "MimeTypes" ) )
650 context
= KIconLoader::MimeType
;
651 else if ( contextStr
== QLatin1String( "FileSystems" ) )
652 context
= KIconLoader::FileSystem
;
653 else if ( contextStr
== QLatin1String( "Applications" ) )
654 context
= KIconLoader::Application
;
655 else if ( contextStr
== QLatin1String( "Actions" ) )
656 context
= KIconLoader::Action
;
658 KIconDialog
dlg((QWidget
*)0L);
659 kapp
->setTopWidget( &dlg
);
660 dlg
.setup( group
, context
);
662 dlg
.setCaption(title
);
663 Widgets::handleXGeometry(&dlg
);
665 QString result
= dlg
.openDialog();
667 if (!result
.isEmpty()) {
668 cout
<< result
.toLocal8Bit().data() << endl
;
671 return 1; // canceled
674 // --progressbar text totalsteps
675 if (args
->isSet("progressbar"))
677 cout
<< "org.kde.kdialog-" << getpid() << " /ProgressDialog" << endl
;
682 int totalsteps
= 100;
683 QString text
= args
->getOption("progressbar");
685 if (args
->count() == 1)
686 totalsteps
= args
->arg(0).toInt();
688 return Widgets::progressBar(0, title
, text
, totalsteps
) ? 1 : 0;
692 if (args
->isSet("getcolor")) {
693 KColorDialog
dlg((QWidget
*)0L, true);
695 if (args
->isSet("default")) {
696 defaultEntry
= args
->getOption("default");
697 dlg
.setColor(defaultEntry
);
699 Widgets::handleXGeometry(&dlg
);
700 kapp
->setTopWidget(&dlg
);
701 dlg
.setCaption(title
.isNull() ? i18n("Choose Color") : title
);
703 if (dlg
.exec() == KColorDialog::Accepted
) {
705 if (dlg
.color().isValid()) {
706 result
= dlg
.color().name();
708 result
= dlg
.defaultColor().name();
710 cout
<< result
.toLocal8Bit().data() << endl
;
713 return 1; // cancelled
715 if (args
->isSet("slider"))
720 QString text
= args
->getOption( "slider" );
721 if ( args
->count() == 3 )
723 miniValue
= args
->arg(0).toInt();
724 maxValue
= args
->arg( 1 ).toInt();
725 step
= args
->arg( 2 ).toInt();
729 bool returnCode
= Widgets::slider(0, title
, text
, miniValue
, maxValue
, step
, result
);
731 cout
<< result
<< endl
;
734 if (args
->isSet("calendar"))
736 QString text
= args
->getOption( "calendar" );
739 bool returnCode
= Widgets::calendar(0, title
, text
, result
);
741 cout
<< result
.toString().toLocal8Bit().data() << endl
;
745 KCmdLineArgs::usage();
746 return -2; // NOTREACHED
750 int main(int argc
, char *argv
[])
752 KAboutData
aboutData( "kdialog", 0, ki18n("KDialog"),
753 "1.0", ki18n( "KDialog can be used to show nice dialog boxes from shell scripts" ),
754 KAboutData::License_GPL
,
755 ki18n("(C) 2000, Nick Thompson"));
756 aboutData
.addAuthor(ki18n("David Faure"), ki18n("Current maintainer"),"faure@kde.org");
757 aboutData
.addAuthor(ki18n("Brad Hards"), KLocalizedString(), "bradh@frogmouth.net");
758 aboutData
.addAuthor(ki18n("Nick Thompson"),KLocalizedString(), 0/*"nickthompson@lucent.com" bounces*/);
759 aboutData
.addAuthor(ki18n("Matthias Hölzer"),KLocalizedString(),"hoelzer@kde.org");
760 aboutData
.addAuthor(ki18n("David Gümbel"),KLocalizedString(),"david.guembel@gmx.net");
761 aboutData
.addAuthor(ki18n("Richard Moore"),KLocalizedString(),"rich@kde.org");
762 aboutData
.addAuthor(ki18n("Dawit Alemayehu"),KLocalizedString(),"adawit@kde.org");
763 aboutData
.setProgramIconName("system-run");
766 KCmdLineArgs::init(argc
, argv
, &aboutData
);
768 KCmdLineOptions options
;
769 options
.add("yesno <text>", ki18n("Question message box with yes/no buttons"));
770 options
.add("yesnocancel <text>", ki18n("Question message box with yes/no/cancel buttons"));
771 options
.add("warningyesno <text>", ki18n("Warning message box with yes/no buttons"));
772 options
.add("warningcontinuecancel <text>", ki18n("Warning message box with continue/cancel buttons"));
773 options
.add("warningyesnocancel <text>", ki18n("Warning message box with yes/no/cancel buttons"));
774 options
.add("sorry <text>", ki18n("'Sorry' message box"));
775 options
.add("error <text>", ki18n("'Error' message box"));
776 options
.add("msgbox <text>", ki18n("Message Box dialog"));
777 options
.add("inputbox <text> <init>", ki18n("Input Box dialog"));
778 options
.add("password <text>", ki18n("Password dialog"));
779 options
.add("textbox <file> [width] [height]", ki18n("Text Box dialog"));
780 options
.add("textinputbox <text> <init> [width] [height]", ki18n("Text Input Box dialog"));
781 options
.add("combobox <text> [tag item] [tag item] ...", ki18n("ComboBox dialog"));
782 options
.add("menu <text> [tag item] [tag item] ...", ki18n("Menu dialog"));
783 options
.add("checklist <text> [tag item status] ...", ki18n("Check List dialog"));
784 options
.add("radiolist <text> [tag item status] ...", ki18n("Radio List dialog"));
785 options
.add("passivepopup <text> <timeout>", ki18n("Passive Popup"));
786 options
.add("getopenfilename [startDir] [filter]", ki18n("File dialog to open an existing file"));
787 options
.add("getsavefilename [startDir] [filter]", ki18n("File dialog to save a file"));
788 options
.add("getexistingdirectory [startDir]", ki18n("File dialog to select an existing directory"));
789 options
.add("getopenurl [startDir] [filter]", ki18n("File dialog to open an existing URL"));
790 options
.add("getsaveurl [startDir] [filter]", ki18n("File dialog to save a URL"));
791 options
.add("geticon [group] [context]", ki18n("Icon chooser dialog"));
792 options
.add("progressbar <text> [totalsteps]", ki18n("Progress bar dialog, returns a D-Bus reference for communication"));
793 options
.add("getcolor", ki18n("Color dialog to select a color"));
794 // TODO gauge stuff, reading values from stdin
795 options
.add("title <text>", ki18n("Dialog title"));
796 options
.add("default <text>", ki18n("Default entry to use for combobox, menu and color"));
797 options
.add("multiple", ki18n("Allows the --getopenurl and --getopenfilename options to return multiple files"));
798 options
.add("separate-output", ki18n("Return list items on separate lines (for checklist option and file open with --multiple)"));
799 options
.add("print-winid", ki18n("Outputs the winId of each dialog"));
800 options
.add("dontagain <file:entry>", ki18n("Config file and option name for saving the \"do-not-show/ask-again\" state"));
801 options
.add( "slider <text> [minvalue] [maxvalue] [step]", ki18n( "Slider dialogbox, returns value selected" ) );
802 options
.add( "calendar <text>", ki18n( "Calendar dialogbox, return selected date" ) );
803 /* kdialog originally used --embed for attaching the dialog box. However this is misleading and so we changed to --attach.
804 * For backwards compatibility, we silently map --embed to --attach */
805 options
.add("attach <winid>", ki18n("Makes the dialog transient for an X app specified by winid"));
806 options
.add("embed <winid>");
808 options
.add("+[arg]", ki18n("Arguments - depending on main option"));
810 KCmdLineArgs::addCmdLineOptions( options
); // Add our own options.
814 KCmdLineArgs
*args
= KCmdLineArgs::parsedArgs();
816 // execute direct kdialog command
817 return directCommand(args
);