Initial (scripted) port to QCommandLineParser
This commit is contained in:
parent
975053753b
commit
0269c6d1bd
1 changed files with 18 additions and 9 deletions
27
src/main.cpp
27
src/main.cpp
|
@ -22,6 +22,11 @@
|
||||||
#include <KDE/KAboutData>
|
#include <KDE/KAboutData>
|
||||||
#include <KDE/KCmdLineArgs>
|
#include <KDE/KCmdLineArgs>
|
||||||
#include <KDE/KLocale>
|
#include <KDE/KLocale>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <KAboutData>
|
||||||
|
#include <KLocalizedString>
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
#include <QCommandLineOption>
|
||||||
|
|
||||||
static const char description[] =
|
static const char description[] =
|
||||||
I18N_NOOP("A KDE 4 Application");
|
I18N_NOOP("A KDE 4 Application");
|
||||||
|
@ -33,12 +38,17 @@ int main(int argc, char **argv)
|
||||||
KAboutData about("danbooru_client", 0, ki18n("danbooru_client"), version, ki18n(description),
|
KAboutData about("danbooru_client", 0, ki18n("danbooru_client"), version, ki18n(description),
|
||||||
KAboutData::License_GPL, ki18n("(C) %{CURRENT_YEAR} %{AUTHOR}"), KLocalizedString(), 0, "%{EMAIL}");
|
KAboutData::License_GPL, ki18n("(C) %{CURRENT_YEAR} %{AUTHOR}"), KLocalizedString(), 0, "%{EMAIL}");
|
||||||
about.addAuthor( ki18n("%{AUTHOR}"), KLocalizedString(), "%{EMAIL}" );
|
about.addAuthor( ki18n("%{AUTHOR}"), KLocalizedString(), "%{EMAIL}" );
|
||||||
KCmdLineArgs::init(argc, argv, &about);
|
QApplication app(argc, argv);
|
||||||
|
QCommandLineParser parser;
|
||||||
|
KAboutData::setApplicationData(aboutData);
|
||||||
|
parser.addVersionOption();
|
||||||
|
parser.addHelpOption();
|
||||||
|
//PORTING SCRIPT: adapt aboutdata variable if necessary
|
||||||
|
aboutData.setupCommandLine(&parser);
|
||||||
|
parser.process(app);
|
||||||
|
aboutData.processCommandLine(&parser);
|
||||||
|
|
||||||
KCmdLineOptions options;
|
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("+[URL]"), i18n( "Document to open" )));
|
||||||
options.add("+[URL]", ki18n( "Document to open" ));
|
|
||||||
KCmdLineArgs::addCmdLineOptions(options);
|
|
||||||
KApplication app;
|
|
||||||
|
|
||||||
danbooru_client *widget = new danbooru_client;
|
danbooru_client *widget = new danbooru_client;
|
||||||
|
|
||||||
|
@ -50,8 +60,7 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no session.. just start up normally
|
// no session.. just start up normally
|
||||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
if (parser.positionalArguments().count() == 0)
|
||||||
if (args->count() == 0)
|
|
||||||
{
|
{
|
||||||
//danbooru_client *widget = new danbooru_client;
|
//danbooru_client *widget = new danbooru_client;
|
||||||
widget->show();
|
widget->show();
|
||||||
|
@ -59,13 +68,13 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < args->count(); i++)
|
for (; i < parser.positionalArguments().count(); i++)
|
||||||
{
|
{
|
||||||
//danbooru_client *widget = new danbooru_client;
|
//danbooru_client *widget = new danbooru_client;
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue