mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
[Part] Partly add AutoStart functionability
This commit is contained in:
parent
42306d62fb
commit
e928803f70
@ -32,6 +32,13 @@ using namespace std;
|
||||
p.setColor(QPalette::Text, Qt::black); \
|
||||
ui->obj->setPalette(p);
|
||||
|
||||
#ifdef __WIN32
|
||||
#define NEWLINE "\r\n"
|
||||
#else
|
||||
#define NEWLINE "\r"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Qv2ray
|
||||
{
|
||||
namespace QvConfigModels
|
||||
@ -60,13 +67,14 @@ namespace Qv2ray
|
||||
};
|
||||
|
||||
struct Qv2Config_v1 {
|
||||
string v = "1";
|
||||
string v = "1.1";
|
||||
bool runAsRoot;
|
||||
int logLevel;
|
||||
//
|
||||
string language;
|
||||
string v2CorePath;
|
||||
string v2AssetsPath;
|
||||
string autoStartConfig;
|
||||
//
|
||||
bool proxyDefault;
|
||||
bool proxyCN;
|
||||
@ -79,6 +87,7 @@ namespace Qv2ray
|
||||
Qv2Config_v1(): runAsRoot(false), logLevel(), proxyDefault(), proxyCN(), withLocalDNS(), inBoundSettings(), configs(), mux() { }
|
||||
Qv2Config_v1(string lang, string exePath, string assetsPath, int log, QvBasicInboundSetting _inBoundSettings): Qv2Config_v1()
|
||||
{
|
||||
autoStartConfig = "";
|
||||
language = lang;
|
||||
v2CorePath = exePath;
|
||||
v2AssetsPath = assetsPath;
|
||||
@ -93,7 +102,7 @@ namespace Qv2ray
|
||||
proxyDefault = true;
|
||||
withLocalDNS = true;
|
||||
}
|
||||
XTOSTRUCT(O(v, runAsRoot, logLevel, language, v2CorePath, v2AssetsPath, proxyDefault, proxyCN, withLocalDNS, dnsList, inBoundSettings, mux, configs))
|
||||
XTOSTRUCT(O(v, runAsRoot, logLevel, language, autoStartConfig, v2CorePath, v2AssetsPath, proxyDefault, proxyCN, withLocalDNS, dnsList, inBoundSettings, mux, configs))
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -105,4 +114,4 @@ using namespace Qv2ray;
|
||||
using namespace Qv2ray::V2ConfigModels;
|
||||
using namespace Qv2ray::QvConfigModels;
|
||||
|
||||
#endif // HCONFIGOBJECTS_H
|
||||
#endif // QCONFIGOBJECTS_H
|
||||
|
@ -48,20 +48,31 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
hTray->setContextMenu(trayMenu);
|
||||
hTray->show();
|
||||
LoadConnections();
|
||||
|
||||
//
|
||||
if(!vinstance->ValidateV2rayCoreExe()){
|
||||
if (!vinstance->ValidateV2rayCoreExe()) {
|
||||
on_prefrencesBtn_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::LoadConnections()
|
||||
{
|
||||
connections = GetConnections(GetGlobalConfig().configs);
|
||||
auto conf = GetGlobalConfig();
|
||||
connections = GetConnections(conf.configs);
|
||||
ui->connectionListWidget->clear();
|
||||
|
||||
for (int i = 0; i < connections.count(); i++) {
|
||||
ui->connectionListWidget->addItem(connections.keys()[i]);
|
||||
}
|
||||
|
||||
if (conf.autoStartConfig != "" && QList<string>::fromStdList(conf.configs).contains(conf.autoStartConfig)) {
|
||||
CurrentConnectionName = QString::fromStdString(conf.autoStartConfig);
|
||||
auto item = ui->connectionListWidget->findItems(QString::fromStdString(conf.autoStartConfig), Qt::MatchExactly).front();
|
||||
item->setSelected(true);
|
||||
ui->connectionListWidget->setCurrentItem(item);
|
||||
on_connectionListWidget_itemClicked(item);
|
||||
on_startButton_clicked();
|
||||
}
|
||||
}
|
||||
void MainWindow::reload_config()
|
||||
{
|
||||
|
@ -9,8 +9,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>457</height>
|
||||
<width>644</width>
|
||||
<height>522</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -63,9 +63,18 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent),
|
||||
ui->DNSListTxt->clear();
|
||||
|
||||
foreach (auto dnsStr, CurrentConfig.dnsList) {
|
||||
ui->DNSListTxt->appendPlainText(QString::fromStdString(dnsStr) + "\r\n");
|
||||
auto str = QString::fromStdString(dnsStr).trimmed();
|
||||
|
||||
if (!str.isEmpty()) {
|
||||
ui->DNSListTxt->appendPlainText(str);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (auto connection, CurrentConfig.configs) {
|
||||
ui->autoStartCombo->addItem(QString::fromStdString(connection));
|
||||
}
|
||||
|
||||
ui->autoStartCombo->setCurrentText(QString::fromStdString(CurrentConfig.autoStartConfig));
|
||||
finishedLoading = true;
|
||||
}
|
||||
|
||||
@ -124,8 +133,7 @@ void PrefrencesWindow::on_httpAuthCB_stateChanged(int checked)
|
||||
void PrefrencesWindow::on_runAsRootCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
#ifdef __linux
|
||||
// Set UID and GID in *nix
|
||||
// The file is actually not here
|
||||
// Set UID and GID for linux
|
||||
QString vCorePath = QString::fromStdString(CurrentConfig.v2CorePath);
|
||||
QFileInfo v2rayCoreExeFile(vCorePath);
|
||||
|
||||
@ -146,6 +154,7 @@ void PrefrencesWindow::on_runAsRootCheckBox_stateChanged(int arg1)
|
||||
|
||||
#else
|
||||
Q_UNUSED(arg1)
|
||||
ui->runAsRootCheckBox->setChecked(false);
|
||||
// No such uid gid thing on Windows and MacOS is in TODO ....
|
||||
QvMessageBox(this, tr("Prefrences"), tr("RunAsRootNotOnWindows"));
|
||||
#endif
|
||||
@ -276,3 +285,8 @@ void PrefrencesWindow::on_vCoreAssetsPathTxt_textChanged(const QString &arg1)
|
||||
{
|
||||
CurrentConfig.v2AssetsPath = arg1.toStdString();
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_autoStartCombo_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
CurrentConfig.autoStartConfig = arg1.toStdString();
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ class PrefrencesWindow : public QDialog
|
||||
|
||||
void on_vCoreAssetsPathTxt_textChanged(const QString &arg1);
|
||||
|
||||
void on_autoStartCombo_currentTextChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
bool finishedLoading = false;
|
||||
Qv2ray::QvConfigModels::Qv2Config_v1 CurrentConfig;
|
||||
|
@ -122,14 +122,14 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>#VCoreExePath</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="vCoreExePathTxt"/>
|
||||
@ -143,14 +143,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>#VCoreAssetsPath</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="vCoreAssetsPathTxt"/>
|
||||
@ -164,6 +164,22 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>#AutoStartEntry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="autoStartCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
@ -438,6 +454,11 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
<string>#About</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user