mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
[add][fix] Added Windows start with boot support and fixed UI.
This commit is contained in:
parent
62d72a2ddf
commit
80d5465ded
@ -1 +1 @@
|
||||
2396
|
||||
2398
|
||||
|
@ -27,6 +27,7 @@ include(3rdparty/QNodeEditor/QNodeEditor.pri)
|
||||
CONFIG += lrelease embed_translations
|
||||
|
||||
SOURCES += \
|
||||
src/components/QvAutoStartConfigurator.cpp \
|
||||
src/components/QvComponentsHandler.cpp \
|
||||
src/components/QvPACHandler.cpp \
|
||||
src/components/QvSystemProxyConfigurator.cpp \
|
||||
@ -75,6 +76,7 @@ HEADERS += \
|
||||
src/QvCoreConfigObjects.hpp \
|
||||
src/QvCoreConfigOperations.hpp \
|
||||
src/QvUtils.hpp \
|
||||
src/components/QvAutoStartConfigurator.hpp \
|
||||
src/components/QvComponentsHandler.hpp \
|
||||
src/components/QvCoreInteractions.hpp \
|
||||
src/components/QvHTTPRequestHelper.hpp \
|
||||
|
39
src/components/QvAutoStartConfigurator.cpp
Normal file
39
src/components/QvAutoStartConfigurator.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "QvAutoStartConfigurator.hpp"
|
||||
#include <QSettings>
|
||||
#include <QApplication>
|
||||
|
||||
namespace Qv2ray
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
bool InstallAutoStart()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||
auto path = qApp->applicationFilePath();
|
||||
|
||||
// Make it suitable for Windows.
|
||||
if (path.contains(" ")) {
|
||||
path = "\"" + path + "\"";
|
||||
}
|
||||
|
||||
path = path.replace('/', '\\');
|
||||
LOG(MODULE_CONFIG, "Qv2ray executable path: " + path.toStdString())
|
||||
settings.setValue("Qv2ray", path);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool RemoveAutoStart()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||
settings.remove("Qv2ray");
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
17
src/components/QvAutoStartConfigurator.hpp
Normal file
17
src/components/QvAutoStartConfigurator.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef QVAUTOSTARTCONFIGURATOR_H
|
||||
#define QVAUTOSTARTCONFIGURATOR_H
|
||||
|
||||
#include "QvUtils.hpp"
|
||||
|
||||
namespace Qv2ray
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
bool InstallAutoStart();
|
||||
bool RemoveAutoStart();
|
||||
}
|
||||
}
|
||||
|
||||
using namespace Qv2ray::Components;
|
||||
|
||||
#endif // QVAUTOSTARTCONFIGURATOR_H
|
@ -222,6 +222,8 @@ int main(int argc, char *argv[])
|
||||
"Copyright (c) 2019 Nikolaos Ftylitakis (@ftylitak): QZXing (Apache2)" NEWLINE
|
||||
"Copyright (c) 2016 Singein (@Singein): ScreenShot (MIT)" NEWLINE
|
||||
"Copyright (c) 2016 Nikhil Marathe (@nikhilm): QHttpServer (MIT)" NEWLINE
|
||||
"Copyright (c) 2019 Itay Grudev (@itay-grudev): SingleApplication (MIT)" NEWLINE
|
||||
"Copyright (c) 2019 paceholder (@paceholder): nodeeditor (QNodeEditor modified by lhy0403) (BSD-3-Clause)" NEWLINE
|
||||
NEWLINE
|
||||
"Qv2ray " QV2RAY_VERSION_STRING " running on " +
|
||||
(QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture()).toStdString() + NEWLINE)
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QFileDialog>
|
||||
#include "w_PreferencesWindow.hpp"
|
||||
#include <QFileDialog>
|
||||
#include <QColorDialog>
|
||||
#include <QStyleFactory>
|
||||
#include <QStyle>
|
||||
@ -9,8 +10,8 @@
|
||||
#include "QvNetSpeedPlugin.hpp"
|
||||
#include "QvCoreConfigOperations.hpp"
|
||||
|
||||
#include "w_PreferencesWindow.hpp"
|
||||
#include "QvHTTPRequestHelper.hpp"
|
||||
#include "QvAutoStartConfigurator.hpp"
|
||||
|
||||
#define LOADINGCHECK if(!finishedLoading) return;
|
||||
#define NEEDRESTART if(finishedLoading) IsConnectionPropertyChanged = true;
|
||||
@ -771,10 +772,11 @@ void PreferencesWindow::on_pacGoBtn_clicked()
|
||||
QString gfwLocation;
|
||||
QString fileContent;
|
||||
auto request = new QvHttpRequestHelper();
|
||||
LOG(MODULE_PROXY, "Downloading GFWList file.")
|
||||
|
||||
switch (gfwListCB->currentIndex()) {
|
||||
case 0:
|
||||
gfwLocation = "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt";
|
||||
gfwLocation = "https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt";
|
||||
fileContent = QString::fromUtf8(request->syncget(gfwLocation));
|
||||
break;
|
||||
|
||||
@ -794,7 +796,7 @@ void PreferencesWindow::on_pacGoBtn_clicked()
|
||||
break;
|
||||
|
||||
case 4:
|
||||
gfwLocation = "https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt";
|
||||
gfwLocation = "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt";
|
||||
fileContent = QString::fromUtf8(request->syncget(gfwLocation));
|
||||
break;
|
||||
|
||||
@ -812,7 +814,9 @@ void PreferencesWindow::on_pacGoBtn_clicked()
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
LOG(MODULE_NETWORK, "Fetched: " + gfwLocation.toStdString())
|
||||
|
||||
|
||||
if (!QDir(QV2RAY_RULES_DIR).exists()) {
|
||||
QDir(QV2RAY_RULES_DIR).mkpath(QV2RAY_RULES_DIR);
|
||||
}
|
||||
@ -878,3 +882,21 @@ void PreferencesWindow::on_autoStartConnCombo_currentIndexChanged(const QString
|
||||
LOADINGCHECK
|
||||
CurrentConfig.autoStartConfig.connectionName = arg1.toStdString();
|
||||
}
|
||||
|
||||
void PreferencesWindow::on_installBootStart_clicked()
|
||||
{
|
||||
if (InstallAutoStart()) {
|
||||
QvMessageBox(this, tr("Start with boot"), tr("Successfully installed starting with boot."));
|
||||
} else {
|
||||
QvMessageBox(this, tr("Start with boot"), tr("Only Windows platform is supported currently."));
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesWindow::on_removeBootStart_clicked()
|
||||
{
|
||||
if (RemoveAutoStart()) {
|
||||
QvMessageBox(this, tr("Start with boot"), tr("Successfully removed starting with boot."));
|
||||
} else {
|
||||
QvMessageBox(this, tr("Start with boot"), tr("Only Windows platform is supported currently."));
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +134,10 @@ class PreferencesWindow : public QDialog, private Ui::PreferencesWindow
|
||||
|
||||
void on_autoStartConnCombo_currentIndexChanged(const QString &arg1);
|
||||
|
||||
void on_installBootStart_clicked();
|
||||
|
||||
void on_removeBootStart_clicked();
|
||||
|
||||
private:
|
||||
// Set ui parameters for a line;
|
||||
void ShowLineParameters(QvBarLine &line);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -63,6 +63,7 @@ RouteEditor::RouteEditor(QJsonObject connection, QWidget *parent) : QDialog(pare
|
||||
{
|
||||
setupUi(this);
|
||||
isLoading = true;
|
||||
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
|
||||
//
|
||||
SetupNodeWidget();
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user