mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-22 08:10:07 +08:00
add reset assets button
This commit is contained in:
parent
1e1941807e
commit
1e47e7a626
@ -86,6 +86,8 @@ public:
|
|||||||
|
|
||||||
void DownloadAssets(const QString &geoipUrl, const QString &geositeUrl);
|
void DownloadAssets(const QString &geoipUrl, const QString &geositeUrl);
|
||||||
|
|
||||||
|
void ResetAssets(QString geoipUrl, QString geositeUrl);
|
||||||
|
|
||||||
void UpdateConnectionList(const QMap<QString, Stats::ConnectionMetadata>& toUpdate, const QMap<QString, Stats::ConnectionMetadata>& toAdd);
|
void UpdateConnectionList(const QMap<QString, Stats::ConnectionMetadata>& toUpdate, const QMap<QString, Stats::ConnectionMetadata>& toAdd);
|
||||||
|
|
||||||
void UpdateConnectionListWithRecreate(const QList<Stats::ConnectionMetadata>& connections);
|
void UpdateConnectionListWithRecreate(const QList<Stats::ConnectionMetadata>& connections);
|
||||||
|
|||||||
@ -762,18 +762,6 @@
|
|||||||
<string>Geo Assets and Rule-sets</string>
|
<string>Geo Assets and Rule-sets</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="remove_srs_btn">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><html><head/><body><p>Remove the
|
|
||||||
currently generated rule-sets so that they can be regenerated</p></body></html>
|
|
||||||
</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove Generated Rule-sets</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
@ -812,6 +800,28 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remove_srs_btn">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Remove the
|
||||||
|
currently generated rule-sets so that they can be regenerated</p></body></html>
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove Generated Rule-sets</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="reset_assets">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Downloads and replaces the geo asstes, and removes all generated rule-sets, then restarts the proxy</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset All Assets</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -563,6 +563,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(t, &QTimer::timeout, this, [&] { Configs_sys::logCounter.fetchAndStoreRelaxed(0); });
|
connect(t, &QTimer::timeout, this, [&] { Configs_sys::logCounter.fetchAndStoreRelaxed(0); });
|
||||||
t->start(1000);
|
t->start(1000);
|
||||||
|
|
||||||
|
// auto update timer
|
||||||
TM_auto_update_subsctiption = new QTimer;
|
TM_auto_update_subsctiption = new QTimer;
|
||||||
TM_auto_update_subsctiption_Reset_Minute = [&](int m) {
|
TM_auto_update_subsctiption_Reset_Minute = [&](int m) {
|
||||||
TM_auto_update_subsctiption->stop();
|
TM_auto_update_subsctiption->stop();
|
||||||
@ -571,6 +572,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(TM_auto_update_subsctiption, &QTimer::timeout, this, [&] { UI_update_all_groups(true); });
|
connect(TM_auto_update_subsctiption, &QTimer::timeout, this, [&] { UI_update_all_groups(true); });
|
||||||
TM_auto_update_subsctiption_Reset_Minute(Configs::dataStore->sub_auto_update);
|
TM_auto_update_subsctiption_Reset_Minute(Configs::dataStore->sub_auto_update);
|
||||||
|
|
||||||
|
// asset updater timer
|
||||||
|
|
||||||
|
|
||||||
if (!Configs::dataStore->flag_tray) show();
|
if (!Configs::dataStore->flag_tray) show();
|
||||||
|
|
||||||
if (Configs::NeedGeoAssets()) {
|
if (Configs::NeedGeoAssets()) {
|
||||||
@ -712,6 +716,13 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
|
|||||||
DownloadAssets(splitted[1], splitted[2]);
|
DownloadAssets(splitted[1], splitted[2]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (info.contains("ResetAssets"))
|
||||||
|
{
|
||||||
|
auto splitted = info.split(";");
|
||||||
|
runOnNewThread([=](){
|
||||||
|
ResetAssets(splitted[1], splitted[2]);
|
||||||
|
});
|
||||||
|
}
|
||||||
//
|
//
|
||||||
if (info == "RestartProgram") {
|
if (info == "RestartProgram") {
|
||||||
this->exit_reason = 2;
|
this->exit_reason = 2;
|
||||||
@ -2306,6 +2317,25 @@ void MainWindow::DownloadAssets(const QString &geoipUrl, const QString &geositeU
|
|||||||
MW_show_log(tr("Geo Asset update completed!"));
|
MW_show_log(tr("Geo Asset update completed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ResetAssets(QString geoipUrl, QString geositeUrl)
|
||||||
|
{
|
||||||
|
if (geoipUrl.isEmpty()) geoipUrl = Configs::dataStore->geoip_download_url;
|
||||||
|
if (geositeUrl.isEmpty()) geositeUrl = Configs::dataStore->geosite_download_url;
|
||||||
|
DownloadAssets(geoipUrl, geositeUrl);
|
||||||
|
auto entries = QDir(RULE_SETS_DIR).entryList(QDir::Files);
|
||||||
|
for (const auto &item: entries) {
|
||||||
|
if (!QFile(RULE_SETS_DIR + "/" + item).remove()) {
|
||||||
|
MW_show_log("Failed to remove " + item + ", stop the core then try again");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MW_show_log(tr("Removed all rule-set files"));
|
||||||
|
|
||||||
|
runOnUiThread([=]
|
||||||
|
{
|
||||||
|
if (Configs::dataStore->started_id >= 0) profile_start(Configs::dataStore->started_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// to parse versions of format Throne-1.2.3-beta.2 or Throne-1.2.3
|
// to parse versions of format Throne-1.2.3-beta.2 or Throne-1.2.3
|
||||||
bool isNewer(QString version) {
|
bool isNewer(QString version) {
|
||||||
if (QString(NKR_VERSION).isEmpty()) return false;
|
if (QString(NKR_VERSION).isEmpty()) return false;
|
||||||
|
|||||||
@ -130,6 +130,10 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
}
|
}
|
||||||
MW_show_log(tr("Removed all rule-set files"));
|
MW_show_log(tr("Removed all rule-set files"));
|
||||||
});
|
});
|
||||||
|
connect(ui->reset_assets, &QPushButton::clicked, this, [=]()
|
||||||
|
{
|
||||||
|
MW_dialog_message(Dialog_DialogBasicSettings, "ResetAssets;"+ui->geoip_url->currentText()+";"+ui->geosite_url->currentText());
|
||||||
|
});
|
||||||
|
|
||||||
// Mux
|
// Mux
|
||||||
D_LOAD_INT(mux_concurrency)
|
D_LOAD_INT(mux_concurrency)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user