1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-22 18:03:57 +03:00

Refactor groub policy tab widget

Inheritance widget and gpo options check box are removed from .ui
and created in tab's ctor now. Group policy tab is also initialized
with console ptr now.
This commit is contained in:
Semyon Knyazev 2024-02-09 21:32:46 +04:00
parent e6f5638db5
commit be61501281
3 changed files with 18 additions and 26 deletions

View File

@ -36,28 +36,34 @@
#include <QMenu>
#include <QPushButton>
#include <QStandardItemModel>
#include <QVBoxLayout>
#include <QCheckBox>
GroupPolicyTab::GroupPolicyTab(QList<AttributeEdit *> *edit_list, ConsoleWidget *console_widget, const QString &ou_dn, QWidget *parent)
: QWidget(parent) {
: QWidget(parent), console(console_widget) {
ui = new Ui::GroupPolicyTab();
ui->setupUi(this);
auto options_edit = new GpoptionsEdit(ui->gpo_options_check, this);
inheritance_widget = new InheritedPoliciesWidget(console, this);
gpo_options_check = new QCheckBox(tr("Block policy inheritance"), this);
auto options_edit = new GpoptionsEdit(gpo_options_check, this);
ui->verticalLayout->addWidget(inheritance_widget);
ui->verticalLayout->addWidget(gpo_options_check);
edit_list->append({options_edit});
console = console_widget;
target_ou_index = search_gpo_ou_index(console, ou_dn);
if (console && target_ou_index.isValid()) {
ui->inheritance_widget->update(target_ou_index);
connect(ui->gpo_options_check, &QCheckBox::toggled, [this](bool toggled) {
ui->inheritance_widget->hide_not_enforced_inherited_links(toggled);
inheritance_widget->update(target_ou_index);
connect(gpo_options_check, &QCheckBox::toggled, [this](bool toggled) {
inheritance_widget->hide_not_enforced_inherited_links(toggled);
});
connect(options_edit, &GpoptionsEdit::gp_options_changed, [this](bool inheritance_blocked) {
console->get_item(target_ou_index)->setData(inheritance_blocked, PolicyOURole_Inheritance_Block);
ui->inheritance_widget->update(target_ou_index);
inheritance_widget->update(target_ou_index);
PolicyOUResultsWidget *result_ou_widget = dynamic_cast<PolicyOUResultsWidget*>(console->get_result_widget_for_index(target_ou_index));
if (result_ou_widget)

View File

@ -33,6 +33,8 @@
*/
class ConsoleWidget;
class InheritedPoliciesWidget;
class QCheckBox;
namespace Ui {
class GroupPolicyTab;
@ -50,6 +52,8 @@ public:
private:
ConsoleWidget *console;
QModelIndex target_ou_index;
InheritedPoliciesWidget *inheritance_widget;
QCheckBox *gpo_options_check;
};
#endif /* GROUP_POLICY_TAB_H */

View File

@ -27,26 +27,8 @@
</property>
</widget>
</item>
<item>
<widget class="InheritedPoliciesWidget" name="inheritance_widget" native="true"/>
</item>
<item>
<widget class="QCheckBox" name="gpo_options_check">
<property name="text">
<string>Block policy inheritance</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>InheritedPoliciesWidget</class>
<extends>QWidget</extends>
<header>policy_ou_results_widget/inherited_policies_widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>