From 7d3aa4af6ac740495731af85e357f2ad1d3d1186 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 26 May 2021 09:35:49 +0300 Subject: [PATCH] UI: Connections: Apply options on window open. --- src/ui/form/stat/pages/connectionspage.cpp | 16 +++++++++------- src/ui/form/stat/pages/connectionspage.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ui/form/stat/pages/connectionspage.cpp b/src/ui/form/stat/pages/connectionspage.cpp index 4571bda7..6818d50b 100644 --- a/src/ui/form/stat/pages/connectionspage.cpp +++ b/src/ui/form/stat/pages/connectionspage.cpp @@ -30,6 +30,9 @@ ConnectionsPage::ConnectionsPage(StatisticsController *ctrl, QWidget *parent) : StatBasePage(ctrl, parent) { setupUi(); + + updateAutoScroll(); + updateShowHostNames(); } ConnListModel *ConnectionsPage::connListModel() const @@ -173,7 +176,7 @@ void ConnectionsPage::setupAutoScroll() iniUser()->setStatAutoScroll(checked); confManager()->saveIniUser(); - syncAutoScroll(); + updateAutoScroll(); }); } @@ -187,7 +190,7 @@ void ConnectionsPage::setupShowHostNames() iniUser()->setStatShowHostNames(checked); confManager()->saveIniUser(); - syncShowHostNames(); + updateShowHostNames(); }); } @@ -260,20 +263,19 @@ void ConnectionsPage::setupTableConnsChanged() connect(m_connListView, &TableView::currentIndexChanged, this, refreshTableConnsChanged); } -void ConnectionsPage::syncAutoScroll() +void ConnectionsPage::updateAutoScroll() { if (iniUser()->statAutoScroll()) { - connect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView, + connect(connListModel(), &QAbstractItemModel::modelReset, m_connListView, &QAbstractItemView::scrollToBottom); m_connListView->scrollToBottom(); } else { - disconnect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView, - &QAbstractItemView::scrollToBottom); + connListModel()->disconnect(m_connListView); } } -void ConnectionsPage::syncShowHostNames() +void ConnectionsPage::updateShowHostNames() { connListModel()->setResolveAddress(iniUser()->statShowHostNames()); } diff --git a/src/ui/form/stat/pages/connectionspage.h b/src/ui/form/stat/pages/connectionspage.h index 33c4f37b..484aa697 100644 --- a/src/ui/form/stat/pages/connectionspage.h +++ b/src/ui/form/stat/pages/connectionspage.h @@ -45,8 +45,8 @@ private: void setupAppInfoRow(); void setupTableConnsChanged(); - void syncAutoScroll(); - void syncShowHostNames(); + void updateAutoScroll(); + void updateShowHostNames(); void deleteConn(int row);