Adapt to changes in QCommandLine

This commit is contained in:
Aleix Pol 2013-07-03 19:16:19 +02:00
parent 5b0b17f86a
commit 80bf4d66da
2 changed files with 23 additions and 23 deletions

View File

@ -26,30 +26,30 @@
int main(int argc, char **argv)
{
QCommandLineParser *parser = new QCommandLineParser;
Plasma::PlasmaPkg app(argc, argv, parser);
QCommandLineParser parser;
Plasma::PlasmaPkg app(argc, argv, &parser);
const QString description = i18n("Plasma Package Manager");
const char version[] = "2.0";
app.setApplicationVersion(version);
parser->addVersionOption();
parser->addHelpOption(description);
parser->addOption(QCommandLineOption(QStringList() << "h" << "hash", i18nc("Do not translate <path>", "Generate a SHA1 hash for the package at <path>"), "path"));
parser->addOption(QCommandLineOption(QStringList() << "g" << "global", i18n("For install or remove, operates on packages installed for all users.")));
parser->addOption(QCommandLineOption(QStringList() << "type",
parser.addVersionOption();
parser.addHelpOption(description);
parser.addOption(QCommandLineOption(QStringList() << "h" << "hash", i18nc("Do not translate <path>", "Generate a SHA1 hash for the package at <path>"), "path"));
parser.addOption(QCommandLineOption(QStringList() << "g" << "global", i18n("For install or remove, operates on packages installed for all users.")));
parser.addOption(QCommandLineOption(QStringList() << "type",
i18nc("theme, wallpaper, etc. are keywords, but they may be translated, as both versions "
"are recognized by the application "
"(if translated, should be same as messages with 'package type' context below)",
"The type of package, e.g. theme, wallpaper, plasmoid, dataengine, runner, layout-template, etc."),
"type", false, QStringList() << "plasmoid"));
parser->addOption(QCommandLineOption(QStringList() << "i" << "install", i18nc("Do not translate <path>", "Install the package at <path>"), "path"));
parser->addOption(QCommandLineOption(QStringList() << "s" << "show", i18nc("Do not translate <name>", "Show information of package <name>"), "name"));
parser->addOption(QCommandLineOption(QStringList() << "u" << "upgrade", i18nc("Do not translate <path>", "Upgrade the package at <path>"), "path"));
parser->addOption(QCommandLineOption(QStringList() << "l" << "list", i18n("List installed packages")));
parser->addOption(QCommandLineOption(QStringList() << "list-types", i18n("lists all known Package types that can be installed")));
parser->addOption(QCommandLineOption(QStringList() << "r" << "remove", i18nc("Do not translate <name>", "Remove the package named <name>"), "name"));
parser->addOption(QCommandLineOption(QStringList() << "p" << "packageroot", i18n("Absolute path to the package root. If not supplied, then the standard data directories for this KDE session will be searched instead."), "path"));
"type", "plasmoid"));
parser.addOption(QCommandLineOption(QStringList() << "i" << "install", i18nc("Do not translate <path>", "Install the package at <path>"), "path"));
parser.addOption(QCommandLineOption(QStringList() << "s" << "show", i18nc("Do not translate <name>", "Show information of package <name>"), "name"));
parser.addOption(QCommandLineOption(QStringList() << "u" << "upgrade", i18nc("Do not translate <path>", "Upgrade the package at <path>"), "path"));
parser.addOption(QCommandLineOption(QStringList() << "l" << "list", i18n("List installed packages")));
parser.addOption(QCommandLineOption(QStringList() << "list-types", i18n("lists all known Package types that can be installed")));
parser.addOption(QCommandLineOption(QStringList() << "r" << "remove", i18nc("Do not translate <name>", "Remove the package named <name>"), "name"));
parser.addOption(QCommandLineOption(QStringList() << "p" << "packageroot", i18n("Absolute path to the package root. If not supplied, then the standard data directories for this KDE session will be searched instead."), "path"));
return app.exec();
}

View File

@ -87,7 +87,7 @@ void PlasmaPkg::runMain()
{
Plasma::PackageStructure* structure = new Plasma::PackageStructure;
if (d->parser->isSet("hash")) {
const QString path = d->parser->argument("hash");
const QString path = d->parser->value("hash");
Plasma::Package package(structure);
package.setPath(path);
const QString hash = package.contentsHash();
@ -107,19 +107,19 @@ void PlasmaPkg::runMain()
return;
}
QString type = d->parser->argument("type");
QString type = d->parser->value("type");
QString packageRoot = type;
d->pluginTypes.clear();
d->installer = 0;
if (d->parser->isSet("remove")) {
d->package = d->parser->argument("remove");
d->package = d->parser->value("remove");
} else if (d->parser->isSet("upgrade")) {
d->package = d->parser->argument("upgrade");
d->package = d->parser->value("upgrade");
} else if (d->parser->isSet("install")) {
d->package = d->parser->argument("install");
d->package = d->parser->value("install");
} else if (d->parser->isSet("show")) {
d->package = d->parser->argument("show");
d->package = d->parser->value("show");
}
if (!QDir::isAbsolutePath(d->package)) {
@ -269,7 +269,7 @@ void PlasmaPkg::runMain()
if (!d->installer) {
d->coutput(i18n("Could not load installer for package of type %1. Error reported was: %2",
d->parser->argument("type"), error));
d->parser->value("type"), error));
return;
}
@ -442,7 +442,7 @@ QString PlasmaPkg::findPackageRoot(const QString& pluginName, const QString& pre
qWarning() << i18nc("The user entered conflicting options packageroot and global, this is the error message telling the user he can use only one", "The packageroot and global options conflict each other, please select only one.");
::exit(1);
} else if (d->parser->isSet("packageroot")) {
packageRoot = d->parser->argument("packageroot");
packageRoot = d->parser->value("packageroot");
//qDebug() << "(set via arg) d->packageRoot is: " << d->packageRoot;
} else if (d->parser->isSet("global")) {
packageRoot = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, d->packageRoot, QStandardPaths::LocateDirectory).last();