Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dock-network-plugin/dockcontentwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Q_SLOTS:
m_netView->setMaxHeight(h);
if (m_netView->height() > h)
m_netView->setFixedHeight(h);
setFixedSize(m_netView->width(), qMax(m_minHeight, m_netView->height() + 20 + m_mainLayout->contentsMargins().top() + (m_netCheckBtn->isVisibleTo(this) ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height())));
resize(m_netView->width(), qMax(m_minHeight, m_netView->height() + 20 + m_mainLayout->contentsMargins().top() + (m_netCheckBtn->isVisibleTo(this) ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height())));
}
void setNetCheckBtnVisible(bool visible) {
m_netCheckBtn->setVisible(visible);
Expand Down
12 changes: 4 additions & 8 deletions net-view/window/netview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ NetView::NetView(NetManager *manager)
: QTreeView(nullptr)
, m_manager(manager)
, m_closeOnClear(true)
, m_shouldUpdateExpand(true)
, m_maxHeight(400)
{
#ifdef QT_SCROLL_WHEEL_ANI
Expand Down Expand Up @@ -113,7 +112,6 @@ void NetView::clear()

m_manager->exec(NetManager::UserCancelRequest, "");
scrollTo(model()->index(0, 0));
m_shouldUpdateExpand = true;
}

void NetView::rowsInserted(const QModelIndex &parent, int start, int end)
Expand Down Expand Up @@ -142,11 +140,15 @@ void NetView::rowsInserted(const QModelIndex &parent, int start, int end)
case NetType::WirelessOtherItem: {
NetWirelessOtherItem *otherItem = NetItem::toItem<NetWirelessOtherItem>(item);
if (otherItem) {
// 添加的节点后更新一下展开状态
m_manager->exec(NetManager::ToggleExpand, "");
updateItemExpand(otherItem);
connect(otherItem, &NetWirelessOtherItem::expandedChanged, this, &NetView::onExpandStatusChanged, Qt::UniqueConnection);
}
} break;
case NetType::WirelessMineItem:
// 添加的节点后更新一下展开状态
m_manager->exec(NetManager::ToggleExpand, "");
updateItemExpand(item);
break;
case NetType::VPNControlItem: {
Expand Down Expand Up @@ -409,11 +411,6 @@ void NetView::showEvent(QShowEvent *event)
{
QTreeView::showEvent(event);
m_manager->setAutoScanEnabled(true);
// 首次打开,需要刷新展开状态
if (m_shouldUpdateExpand)
m_manager->exec(NetManager::ToggleExpand, "");
m_shouldUpdateExpand = false;
updateGeometries();
}

void NetView::hideEvent(QHideEvent *event)
Expand All @@ -425,7 +422,6 @@ void NetView::hideEvent(QHideEvent *event)
// 而网络面板大概在200毫秒之后显示,500毫秒为为了准备足够长的时间(防止不同性能的机器时间可能不同)
QTimer::singleShot(500, this, &NetView::clear);
}
m_shouldUpdateExpand = false;
m_manager->exec(NetManager::ToggleExpand, "");
Q_EMIT updateSize();
m_manager->setAutoScanEnabled(false);
Expand Down
1 change: 0 additions & 1 deletion net-view/window/netview.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ protected Q_SLOTS:
NetModel *m_model;
NetDelegate *m_delegate;
bool m_closeOnClear;
bool m_shouldUpdateExpand;
int m_maxHeight;
};

Expand Down