mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
improve scroll
This commit is contained in:
@@ -17,5 +17,6 @@ namespace NekoRay {
|
||||
GroupSortMethod::GroupSortMethod method = GroupSortMethod::Raw;
|
||||
bool save_sort = false; //保存到文件
|
||||
bool descending = false; //默认升序,开这个就是降序
|
||||
bool scroll_to_started = false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -467,12 +467,16 @@ void MainWindow::show_group(int gid) {
|
||||
MessageBoxWarning(tr("Error"), QString("No such group: %1").arg(gid));
|
||||
return;
|
||||
}
|
||||
|
||||
if (NekoRay::dataStore->current_group != gid) {
|
||||
NekoRay::dataStore->current_group = gid;
|
||||
NekoRay::dataStore->Save();
|
||||
}
|
||||
ui->tabWidget->widget(groupId2TabIndex(gid))->layout()->addWidget(ui->proxyListTable);
|
||||
refresh_proxy_list();
|
||||
|
||||
NekoRay::GroupSortAction gsa;
|
||||
gsa.scroll_to_started = true;
|
||||
refresh_proxy_list_impl(-1, gsa);
|
||||
}
|
||||
|
||||
// callback
|
||||
@@ -727,6 +731,8 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction
|
||||
ui->proxyListTable->setRowCount(0);
|
||||
}
|
||||
|
||||
QTableWidgetItem *started_item = nullptr;
|
||||
|
||||
// 绘制或更新item(s)
|
||||
int row = -1;
|
||||
for (const auto &profile: NekoRay::profileManager->profiles) {
|
||||
@@ -751,6 +757,7 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction
|
||||
auto f = f0->clone();
|
||||
if (profile->id == NekoRay::dataStore->started_id) {
|
||||
f->setText("✓");
|
||||
if (groupSortAction.scroll_to_started) started_item = f;
|
||||
} else {
|
||||
f->setText(" ");
|
||||
}
|
||||
@@ -851,6 +858,12 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction
|
||||
}
|
||||
ui->proxyListTable->update_order(groupSortAction.save_sort);
|
||||
}
|
||||
|
||||
if (started_item != nullptr) {
|
||||
runOnUiThread([=] {
|
||||
ui->proxyListTable->verticalScrollBar()->setSliderPosition(started_item->row());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// table菜单相关
|
||||
|
||||
@@ -242,9 +242,6 @@
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user