mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-19 02:10:28 +08:00
add: added recent jumplist, KnownBug: 1
This commit is contained in:
parent
9245cd81f3
commit
66e2832b7b
@ -1 +1 @@
|
||||
5269
|
||||
5270
|
@ -102,14 +102,17 @@ namespace Qv2ray::base::config
|
||||
{
|
||||
QString theme;
|
||||
QString language;
|
||||
QList<QString> recentConnections;
|
||||
bool quietMode;
|
||||
bool useDarkTheme;
|
||||
bool useDarkTrayIcon;
|
||||
int maximumLogLines;
|
||||
Qv2rayUIConfig() : theme("Fusion"), language("en_US"), useDarkTheme(false), useDarkTrayIcon(true), maximumLogLines(500)
|
||||
int maxJumpListCount;
|
||||
Qv2rayUIConfig()
|
||||
: theme("Fusion"), language("en_US"), useDarkTheme(false), useDarkTrayIcon(true), maximumLogLines(500), maxJumpListCount(20)
|
||||
{
|
||||
}
|
||||
XTOSTRUCT(O(theme, language, quietMode, useDarkTheme, useDarkTrayIcon, maximumLogLines))
|
||||
XTOSTRUCT(O(theme, language, quietMode, useDarkTheme, useDarkTrayIcon, maximumLogLines, maxJumpListCount, recentConnections))
|
||||
};
|
||||
|
||||
struct Qv2rayRouteConfig_Impl
|
||||
|
@ -338,6 +338,29 @@ namespace Qv2ray::core::handlers
|
||||
CheckConnectionExistance(id);
|
||||
connections[id].lastConnected = system_clock::to_time_t(system_clock::now());
|
||||
CONFIGROOT root = GetConnectionRoot(id);
|
||||
auto &list = GlobalConfig.uiConfig.recentConnections;
|
||||
|
||||
bool recentListChanged = false;
|
||||
// If the 1st of the list is NOT the current connection.
|
||||
if (!list.isEmpty() && list.first() != id.toString())
|
||||
{
|
||||
list.removeAll(id.toString());
|
||||
// Make it the first.
|
||||
list.push_front(id.toString());
|
||||
recentListChanged = true;
|
||||
}
|
||||
|
||||
while (list.count() > GlobalConfig.uiConfig.maxJumpListCount)
|
||||
{
|
||||
recentListChanged = true;
|
||||
list.removeLast();
|
||||
}
|
||||
|
||||
if (recentListChanged)
|
||||
{
|
||||
emit OnRecentConnectionsChanged(list);
|
||||
}
|
||||
|
||||
return kernelHandler->StartConnection(id, root);
|
||||
}
|
||||
|
||||
@ -501,7 +524,7 @@ namespace Qv2ray::core::handlers
|
||||
// Anyway, we try our best to preserve the connection id.
|
||||
QMultiMap<QString, ConnectionId> nameMap;
|
||||
QMultiMap<tuple<QString, QString, int>, ConnectionId> typeMap;
|
||||
for (const auto conn : groups[id].connections)
|
||||
for (const auto &conn : groups[id].connections)
|
||||
{
|
||||
nameMap.insertMulti(GetDisplayName(conn), conn);
|
||||
auto [protocol, host, port] = GetConnectionInfo(conn);
|
||||
@ -526,7 +549,7 @@ namespace Qv2ray::core::handlers
|
||||
// Things may go wrong when updating a subscription with ssd:// link
|
||||
for (auto _alias : conf.keys())
|
||||
{
|
||||
for (const auto config : conf.values(_alias))
|
||||
for (const auto &config : conf.values(_alias))
|
||||
{
|
||||
if (!errMessage.isEmpty())
|
||||
{
|
||||
|
@ -103,6 +103,7 @@ namespace Qv2ray::core::handlers
|
||||
const tuple<QString, int64_t, float> GetSubscriptionData(const GroupId &id) const;
|
||||
|
||||
signals:
|
||||
void OnRecentConnectionsChanged(const QList<QString> &connections);
|
||||
void OnKernelLogAvailable(const ConnectionId &id, const QString &log);
|
||||
void OnStatsAvailable(const ConnectionId &id, const quint64 upS, const quint64 downS, const quint64 upD, const quint64 downD);
|
||||
//
|
||||
|
@ -113,6 +113,34 @@ void MainWindow::SortConnectionList(MW_ITEM_COL byCol, bool asending)
|
||||
on_locateBtn_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::ReloadRecentConnectionList(const QList<QString> &items)
|
||||
{
|
||||
QList<QAction *> newActions;
|
||||
for (const auto &item : items)
|
||||
{
|
||||
auto action = new QAction(tray_RecentConnectionsMenu);
|
||||
action->setText(GetDisplayName(ConnectionId{ item }));
|
||||
action->setData(item);
|
||||
connect(ConnectionManager, &QvConfigHandler::OnConnectionRenamed,
|
||||
[action](const ConnectionId &_t1, const QString &, const QString &_t3) {
|
||||
if (_t1.toString() == action->data().toString())
|
||||
{
|
||||
action->setText(_t3);
|
||||
}
|
||||
});
|
||||
connect(action, &QAction::triggered, [action]() { //
|
||||
emit ConnectionManager->StartConnection(ConnectionId{ action->data().toString() });
|
||||
});
|
||||
newActions << action;
|
||||
}
|
||||
for (const auto action : tray_RecentConnectionsMenu->actions())
|
||||
{
|
||||
tray_RecentConnectionsMenu->removeAction(action);
|
||||
action->deleteLater();
|
||||
}
|
||||
tray_RecentConnectionsMenu->addActions(newActions);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
@ -159,6 +187,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
if (connectionNodes.contains(id))
|
||||
connectionNodes.value(id)->setText(MW_ITEM_COL_PING, NumericString(avg)); //
|
||||
});
|
||||
connect(ConnectionManager, &QvConfigHandler::OnRecentConnectionsChanged, this, &MainWindow::ReloadRecentConnectionList);
|
||||
//
|
||||
connect(infoWidget, &ConnectionInfoWidget::OnEditRequested, this, &MainWindow::OnEditRequested);
|
||||
connect(infoWidget, &ConnectionInfoWidget::OnJsonEditRequested, this, &MainWindow::OnEditJsonRequested);
|
||||
@ -292,6 +321,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
connectionListWidget->setCurrentItem(item);
|
||||
on_connectionListWidget_itemClicked(item, 0);
|
||||
}
|
||||
ReloadRecentConnectionList(GlobalConfig.uiConfig.recentConnections);
|
||||
if (needShowWindow)
|
||||
this->show();
|
||||
|
||||
|
@ -96,6 +96,8 @@ class MainWindow
|
||||
void OnGroupDeleted(const GroupId &id, const QList<ConnectionId> &connections);
|
||||
//
|
||||
void SortConnectionList(MW_ITEM_COL byCol, bool asending);
|
||||
//
|
||||
void ReloadRecentConnectionList(const QList<QString> &items);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
@ -1249,3 +1249,8 @@ void PreferencesWindow::on_customProxySettingsGroupBox_clicked(bool checked)
|
||||
{
|
||||
CurrentConfig.networkConfig.useCustomProxy = checked;
|
||||
}
|
||||
|
||||
void PreferencesWindow::on_jumpListCountSB_valueChanged(int arg1)
|
||||
{
|
||||
CurrentConfig.uiConfig.maxJumpListCount = arg1;
|
||||
}
|
||||
|
@ -192,6 +192,8 @@ class PreferencesWindow
|
||||
|
||||
void on_customProxySettingsGroupBox_clicked(bool checked);
|
||||
|
||||
void on_jumpListCountSB_valueChanged(int arg1);
|
||||
|
||||
private:
|
||||
//
|
||||
RouteSettingsMatrixWidget *routeSettingsWidget;
|
||||
|
@ -116,14 +116,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="text">
|
||||
<string>Maximum log lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="maxLogLinesSB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
@ -148,6 +148,29 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="text">
|
||||
<string>Recent Jumplist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="jumpListCountSB">
|
||||
<property name="suffix">
|
||||
<string> Connections</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user