mirror of
https://github.com/altlinux/admc.git
synced 2024-10-27 01:55:37 +03:00
add UserWidget
This commit is contained in:
parent
3e68dec885
commit
e9f34d36cc
@ -65,6 +65,7 @@ set(ADTOOL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/advanced_view_proxy.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/dn_column_proxy.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/user_widget.cpp
|
||||
)
|
||||
|
||||
add_definitions(${QT5_DEFINITIONS})
|
||||
|
@ -428,7 +428,6 @@ void AdInterface::set_pass(const QString &dn, const QString &password) {
|
||||
int result = connection->setpass(dn_cstr, password_cstr);
|
||||
|
||||
if (result == AD_SUCCESS) {
|
||||
// TODO: which attribs get updated? pass shouldn't be shown
|
||||
load_attributes(dn);
|
||||
emit attributes_changed(dn);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "entry_context_menu.h"
|
||||
#include "containers_widget.h"
|
||||
#include "contents_widget.h"
|
||||
#include "user_widget.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QStandardItemModel>
|
||||
@ -35,10 +36,12 @@ DetailsWidget::DetailsWidget(EntryContextMenu *entry_context_menu, ContainersWid
|
||||
{
|
||||
members_widget = new MembersWidget(entry_context_menu, this);
|
||||
attributes_widget = new AttributesWidget(this);
|
||||
user_widget = new UserWidget(this);
|
||||
|
||||
// Add all tabs to take ownership of them
|
||||
// Add all tabs to incorporate them in the layout
|
||||
addTab(attributes_widget, "");
|
||||
addTab(members_widget, "");
|
||||
addTab(user_widget, "");
|
||||
|
||||
connect(
|
||||
AD(), &AdInterface::ad_interface_login_complete,
|
||||
@ -82,6 +85,11 @@ void DetailsWidget::change_target(const QString &dn) {
|
||||
addTab(members_widget, "Group members");
|
||||
}
|
||||
|
||||
bool is_user = AD()->is_user(target_dn);
|
||||
if (is_user) {
|
||||
addTab(user_widget, "User");
|
||||
}
|
||||
|
||||
// Restore current index if it is still shown
|
||||
// Otherwise current index is set to first tab by default
|
||||
const int old_tab_index_in_new_tabs = indexOf(old_tab);
|
||||
|
@ -29,6 +29,7 @@ class MembersWidget;
|
||||
class EntryContextMenu;
|
||||
class ContainersWidget;
|
||||
class ContentsWidget;
|
||||
class UserWidget;
|
||||
|
||||
// Shows info about entry's attributes in multiple tabs
|
||||
// Targeted at a particular entry
|
||||
@ -52,6 +53,7 @@ private slots:
|
||||
private:
|
||||
AttributesWidget *attributes_widget = nullptr;
|
||||
MembersWidget *members_widget = nullptr;
|
||||
UserWidget *user_widget = nullptr;
|
||||
QString target_dn;
|
||||
|
||||
void change_target(const QString &dn);
|
||||
|
56
src/user_widget.cpp
Normal file
56
src/user_widget.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 "user_widget.h"
|
||||
#include "ad_interface.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QInputDialog>
|
||||
|
||||
UserWidget::UserWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
const auto reset_password_button = new QPushButton("Reset password", this);
|
||||
|
||||
const auto layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(reset_password_button);
|
||||
|
||||
connect(
|
||||
reset_password_button, &QAbstractButton::clicked,
|
||||
this, &UserWidget::on_reset_password_button);
|
||||
}
|
||||
|
||||
void UserWidget::change_target(const QString &dn) {
|
||||
target = dn;
|
||||
}
|
||||
|
||||
void UserWidget::on_reset_password_button() {
|
||||
const QString title = "Reset password";
|
||||
const QString input_label = "New password:";
|
||||
bool ok;
|
||||
const QString new_password = QInputDialog::getText(this, title, input_label, QLineEdit::Normal, "", &ok);
|
||||
|
||||
if (ok && !new_password.isEmpty()) {
|
||||
AD()->set_pass(target, new_password);
|
||||
}
|
||||
}
|
43
src/user_widget.h
Normal file
43
src/user_widget.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 USER_WIDGET_H
|
||||
#define USER_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QString;
|
||||
|
||||
// Details tab with user-related stuff
|
||||
class UserWidget final : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UserWidget(QWidget *parent);
|
||||
|
||||
void change_target(const QString &dn);
|
||||
|
||||
private slots:
|
||||
void on_reset_password_button();
|
||||
|
||||
private:
|
||||
QString target;
|
||||
};
|
||||
|
||||
#endif /* USER_WIDGET_H */
|
Loading…
Reference in New Issue
Block a user