Fix previous commit.

This commit is contained in:
Nodir Temirkhodjaev 2021-02-21 23:04:03 +05:00
parent ed942cc4d4
commit f556d7e103
2 changed files with 23 additions and 19 deletions

View File

@ -29,6 +29,8 @@ ConnectionsWindow::ConnectionsWindow(FortManager *fortManager, QWidget *parent)
{ {
setupUi(); setupUi();
setupController(); setupController();
syncAutoScroll();
} }
void ConnectionsWindow::setupController() void ConnectionsWindow::setupController()
@ -193,27 +195,14 @@ void ConnectionsWindow::setupLogBlockedIp()
void ConnectionsWindow::setupAutoScroll() void ConnectionsWindow::setupAutoScroll()
{ {
const auto syncAutoScroll = [&] { m_cbAutoScroll = ControlUtil::createCheckBox(settings()->connAutoScroll(), [&](bool checked) {
if (settings()->connAutoScroll()) { if (settings()->connAutoScroll() == checked)
connect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView, return;
&QAbstractItemView::scrollToBottom);
} else {
disconnect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView,
&QAbstractItemView::scrollToBottom);
}
};
syncAutoScroll(); settings()->setConnAutoScroll(checked);
m_cbAutoScroll = ControlUtil::createCheckBox( syncAutoScroll();
settings()->connAutoScroll(), [&, syncAutoScroll](bool checked) { });
if (settings()->connAutoScroll() == checked)
return;
settings()->setConnAutoScroll(checked);
syncAutoScroll();
});
} }
void ConnectionsWindow::setupTableConnList() void ConnectionsWindow::setupTableConnList()
@ -281,6 +270,19 @@ void ConnectionsWindow::setupTableConnsChanged()
connect(m_connListView, &TableView::currentIndexChanged, this, refreshTableConnsChanged); connect(m_connListView, &TableView::currentIndexChanged, this, refreshTableConnsChanged);
} }
void ConnectionsWindow::syncAutoScroll()
{
if (settings()->connAutoScroll()) {
connect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView,
&QAbstractItemView::scrollToBottom);
m_connListView->scrollToBottom();
} else {
disconnect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView,
&QAbstractItemView::scrollToBottom);
}
}
void ConnectionsWindow::deleteConn(int row) void ConnectionsWindow::deleteConn(int row)
{ {
const auto connRow = connListModel()->connRowAt(row); const auto connRow = connListModel()->connRowAt(row);

View File

@ -42,6 +42,8 @@ private:
void setupAppInfoRow(); void setupAppInfoRow();
void setupTableConnsChanged(); void setupTableConnsChanged();
void syncAutoScroll();
void deleteConn(int row); void deleteConn(int row);
void deleteSelectedConns(); void deleteSelectedConns();