mirror of
https://github.com/altlinux/admc.git
synced 2025-02-09 01:57:26 +03:00
merge MainWindow::connect_to_server() into ctor
don't need to disable/enable filter action anymore also don't need to save some impl's as members move state/geom restore to before connections
This commit is contained in:
parent
13aa4a9cfc
commit
143072a63c
@ -59,6 +59,7 @@ MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
|
||||
g_status()->init(ui->statusbar, ui->message_log_edit);
|
||||
|
||||
d->client_user_label = new QLabel();
|
||||
d->client_user_label->setText(ad.client_user());
|
||||
ui->statusbar->addPermanentWidget(d->client_user_label);
|
||||
|
||||
auto action_show_client_user = new QAction("Show Client User", this);
|
||||
@ -67,10 +68,6 @@ MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
|
||||
|
||||
d->filter_dialog = new ConsoleFilterDialog(this);
|
||||
|
||||
// NOTE: disable console filter until connection because
|
||||
// connection is required to init the dialog
|
||||
ui->action_filter_objects->setEnabled(false);
|
||||
|
||||
//
|
||||
// Console
|
||||
//
|
||||
@ -83,14 +80,14 @@ MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
|
||||
auto policy_impl = new PolicyImpl(ui->console);
|
||||
ui->console->register_impl(ItemType_Policy, policy_impl);
|
||||
|
||||
d->query_item_impl = new QueryItemImpl(ui->console);
|
||||
ui->console->register_impl(ItemType_QueryItem, d->query_item_impl);
|
||||
auto query_item_impl = new QueryItemImpl(ui->console);
|
||||
ui->console->register_impl(ItemType_QueryItem, query_item_impl);
|
||||
|
||||
d->query_folder_impl = new QueryFolderImpl(ui->console);
|
||||
ui->console->register_impl(ItemType_QueryFolder, d->query_folder_impl);
|
||||
auto query_folder_impl = new QueryFolderImpl(ui->console);
|
||||
ui->console->register_impl(ItemType_QueryFolder, query_folder_impl);
|
||||
|
||||
d->object_impl->set_policy_impl(policy_impl);
|
||||
d->query_item_impl->set_query_folder_impl(d->query_folder_impl);
|
||||
query_item_impl->set_query_folder_impl(query_folder_impl);
|
||||
|
||||
// Create dialogs opened from menubar
|
||||
auto manual_dialog = new ManualDialog(this);
|
||||
@ -178,8 +175,60 @@ MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
|
||||
ui->menu_view->removeAction(ui->action_toggle_message_log);
|
||||
ui->menu_view->removeAction(ui->action_toggle_toolbar);
|
||||
|
||||
// Load console tree's
|
||||
console_object_tree_init(ui->console, ad);
|
||||
console_policy_tree_init(ui->console);
|
||||
console_query_tree_init(ui->console);
|
||||
|
||||
// Set current scope to object head to load it
|
||||
const QModelIndex object_tree_root = get_object_tree_root(ui->console);
|
||||
if (object_tree_root.isValid()) {
|
||||
ui->console->set_current_scope(object_tree_root);
|
||||
}
|
||||
|
||||
d->filter_dialog->init(ad.adconfig());
|
||||
on_filter_dialog_accepted();
|
||||
|
||||
query_item_impl->init(ad.adconfig());
|
||||
query_folder_impl->init(ad.adconfig());
|
||||
|
||||
// Display any errors that happened when loading the
|
||||
// console
|
||||
g_status()->display_ad_messages(ad, this);
|
||||
|
||||
//
|
||||
// Connect actions
|
||||
// Restore state
|
||||
//
|
||||
|
||||
// NOTE: must restore state after everything is setup
|
||||
const QVariant console_widget_state = settings_get_variant(SETTING_console_widget_state);
|
||||
ui->console->restore_state(console_widget_state);
|
||||
|
||||
const bool restored_geometry = settings_restore_geometry(SETTING_main_window_geometry, this);
|
||||
if (!restored_geometry) {
|
||||
resize(1024, 768);
|
||||
}
|
||||
|
||||
const QByteArray state = settings_get_variant(SETTING_main_window_state).toByteArray();
|
||||
if (!state.isEmpty()) {
|
||||
restoreState(state);
|
||||
} else {
|
||||
// Hide message log by default
|
||||
ui->message_log->hide();
|
||||
}
|
||||
|
||||
const bool first_time_opening_this_version = []() {
|
||||
const QString last_version = settings_get_variant(SETTING_last_opened_version).toString();
|
||||
|
||||
return (last_version != ADMC_VERSION);
|
||||
}();
|
||||
if (first_time_opening_this_version) {
|
||||
settings_set_variant(SETTING_last_opened_version, ADMC_VERSION);
|
||||
changelog_dialog->show();
|
||||
}
|
||||
|
||||
//
|
||||
// Connect
|
||||
//
|
||||
connect(
|
||||
ui->action_connection_options, &QAction::triggered,
|
||||
@ -248,34 +297,6 @@ MainWindow::MainWindow(AdInterface &ad, QWidget *parent)
|
||||
connect(
|
||||
ui->menu_action, &QMenu::aboutToShow,
|
||||
ui->console, &ConsoleWidget::update_actions);
|
||||
|
||||
const bool restored_geometry = settings_restore_geometry(SETTING_main_window_geometry, this);
|
||||
if (!restored_geometry) {
|
||||
resize(1024, 768);
|
||||
}
|
||||
|
||||
const QByteArray state = settings_get_variant(SETTING_main_window_state).toByteArray();
|
||||
if (!state.isEmpty()) {
|
||||
restoreState(state);
|
||||
} else {
|
||||
// Hide message log by default
|
||||
ui->message_log->hide();
|
||||
}
|
||||
|
||||
const QVariant console_widget_state = settings_get_variant(SETTING_console_widget_state);
|
||||
ui->console->restore_state(console_widget_state);
|
||||
|
||||
connect_to_server(ad);
|
||||
|
||||
const bool first_time_opening_this_version = []() {
|
||||
const QString last_version = settings_get_variant(SETTING_last_opened_version).toString();
|
||||
|
||||
return (last_version != ADMC_VERSION);
|
||||
}();
|
||||
if (first_time_opening_this_version) {
|
||||
settings_set_variant(SETTING_last_opened_version, ADMC_VERSION);
|
||||
changelog_dialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
@ -397,41 +418,6 @@ void MainWindow::on_language_action(bool checked) {
|
||||
message_box_information(this, tr("Info"), tr("Restart the app to switch to the selected language."));
|
||||
}
|
||||
|
||||
void MainWindow::connect_to_server(AdInterface &ad) {
|
||||
d->client_user_label->setText(ad.client_user());
|
||||
|
||||
// Load console tree's
|
||||
console_object_tree_init(ui->console, ad);
|
||||
console_policy_tree_init(ui->console);
|
||||
console_query_tree_init(ui->console);
|
||||
|
||||
// Set current scope to object head to load it
|
||||
const QModelIndex object_tree_root = get_object_tree_root(ui->console);
|
||||
if (object_tree_root.isValid()) {
|
||||
ui->console->set_current_scope(object_tree_root);
|
||||
}
|
||||
|
||||
// Display any errors that happened when loading the
|
||||
// console
|
||||
g_status()->display_ad_messages(ad, this);
|
||||
|
||||
d->filter_dialog->init(ad.adconfig());
|
||||
on_filter_dialog_accepted();
|
||||
|
||||
d->query_item_impl->init(ad.adconfig());
|
||||
d->query_folder_impl->init(ad.adconfig());
|
||||
|
||||
ui->action_filter_objects->setEnabled(true);
|
||||
|
||||
// NOTE: need to restore console state again after
|
||||
// successful connection because some state like column
|
||||
// visibility requires models to be populated with
|
||||
// items. Until connection to the domain, the object
|
||||
// tree is empty.
|
||||
const QVariant console_widget_state = settings_get_variant(SETTING_console_widget_state);
|
||||
ui->console->restore_state(console_widget_state);
|
||||
}
|
||||
|
||||
void MainWindow::refresh_object_tree() {
|
||||
const QModelIndex object_tree_root = get_object_tree_root(ui->console);
|
||||
if (!object_tree_root.isValid()) {
|
||||
|
@ -45,7 +45,6 @@ protected:
|
||||
private:
|
||||
MainWindowPrivate *d;
|
||||
|
||||
void connect_to_server(AdInterface &ad);
|
||||
void refresh_object_tree();
|
||||
void on_show_non_containers(bool checked);
|
||||
void on_dev_mode(bool checked);
|
||||
|
@ -26,14 +26,10 @@
|
||||
class ObjectImpl;
|
||||
class ConsoleFilterDialog;
|
||||
class QLabel;
|
||||
class QueryItemImpl;
|
||||
class QueryFolderImpl;
|
||||
|
||||
class MainWindowPrivate final {
|
||||
public:
|
||||
ObjectImpl *object_impl;
|
||||
QueryItemImpl *query_item_impl;
|
||||
QueryFolderImpl *query_folder_impl;
|
||||
ConsoleFilterDialog *filter_dialog;
|
||||
QLabel *client_user_label;
|
||||
QHash<QLocale::Language, QAction *> language_action_map;
|
||||
|
Loading…
x
Reference in New Issue
Block a user