mirror of
https://github.com/altlinux/admc.git
synced 2025-03-29 22:50:35 +03:00
change actions to be static MainWindow members
delete actions.cpp
This commit is contained in:
parent
66b6fb878c
commit
2b4127882e
@ -59,7 +59,6 @@ set(ADTOOL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/create_entry_dialog.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/entry_widget.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/actions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/status_bar.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/members_model.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/members_widget.cpp
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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 "actions.h"
|
||||
|
||||
QAction action_advanced_view("Advanced view");
|
||||
QAction action_toggle_dn("Show DN");
|
||||
QAction action_details("Details");
|
||||
QAction action_delete_entry("Delete");
|
||||
QAction action_new_user("New User");
|
||||
QAction action_new_computer("New Computer");
|
||||
QAction action_new_group("New Group");
|
||||
QAction action_new_ou("New OU");
|
||||
QAction action_edit_policy("Edit policy");
|
||||
|
||||
void actions_init() {
|
||||
action_advanced_view.setCheckable(true);
|
||||
action_toggle_dn.setCheckable(true);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 ACTIONS_H
|
||||
#define ACTIONS_H
|
||||
|
||||
#include <QAction>
|
||||
|
||||
extern QAction action_advanced_view;
|
||||
extern QAction action_toggle_dn;
|
||||
extern QAction action_details;
|
||||
extern QAction action_delete_entry;
|
||||
extern QAction action_new_user;
|
||||
extern QAction action_new_computer;
|
||||
extern QAction action_new_group;
|
||||
extern QAction action_new_ou;
|
||||
extern QAction action_edit_policy;
|
||||
|
||||
void actions_init();
|
||||
|
||||
#endif /* ACTIONS_H */
|
@ -20,7 +20,9 @@
|
||||
#include "ad_proxy_model.h"
|
||||
#include "ad_model.h"
|
||||
#include "ad_interface.h"
|
||||
#include "actions.h"
|
||||
#include "main_window.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
AdProxyModel::AdProxyModel(AdModel *model, QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
@ -28,7 +30,7 @@ AdProxyModel::AdProxyModel(AdModel *model, QObject *parent)
|
||||
setSourceModel(model);
|
||||
|
||||
connect(
|
||||
&action_advanced_view, &QAction::triggered,
|
||||
MainWindow::action_advanced_view, &QAction::triggered,
|
||||
this, &AdProxyModel::on_advanced_view_toggled);
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ bool AdProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_pa
|
||||
|
||||
// Hide advanced view only entries if advanced view is OFF
|
||||
const bool advanced_view_only = index.data(AdModel::Roles::AdvancedViewOnly).toBool();
|
||||
const bool advanced_view_is_on = action_advanced_view.isChecked();
|
||||
const bool advanced_view_is_on = MainWindow::action_advanced_view->isChecked();
|
||||
if (advanced_view_only && !advanced_view_is_on) {
|
||||
return false;
|
||||
}
|
||||
|
@ -18,9 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "entry_widget.h"
|
||||
#include "main_window.h"
|
||||
#include "ad_interface.h"
|
||||
#include "entry_model.h"
|
||||
#include "actions.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QItemSelection>
|
||||
@ -33,6 +33,7 @@
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
QSet<EntryWidget *> EntryWidget::instances;
|
||||
|
||||
@ -58,7 +59,7 @@ EntryWidget::EntryWidget(EntryModel *model)
|
||||
update_column_visibility();
|
||||
|
||||
connect(
|
||||
&action_toggle_dn, &QAction::triggered,
|
||||
MainWindow::action_toggle_dn, &QAction::triggered,
|
||||
this, &EntryWidget::on_action_toggle_dn);
|
||||
|
||||
connect(
|
||||
@ -84,23 +85,23 @@ void EntryWidget::on_context_menu_requested(const QPoint &pos) {
|
||||
|
||||
QMenu menu;
|
||||
|
||||
menu.addAction(&action_details);
|
||||
menu.addAction(&action_delete_entry);
|
||||
menu.addAction(MainWindow::action_details);
|
||||
menu.addAction(MainWindow::action_delete_entry);
|
||||
|
||||
QMenu *submenu_new = menu.addMenu("New");
|
||||
submenu_new->addAction(&action_new_user);
|
||||
submenu_new->addAction(&action_new_computer);
|
||||
submenu_new->addAction(&action_new_group);
|
||||
submenu_new->addAction(&action_new_ou);
|
||||
submenu_new->addAction(MainWindow::action_new_user);
|
||||
submenu_new->addAction(MainWindow::action_new_computer);
|
||||
submenu_new->addAction(MainWindow::action_new_group);
|
||||
submenu_new->addAction(MainWindow::action_new_ou);
|
||||
|
||||
const QString dn = entry_model->get_dn_from_index(index);
|
||||
const bool entry_is_policy = attribute_value_exists(dn, "objectClass", "groupPolicyContainer");
|
||||
if (entry_is_policy) {
|
||||
menu.addAction(&action_edit_policy);
|
||||
menu.addAction(MainWindow::action_edit_policy);
|
||||
}
|
||||
|
||||
QPoint global_pos = view->mapToGlobal(pos);
|
||||
menu.exec(global_pos, &action_details);
|
||||
menu.exec(global_pos, MainWindow::action_details);
|
||||
}
|
||||
|
||||
QString EntryWidget::get_selected_dn() {
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "ad_model.h"
|
||||
#include "attributes_model.h"
|
||||
#include "create_entry_dialog.h"
|
||||
#include "actions.h"
|
||||
#include "status_bar.h"
|
||||
|
||||
#include <QString>
|
||||
@ -42,6 +41,16 @@
|
||||
#include <QProcess>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
QAction *MainWindow::action_advanced_view = new QAction("Advanced view");
|
||||
QAction *MainWindow::action_toggle_dn = new QAction("Show DN");
|
||||
QAction *MainWindow::action_details = new QAction("Details");
|
||||
QAction *MainWindow::action_delete_entry = new QAction("Delete");
|
||||
QAction *MainWindow::action_new_user = new QAction("New User");
|
||||
QAction *MainWindow::action_new_computer = new QAction("New Computer");
|
||||
QAction *MainWindow::action_new_group = new QAction("New Group");
|
||||
QAction *MainWindow::action_new_ou = new QAction("New OU");
|
||||
QAction *MainWindow::action_edit_policy = new QAction("Edit policy");
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: QMainWindow()
|
||||
{
|
||||
@ -52,7 +61,6 @@ MainWindow::MainWindow()
|
||||
//
|
||||
// Setup widgets
|
||||
//
|
||||
actions_init();
|
||||
|
||||
// TODO: setting width to 1600+ fullscreens the window, no idea why
|
||||
resize(1500, 1000);
|
||||
@ -71,14 +79,14 @@ MainWindow::MainWindow()
|
||||
setMenuBar(menubar);
|
||||
|
||||
const auto menubar_new = menubar->addMenu("New");
|
||||
menubar_new->addAction(&action_new_user);
|
||||
menubar_new->addAction(&action_new_computer);
|
||||
menubar_new->addAction(&action_new_group);
|
||||
menubar_new->addAction(&action_new_ou);
|
||||
menubar_new->addAction(action_new_user);
|
||||
menubar_new->addAction(action_new_computer);
|
||||
menubar_new->addAction(action_new_group);
|
||||
menubar_new->addAction(action_new_ou);
|
||||
|
||||
const auto menubar_view = menubar->addMenu("View");
|
||||
menubar_view->addAction(&action_advanced_view);
|
||||
menubar_view->addAction(&action_toggle_dn);
|
||||
menubar_view->addAction(action_advanced_view);
|
||||
menubar_view->addAction(action_toggle_dn);
|
||||
|
||||
const auto menubar_preferences = menubar->addMenu("Preferences");
|
||||
action_containers_click_attributes = menubar_preferences->addAction("Open attributes on left click in Containers window");
|
||||
@ -105,29 +113,32 @@ MainWindow::MainWindow()
|
||||
splitter->setStretchFactor(2, 2);
|
||||
|
||||
//
|
||||
// Connect actions
|
||||
// Setup actions
|
||||
//
|
||||
action_advanced_view->setCheckable(true);
|
||||
action_toggle_dn->setCheckable(true);
|
||||
|
||||
connect(
|
||||
&action_details, &QAction::triggered,
|
||||
action_details, &QAction::triggered,
|
||||
this, &MainWindow::on_action_details);
|
||||
connect(
|
||||
&action_delete_entry, &QAction::triggered,
|
||||
action_delete_entry, &QAction::triggered,
|
||||
this, &MainWindow::on_action_delete_entry);
|
||||
connect(
|
||||
&action_new_user, &QAction::triggered,
|
||||
action_new_user, &QAction::triggered,
|
||||
this, &MainWindow::on_action_new_user);
|
||||
connect(
|
||||
&action_new_computer, &QAction::triggered,
|
||||
action_new_computer, &QAction::triggered,
|
||||
this, &MainWindow::on_action_new_computer);
|
||||
connect(
|
||||
&action_new_group, &QAction::triggered,
|
||||
action_new_group, &QAction::triggered,
|
||||
this, &MainWindow::on_action_new_group);
|
||||
connect(
|
||||
&action_new_ou, &QAction::triggered,
|
||||
action_new_ou, &QAction::triggered,
|
||||
this, &MainWindow::on_action_new_ou);
|
||||
|
||||
connect(
|
||||
&action_edit_policy, &QAction::triggered,
|
||||
action_edit_policy, &QAction::triggered,
|
||||
this, &MainWindow::on_action_edit_policy);
|
||||
|
||||
// Set root index of contents view to selection of containers view
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QAction;
|
||||
class QString;
|
||||
class AdModel;
|
||||
class ContainersWidget;
|
||||
@ -36,6 +37,16 @@ Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow();
|
||||
|
||||
static QAction *action_advanced_view;
|
||||
static QAction *action_toggle_dn;
|
||||
static QAction *action_details;
|
||||
static QAction *action_delete_entry;
|
||||
static QAction *action_new_user;
|
||||
static QAction *action_new_computer;
|
||||
static QAction *action_new_group;
|
||||
static QAction *action_new_ou;
|
||||
static QAction *action_edit_policy;
|
||||
|
||||
private slots:
|
||||
void on_action_details();
|
||||
void on_action_delete_entry();
|
||||
|
Loading…
x
Reference in New Issue
Block a user