From 5bdfc9eaeaac04b3d5d55025559ee84eece8ce41 Mon Sep 17 00:00:00 2001 From: august-alt <77973983+august-alt@users.noreply.github.com> Date: Wed, 30 Mar 2022 12:30:59 +0400 Subject: [PATCH] feat: add option to provide window title through admc --- setup/man/en/gpui.1 | 6 +++++- setup/man/ru/gpui.1 | 5 ++++- src/gui/commandlineoptions.h | 3 ++- src/gui/commandlineparser.cpp | 14 ++++++++++++++ src/gui/i18n/gui_en.ts | 23 +++++++++++++++++++---- src/gui/i18n/gui_ru.ts | 23 +++++++++++++++++++---- src/gui/mainwindow.cpp | 5 +++++ 7 files changed, 68 insertions(+), 11 deletions(-) diff --git a/setup/man/en/gpui.1 b/setup/man/en/gpui.1 index 4363ade..b571d80 100644 --- a/setup/man/en/gpui.1 +++ b/setup/man/en/gpui.1 @@ -4,7 +4,7 @@ .SH NAME gpui-main \- manage group policy templates .SH SYNOPSIS -gpui-main [-p policy path] [-b admx path] [-h | --help] [-v | --version] +gpui-main [-p policy path] [-b admx path] [-n name of a policy] [-h | --help] [-v | --version] .SH DESCRIPTION gpui-main is a program for managing group policy templates. .SH OPTIONS @@ -14,6 +14,10 @@ Provide the full path of the policy to edit. .TP .if !'po4a'hide' .BR \-b Provide the path of admx files to load. +.TP +.if !'po4a'hide' .BR \-n +The parameter to be used in conjunction with ADMC, allows ADMC to pass the name of the GPO which will be used in +a window title. .TP .if !'po4a'hide' .BR \-h ", " \-\-help Show help message and exit program. diff --git a/setup/man/ru/gpui.1 b/setup/man/ru/gpui.1 index 9dcf133..e8a466a 100644 --- a/setup/man/ru/gpui.1 +++ b/setup/man/ru/gpui.1 @@ -4,7 +4,7 @@ .SH NAME gpui-main \- редактирует шаблоны групповых политик .SH SYNOPSIS -gpui-main [-p путь к политике] [-b путь к admx файлам] [-h | --help] [-v | --version] +gpui-main [-p путь к политике] [-b путь к admx файлам] [-n имя политики для отображения] [-h | --help] [-v | --version] .SH DESCRIPTION gpui-main это программа для управления шаблонами групповой политики. .SH OPTIONS @@ -14,6 +14,9 @@ gpui-main это программа для управления шаблонам .TP .if !'po4a'hide' .BR \-b Позволяет указать путь для загрузки admx файлов. +.TP +.if !'po4a'hide' .BR \-n +Параметр для использования совместно с ADMC, позволяет ADMC передать имя GPO для отображения. .TP .if !'po4a'hide' .BR \-h ", " \-\-help Показать справочное сообщение и закончить работу. diff --git a/src/gui/commandlineoptions.h b/src/gui/commandlineoptions.h index cbae38f..ea9bbb1 100644 --- a/src/gui/commandlineoptions.h +++ b/src/gui/commandlineoptions.h @@ -28,8 +28,9 @@ namespace gpui { class CommandLineOptions { public: - QString policyBundle {}; QString path {}; + QString policyBundle {}; + QString policyName {}; }; } diff --git a/src/gui/commandlineparser.cpp b/src/gui/commandlineparser.cpp index 62fdef5..867eb8b 100644 --- a/src/gui/commandlineparser.cpp +++ b/src/gui/commandlineparser.cpp @@ -72,6 +72,7 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co const QCommandLineOption pathOption("p", QObject::tr("The full path of policy to edit."), QObject::tr("path")); const QCommandLineOption bundleOption("b", QObject::tr("The full path of policy bundle to load."), QObject::tr("path")); + const QCommandLineOption nameOption("n", QObject::tr("The name of a policy to display."), QObject::tr("name")); const QCommandLineOption helpOption(QStringList() #ifdef Q_OS_WIN << QStringLiteral("?") @@ -126,6 +127,19 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co } } + if (d->parser->isSet(nameOption)) + { + const QString name = d->parser->value(nameOption); + options->policyName = name; + + if (options->policyName.isNull() || options->policyName.isEmpty()) + { + *errorMessage = QObject::tr("Bad policy name: ") + name; + return CommandLineError; + } + } + + return CommandLineOk; } diff --git a/src/gui/i18n/gui_en.ts b/src/gui/i18n/gui_en.ts index 6bea81a..81826ef 100644 --- a/src/gui/i18n/gui_en.ts +++ b/src/gui/i18n/gui_en.ts @@ -748,6 +748,16 @@ context (user policy option).</translation> <source>The full path of policy bundle to load.</source> <translation>The full path of policy bundle to load.</translation> </message> + <message> + <location line="+1"/> + <source>The name of a policy to display.</source> + <translation>The name of a policy to display.</translation> + </message> + <message> + <location line="+0"/> + <source>name</source> + <translation>name</translation> + </message> <message> <location line="+6"/> <source>Displays help on commandline options.</source> @@ -760,7 +770,12 @@ context (user policy option).</translation> <translation>Bad policy path: </translation> </message> <message> - <location filename="../contentwidget.cpp" line="+209"/> + <location line="+12"/> + <source>Bad policy name: </source> + <translation>Bad policy name: </translation> + </message> + <message> + <location filename="../contentwidget.cpp" line="+216"/> <source>Save settings dialog</source> <translation>Save settings dialog</translation> </message> @@ -811,18 +826,18 @@ context (user policy option).</translation> </message> <message> <location filename="../mainwindow.cpp" line="+165"/> - <location line="+330"/> + <location line="+335"/> <location line="+62"/> <source>Error</source> <translation>Error</translation> </message> <message> - <location line="-391"/> + <location line="-396"/> <source>Error writing file:</source> <translation>Error writing file:</translation> </message> <message> - <location line="+145"/> + <location line="+150"/> <source>[Domain Group Policy]</source> <translation>[Domain Group Policy]</translation> </message> diff --git a/src/gui/i18n/gui_ru.ts b/src/gui/i18n/gui_ru.ts index a8bce33..bc86cef 100644 --- a/src/gui/i18n/gui_ru.ts +++ b/src/gui/i18n/gui_ru.ts @@ -746,6 +746,16 @@ context (user policy option).</source> <source>The full path of policy bundle to load.</source> <translation>Полный путь к набору ADMX файлов.</translation> </message> + <message> + <location line="+1"/> + <source>The name of a policy to display.</source> + <translation>Имя политики для отображения.</translation> + </message> + <message> + <location line="+0"/> + <source>name</source> + <translation>имя</translation> + </message> <message> <location line="+6"/> <source>Displays help on commandline options.</source> @@ -758,7 +768,12 @@ context (user policy option).</source> <translation>Неверный путь к политике: </translation> </message> <message> - <location filename="../contentwidget.cpp" line="+209"/> + <location line="+12"/> + <source>Bad policy name: </source> + <translation>Ошибочное название политики: </translation> + </message> + <message> + <location filename="../contentwidget.cpp" line="+216"/> <source>Save settings dialog</source> <translation>Состояние настроек</translation> </message> @@ -809,18 +824,18 @@ context (user policy option).</source> </message> <message> <location filename="../mainwindow.cpp" line="+165"/> - <location line="+330"/> + <location line="+335"/> <location line="+62"/> <source>Error</source> <translation>Ошибка</translation> </message> <message> - <location line="-391"/> + <location line="-396"/> <source>Error writing file:</source> <translation>Ошибка записи файла:</translation> </message> <message> - <location line="+145"/> + <location line="+150"/> <source>[Domain Group Policy]</source> <translation>[Доменная групповая политика]</translation> </message> diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index f5ffffd..7447afc 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -248,6 +248,11 @@ MainWindow::MainWindow(CommandLineOptions &options, QWidget *parent) onIniFileOpen(d->options.path + "/gpt.ini"); } + if (!d->options.policyName.isEmpty()) + { + setWindowTitle("GPUI - " + d->options.policyName); + } + connect(d->contentWidget, &ContentWidget::savePolicyChanges, this, &MainWindow::onRegistrySourceSave); connect(ui->searchLineEdit, &QLineEdit::textChanged, [&](const QString& text) {