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