Skip to content

Commit

Permalink
Add separate about command for about
Browse files Browse the repository at this point in the history
WE2-713

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored and mrts committed Sep 18, 2023
1 parent 4f378e4 commit 6a1db3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion install/web-eid.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application

Exec=web-eid %F
Exec=web-eid --about
Icon=web-eid

Name=Web eID
Expand Down
29 changes: 22 additions & 7 deletions src/controller/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Application::loadTranslations(const QString& lang)
{
static const QStringList SUPPORTED_LANGS {
QStringLiteral("en"), QStringLiteral("et"), QStringLiteral("fi"), QStringLiteral("hr"),
QStringLiteral("ru"), QStringLiteral("de"), QStringLiteral("fr"), QStringLiteral("nl"),
QStringLiteral("ru"), QStringLiteral("de"), QStringLiteral("fr"), QStringLiteral("nl"),
QStringLiteral("cs"), QStringLiteral("sk")};
QLocale locale;
QString langSetting = QSettings().value(QStringLiteral("lang"), lang).toString();
Expand All @@ -116,9 +116,14 @@ void Application::loadTranslations(const QString& lang)

CommandWithArgumentsPtr Application::parseArgs()
{
QCommandLineOption parentWindow(QStringLiteral("parent-window"),
QStringLiteral("Parent window handle (unused)"),
QStringLiteral("parent-window"));
QCommandLineOption argumentFromExtension(
QStringLiteral("argument-from-extension"),
QStringLiteral("The first argument from the extension. "
"This could be the path to the app manifest (Firefox) or "
"the origin of the extension that started it (Chrome)."),
QStringLiteral("argument-from-extension"));
QCommandLineOption aboutArgument(QStringLiteral("about"),
QStringLiteral("Show Web-eID about window"));
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral(
"Application that communicates with the Web eID browser extension via standard input and "
Expand All @@ -129,7 +134,8 @@ CommandWithArgumentsPtr Application::parseArgs()
parser.addOptions({{{"c", "command-line-mode"},
"Command-line mode, read commands from command line arguments instead of "
"standard input."},
parentWindow});
aboutArgument,
argumentFromExtension});

static const auto COMMANDS = "'" + CMDLINE_GET_SIGNING_CERTIFICATE + "', '"
+ CMDLINE_AUTHENTICATE + "', '" + CMDLINE_SIGN + "'.";
Expand Down Expand Up @@ -158,13 +164,22 @@ CommandWithArgumentsPtr Application::parseArgs()
}
throw ArgumentError("The command has to be one of " + COMMANDS.toStdString());
}
if (parser.isSet(parentWindow)) {
if (parser.isSet(argumentFromExtension)) {
// https://bugs.chromium.org/p/chromium/issues/detail?id=354597#c2
qDebug() << "Parent window handle is unused" << parser.value(parentWindow);
qDebug() << "Argument from extension is unused" << parser.value(argumentFromExtension);
}
if (parser.isSet(aboutArgument)) {
return std::make_unique<CommandWithArguments>(CommandType::ABOUT, QVariantMap());
}
// In Linux, when the application is launched via xdg-desktop-portal from a browser that runs
// inside a Snap/Flatpack/other container, it doesn't receive the extension origin command-line
// argument. Hence, a special case is required to run the application in input-output mode
// instead of opening the about window in Linux.
#ifndef Q_OS_LINUX
if (arguments().size() == 1) {
return std::make_unique<CommandWithArguments>(CommandType::ABOUT, QVariantMap());
}
#endif
return nullptr;
}

Expand Down

0 comments on commit 6a1db3a

Please sign in to comment.