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();
setupController();
syncAutoScroll();
}
void ConnectionsWindow::setupController()
@ -193,27 +195,14 @@ void ConnectionsWindow::setupLogBlockedIp()
void ConnectionsWindow::setupAutoScroll()
{
const auto syncAutoScroll = [&] {
if (settings()->connAutoScroll()) {
connect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView,
&QAbstractItemView::scrollToBottom);
} else {
disconnect(connListModel(), &QAbstractItemModel::rowsInserted, m_connListView,
&QAbstractItemView::scrollToBottom);
}
};
m_cbAutoScroll = ControlUtil::createCheckBox(settings()->connAutoScroll(), [&](bool checked) {
if (settings()->connAutoScroll() == checked)
return;
syncAutoScroll();
settings()->setConnAutoScroll(checked);
m_cbAutoScroll = ControlUtil::createCheckBox(
settings()->connAutoScroll(), [&, syncAutoScroll](bool checked) {
if (settings()->connAutoScroll() == checked)
return;
settings()->setConnAutoScroll(checked);
syncAutoScroll();
});
syncAutoScroll();
});
}
void ConnectionsWindow::setupTableConnList()
@ -281,6 +270,19 @@ void ConnectionsWindow::setupTableConnsChanged()
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)
{
const auto connRow = connListModel()->connRowAt(row);

View File

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