diff --git a/include/global/DataStore.hpp b/include/global/DataStore.hpp
index c06b2e6..339a203 100644
--- a/include/global/DataStore.hpp
+++ b/include/global/DataStore.hpp
@@ -104,6 +104,7 @@ namespace Configs {
bool skip_cert = false;
QString utlsFingerprint = "";
bool disable_run_admin = false; // windows only
+ bool use_mozilla_certs = false;
// Remember
QStringList remember_spmode = {};
diff --git a/include/ui/setting/dialog_basic_settings.ui b/include/ui/setting/dialog_basic_settings.ui
index 58de77e..ebf746b 100644
--- a/include/ui/setting/dialog_basic_settings.ui
+++ b/include/ui/setting/dialog_basic_settings.ui
@@ -887,6 +887,13 @@
+ -
+
+
+ Use Mozilla Certificate Store
+
+
+
-
diff --git a/src/api/RPC.cpp b/src/api/RPC.cpp
index 7ab8995..1ae2d3b 100644
--- a/src/api/RPC.cpp
+++ b/src/api/RPC.cpp
@@ -5,7 +5,7 @@
namespace API {
Client::Client(std::function onError, const QString &host, int port) {
- this->make_rpc_client = [=]() { return std::make_unique(host.toStdString().c_str(), port); };
+ this->make_rpc_client = [=,this]() { return std::make_unique(host.toStdString().c_str(), port); };
this->onError = std::move(onError);
}
diff --git a/src/configs/ConfigBuilder.cpp b/src/configs/ConfigBuilder.cpp
index 2d20ddb..68ca848 100644
--- a/src/configs/ConfigBuilder.cpp
+++ b/src/configs/ConfigBuilder.cpp
@@ -932,6 +932,7 @@ namespace Configs {
}
status->result->coreConfig.insert("log", QJsonObject{{"level", dataStore->log_level}});
+ status->result->coreConfig.insert("certificate", QJsonObject{{"store", dataStore->use_mozilla_certs ? "mozilla" : "system"}});
status->result->coreConfig.insert("dns", dns);
status->result->coreConfig.insert("inbounds", status->inbounds);
status->result->coreConfig.insert("outbounds", status->outbounds);
diff --git a/src/configs/proxy/AbstractBean.cpp b/src/configs/proxy/AbstractBean.cpp
index b474387..698a84e 100644
--- a/src/configs/proxy/AbstractBean.cpp
+++ b/src/configs/proxy/AbstractBean.cpp
@@ -53,7 +53,7 @@ namespace Configs {
onFinished();
return;
}
- QHostInfo::lookupHost(serverAddress, QApplication::instance(), [=](const QHostInfo &host) {
+ QHostInfo::lookupHost(serverAddress, QApplication::instance(), [=,this](const QHostInfo &host) {
auto addr = host.addresses();
if (!addr.isEmpty()) {
auto domain = serverAddress;
diff --git a/src/configs/sub/GroupUpdater.cpp b/src/configs/sub/GroupUpdater.cpp
index 952f0e6..894430c 100644
--- a/src/configs/sub/GroupUpdater.cpp
+++ b/src/configs/sub/GroupUpdater.cpp
@@ -668,7 +668,7 @@ namespace Subscription {
updated_order += ent;
}
} catch (const fkyaml::exception &ex) {
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
MessageBoxWarning("YAML Exception", ex.what());
});
}
@@ -695,7 +695,7 @@ namespace Subscription {
if (items.indexOf(a) == 1) createNewGroup = true;
}
- runOnNewThread([=] {
+ runOnNewThread([=,this] {
auto gid = _sub_gid;
if (createNewGroup) {
auto group = Configs::ProfileManager::NewGroup();
diff --git a/src/dataStore/Database.cpp b/src/dataStore/Database.cpp
index d2653aa..3e2fead 100644
--- a/src/dataStore/Database.cpp
+++ b/src/dataStore/Database.cpp
@@ -246,7 +246,7 @@ namespace Configs {
ent->fn = QString("profiles/%1.json").arg(ent->id);
}
group->Save();
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
for (const auto& ent : ents) ent->Save();
});
@@ -294,7 +294,7 @@ namespace Configs {
}
profilesIdOrder = newOrder;
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
for (int id : deleted_ids) QFile(QString("profiles/%1.json").arg(id)).remove();
});
diff --git a/src/global/Configs.cpp b/src/global/Configs.cpp
index ad92d1a..7791e54 100644
--- a/src/global/Configs.cpp
+++ b/src/global/Configs.cpp
@@ -313,6 +313,7 @@ namespace Configs {
_add(new configItem("disable_privilege_req", &disable_privilege_req, itemType::boolean));
_add(new configItem("enable_tun_routing", &enable_tun_routing, itemType::boolean));
_add(new configItem("speed_test_mode", &speed_test_mode, itemType::integer));
+ _add(new configItem("use_mozilla_certs", &use_mozilla_certs, itemType::boolean));
}
void DataStore::UpdateStartedId(int id) {
diff --git a/src/stats/connectionLister/connectionLister.cpp b/src/stats/connectionLister/connectionLister.cpp
index ed6e695..3e8f825 100644
--- a/src/stats/connectionLister/connectionLister.cpp
+++ b/src/stats/connectionLister/connectionLister.cpp
@@ -84,7 +84,7 @@ namespace Stats
if (sort == Default)
{
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
auto m = GetMainWindow();
m->UpdateConnectionList(toUpdate, toAdd);
});
@@ -92,7 +92,7 @@ namespace Stats
{
if (sort == ByDownload)
{
- std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
+ std::sort(sorted.begin(), sorted.end(), [=,this](const ConnectionMetadata& a, const ConnectionMetadata& b)
{
if (a.download == b.download) return asc ? a.id > b.id : a.id < b.id;
return asc ? a.download < b.download : a.download > b.download;
@@ -100,7 +100,7 @@ namespace Stats
}
if (sort == ByUpload)
{
- std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
+ std::sort(sorted.begin(), sorted.end(), [=,this](const ConnectionMetadata& a, const ConnectionMetadata& b)
{
if (a.upload == b.upload) return asc ? a.id > b.id : a.id < b.id;
return asc ? a.upload < b.upload : a.upload > b.upload;
@@ -108,7 +108,7 @@ namespace Stats
}
if (sort == ByProcess)
{
- std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
+ std::sort(sorted.begin(), sorted.end(), [=,this](const ConnectionMetadata& a, const ConnectionMetadata& b)
{
if (a.process == b.process) return asc ? a.id > b.id : a.id < b.id;
return asc ? a.process > b.process : a.process < b.process;
@@ -116,7 +116,7 @@ namespace Stats
}
if (sort == ByOutbound)
{
- std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
+ std::sort(sorted.begin(), sorted.end(), [=,this](const ConnectionMetadata& a, const ConnectionMetadata& b)
{
if (a.outbound == b.outbound) return asc ? a.id > b.id : a.id < b.id;
return asc ? a.outbound > b.outbound : a.outbound < b.outbound;
@@ -124,13 +124,13 @@ namespace Stats
}
if (sort == ByProtocol)
{
- std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
+ std::sort(sorted.begin(), sorted.end(), [=,this](const ConnectionMetadata& a, const ConnectionMetadata& b)
{
if (a.protocol == b.protocol) return asc ? a.id > b.id : a.id < b.id;
return asc ? a.protocol > b.protocol : a.protocol < b.protocol;
});
}
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
auto m = GetMainWindow();
m->UpdateConnectionListWithRecreate(sorted);
});
diff --git a/src/stats/traffic/TrafficLooper.cpp b/src/stats/traffic/TrafficLooper.cpp
index dfea54d..3f53c67 100644
--- a/src/stats/traffic/TrafficLooper.cpp
+++ b/src/stats/traffic/TrafficLooper.cpp
@@ -78,12 +78,12 @@ namespace Stats {
// 停止
if (looping) {
looping = false;
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
auto m = GetMainWindow();
m->refresh_status("STOP");
});
}
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
auto m = GetMainWindow();
m->update_traffic_graph(0, 0, 0, 0);
@@ -104,7 +104,7 @@ namespace Stats {
loop_mutex.unlock();
// post to UI
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
auto m = GetMainWindow();
if (proxy != nullptr) {
m->refresh_status(QObject::tr("Proxy: %1\nDirect: %2").arg(proxy->DisplaySpeed(), direct->DisplaySpeed()));
diff --git a/src/sys/Process.cpp b/src/sys/Process.cpp
index c83b4e1..8bf749c 100644
--- a/src/sys/Process.cpp
+++ b/src/sys/Process.cpp
@@ -75,7 +75,7 @@ namespace Configs_sys {
// Restart
start_profile_when_core_is_up = Configs::dataStore->started_id;
MW_show_log("[Fatal] " + QObject::tr("Core exited, restarting."));
- setTimeout([=] { Restart(); }, this, 200);
+ setTimeout([=,this] { Restart(); }, this, 200);
}
});
}
diff --git a/src/ui/group/GroupItem.cpp b/src/ui/group/GroupItem.cpp
index ecdf5a3..5ecd892 100644
--- a/src/ui/group/GroupItem.cpp
+++ b/src/ui/group/GroupItem.cpp
@@ -50,7 +50,7 @@ GroupItem::GroupItem(QWidget *parent, const std::shared_ptr &ent
if (ent == nullptr) return;
connect(this, &GroupItem::edit_clicked, this, &GroupItem::on_edit_clicked);
- connect(Subscription::groupUpdater, &Subscription::GroupUpdater::asyncUpdateCallback, this, [=](int gid) { if (gid == this->ent->id) refresh_data(); });
+ connect(Subscription::groupUpdater, &Subscription::GroupUpdater::asyncUpdateCallback, this, [=,this](int gid) { if (gid == this->ent->id) refresh_data(); });
refresh_data();
}
@@ -89,7 +89,7 @@ void GroupItem::refresh_data() {
}
}
runOnThread(
- [=] {
+ [=,this] {
adjustSize();
item->setSizeHint(sizeHint());
dynamic_cast(parent())->adjustSize();
@@ -103,7 +103,7 @@ void GroupItem::on_update_sub_clicked() {
void GroupItem::on_edit_clicked() {
auto dialog = new DialogEditGroup(ent, parentWindow);
- connect(dialog, &QDialog::finished, this, [=] {
+ connect(dialog, &QDialog::finished, this, [=,this] {
if (dialog->result() == QDialog::Accepted) {
ent->Save();
refresh_data();
diff --git a/src/ui/group/dialog_edit_group.cpp b/src/ui/group/dialog_edit_group.cpp
index c51a886..0c064b9 100644
--- a/src/ui/group/dialog_edit_group.cpp
+++ b/src/ui/group/dialog_edit_group.cpp
@@ -7,13 +7,13 @@
#include
#include
-#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
+#define ADJUST_SIZE runOnThread([=,this] { adjustSize(); adjustPosition(mainwindow); }, this);
DialogEditGroup::DialogEditGroup(const std::shared_ptr &ent, QWidget *parent) : QDialog(parent), ui(new Ui::DialogEditGroup) {
ui->setupUi(this);
this->ent = ent;
- connect(ui->type, &QComboBox::currentIndexChanged, this, [=](int index) {
+ connect(ui->type, &QComboBox::currentIndexChanged, this, [=,this](int index) {
ui->cat_sub->setHidden(index == 0);
ADJUST_SIZE
});
@@ -55,7 +55,7 @@ DialogEditGroup::DialogEditGroup(const std::shared_ptr &ent, QWi
frontCompleter->setFilterMode(Qt::MatchContains);
ui->front_proxy->setCompleter(nullptr);
ui->front_proxy->lineEdit()->setCompleter(frontCompleter);
- connect(ui->front_proxy, &QComboBox::currentTextChanged, this, [=](const QString &txt){
+ connect(ui->front_proxy, &QComboBox::currentTextChanged, this, [=,this](const QString &txt){
CACHE.front_proxy = get_proxy_id(txt);
});
@@ -69,11 +69,11 @@ DialogEditGroup::DialogEditGroup(const std::shared_ptr &ent, QWi
landingCompleter->setFilterMode(Qt::MatchContains);
ui->landing_proxy->setCompleter(nullptr);
ui->landing_proxy->lineEdit()->setCompleter(frontCompleter);
- connect(ui->landing_proxy, &QComboBox::currentTextChanged, this, [=](const QString &txt){
+ connect(ui->landing_proxy, &QComboBox::currentTextChanged, this, [=,this](const QString &txt){
LANDING.landing_proxy = get_proxy_id(txt);
});
- connect(ui->copy_links, &QPushButton::clicked, this, [=] {
+ connect(ui->copy_links, &QPushButton::clicked, this, [=,this] {
QStringList links;
for (const auto &[_, profile]: Configs::profileManager->profiles) {
if (profile->gid != ent->id) continue;
@@ -82,7 +82,7 @@ DialogEditGroup::DialogEditGroup(const std::shared_ptr &ent, QWi
QApplication::clipboard()->setText(links.join("\n"));
MessageBoxInfo(software_name, tr("Copied"));
});
- connect(ui->copy_links_nkr, &QPushButton::clicked, this, [=] {
+ connect(ui->copy_links_nkr, &QPushButton::clicked, this, [=,this] {
QStringList links;
for (const auto &[_, profile]: Configs::profileManager->profiles) {
if (profile->gid != ent->id) continue;
diff --git a/src/ui/group/dialog_manage_groups.cpp b/src/ui/group/dialog_manage_groups.cpp
index 425457b..2007be5 100644
--- a/src/ui/group/dialog_manage_groups.cpp
+++ b/src/ui/group/dialog_manage_groups.cpp
@@ -27,7 +27,7 @@ DialogManageGroups::DialogManageGroups(QWidget *parent) : QDialog(parent), ui(ne
AddGroupToListIfExist(id)
}
- connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, [=](QListWidgetItem *wI) {
+ connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, [=,this](QListWidgetItem *wI) {
auto w = dynamic_cast(ui->listWidget->itemWidget(wI));
emit w->edit_clicked();
});
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index ca0a605..856e6c8 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -63,8 +63,8 @@ void UI_InitMainWindow() {
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
mainwindow = this;
- MW_dialog_message = [=](const QString &a, const QString &b) {
- runOnUiThread([=]
+ MW_dialog_message = [=,this](const QString &a, const QString &b) {
+ runOnUiThread([=,this]
{
dialog_message_impl(a, b);
});
@@ -92,12 +92,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->masterLogBrowser->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
- connect(qApp->styleHints(), &QStyleHints::colorSchemeChanged, this, [=](const Qt::ColorScheme& scheme) {
+ connect(qApp->styleHints(), &QStyleHints::colorSchemeChanged, this, [=,this](const Qt::ColorScheme& scheme) {
new SyntaxHighlighter(scheme == Qt::ColorScheme::Dark, qvLogDocument);
themeManager->ApplyTheme(Configs::dataStore->theme, true);
});
#endif
- connect(themeManager, &ThemeManager::themeChanged, this, [=](const QString& theme){
+ connect(themeManager, &ThemeManager::themeChanged, this, [=,this](const QString& theme){
if (theme.toLower().contains("vista")) {
// light themes
new SyntaxHighlighter(false, qvLogDocument);
@@ -109,20 +109,20 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
new SyntaxHighlighter(isDarkMode(), qvLogDocument);
}
});
- connect(ui->masterLogBrowser->verticalScrollBar(), &QSlider::valueChanged, this, [=](int value) {
+ connect(ui->masterLogBrowser->verticalScrollBar(), &QSlider::valueChanged, this, [=,this](int value) {
if (ui->masterLogBrowser->verticalScrollBar()->maximum() == value)
qvLogAutoScoll = true;
else
qvLogAutoScoll = false;
});
- connect(ui->masterLogBrowser, &QTextBrowser::textChanged, this, [=]() {
+ connect(ui->masterLogBrowser, &QTextBrowser::textChanged, this, [=,this]() {
if (!qvLogAutoScoll)
return;
auto bar = ui->masterLogBrowser->verticalScrollBar();
bar->setValue(bar->maximum());
});
- MW_show_log = [=](const QString &log) {
- runOnUiThread([=] { show_log_impl(log); });
+ MW_show_log = [=,this](const QString &log) {
+ runOnUiThread([=,this] { show_log_impl(log); });
};
// Listen port if random
@@ -145,7 +145,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// Start core
runOnThread(
- [=] {
+ [=,this] {
core_process = new Configs_sys::CoreProcess(core_path, args);
// Remember last started
if (Configs::dataStore->remember_enable && Configs::dataStore->remember_id >= 0) {
@@ -170,9 +170,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
parallelCoreCallPool->setMaxThreadCount(10); // constant value
//
- connect(ui->menu_start, &QAction::triggered, this, [=]() { profile_start(); });
- connect(ui->menu_stop, &QAction::triggered, this, [=]() { profile_stop(false, false, true); });
- connect(ui->tabWidget->tabBar(), &QTabBar::tabMoved, this, [=](int from, int to) {
+ connect(ui->menu_start, &QAction::triggered, this, [=,this]() { profile_start(); });
+ connect(ui->menu_stop, &QAction::triggered, this, [=,this]() { profile_stop(false, false, true); });
+ connect(ui->tabWidget->tabBar(), &QTabBar::tabMoved, this, [=,this](int from, int to) {
// use tabData to track tab & gid
Configs::profileManager->groupsTabOrder.clear();
for (int i = 0; i < ui->tabWidget->tabBar()->count(); i++) {
@@ -220,7 +220,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->toolButton_server->setMenu(ui->menu_server);
ui->toolButton_routing->setMenu(ui->menuRouting_Menu);
ui->menubar->setVisible(false);
- connect(ui->toolButton_update, &QToolButton::clicked, this, [=] { runOnNewThread([=] { CheckUpdate(); }); });
+ connect(ui->toolButton_update, &QToolButton::clicked, this, [=,this] { runOnNewThread([=,this] { CheckUpdate(); }); });
if (!QFile::exists(QApplication::applicationDirPath() + "/updater") && !QFile::exists(QApplication::applicationDirPath() + "/updater.exe"))
{
ui->toolButton_update->hide();
@@ -229,11 +229,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// setup connection UI
setupConnectionList();
ui->stats_widget->tabBar()->setCurrentIndex(Configs::dataStore->stats_tab);
- connect(ui->stats_widget->tabBar(), &QTabBar::currentChanged, this, [=](int index)
+ connect(ui->stats_widget->tabBar(), &QTabBar::currentChanged, this, [=,this](int index)
{
Configs::dataStore->stats_tab = ui->stats_widget->tabBar()->currentIndex();
});
- connect(ui->connections->horizontalHeader(), &QHeaderView::sectionClicked, this, [=](int index)
+ connect(ui->connections->horizontalHeader(), &QHeaderView::sectionClicked, this, [=,this](int index)
{
Stats::ConnectionSort sortType;
@@ -255,7 +255,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->graph_tab->layout()->addWidget(speedChartWidget);
// table UI
- ui->proxyListTable->rowsSwapped = [=](int row1, int row2)
+ ui->proxyListTable->rowsSwapped = [=,this](int row1, int row2)
{
if (row1 == row2) return;
auto group = Configs::profileManager->CurrentGroup();
@@ -265,9 +265,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
};
if (auto button = ui->proxyListTable->findChild(QString(), Qt::FindDirectChildrenOnly)) {
// Corner Button
- connect(button, &QAbstractButton::clicked, this, [=] { refresh_proxy_list_impl(-1, {GroupSortMethod::ById}); });
+ connect(button, &QAbstractButton::clicked, this, [=,this] { refresh_proxy_list_impl(-1, {GroupSortMethod::ById}); });
}
- connect(ui->proxyListTable->horizontalHeader(), &QHeaderView::sectionClicked, this, [=](int logicalIndex) {
+ connect(ui->proxyListTable->horizontalHeader(), &QHeaderView::sectionClicked, this, [=, this](int logicalIndex) {
GroupSortAction action;
if (proxy_last_order == logicalIndex) {
action.descending = true;
@@ -290,7 +290,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
refresh_proxy_list_impl(-1, action);
Configs::profileManager->CurrentGroup()->Save();
});
- connect(ui->proxyListTable->horizontalHeader(), &QHeaderView::sectionResized, this, [=](int logicalIndex, int oldSize, int newSize) {
+ connect(ui->proxyListTable->horizontalHeader(), &QHeaderView::sectionResized, this, [=, this](int logicalIndex, int oldSize, int newSize) {
auto group = Configs::profileManager->CurrentGroup();
if (Configs::dataStore->refreshing_group || group == nullptr || !group->manually_column_width) return;
// save manually column width
@@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->proxyListTable->setTabKeyNavigation(false);
// search box
- connect(shortcut_esc, &QShortcut::activated, this, [=] {
+ connect(shortcut_esc, &QShortcut::activated, this, [=,this] {
if (select_mode) {
emit profile_selected(-1);
select_mode = false;
@@ -333,7 +333,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
trayMenu->addAction(ui->menu_exit);
tray->setVisible(!Configs::dataStore->disable_tray);
tray->setContextMenu(trayMenu);
- connect(tray, &QSystemTrayIcon::activated, qApp, [=](QSystemTrayIcon::ActivationReason reason) {
+ connect(tray, &QSystemTrayIcon::activated, qApp, [=, this](QSystemTrayIcon::ActivationReason reason) {
if (reason == QSystemTrayIcon::Trigger) {
ActivateWindow(this);
}
@@ -344,41 +344,41 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->actionStart_with_system->setChecked(AutoRun_IsEnabled());
ui->actionAllow_LAN->setChecked(QStringList{"::", "0.0.0.0"}.contains(Configs::dataStore->inbound_address));
- connect(ui->menu_open_config_folder, &QAction::triggered, this, [=] { QDesktopServices::openUrl(QUrl::fromLocalFile(QDir::currentPath())); });
+ connect(ui->menu_open_config_folder, &QAction::triggered, this, [=,this] { QDesktopServices::openUrl(QUrl::fromLocalFile(QDir::currentPath())); });
connect(ui->menu_add_from_clipboard2, &QAction::triggered, ui->menu_add_from_clipboard, &QAction::trigger);
- connect(ui->actionRestart_Proxy, &QAction::triggered, this, [=] { if (Configs::dataStore->started_id>=0) profile_start(Configs::dataStore->started_id); });
- connect(ui->actionRestart_Program, &QAction::triggered, this, [=] { MW_dialog_message("", "RestartProgram"); });
- connect(ui->actionShow_window, &QAction::triggered, this, [=] { ActivateWindow(this); });
- connect(ui->actionRemember_last_proxy, &QAction::triggered, this, [=](bool checked) {
+ connect(ui->actionRestart_Proxy, &QAction::triggered, this, [=,this] { if (Configs::dataStore->started_id>=0) profile_start(Configs::dataStore->started_id); });
+ connect(ui->actionRestart_Program, &QAction::triggered, this, [=,this] { MW_dialog_message("", "RestartProgram"); });
+ connect(ui->actionShow_window, &QAction::triggered, this, [=,this] { ActivateWindow(this); });
+ connect(ui->actionRemember_last_proxy, &QAction::triggered, this, [=,this](bool checked) {
Configs::dataStore->remember_enable = checked;
ui->actionRemember_last_proxy->setChecked(checked);
Configs::dataStore->Save();
});
- connect(ui->actionStart_with_system, &QAction::triggered, this, [=](bool checked) {
+ connect(ui->actionStart_with_system, &QAction::triggered, this, [=,this](bool checked) {
AutoRun_SetEnabled(checked);
ui->actionStart_with_system->setChecked(checked);
});
- connect(ui->actionAllow_LAN, &QAction::triggered, this, [=](bool checked) {
+ connect(ui->actionAllow_LAN, &QAction::triggered, this, [=,this](bool checked) {
Configs::dataStore->inbound_address = checked ? "::" : "127.0.0.1";
ui->actionAllow_LAN->setChecked(checked);
MW_dialog_message("", "UpdateDataStore");
});
//
- connect(ui->checkBox_VPN, &QCheckBox::clicked, this, [=](bool checked) { set_spmode_vpn(checked); });
- connect(ui->checkBox_SystemProxy, &QCheckBox::clicked, this, [=](bool checked) { set_spmode_system_proxy(checked); });
- connect(ui->menu_spmode, &QMenu::aboutToShow, this, [=]() {
+ connect(ui->checkBox_VPN, &QCheckBox::clicked, this, [=,this](bool checked) { set_spmode_vpn(checked); });
+ connect(ui->checkBox_SystemProxy, &QCheckBox::clicked, this, [=,this](bool checked) { set_spmode_system_proxy(checked); });
+ connect(ui->menu_spmode, &QMenu::aboutToShow, this, [=,this]() {
ui->menu_spmode_disabled->setChecked(!(Configs::dataStore->spmode_system_proxy || Configs::dataStore->spmode_vpn));
ui->menu_spmode_system_proxy->setChecked(Configs::dataStore->spmode_system_proxy);
ui->menu_spmode_vpn->setChecked(Configs::dataStore->spmode_vpn);
});
- connect(ui->menu_spmode_system_proxy, &QAction::triggered, this, [=](bool checked) { set_spmode_system_proxy(checked); });
- connect(ui->menu_spmode_vpn, &QAction::triggered, this, [=](bool checked) { set_spmode_vpn(checked); });
- connect(ui->menu_spmode_disabled, &QAction::triggered, this, [=]() {
+ connect(ui->menu_spmode_system_proxy, &QAction::triggered, this, [=,this](bool checked) { set_spmode_system_proxy(checked); });
+ connect(ui->menu_spmode_vpn, &QAction::triggered, this, [=,this](bool checked) { set_spmode_vpn(checked); });
+ connect(ui->menu_spmode_disabled, &QAction::triggered, this, [=,this]() {
set_spmode_system_proxy(false);
set_spmode_vpn(false);
});
- connect(ui->menu_qr, &QAction::triggered, this, [=]() { display_qr_link(false); });
- connect(ui->system_dns, &QCheckBox::clicked, this, [=](bool checked) {
+ connect(ui->menu_qr, &QAction::triggered, this, [=,this]() { display_qr_link(false); });
+ connect(ui->system_dns, &QCheckBox::clicked, this, [=,this](bool checked) {
if (const auto ok = set_system_dns(checked); !ok) {
ui->system_dns->setChecked(!checked);
} else {
@@ -390,7 +390,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->system_dns->hide();
#endif
- connect(ui->menu_server, &QMenu::aboutToShow, this, [=](){
+ connect(ui->menu_server, &QMenu::aboutToShow, this, [=,this](){
if (running)
{
ui->actionSpeedtest_Current->setEnabled(true);
@@ -417,7 +417,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
}
});
- auto getRemoteRouteProfiles = [=]
+ auto getRemoteRouteProfiles = [=,this]
{
auto resp = NetworkRequestHelper::HttpGet("https://api.github.com/repos/throneproj/routeprofiles/releases/latest");
if (resp.error.isEmpty()) {
@@ -437,7 +437,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
};
runOnNewThread(getRemoteRouteProfiles);
- connect(ui->menuRouting_Menu, &QMenu::aboutToShow, this, [=]()
+ connect(ui->menuRouting_Menu, &QMenu::aboutToShow, this, [=,this]()
{
// refresh it on every menu show
runOnNewThread(getRemoteRouteProfiles);
@@ -450,11 +450,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
{
auto* action = new QAction(profilesMenu);
action->setText(profile);
- connect(action, &QAction::triggered, this, [=]()
+ connect(action, &QAction::triggered, this, [=,this]()
{
auto resp = NetworkRequestHelper::HttpGet("https://github.com/throneproj/routeprofiles/releases/latest/download/" + profile + ".json");
if (!resp.error.isEmpty()) {
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
MessageBoxWarning(QObject::tr("Download Profiles"), QObject::tr("Requesting profile error: %1").arg(resp.error + "\n" + resp.data));
});
return;
@@ -462,7 +462,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
auto err = new QString;
auto parsed = Configs::RoutingChain::parseJsonArray(QString2QJsonArray(resp.data), err);
if (!err->isEmpty()) {
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
MessageBoxInfo(tr("Invalid JSON Array"), tr("The provided input cannot be parsed to a valid route rule array:\n") + *err);
});
@@ -488,7 +488,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
action->setData(route.second->id);
action->setCheckable(true);
action->setChecked(Configs::dataStore->routing->current_route_id == route.first);
- connect(action, &QAction::triggered, this, [=]()
+ connect(action, &QAction::triggered, this, [=,this]()
{
auto routeID = action->data().toInt();
if (Configs::dataStore->routing->current_route_id == routeID) return;
@@ -499,39 +499,39 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->menuRouting_Menu->addAction(action);
}
});
- connect(ui->actionUrl_Test_Selected, &QAction::triggered, this, [=]() {
+ connect(ui->actionUrl_Test_Selected, &QAction::triggered, this, [=,this]() {
urltest_current_group(get_now_selected_list());
});
- connect(ui->actionUrl_Test_Group, &QAction::triggered, this, [=]() {
+ connect(ui->actionUrl_Test_Group, &QAction::triggered, this, [=,this]() {
urltest_current_group(Configs::profileManager->CurrentGroup()->GetProfileEnts());
});
- connect(ui->actionSpeedtest_Current, &QAction::triggered, this, [=]()
+ connect(ui->actionSpeedtest_Current, &QAction::triggered, this, [=,this]()
{
if (running != nullptr)
{
speedtest_current_group({}, true);
}
});
- connect(ui->actionSpeedtest_Selected, &QAction::triggered, this, [=]()
+ connect(ui->actionSpeedtest_Selected, &QAction::triggered, this, [=,this]()
{
speedtest_current_group(get_now_selected_list());
});
- connect(ui->actionSpeedtest_Group, &QAction::triggered, this, [=]()
+ connect(ui->actionSpeedtest_Group, &QAction::triggered, this, [=,this]()
{
speedtest_current_group(Configs::profileManager->CurrentGroup()->GetProfileEnts());
});
- connect(ui->menu_stop_testing, &QAction::triggered, this, [=]() { stopTests(); });
+ connect(ui->menu_stop_testing, &QAction::triggered, this, [=,this]() { stopTests(); });
//
- auto set_selected_or_group = [=](int mode) {
+ auto set_selected_or_group = [=,this](int mode) {
// 0=group 1=select 2=unknown(menu is hide)
ui->menu_server->setProperty("selected_or_group", mode);
};
- connect(ui->menu_server, &QMenu::aboutToHide, this, [=] {
- setTimeout([=] { set_selected_or_group(2); }, this, 200);
+ connect(ui->menu_server, &QMenu::aboutToHide, this, [=,this] {
+ setTimeout([=,this] { set_selected_or_group(2); }, this, 200);
});
set_selected_or_group(2);
//
- connect(ui->menu_share_item, &QMenu::aboutToShow, this, [=] {
+ connect(ui->menu_share_item, &QMenu::aboutToShow, this, [=,this] {
QString name;
auto selected = get_now_selected_list();
if (!selected.isEmpty()) {
@@ -546,7 +546,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(qApp, &QGuiApplication::commitDataRequest, this, &MainWindow::on_commitDataRequest);
auto t = new QTimer;
- connect(t, &QTimer::timeout, this, [=]() { refresh_status(); });
+ connect(t, &QTimer::timeout, this, [=,this]() { refresh_status(); });
t->start(2000);
t = new QTimer;
@@ -569,7 +569,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
auto reset_interval = Configs::GeoAssets::ResetAssetsOptions[Configs::dataStore->auto_reset_assets_idx];
if (reset_interval > 0 && QDateTime::currentSecsSinceEpoch() - Configs::dataStore->last_asset_reset_epoch_secs > reset_interval)
{
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
ResetAssets(Configs::dataStore->geoip_download_url, Configs::dataStore->geosite_download_url);
});
@@ -582,7 +582,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
if (Configs::NeedGeoAssets()) {
auto n = QMessageBox::warning(GetMessageBoxParent(), software_name, tr("Geo Assets are missing, want to download them now?"), QMessageBox::Yes | QMessageBox::No);
if (n == QMessageBox::Yes) {
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
DownloadAssets(!Configs::dataStore->geoip_download_url.isEmpty() ? Configs::dataStore->geoip_download_url : Configs::GeoAssets::GeoIPURLs[0],
!Configs::dataStore->geosite_download_url.isEmpty() ? Configs::dataStore->geosite_download_url : Configs::GeoAssets::GeoSiteURLs[0]);
@@ -723,14 +723,14 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
}
if (info.contains("DownloadAssets")) {
auto splitted = info.split(";");
- runOnNewThread([=](){
+ runOnNewThread([=,this](){
DownloadAssets(splitted[1], splitted[2]);
});
}
if (info.contains("ResetAssets"))
{
auto splitted = info.split(";");
- runOnNewThread([=](){
+ runOnNewThread([=,this](){
ResetAssets(splitted[1], splitted[2]);
});
}
@@ -807,7 +807,7 @@ inline bool dialog_is_using = false;
if (dialog_is_using) return; \
dialog_is_using = true; \
auto dialog = new a(this); \
- connect(dialog, &QDialog::finished, this, [=] { \
+ connect(dialog, &QDialog::finished, this, [=,this] { \
dialog->deleteLater(); \
dialog_is_using = false; \
}); \
@@ -883,7 +883,7 @@ void MainWindow::prepare_exit()
QMutex coreKillMu;
coreKillMu.lock();
- runOnThread([=, &coreKillMu]()
+ runOnThread([=, this, &coreKillMu]()
{
core_process->Kill();
coreKillMu.unlock();
@@ -951,7 +951,7 @@ bool MainWindow::get_elevated_permissions(int reason) {
}
auto n = QMessageBox::warning(GetMessageBoxParent(), software_name, tr("Please give the core root privileges"), QMessageBox::Yes | QMessageBox::No);
if (n == QMessageBox::Yes) {
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
auto chownArgs = QString("root:root " + Configs::FindCoreRealPath());
auto ret = Linux_Run_Command("chown", chownArgs);
@@ -1085,7 +1085,7 @@ void MainWindow::setupConnectionList()
ui->connections->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
ui->connections->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
ui->connections->verticalHeader()->hide();
- connect(ui->connections, &QTableWidget::cellClicked, this, [=](int row, int column)
+ connect(ui->connections, &QTableWidget::cellClicked, this, [=,this](int row, int column)
{
if (column > 3) return;
auto selected = ui->connections->item(row, column);
@@ -1093,7 +1093,7 @@ void MainWindow::setupConnectionList()
QPoint pos = ui->connections->mapToGlobal(ui->connections->visualItemRect(selected).center());
QToolTip::showText(pos, "Copied!", this);
auto r = ++toolTipID;
- QTimer::singleShot(1500, [=] {
+ QTimer::singleShot(1500, [=,this] {
if (r != toolTipID)
{
return;
@@ -1217,7 +1217,7 @@ void MainWindow::UpdateConnectionListWithRecreate(const QListdisable_traffic_stats) {
ui->label_speed->setText("");
}
@@ -1267,7 +1267,7 @@ void MainWindow::refresh_status(const QString &traffic_update) {
ui->label_running->setToolTip({});
}
- auto make_title = [=](bool isTray) {
+ auto make_title = [=,this](bool isTray) {
QStringList tt;
if (!isTray && Configs::IsAdmin()) tt << "[Admin]";
if (select_mode) tt << "[" + tr("Select") + "]";
@@ -1392,7 +1392,7 @@ void MainWindow::refresh_proxy_list_impl(const int &id, GroupSortAction groupSor
case GroupSortMethod::ByLatency:
case GroupSortMethod::ByType: {
std::sort(currentGroup->profiles.begin(), currentGroup->profiles.end(),
- [=](int a, int b) {
+ [=,this](int a, int b) {
QString ms_a;
QString ms_b;
if (groupSortAction.method == GroupSortMethod::ByType) {
@@ -1909,7 +1909,7 @@ void MainWindow::on_menu_remove_unavailable_triggered() {
}
void MainWindow::on_menu_remove_invalid_triggered() {
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
QList> out_del;
@@ -1945,7 +1945,7 @@ void MainWindow::on_menu_remove_invalid_triggered() {
}
}
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
if (!out_del.empty() &&
QMessageBox::question(this, tr("Confirmation"), tr("Remove %1 Invalid item(s) ?").arg(out_del.length()) + "\n" + remove_display) == QMessageBox::StandardButton::Yes) {
@@ -1970,7 +1970,7 @@ void MainWindow::on_menu_resolve_selected_triggered() {
Configs::dataStore->resolve_count = profiles.count();
for (const auto &profile: profiles) {
- profile->bean->ResolveDomainToIP([=] {
+ profile->bean->ResolveDomainToIP([=,this] {
profile->Save();
if (--Configs::dataStore->resolve_count != 0) return;
refresh_proxy_list();
@@ -1998,7 +1998,7 @@ void MainWindow::on_menu_resolve_domain_triggered() {
for (const auto id: profiles) {
auto profile = Configs::profileManager->GetProfile(id);
- profile->bean->ResolveDomainToIP([=] {
+ profile->bean->ResolveDomainToIP([=,this] {
profile->Save();
if (--Configs::dataStore->resolve_count != 0) return;
refresh_proxy_list();
@@ -2094,7 +2094,7 @@ void MainWindow::on_masterLogBrowser_customContextMenuRequested(const QPoint &po
auto action_clear = new QAction(this);
action_clear->setText(tr("Clear"));
- connect(action_clear, &QAction::triggered, this, [=] {
+ connect(action_clear, &QAction::triggered, this, [=,this] {
qvLogDocument->clear();
ui->masterLogBrowser->clear();
});
@@ -2108,7 +2108,7 @@ void MainWindow::on_tabWidget_customContextMenuRequested(const QPoint &p) {
if (clickedIndex == -1) {
auto* menu = new QMenu(this);
auto* addAction = new QAction(tr("Add new Group"), this);
- connect(addAction, &QAction::triggered, this, [=]{
+ connect(addAction, &QAction::triggered, this, [=,this]{
auto ent = Configs::ProfileManager::NewGroup();
auto dialog = new DialogEditGroup(ent, this);
int ret = dialog->exec();
@@ -2131,7 +2131,7 @@ void MainWindow::on_tabWidget_customContextMenuRequested(const QPoint &p) {
auto* addAction = new QAction(tr("Add new Group"), this);
auto* deleteAction = new QAction(tr("Delete selected Group"), this);
auto* editAction = new QAction(tr("Edit selected Group"), this);
- connect(addAction, &QAction::triggered, this, [=]{
+ connect(addAction, &QAction::triggered, this, [=,this]{
auto ent = Configs::ProfileManager::NewGroup();
auto dialog = new DialogEditGroup(ent, this);
int ret = dialog->exec();
@@ -2142,7 +2142,7 @@ void MainWindow::on_tabWidget_customContextMenuRequested(const QPoint &p) {
MW_dialog_message(Dialog_DialogManageGroups, "refresh-1");
}
});
- connect(deleteAction, &QAction::triggered, this, [=] {
+ connect(deleteAction, &QAction::triggered, this, [=,this] {
auto id = Configs::profileManager->groupsTabOrder[clickedIndex];
if (QMessageBox::question(this, tr("Confirmation"), tr("Remove %1?").arg(Configs::profileManager->groups[id]->name)) ==
QMessageBox::StandardButton::Yes) {
@@ -2150,11 +2150,11 @@ void MainWindow::on_tabWidget_customContextMenuRequested(const QPoint &p) {
MW_dialog_message(Dialog_DialogManageGroups, "refresh-1");
}
});
- connect(editAction, &QAction::triggered, this, [=]{
+ connect(editAction, &QAction::triggered, this, [=,this]{
auto id = Configs::profileManager->groupsTabOrder[clickedIndex];
auto ent = Configs::profileManager->groups[id];
auto dialog = new DialogEditGroup(ent, this);
- connect(dialog, &QDialog::finished, this, [=] {
+ connect(dialog, &QDialog::finished, this, [=,this] {
if (dialog->result() == QDialog::Accepted) {
ent->Save();
MW_dialog_message(Dialog_DialogManageGroups, "refresh" + Int2String(ent->id));
@@ -2252,7 +2252,7 @@ void MainWindow::RegisterHotkey(bool unregister) {
auto hk = std::make_shared(k, true);
if (hk->isRegistered()) {
RegisteredHotkey += hk;
- connect(hk.get(), &QHotkey::activated, this, [=] { HotkeyEvent(key); });
+ connect(hk.get(), &QHotkey::activated, this, [=,this] { HotkeyEvent(key); });
} else {
hk->deleteLater();
}
@@ -2261,7 +2261,7 @@ void MainWindow::RegisterHotkey(bool unregister) {
void MainWindow::RegisterShortcuts() {
for (const auto &action: ui->menuHidden_menu->actions()) {
- new QShortcut(action->shortcut(), this, [=](){
+ new QShortcut(action->shortcut(), this, [=,this](){
action->trigger();
});
}
@@ -2269,7 +2269,7 @@ void MainWindow::RegisterShortcuts() {
void MainWindow::HotkeyEvent(const QString &key) {
if (key.isEmpty()) return;
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
if (key == Configs::dataStore->hotkey_mainwindow) {
tray->activated(QSystemTrayIcon::ActivationReason::Trigger);
} else if (key == Configs::dataStore->hotkey_group) {
@@ -2287,7 +2287,7 @@ void MainWindow::HotkeyEvent(const QString &key) {
bool MainWindow::StopVPNProcess() {
QMutex waitStop;
waitStop.lock();
- runOnThread([=, &waitStop]
+ runOnThread([=, this, &waitStop]
{
core_process->Kill();
waitStop.unlock();
@@ -2300,7 +2300,7 @@ bool MainWindow::StopVPNProcess() {
void MainWindow::DownloadAssets(const QString &geoipUrl, const QString &geositeUrl) {
if (!mu_download_assets.tryLock()) {
- runOnUiThread([=](){
+ runOnUiThread([=,this](){
MessageBoxWarning(tr("Cannot start"), tr("Last download request has not finished yet"));
});
return;
@@ -2323,7 +2323,7 @@ void MainWindow::DownloadAssets(const QString &geoipUrl, const QString &geositeU
}
mu_download_assets.unlock();
if (!errors.isEmpty()) {
- runOnUiThread([=](){
+ runOnUiThread([=,this](){
MessageBoxWarning(tr("Failed to download geo assets"), errors);
});
}
@@ -2346,7 +2346,7 @@ void MainWindow::ResetAssets(const QString& geoipUrl, const QString& geositeUrl)
}
MW_show_log(tr("Removed all rule-set files"));
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
if (Configs::dataStore->started_id >= 0) profile_start(Configs::dataStore->started_id);
});
@@ -2450,7 +2450,7 @@ void MainWindow::CheckUpdate() {
# endif
#endif
if (search.isEmpty()) {
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
MessageBoxWarning(QObject::tr("Update"), QObject::tr("Not official support platform"));
});
return;
@@ -2458,7 +2458,7 @@ void MainWindow::CheckUpdate() {
auto resp = NetworkRequestHelper::HttpGet("https://api.github.com/repos/throneproj/Throne/releases");
if (!resp.error.isEmpty()) {
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
MessageBoxWarning(QObject::tr("Update"), QObject::tr("Requesting update error: %1").arg(resp.error + "\n" + resp.data));
});
return;
@@ -2484,13 +2484,13 @@ void MainWindow::CheckUpdate() {
}
if (release_download_url.isEmpty() || !isNewer(assets_name)) {
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
MessageBoxInfo(QObject::tr("Update"), QObject::tr("No update"));
});
return;
}
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
auto allow_updater = !Configs::dataStore->flag_use_appdata;
QMessageBox box(QMessageBox::Question, QObject::tr("Update") + note_pre_release,
QObject::tr("Update found: %1\nRelease note:\n%2").arg(assets_name, release_note));
@@ -2505,9 +2505,9 @@ void MainWindow::CheckUpdate() {
//
if (btn1 == box.clickedButton() && allow_updater) {
// Download Update
- runOnNewThread([=] {
+ runOnNewThread([=,this] {
if (!mu_download_update.tryLock()) {
- runOnUiThread([=](){
+ runOnUiThread([=,this](){
MessageBoxWarning(tr("Cannot start"), tr("Last download request has not finished yet"));
});
return;
@@ -2520,7 +2520,7 @@ void MainWindow::CheckUpdate() {
}
}
mu_download_update.unlock();
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
if (errors.isEmpty()) {
auto q = QMessageBox::question(nullptr, QObject::tr("Update"),
QObject::tr("Update is ready, restart to install?"));
diff --git a/src/ui/mainwindow_grpc.cpp b/src/ui/mainwindow_grpc.cpp
index 56d82d6..e36b0f5 100644
--- a/src/ui/mainwindow_grpc.cpp
+++ b/src/ui/mainwindow_grpc.cpp
@@ -46,7 +46,7 @@ void MainWindow::runURLTest(const QString& config, bool useDefault, const QStrin
auto done = new QMutex;
done->lock();
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
bool ok;
while (true)
@@ -88,7 +88,7 @@ void MainWindow::runURLTest(const QString& config, bool useDefault, const QStrin
}
if (needRefresh)
{
- runOnUiThread([=]{
+ runOnUiThread([=,this]{
refresh_proxy_list();
});
}
@@ -177,7 +177,7 @@ void MainWindow::urltest_current_group(const QListlabel_running->setText(tr("Testing"));
- runOnNewThread([=] {
+ runOnNewThread([=,this] {
libcore::TestReq req;
req.test_current = true;
req.url = Configs::dataStore->test_latency_url.toStdString();
@@ -210,7 +210,7 @@ void MainWindow::url_test_current() {
auto latency = result.results[0].latency_ms.value();
last_test_time = QTime::currentTime();
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
if (!result.results[0].error.value().empty()) {
MW_show_log(QString("UrlTest error: %1").arg(QString::fromStdString(result.results[0].error.value())));
}
@@ -259,7 +259,7 @@ void MainWindow::speedtest_current_group(const QListlock();
- runOnNewThread([=]
+ runOnNewThread([=,this]
{
QDateTime lastProxyListUpdate = QDateTime::currentDateTime();
bool ok;
@@ -309,7 +309,7 @@ void MainWindow::runSpeedTest(const QString& config, bool useDefault, bool testC
{
continue;
}
- runOnUiThread([=, &lastProxyListUpdate]
+ runOnUiThread([=, this, &lastProxyListUpdate]
{
showSpeedtestData = true;
currentSptProfileName = profile->bean->name;
@@ -326,7 +326,7 @@ void MainWindow::runSpeedTest(const QString& config, bool useDefault, bool testC
}
});
}
- runOnUiThread([=]
+ runOnUiThread([=, this]
{
showSpeedtestData = false;
UpdateDataView(true);
@@ -426,7 +426,7 @@ void MainWindow::profile_start(int _id) {
return;
}
- auto profile_start_stage2 = [=] {
+ auto profile_start_stage2 = [=, this] {
libcore::LoadConfigReq req;
req.core_config = QJsonObject2QString(result->coreConfig, true).toStdString();
req.disable_stats = Configs::dataStore->disable_traffic_stats;
@@ -447,7 +447,7 @@ void MainWindow::profile_start(int _id) {
}
if (!error.isEmpty()) {
if (error.contains("configure tun interface")) {
- runOnUiThread([=] {
+ runOnUiThread([=, this] {
QMessageBox msg(
QMessageBox::Information,
@@ -469,7 +469,7 @@ void MainWindow::profile_start(int _id) {
});
return false;
}
- runOnUiThread([=] { MessageBoxWarning("LoadConfig return error", error); });
+ runOnUiThread([=,this] { MessageBoxWarning("LoadConfig return error", error); });
return false;
}
//
@@ -483,7 +483,7 @@ void MainWindow::profile_start(int _id) {
Configs::dataStore->UpdateStartedId(ent->id);
running = ent;
- runOnUiThread([=] {
+ runOnUiThread([=, this] {
refresh_status();
refresh_proxy_list(ent->id);
});
@@ -505,7 +505,7 @@ void MainWindow::profile_start(int _id) {
// check core state
if (!Configs::dataStore->core_running) {
runOnThread(
- [=] {
+ [=, this] {
MW_show_log(tr("Try to start the config, but the core has not listened to the grpc port, so restart it..."));
core_process->start_profile_when_core_is_up = ent->id;
core_process->Restart();
@@ -518,13 +518,13 @@ void MainWindow::profile_start(int _id) {
// timeout message
auto restartMsgbox = new QMessageBox(QMessageBox::Question, software_name, tr("If there is no response for a long time, it is recommended to restart the software."),
QMessageBox::Yes | QMessageBox::No, this);
- connect(restartMsgbox, &QMessageBox::accepted, this, [=] { MW_dialog_message("", "RestartProgram"); });
+ connect(restartMsgbox, &QMessageBox::accepted, this, [=,this] { MW_dialog_message("", "RestartProgram"); });
auto restartMsgboxTimer = new MessageBoxTimer(this, restartMsgbox, 5000);
- runOnNewThread([=] {
+ runOnNewThread([=, this] {
// stop current running
if (running != nullptr) {
- runOnUiThread([=] { profile_stop(false, true, true); });
+ runOnUiThread([=,this] { profile_stop(false, true, true); });
sem_stopped.acquire();
}
// do start
@@ -534,7 +534,7 @@ void MainWindow::profile_start(int _id) {
}
mu_starting.unlock();
// cancel timeout
- runOnUiThread([=] {
+ runOnUiThread([=,this] {
restartMsgboxTimer->cancel();
restartMsgboxTimer->deleteLater();
restartMsgbox->deleteLater();
@@ -571,12 +571,12 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
return;
}
- auto profile_stop_stage2 = [=] {
+ auto profile_stop_stage2 = [=,this] {
if (!crash) {
bool rpcOK;
QString error = defaultClient->Stop(&rpcOK);
if (rpcOK && !error.isEmpty()) {
- runOnUiThread([=] { MessageBoxWarning(tr("Stop return error"), error); });
+ runOnUiThread([=,this] { MessageBoxWarning(tr("Stop return error"), error); });
return false;
} else if (!rpcOK) {
return false;
@@ -593,7 +593,7 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
// timeout message
auto restartMsgbox = new QMessageBox(QMessageBox::Question, software_name, tr("If there is no response for a long time, it is recommended to restart the software."),
QMessageBox::Yes | QMessageBox::No, this);
- connect(restartMsgbox, &QMessageBox::accepted, this, [=] { MW_dialog_message("", "RestartProgram"); });
+ connect(restartMsgbox, &QMessageBox::accepted, this, [=,this] { MW_dialog_message("", "RestartProgram"); });
auto restartMsgboxTimer = new MessageBoxTimer(this, restartMsgbox, 5000);
Stats::trafficLooper->loop_enabled = false;
@@ -612,7 +612,7 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
restartMsgboxTimer->deleteLater();
restartMsgbox->deleteLater();
- runOnNewThread([=] {
+ runOnNewThread([=, this] {
// do stop
MW_show_log(">>>>>>>> " + tr("Stopping profile %1").arg(running->bean->DisplayTypeAndName()));
if (!profile_stop_stage2()) {
@@ -625,7 +625,7 @@ void MainWindow::profile_stop(bool crash, bool sem, bool manual) {
if (sem) sem_stopped.release();
- runOnUiThread([=] {
+ runOnUiThread([=, this] {
refresh_status();
refresh_proxy_list_impl_refresh_data(id, true);
diff --git a/src/ui/profile/ProxyItem.cpp b/src/ui/profile/ProxyItem.cpp
index d80bbfd..6ad0ac2 100644
--- a/src/ui/profile/ProxyItem.cpp
+++ b/src/ui/profile/ProxyItem.cpp
@@ -26,7 +26,7 @@ void ProxyItem::refresh_data() {
ui->test_result->setText(ent->DisplayTestResult());
runOnThread(
- [=] {
+ [=,this] {
adjustSize();
item->setSizeHint(sizeHint());
dynamic_cast(parent())->adjustSize();
diff --git a/src/ui/profile/dialog_edit_profile.cpp b/src/ui/profile/dialog_edit_profile.cpp
index 69eab06..c9face1 100644
--- a/src/ui/profile/dialog_edit_profile.cpp
+++ b/src/ui/profile/dialog_edit_profile.cpp
@@ -20,7 +20,7 @@
#include
#include
-#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
+#define ADJUST_SIZE runOnThread([=,this] { adjustSize(); adjustPosition(mainwindow); }, this);
#define LOAD_TYPE(a) ui->type->addItem(Configs::ProfileManager::NewProxyEntity(a)->bean->DisplayType(), a);
DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId, QWidget *parent)
@@ -31,7 +31,7 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
// network changed
network_title_base = ui->network_box->title();
- connect(ui->network, &QComboBox::currentTextChanged, this, [=](const QString &txt) {
+ connect(ui->network, &QComboBox::currentTextChanged, this, [=,this](const QString &txt) {
ui->network_box->setTitle(network_title_base.arg(txt));
if (txt == "tcp") {
ui->header_type->setVisible(true);
@@ -111,7 +111,7 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
ui->network->removeItem(0);
// security changed
- connect(ui->security, &QComboBox::currentTextChanged, this, [=](const QString &txt) {
+ connect(ui->security, &QComboBox::currentTextChanged, this, [=,this](const QString &txt) {
if (txt == "tls") {
ui->security_box->setVisible(true);
ui->tls_camouflage_box->setVisible(true);
@@ -135,13 +135,13 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
emit ui->security->currentTextChanged(ui->security->currentText());
// for fragment
- connect(ui->tls_frag, &QCheckBox::checkStateChanged, this, [=](bool state)
+ connect(ui->tls_frag, &QCheckBox::checkStateChanged, this, [=,this](bool state)
{
ui->tls_frag_fall_delay->setEnabled(state);
});
// mux setting changed
- connect(ui->multiplex, &QComboBox::currentTextChanged, this, [=](const QString &txt) {
+ connect(ui->multiplex, &QComboBox::currentTextChanged, this, [=,this](const QString &txt) {
if (txt == "Off") {
ui->brutal_enable->setCheckState(Qt::CheckState::Unchecked);
ui->brutal_box->setEnabled(false);
@@ -174,7 +174,7 @@ DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId,
LOAD_TYPE("chain")
// type changed
- connect(ui->type, &QComboBox::currentIndexChanged, this, [=](int index) {
+ connect(ui->type, &QComboBox::currentIndexChanged, this, [=,this](int index) {
typeSelected(ui->type->itemData(index).toString());
});
@@ -219,7 +219,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
auto _innerWidget = new EditTrojanVLESS(this);
innerWidget = _innerWidget;
innerEditor = _innerWidget;
- connect(_innerWidget->flow_, &QComboBox::currentTextChanged, _innerWidget, [=](const QString &txt)
+ connect(_innerWidget->flow_, &QComboBox::currentTextChanged, _innerWidget, [=,this](const QString &txt)
{
if (txt == "xtls-rprx-vision")
{
@@ -347,7 +347,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
innerEditor->get_edit_text_name = [&]() { return ui->name->text(); };
innerEditor->get_edit_text_serverAddress = [&]() { return ui->address->text(); };
innerEditor->get_edit_text_serverPort = [&]() { return ui->port->text(); };
- innerEditor->editor_cache_updated = [=] { editor_cache_updated_impl(); };
+ innerEditor->editor_cache_updated = [=,this] { editor_cache_updated_impl(); };
innerEditor->onStart(ent);
// 左边 common
@@ -407,7 +407,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
// 第一次显示
if (isHidden()) {
- runOnThread([=] { show(); }, this);
+ runOnThread([=,this] { show(); }, this);
}
}
@@ -576,7 +576,7 @@ void DialogEditProfile::on_apply_to_group_clicked() {
void DialogEditProfile::do_apply_to_group(const std::shared_ptr &group, QWidget *key) {
auto stream = GetStreamSettings(ent->bean.get());
- auto copyStream = [=](void *p) {
+ auto copyStream = [=,this](void *p) {
for (const auto &profile: group->GetProfileEnts()) {
auto newStream = GetStreamSettings(profile->bean.get());
if (newStream == nullptr) continue;
@@ -587,7 +587,7 @@ void DialogEditProfile::do_apply_to_group(const std::shared_ptr
}
};
- auto copyBean = [=](void *p) {
+ auto copyBean = [=,this](void *p) {
for (const auto &profile: group->GetProfileEnts()) {
if (profile == ent) continue;
profile->bean->_setValue(ent->bean->_name(p), p);
diff --git a/src/ui/profile/edit_chain.cpp b/src/ui/profile/edit_chain.cpp
index 4b581cf..48cb1cd 100644
--- a/src/ui/profile/edit_chain.cpp
+++ b/src/ui/profile/edit_chain.cpp
@@ -42,7 +42,7 @@ bool EditChain::onEnd() {
void EditChain::on_select_profile_clicked() {
get_edit_dialog()->hide();
- GetMainWindow()->start_select_mode(this, [=](int id) {
+ GetMainWindow()->start_select_mode(this, [=,this](int id) {
get_edit_dialog()->show();
AddProfileToListIfExist(id);
});
@@ -57,9 +57,9 @@ void EditChain::AddProfileToListIfExist(int profileId) {
ui->listWidget->addItem(wI);
ui->listWidget->setItemWidget(wI, w);
// change button
- connect(w->get_change_button(), &QPushButton::clicked, w, [=] {
+ connect(w->get_change_button(), &QPushButton::clicked, w, [=,this] {
get_edit_dialog()->hide();
- GetMainWindow()->start_select_mode(w, [=](int newId) {
+ GetMainWindow()->start_select_mode(w, [=,this](int newId) {
get_edit_dialog()->show();
ReplaceProfile(w, newId);
});
diff --git a/src/ui/profile/edit_extra_core.cpp b/src/ui/profile/edit_extra_core.cpp
index a19dcb7..fe1e45d 100644
--- a/src/ui/profile/edit_extra_core.cpp
+++ b/src/ui/profile/edit_extra_core.cpp
@@ -27,7 +27,7 @@ void EditExtraCore::onStart(std::shared_ptr _ent) {
ui->path_combo->addItems(Configs::profileManager->GetExtraCorePaths());
ui->path_combo->setCurrentText(bean->extraCorePath);
- connect(ui->path_button, &QPushButton::pressed, this, [=]
+ connect(ui->path_button, &QPushButton::pressed, this, [=,this]
{
auto f = QFileDialog::getOpenFileName();
if (f.isEmpty())
diff --git a/src/ui/profile/edit_quic.cpp b/src/ui/profile/edit_quic.cpp
index 9e95fc1..0c8baf8 100644
--- a/src/ui/profile/edit_quic.cpp
+++ b/src/ui/profile/edit_quic.cpp
@@ -7,7 +7,7 @@
EditQUIC::EditQUIC(QWidget *parent) : QWidget(parent), ui(new Ui::EditQUIC) {
ui->setupUi(this);
- connect(ui->uuidgen, &QPushButton::clicked, this, [=] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); });
+ connect(ui->uuidgen, &QPushButton::clicked, this, [=,this] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); });
}
EditQUIC::~EditQUIC() {
diff --git a/src/ui/profile/edit_ssh.cpp b/src/ui/profile/edit_ssh.cpp
index a50911d..86de0b2 100644
--- a/src/ui/profile/edit_ssh.cpp
+++ b/src/ui/profile/edit_ssh.cpp
@@ -24,7 +24,7 @@ void EditSSH::onStart(std::shared_ptr _ent) {
ui->host_key_algs->setText(bean->hostKeyAlgs.join(","));
ui->client_version->setText(bean->clientVersion);
- connect(ui->choose_pk, &QPushButton::clicked, this, [=] {
+ connect(ui->choose_pk, &QPushButton::clicked, this, [=,this] {
auto fn = QFileDialog::getOpenFileName(this, QObject::tr("Select"), QDir::currentPath(),
"", nullptr, QFileDialog::Option::ReadOnly);
if (!fn.isEmpty()) {
diff --git a/src/ui/profile/edit_vmess.cpp b/src/ui/profile/edit_vmess.cpp
index 9242c9b..a8d87db 100644
--- a/src/ui/profile/edit_vmess.cpp
+++ b/src/ui/profile/edit_vmess.cpp
@@ -6,7 +6,7 @@
EditVMess::EditVMess(QWidget *parent) : QWidget(parent), ui(new Ui::EditVMess) {
ui->setupUi(this);
- connect(ui->uuidgen, &QPushButton::clicked, this, [=] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); });
+ connect(ui->uuidgen, &QPushButton::clicked, this, [=,this] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); });
}
EditVMess::~EditVMess() {
diff --git a/src/ui/setting/RouteItem.cpp b/src/ui/setting/RouteItem.cpp
index b34e287..f2d4c25 100644
--- a/src/ui/setting/RouteItem.cpp
+++ b/src/ui/setting/RouteItem.cpp
@@ -72,7 +72,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrrule_attr_data->layout()->addWidget(rule_set_editor);
ui->rule_attr_data->adjustSize();
rule_set_editor->hide();
- connect(rule_set_editor, &QPlainTextEdit::textChanged, this, [=]{
+ connect(rule_set_editor, &QPlainTextEdit::textChanged, this, [=,this]{
if (currentIndex == -1) return;
auto currentVal = rule_set_editor->toPlainText().split('\n');
chain->Rules[currentIndex]->set_field_value(ui->rule_attr->currentText(), currentVal);
@@ -145,7 +145,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrsetPlainText(chain->GetSimpleRules(Configs::block));
simpleProxy->setPlainText(chain->GetSimpleRules(Configs::proxy));
- connect(ui->tabWidget->tabBar(), &QTabBar::currentChanged, this, [=]()
+ connect(ui->tabWidget->tabBar(), &QTabBar::currentChanged, this, [=,this]()
{
if (ui->tabWidget->tabBar()->currentIndex() == 1)
{
@@ -155,7 +155,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrUpdateSimpleRules(simpleProxy->toPlainText(), Configs::proxy);
if (!res.isEmpty())
{
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
MessageBoxWarning(tr("Invalid rules"), tr("Some rules could not be added:\n") + res);
});
@@ -174,15 +174,15 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrhowtouse_button, &QPushButton::clicked, this, [=]()
+ connect(ui->howtouse_button, &QPushButton::clicked, this, [=,this]()
{
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
MessageBoxInfo(tr("Simple rule manual"), Configs::Information::SimpleRuleInfo);
});
});
- connect(ui->route_import_json, &QPushButton::clicked, this, [=] {
+ connect(ui->route_import_json, &QPushButton::clicked, this, [=,this] {
auto w = new QDialog(this);
w->setWindowTitle("Import JSON Array");
w->setWindowModality(Qt::ApplicationModal);
@@ -209,7 +209,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrsetStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
layout->addWidget(buttons, line, 0);
- connect(buttons, &QDialogButtonBox::accepted, w, [=]{
+ connect(buttons, &QDialogButtonBox::accepted, w, [=,this]{
auto err = new QString;
auto parsed = Configs::RoutingChain::parseJsonArray(QString2QJsonArray(tEdit->toPlainText()), err);
if (!err->isEmpty()) {
@@ -229,13 +229,13 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrdeleteLater();
});
- connect(ui->rule_name, &QLineEdit::textChanged, this, [=](const QString& text) {
+ connect(ui->rule_name, &QLineEdit::textChanged, this, [=,this](const QString& text) {
if (currentIndex == -1) return;
chain->Rules[currentIndex]->name = QString(text);
updateRouteItemsView();
});
- connect(ui->rule_attr_selector, &QComboBox::currentTextChanged, this, [=](const QString& text){
+ connect(ui->rule_attr_selector, &QComboBox::currentTextChanged, this, [=,this](const QString& text){
if (currentIndex == -1) return;
if (ui->rule_attr->currentText() == "outbound")
{
@@ -247,33 +247,33 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptrrule_attr_text, &QPlainTextEdit::textChanged, this, [=] {
+ connect(ui->rule_attr_text, &QPlainTextEdit::textChanged, this, [=,this] {
if (currentIndex == -1) return;
auto currentVal = ui->rule_attr_text->toPlainText().split('\n');
chain->Rules[currentIndex]->set_field_value(ui->rule_attr->currentText(), currentVal);
updateRulePreview();
});
- connect(ui->route_items, &QListWidget::currentRowChanged, this, [=](const int idx) {
+ connect(ui->route_items, &QListWidget::currentRowChanged, this, [=,this](const int idx) {
if (idx == -1) return;
currentIndex = idx;
updateRuleSection();
});
- connect(ui->rule_attr, &QComboBox::currentTextChanged, this, [=](const QString& text){
+ connect(ui->rule_attr, &QComboBox::currentTextChanged, this, [=,this](const QString& text){
updateRuleSection();
});
- connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=]{
+ connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=,this]{
accept();
});
- connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=]{
+ connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=,this]{
QDialog::reject();
});
deleteShortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this);
- connect(deleteShortcut, &QShortcut::activated, this, [=]{
+ connect(deleteShortcut, &QShortcut::activated, this, [=,this]{
on_delete_route_item_clicked();
});
@@ -314,7 +314,7 @@ void RouteItem::accept() {
res += chain->UpdateSimpleRules(simpleProxy->toPlainText(), Configs::proxy);
if (!res.isEmpty())
{
- runOnUiThread([=]
+ runOnUiThread([=,this]
{
MessageBoxWarning(tr("Invalid rules"), tr("Some rules could not be added, fix them before saving:\n") + res);
});
diff --git a/src/ui/setting/dialog_basic_settings.cpp b/src/ui/setting/dialog_basic_settings.cpp
index 8ee6151..fd7f089 100644
--- a/src/ui/setting/dialog_basic_settings.cpp
+++ b/src/ui/setting/dialog_basic_settings.cpp
@@ -38,13 +38,13 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->speedtest_mode->setCurrentIndex(Configs::dataStore->speed_test_mode);
ui->simple_down_url->setText(Configs::dataStore->simple_dl_url);
- connect(ui->custom_inbound_edit, &QPushButton::clicked, this, [=] {
+ connect(ui->custom_inbound_edit, &QPushButton::clicked, this, [=,this] {
C_EDIT_JSON_ALLOW_EMPTY(custom_inbound)
});
- connect(ui->disable_tray, &QCheckBox::stateChanged, this, [=](const bool &) {
+ connect(ui->disable_tray, &QCheckBox::stateChanged, this, [=,this](const bool &) {
CACHE.updateDisableTray = true;
});
- connect(ui->random_listen_port, &QCheckBox::stateChanged, this, [=](const bool &state)
+ connect(ui->random_listen_port, &QCheckBox::stateChanged, this, [=,this](const bool &state)
{
if (state)
{
@@ -67,10 +67,10 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
D_LOAD_INT(max_log_line)
//
ui->language->setCurrentIndex(Configs::dataStore->language);
- connect(ui->language, &QComboBox::currentIndexChanged, this, [=](int index) {
+ connect(ui->language, &QComboBox::currentIndexChanged, this, [=,this](int index) {
CACHE.needRestart = true;
});
- connect(ui->font, &QComboBox::currentTextChanged, this, [=](const QString &fontName) {
+ connect(ui->font, &QComboBox::currentTextChanged, this, [=,this](const QString &fontName) {
auto font = qApp->font();
font.setFamily(fontName);
qApp->setFont(font);
@@ -82,7 +82,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->font_size->addItem(Int2String(i));
}
ui->font_size->setCurrentText(Int2String(qApp->font().pointSize()));
- connect(ui->font_size, &QComboBox::currentTextChanged, this, [=](const QString &sizeStr) {
+ connect(ui->font_size, &QComboBox::currentTextChanged, this, [=,this](const QString &sizeStr) {
auto font = qApp->font();
font.setPointSize(sizeStr.toInt());
qApp->setFont(font);
@@ -102,7 +102,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->theme->setCurrentText(Configs::dataStore->theme);
}
//
- connect(ui->theme, static_cast(&QComboBox::currentIndexChanged), this, [=](int index) {
+ connect(ui->theme, static_cast(&QComboBox::currentIndexChanged), this, [=,this](int index) {
themeManager->ApplyTheme(ui->theme->currentText());
Configs::dataStore->theme = ui->theme->currentText();
Configs::dataStore->Save();
@@ -129,10 +129,10 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->geosite_url->setCurrentText(Configs::dataStore->geosite_download_url);
ui->auto_reset->setCurrentIndex(Configs::dataStore->auto_reset_assets_idx);
- connect(ui->download_geo_btn, &QPushButton::clicked, this, [=]() {
+ connect(ui->download_geo_btn, &QPushButton::clicked, this, [=,this]() {
MW_dialog_message(Dialog_DialogBasicSettings, "DownloadAssets;"+ui->geoip_url->currentText()+";"+ui->geosite_url->currentText());
});
- connect(ui->remove_srs_btn, &QPushButton::clicked, this, [=](){
+ connect(ui->remove_srs_btn, &QPushButton::clicked, this, [=,this](){
auto rsDir = QDir(RULE_SETS_DIR);
auto entries = rsDir.entryList(QDir::Files);
for (const auto &item: entries) {
@@ -142,7 +142,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
}
MW_show_log(tr("Removed all rule-set files"));
});
- connect(ui->reset_assets, &QPushButton::clicked, this, [=]()
+ connect(ui->reset_assets, &QPushButton::clicked, this, [=,this]()
{
MW_dialog_message(Dialog_DialogBasicSettings, "ResetAssets;"+ui->geoip_url->currentText()+";"+ui->geosite_url->currentText());
});
@@ -161,7 +161,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->ntp_server->setText(Configs::dataStore->ntp_server_address);
ui->ntp_port->setText(Int2String(Configs::dataStore->ntp_server_port));
ui->ntp_interval->setCurrentText(Configs::dataStore->ntp_interval);
- connect(ui->ntp_enable, &QCheckBox::stateChanged, this, [=](const bool &state) {
+ connect(ui->ntp_enable, &QCheckBox::stateChanged, this, [=,this](const bool &state) {
ui->ntp_server->setEnabled(state);
ui->ntp_port->setEnabled(state);
ui->ntp_interval->setEnabled(state);
@@ -172,6 +172,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->utlsFingerprint->addItems(Preset::SingBox::UtlsFingerPrint);
ui->disable_priv_req->setChecked(Configs::dataStore->disable_privilege_req);
ui->windows_no_admin->setChecked(Configs::dataStore->disable_run_admin);
+ ui->mozilla_cert->setChecked(Configs::dataStore->use_mozilla_certs);
D_LOAD_BOOL(skip_cert)
ui->utlsFingerprint->setCurrentText(Configs::dataStore->utlsFingerprint);
@@ -252,6 +253,7 @@ void DialogBasicSettings::accept() {
Configs::dataStore->utlsFingerprint = ui->utlsFingerprint->currentText();
Configs::dataStore->disable_privilege_req = ui->disable_priv_req->isChecked();
Configs::dataStore->disable_run_admin = ui->windows_no_admin->isChecked();
+ Configs::dataStore->use_mozilla_certs = ui->mozilla_cert->isChecked();
QStringList str{"UpdateDataStore"};
if (CACHE.needRestart) str << "NeedRestart";
@@ -304,7 +306,7 @@ void DialogBasicSettings::on_core_settings_clicked() {
auto box = new QDialogButtonBox;
box->setOrientation(Qt::Horizontal);
box->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
- connect(box, &QDialogButtonBox::accepted, w, [=] {
+ connect(box, &QDialogButtonBox::accepted, w, [=,this] {
Configs::dataStore->core_box_underlying_dns = core_box_underlying_dns->text();
Configs::dataStore->core_box_clash_api = core_box_clash_api->text().toInt();
Configs::dataStore->core_box_clash_listen_addr = core_box_clash_listen_addr->text();
diff --git a/src/ui/setting/dialog_manage_routes.cpp b/src/ui/setting/dialog_manage_routes.cpp
index 8f0b160..4402eb4 100644
--- a/src/ui/setting/dialog_manage_routes.cpp
+++ b/src/ui/setting/dialog_manage_routes.cpp
@@ -86,16 +86,16 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
ui->remote_dns_strategy->addItems(qsValue);
ui->enable_fakeip->setChecked(Configs::dataStore->fake_dns);
//
- connect(ui->use_dns_object, &QCheckBox::stateChanged, this, [=](int state) {
+ connect(ui->use_dns_object, &QCheckBox::stateChanged, this, [=,this](int state) {
auto useDNSObject = state == Qt::Checked;
ui->simple_dns_box->setDisabled(useDNSObject);
ui->dns_object->setDisabled(!useDNSObject);
});
ui->use_dns_object->stateChanged(Qt::Unchecked); // uncheck to uncheck
- connect(ui->dns_document, &QPushButton::clicked, this, [=] {
+ connect(ui->dns_document, &QPushButton::clicked, this, [=,this] {
MessageBoxInfo("DNS", dnsHelpDocumentUrl);
});
- connect(ui->format_dns_object, &QPushButton::clicked, this, [=] {
+ connect(ui->format_dns_object, &QPushButton::clicked, this, [=,this] {
auto obj = QString2QJsonObject(ui->dns_object->toPlainText());
if (obj.isEmpty()) {
MessageBoxInfo("DNS", "invaild json");
@@ -115,7 +115,7 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
ui->dns_final_out->setCurrentText(Configs::dataStore->routing->dns_final_out);
reloadProfileItems();
- connect(ui->route_profiles, &QListWidget::itemDoubleClicked, this, [=](const QListWidgetItem* item){
+ connect(ui->route_profiles, &QListWidget::itemDoubleClicked, this, [=,this](const QListWidgetItem* item){
on_edit_route_clicked();
});
@@ -123,7 +123,7 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
deleteShortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this);
- connect(deleteShortcut, &QShortcut::activated, this, [=]{
+ connect(deleteShortcut, &QShortcut::activated, this, [=,this]{
on_delete_route_clicked();
});
@@ -135,7 +135,7 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
ui->dnshijack_listenport->setText(Int2String(Configs::dataStore->dns_server_listen_port));
ui->dnshijack_v4resp->setText(Configs::dataStore->dns_v4_resp);
ui->dnshijack_v6resp->setText(Configs::dataStore->dns_v6_resp);
- connect(ui->dnshijack_what, &QPushButton::clicked, this, [=] {
+ connect(ui->dnshijack_what, &QPushButton::clicked, this, [=,this] {
MessageBoxInfo("What is this?", Configs::Information::HijackInfo);
});
@@ -165,10 +165,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
ui->redirect_listenport->setValidator(QRegExpValidator_Number);
ui->redirect_listenport->setText(Int2String(Configs::dataStore->redirect_listen_port));
- connect(ui->dnshijack_enable, &QCheckBox::stateChanged, this, [=](bool state) {
+ connect(ui->dnshijack_enable, &QCheckBox::stateChanged, this, [=,this](bool state) {
set_dns_hijack_enability(state);
});
- connect(ui->redirect_enable, &QCheckBox::stateChanged, this, [=](bool state) {
+ connect(ui->redirect_enable, &QCheckBox::stateChanged, this, [=,this](bool state) {
ui->redirect_listenaddr->setEnabled(state);
ui->redirect_listenport->setEnabled(state);
});
@@ -238,7 +238,7 @@ void DialogManageRoutes::on_new_route_clicked() {
routeChainWidget = new RouteItem(this, Configs::ProfileManager::NewRouteChain());
routeChainWidget->setWindowModality(Qt::ApplicationModal);
routeChainWidget->show();
- connect(routeChainWidget, &RouteItem::settingsChanged, this, [=](const std::shared_ptr& chain) {
+ connect(routeChainWidget, &RouteItem::settingsChanged, this, [=,this](const std::shared_ptr& chain) {
chainList << chain;
reloadProfileItems();
});
@@ -259,7 +259,7 @@ void DialogManageRoutes::on_export_route_clicked()
QToolTip::showText(QCursor::pos(), "Copied!", this);
int r = ++tooltipID;
- QTimer::singleShot(1500, [=] {
+ QTimer::singleShot(1500, [=,this] {
if (tooltipID != r) return;
QToolTip::hideText();
});
@@ -284,7 +284,7 @@ void DialogManageRoutes::on_edit_route_clicked() {
routeChainWidget = new RouteItem(this, chainList[idx]);
routeChainWidget->setWindowModality(Qt::ApplicationModal);
routeChainWidget->show();
- connect(routeChainWidget, &RouteItem::settingsChanged, this, [=](const std::shared_ptr& chain) {
+ connect(routeChainWidget, &RouteItem::settingsChanged, this, [=,this](const std::shared_ptr& chain) {
if (currentRoute == chainList[idx]) currentRoute = chain;
chainList[idx] = chain;
reloadProfileItems();
diff --git a/src/ui/setting/dialog_vpn_settings.cpp b/src/ui/setting/dialog_vpn_settings.cpp
index df977ff..d729f9c 100644
--- a/src/ui/setting/dialog_vpn_settings.cpp
+++ b/src/ui/setting/dialog_vpn_settings.cpp
@@ -9,7 +9,7 @@
#endif
#include
-#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
+#define ADJUST_SIZE runOnThread([=,this] { adjustSize(); adjustPosition(mainwindow); }, this);
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
ui->setupUi(this);
ADD_ASTERISK(this);