mirror of
https://github.com/altlinux/admc.git
synced 2025-02-13 17:57:25 +03:00
add unlock edit
change it from button to a one-way checkbox now has the edit marker
This commit is contained in:
parent
752a9afcd4
commit
afc3c9280b
@ -78,6 +78,7 @@ set(ADMC_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/attribute_edit.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/country_edit.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/expiry_edit.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/unlock_edit.cpp
|
||||
)
|
||||
|
||||
set(TS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/translations)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "utils.h"
|
||||
#include "attribute_edit.h"
|
||||
#include "expiry_edit.h"
|
||||
#include "unlock_edit.h"
|
||||
#include "ad_interface.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
@ -36,7 +37,7 @@ AccountTab::AccountTab(DetailsWidget *details_arg)
|
||||
const auto logon_name_edit = new StringEdit(ATTRIBUTE_USER_PRINCIPAL_NAME);
|
||||
edits.append(logon_name_edit);
|
||||
|
||||
const auto unlock_button = new QPushButton(tr("Unlock account"));
|
||||
edits.append(new UnlockEdit());
|
||||
|
||||
QList<AccountOption> options;
|
||||
for (int i = 0; i < AccountOption_COUNT; i++) {
|
||||
@ -60,10 +61,6 @@ AccountTab::AccountTab(DetailsWidget *details_arg)
|
||||
const auto top_layout = new QVBoxLayout();
|
||||
setLayout(top_layout);
|
||||
top_layout->addLayout(edits_layout);
|
||||
|
||||
connect(
|
||||
unlock_button, &QAbstractButton::clicked,
|
||||
this, &AccountTab::on_unlock_button);
|
||||
}
|
||||
|
||||
bool AccountTab::changed() const {
|
||||
@ -87,7 +84,3 @@ bool AccountTab::accepts_target() const {
|
||||
|
||||
return is_user;
|
||||
}
|
||||
|
||||
void AccountTab::on_unlock_button() {
|
||||
AdInterface::instance()->user_unlock(target());
|
||||
}
|
||||
|
@ -33,9 +33,6 @@ public:
|
||||
AccountTab(DetailsWidget *details_arg);
|
||||
DECL_DETAILS_TAB_VIRTUALS();
|
||||
|
||||
private slots:
|
||||
void on_unlock_button();
|
||||
|
||||
private:
|
||||
QList<AttributeEdit *> edits;
|
||||
};
|
||||
|
68
src/unlock_edit.cpp
Normal file
68
src/unlock_edit.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "unlock_edit.h"
|
||||
#include "ad_interface.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
|
||||
// This edit works differently from other account option edits. The checkbox starts out as unchecked, if it's checked, then applying will unlock the user. Unchecking only disables the unlock action, it DOES NOT lock the user. Can't lock the account manually. Also finding out whether user is locked is convoluted, so can't show any status about that.
|
||||
|
||||
UnlockEdit::UnlockEdit() {
|
||||
check = new QCheckBox();
|
||||
|
||||
connect(
|
||||
check, &QCheckBox::stateChanged,
|
||||
[this]() {
|
||||
emit edited();
|
||||
});
|
||||
}
|
||||
|
||||
void UnlockEdit::load(const QString &dn) {
|
||||
check->setChecked(false);
|
||||
}
|
||||
|
||||
void UnlockEdit::add_to_layout(QGridLayout *layout) {
|
||||
const auto label = new QLabel(tr("Unlock account"));
|
||||
|
||||
label->setToolTip(tr("Can only unlock the account, impossible to lock it manually."));
|
||||
|
||||
setup_edit_marker(this, label);
|
||||
append_to_grid_layout_with_label(layout, label, check);
|
||||
}
|
||||
|
||||
bool UnlockEdit::verify_input(QWidget *parent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnlockEdit::changed() const {
|
||||
return checkbox_is_checked(check);
|
||||
}
|
||||
|
||||
bool UnlockEdit::apply(const QString &dn) {
|
||||
if (checkbox_is_checked(check)) {
|
||||
const bool result = AdInterface::instance()->user_unlock(dn);
|
||||
return result;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
37
src/unlock_edit.h
Normal file
37
src/unlock_edit.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UNLOCK_EDIT_H
|
||||
#define UNLOCK_EDIT_H
|
||||
|
||||
#include "attribute_edit.h"
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
class UnlockEdit final : public AttributeEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UnlockEdit();
|
||||
DECL_ATTRIBUTE_EDIT_VIRTUALS();
|
||||
|
||||
private:
|
||||
QCheckBox *check;
|
||||
};
|
||||
|
||||
#endif /* UNLOCK_EDIT_H */
|
Loading…
x
Reference in New Issue
Block a user