feat: add option to provide window title through admc

This commit is contained in:
august-alt 2022-03-30 12:30:59 +04:00
parent 2f116aaf2e
commit 5bdfc9eaea
7 changed files with 68 additions and 11 deletions

View File

@ -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.

View File

@ -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
Показать справочное сообщение и закончить работу.

View File

@ -28,8 +28,9 @@ namespace gpui {
class CommandLineOptions
{
public:
QString policyBundle {};
QString path {};
QString policyBundle {};
QString policyName {};
};
}

View File

@ -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;
}

View File

@ -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>

View File

@ -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>

View File

@ -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) {