mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 10:50:23 +08:00
[Changed] Changed UI Classpath
This commit is contained in:
parent
08e6e26201
commit
ecad514425
@ -4,9 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
QT += core gui widgets
|
||||
|
||||
TARGET = Qv2ray
|
||||
TEMPLATE = app
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Show MainWindow
|
||||
Ui_Impl::MainWindow w;
|
||||
Ui::MainWindow w;
|
||||
w.show();
|
||||
return _qApp.exec();
|
||||
}
|
||||
|
@ -5,33 +5,30 @@
|
||||
#include <QIntValidator>
|
||||
#include <iostream>
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
ConnectionEditWindow::ConnectionEditWindow(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_WConnectionEdit)
|
||||
{
|
||||
ConnectionEditWindow::ConnectionEditWindow(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_ConnectionEditWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->portLineEdit->setValidator(new QIntValidator());
|
||||
ui->alterLineEdit->setValidator(new QIntValidator());
|
||||
}
|
||||
|
||||
ConnectionEditWindow::~ConnectionEditWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//void ConnectionEditWindow::getConfigFromDialog(Ui::ConnectionEditWindow *ui)
|
||||
//{
|
||||
//this->host = ui->ipLineEdit->text();
|
||||
//this->port = ui->portLineEdit->text();
|
||||
//this->alias = ui->aliasLineEdit->text();
|
||||
//this->uuid = ui->idLineEdit->text();
|
||||
//this->alterid = ui->alterLineEdit->text();
|
||||
//this->security = ui->securityCombo->currentText();
|
||||
//this->isCustom = 0;
|
||||
//}
|
||||
ui->setupUi(this);
|
||||
ui->portLineEdit->setValidator(new QIntValidator());
|
||||
ui->alterLineEdit->setValidator(new QIntValidator());
|
||||
}
|
||||
|
||||
ConnectionEditWindow::~ConnectionEditWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//void ConnectionEditWindow::getConfigFromDialog(Ui::ConnectionEditWindow *ui)
|
||||
//{
|
||||
//this->host = ui->ipLineEdit->text();
|
||||
//this->port = ui->portLineEdit->text();
|
||||
//this->alias = ui->aliasLineEdit->text();
|
||||
//this->uuid = ui->idLineEdit->text();
|
||||
//this->alterid = ui->alterLineEdit->text();
|
||||
//this->security = ui->securityCombo->currentText();
|
||||
//this->isCustom = 0;
|
||||
//}
|
||||
}
|
||||
|
@ -4,21 +4,18 @@
|
||||
#include <QDialog>
|
||||
#include "ui_w_ConnectionEditWindow.h"
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
class ConnectionEditWindow : public QDialog
|
||||
{
|
||||
class ConnectionEditWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectionEditWindow(QWidget *parent = nullptr);
|
||||
~ConnectionEditWindow();
|
||||
public:
|
||||
explicit ConnectionEditWindow(QWidget *parent = nullptr);
|
||||
~ConnectionEditWindow();
|
||||
|
||||
private:
|
||||
Ui_ConnectionEditWindow *ui;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Ui_WConnectionEdit *ui;
|
||||
};
|
||||
}
|
||||
#endif // CONFEDIT_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConnectionEditWindow</class>
|
||||
<widget class="QDialog" name="ConnectionEditWindow">
|
||||
<class>WConnectionEdit</class>
|
||||
<widget class="QDialog" name="WConnectionEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -864,7 +864,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ConnectionEditWindow</receiver>
|
||||
<receiver>WConnectionEdit</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -880,7 +880,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ConnectionEditWindow</receiver>
|
||||
<receiver>WConnectionEdit</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
@ -16,122 +16,120 @@
|
||||
#include "w_ImportConfig.h"
|
||||
|
||||
using namespace Qv2ray;
|
||||
namespace Qv2ray
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
ImportConfig::ImportConfig(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_WImportConfig)
|
||||
{
|
||||
ImportConfig::ImportConfig(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_ImportConfig)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(this, SIGNAL(updateConfTable()), parentWidget(), SLOT(updateConfTable()));
|
||||
}
|
||||
ui->setupUi(this);
|
||||
connect(this, SIGNAL(updateConfTable()), parentWidget(), SLOT(updateConfTable()));
|
||||
}
|
||||
|
||||
ImportConfig::~ImportConfig()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ImportConfig::~ImportConfig()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ImportConfig::on_pushButton_clicked()
|
||||
{
|
||||
QString dir = QFileDialog::getOpenFileName(this, tr("OpenConfigFile"), "~/");
|
||||
ui->fileLineTxt->setText(dir);
|
||||
}
|
||||
void ImportConfig::on_pushButton_clicked()
|
||||
{
|
||||
QString dir = QFileDialog::getOpenFileName(this, tr("OpenConfigFile"), "~/");
|
||||
ui->fileLineTxt->setText(dir);
|
||||
}
|
||||
|
||||
void ImportConfig::savefromFile(QString path, QString alias)
|
||||
{
|
||||
Q_UNUSED(path)
|
||||
Q_UNUSED(alias)
|
||||
//Hv2Config newConfig;
|
||||
//newConfig.alias = alias;
|
||||
//QFile configFile(path);
|
||||
//if(!configFile.open(QIODevice::ReadOnly)) {
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("CannotOpenFile"));
|
||||
// qDebug() << "ImportConfig::CannotOpenFile";
|
||||
// return;
|
||||
//}
|
||||
//QByteArray allData = configFile.readAll();
|
||||
//configFile.close();
|
||||
//QJsonDocument v2conf(QJsonDocument::fromJson(allData));
|
||||
//QJsonObject rootobj = v2conf.object();
|
||||
//QJsonObject outbound;
|
||||
//if(rootobj.contains("outbounds")) {
|
||||
// outbound = rootobj.value("outbounds").toArray().first().toObject();
|
||||
//} else {
|
||||
// outbound = rootobj.value("outbound").toObject();
|
||||
//}
|
||||
//QJsonObject vnext = switchJsonArrayObject(outbound.value("settings").toObject(), "vnext");
|
||||
//QJsonObject user = switchJsonArrayObject(vnext, "users");
|
||||
//newConfig.host = vnext.value("address").toString();
|
||||
//newConfig.port = QString::number(vnext.value("port").toInt());
|
||||
//newConfig.alterid = QString::number(user.value("alterId").toInt());
|
||||
//newConfig.uuid = user.value("id").toString();
|
||||
//newConfig.security = user.value("security").toString();
|
||||
//if (newConfig.security.isNull()) {
|
||||
// newConfig.security = "auto";
|
||||
//}
|
||||
//newConfig.isCustom = 1;
|
||||
//int id = newConfig.save();
|
||||
//if(id < 0)
|
||||
//{
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("SaveFailed"));
|
||||
// qDebug() << "ImportConfig::SaveFailed";
|
||||
// return;
|
||||
//}
|
||||
//emit updateConfTable();
|
||||
//QString newFile = "conf/" + QString::number(id) + ".conf";
|
||||
//if(!QFile::copy(path, newFile)) {
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("CannotCopyCustomConfig"));
|
||||
// qDebug() << "ImportConfig::CannotCopyCustomConfig";
|
||||
//}
|
||||
}
|
||||
void ImportConfig::savefromFile(QString path, QString alias)
|
||||
{
|
||||
Q_UNUSED(path)
|
||||
Q_UNUSED(alias)
|
||||
//Hv2Config newConfig;
|
||||
//newConfig.alias = alias;
|
||||
//QFile configFile(path);
|
||||
//if(!configFile.open(QIODevice::ReadOnly)) {
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("CannotOpenFile"));
|
||||
// qDebug() << "ImportConfig::CannotOpenFile";
|
||||
// return;
|
||||
//}
|
||||
//QByteArray allData = configFile.readAll();
|
||||
//configFile.close();
|
||||
//QJsonDocument v2conf(QJsonDocument::fromJson(allData));
|
||||
//QJsonObject rootobj = v2conf.object();
|
||||
//QJsonObject outbound;
|
||||
//if(rootobj.contains("outbounds")) {
|
||||
// outbound = rootobj.value("outbounds").toArray().first().toObject();
|
||||
//} else {
|
||||
// outbound = rootobj.value("outbound").toObject();
|
||||
//}
|
||||
//QJsonObject vnext = switchJsonArrayObject(outbound.value("settings").toObject(), "vnext");
|
||||
//QJsonObject user = switchJsonArrayObject(vnext, "users");
|
||||
//newConfig.host = vnext.value("address").toString();
|
||||
//newConfig.port = QString::number(vnext.value("port").toInt());
|
||||
//newConfig.alterid = QString::number(user.value("alterId").toInt());
|
||||
//newConfig.uuid = user.value("id").toString();
|
||||
//newConfig.security = user.value("security").toString();
|
||||
//if (newConfig.security.isNull()) {
|
||||
// newConfig.security = "auto";
|
||||
//}
|
||||
//newConfig.isCustom = 1;
|
||||
//int id = newConfig.save();
|
||||
//if(id < 0)
|
||||
//{
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("SaveFailed"));
|
||||
// qDebug() << "ImportConfig::SaveFailed";
|
||||
// return;
|
||||
//}
|
||||
//emit updateConfTable();
|
||||
//QString newFile = "conf/" + QString::number(id) + ".conf";
|
||||
//if(!QFile::copy(path, newFile)) {
|
||||
// showWarnMessageBox(this, tr("ImportConfig"), tr("CannotCopyCustomConfig"));
|
||||
// qDebug() << "ImportConfig::CannotCopyCustomConfig";
|
||||
//}
|
||||
}
|
||||
|
||||
void ImportConfig::on_buttonBox_accepted()
|
||||
{
|
||||
QString alias = ui->nameTxt->text();
|
||||
void ImportConfig::on_buttonBox_accepted()
|
||||
{
|
||||
QString alias = ui->nameTxt->text();
|
||||
|
||||
if (ui->importSourceCombo->currentIndex() == 0) { // From File...
|
||||
QString path = ui->fileLineTxt->text();
|
||||
bool isValid = v2Instance::checkConfigFile(path);
|
||||
if (ui->importSourceCombo->currentIndex() == 0) { // From File...
|
||||
QString path = ui->fileLineTxt->text();
|
||||
bool isValid = v2Instance::checkConfigFile(path);
|
||||
|
||||
if (isValid) {
|
||||
savefromFile(path, alias);
|
||||
}
|
||||
} else {
|
||||
QString vmess = ui->vmessConnectionStringTxt->toPlainText();
|
||||
Py_Initialize();
|
||||
assert(Py_IsInitialized());
|
||||
QString param = "--inbound socks:1080 " + vmess + " -o config.json.tmp";
|
||||
PyRun_SimpleString("import sys");
|
||||
PyRun_SimpleString("sys.path.append('./utils')");
|
||||
PyObject *pModule = PyImport_ImportModule("vmess2json");
|
||||
PyObject *pFunc = PyObject_GetAttrString(pModule, "main");
|
||||
PyObject *arg = PyTuple_New(1);
|
||||
PyObject *arg1 = Py_BuildValue("s", param.toStdString().c_str());
|
||||
PyTuple_SetItem(arg, 0, arg1);
|
||||
PyObject_CallObject(pFunc, arg);
|
||||
Py_Finalize();
|
||||
|
||||
if (QFile::exists(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
ImportConfig *im = new ImportConfig(this->parentWidget());
|
||||
|
||||
if (v2Instance::checkConfigFile(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
im->savefromFile("config.json.tmp", alias);
|
||||
}
|
||||
|
||||
QFile::remove("config.json.tmp");
|
||||
} else {
|
||||
Utils::showWarnMessageBox(this, tr("ImportConfig"), tr("CannotGenerateConfig"));
|
||||
qDebug() << "ImportConfig::CannotGenerateConfig";
|
||||
}
|
||||
if (isValid) {
|
||||
savefromFile(path, alias);
|
||||
}
|
||||
} else {
|
||||
QString vmess = ui->vmessConnectionStringTxt->toPlainText();
|
||||
Py_Initialize();
|
||||
assert(Py_IsInitialized());
|
||||
QString param = "--inbound socks:1080 " + vmess + " -o config.json.tmp";
|
||||
PyRun_SimpleString("import sys");
|
||||
PyRun_SimpleString("sys.path.append('./utils')");
|
||||
PyObject *pModule = PyImport_ImportModule("vmess2json");
|
||||
PyObject *pFunc = PyObject_GetAttrString(pModule, "main");
|
||||
PyObject *arg = PyTuple_New(1);
|
||||
PyObject *arg1 = Py_BuildValue("s", param.toStdString().c_str());
|
||||
PyTuple_SetItem(arg, 0, arg1);
|
||||
PyObject_CallObject(pFunc, arg);
|
||||
Py_Finalize();
|
||||
|
||||
if (ui->useCurrentSettingRidBtn->isChecked()) {
|
||||
// TODO: Use Current Settings...
|
||||
if (QFile::exists(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
ImportConfig *im = new ImportConfig(this->parentWidget());
|
||||
|
||||
if (v2Instance::checkConfigFile(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
im->savefromFile("config.json.tmp", alias);
|
||||
}
|
||||
|
||||
QFile::remove("config.json.tmp");
|
||||
} else {
|
||||
// TODO: Override Inbound....
|
||||
Utils::showWarnMessageBox(this, tr("ImportConfig"), tr("CannotGenerateConfig"));
|
||||
qDebug() << "ImportConfig::CannotGenerateConfig";
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->useCurrentSettingRidBtn->isChecked()) {
|
||||
// TODO: Use Current Settings...
|
||||
} else {
|
||||
// TODO: Override Inbound....
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,29 +4,26 @@
|
||||
#include <QDialog>
|
||||
#include "ui_w_ImportConfig.h"
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
class ImportConfig : public QDialog
|
||||
{
|
||||
class ImportConfig : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportConfig(QWidget *parent = nullptr);
|
||||
void savefromFile(QString path, QString alias);
|
||||
~ImportConfig();
|
||||
public:
|
||||
explicit ImportConfig(QWidget *parent = nullptr);
|
||||
void savefromFile(QString path, QString alias);
|
||||
~ImportConfig();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
signals:
|
||||
void updateConfTable();
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
signals:
|
||||
void updateConfTable();
|
||||
|
||||
private:
|
||||
Ui_ImportConfig *ui;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Ui_WImportConfig *ui;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IMPORTCONF_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImportConfig</class>
|
||||
<widget class="QDialog" name="ImportConfig">
|
||||
<class>WImportConfig</class>
|
||||
<widget class="QDialog" name="WImportConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -162,7 +162,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ImportConfig</receiver>
|
||||
<receiver>WImportConfig</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -178,7 +178,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ImportConfig</receiver>
|
||||
<receiver>WImportConfig</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
@ -15,268 +15,265 @@
|
||||
#include "w_MainWindow.h"
|
||||
#include "w_PrefrencesWindow.h"
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
void MainWindow::CreateTrayIcon()
|
||||
{
|
||||
void MainWindow::CreateTrayIcon()
|
||||
{
|
||||
hTray = new QSystemTrayIcon();
|
||||
hTray->setToolTip(tr("Qv2ray"));
|
||||
hTray->setIcon(this->windowIcon());
|
||||
connect(hTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_activatedTray(QSystemTrayIcon::ActivationReason)));
|
||||
QAction *actionShow = new QAction(this);
|
||||
QAction *actionQuit = new QAction(this);
|
||||
QAction *actionStart = new QAction(this);
|
||||
QAction *actionRestart = new QAction(this);
|
||||
QAction *actionStop = new QAction(this);
|
||||
actionShow->setText(tr("#Hide"));
|
||||
actionQuit->setText(tr("#Quit"));
|
||||
actionStart->setText(tr("#Start"));
|
||||
actionStop->setText(tr("#Stop"));
|
||||
actionRestart->setText(tr("#Restart"));
|
||||
actionStart->setEnabled(true);
|
||||
actionStop->setEnabled(false);
|
||||
actionRestart->setEnabled(false);
|
||||
trayMenu->addAction(actionShow);
|
||||
trayMenu->addSeparator();
|
||||
trayMenu->addAction(actionStart);
|
||||
trayMenu->addAction(actionStop);
|
||||
trayMenu->addAction(actionRestart);
|
||||
trayMenu->addSeparator();
|
||||
trayMenu->addAction(actionQuit);
|
||||
connect(actionShow, SIGNAL(triggered()), this, SLOT(toggleMainWindowVisibility()));
|
||||
connect(actionStart, SIGNAL(triggered()), this, SLOT(on_startButton_clicked()));
|
||||
connect(actionStop, SIGNAL(triggered()), this, SLOT(on_stopButton_clicked()));
|
||||
connect(actionRestart, SIGNAL(triggered()), this, SLOT(on_restartButton_clicked()));
|
||||
connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
||||
hTray->setContextMenu(trayMenu);
|
||||
hTray->show();
|
||||
hTray = new QSystemTrayIcon();
|
||||
hTray->setToolTip(tr("Qv2ray"));
|
||||
hTray->setIcon(this->windowIcon());
|
||||
connect(hTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_activatedTray(QSystemTrayIcon::ActivationReason)));
|
||||
QAction *actionShow = new QAction(this);
|
||||
QAction *actionQuit = new QAction(this);
|
||||
QAction *actionStart = new QAction(this);
|
||||
QAction *actionRestart = new QAction(this);
|
||||
QAction *actionStop = new QAction(this);
|
||||
actionShow->setText(tr("#Hide"));
|
||||
actionQuit->setText(tr("#Quit"));
|
||||
actionStart->setText(tr("#Start"));
|
||||
actionStop->setText(tr("#Stop"));
|
||||
actionRestart->setText(tr("#Restart"));
|
||||
actionStart->setEnabled(true);
|
||||
actionStop->setEnabled(false);
|
||||
actionRestart->setEnabled(false);
|
||||
trayMenu->addAction(actionShow);
|
||||
trayMenu->addSeparator();
|
||||
trayMenu->addAction(actionStart);
|
||||
trayMenu->addAction(actionStop);
|
||||
trayMenu->addAction(actionRestart);
|
||||
trayMenu->addSeparator();
|
||||
trayMenu->addAction(actionQuit);
|
||||
connect(actionShow, SIGNAL(triggered()), this, SLOT(toggleMainWindowVisibility()));
|
||||
connect(actionStart, SIGNAL(triggered()), this, SLOT(on_startButton_clicked()));
|
||||
connect(actionStop, SIGNAL(triggered()), this, SLOT(on_stopButton_clicked()));
|
||||
connect(actionRestart, SIGNAL(triggered()), this, SLOT(on_restartButton_clicked()));
|
||||
connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
||||
hTray->setContextMenu(trayMenu);
|
||||
hTray->show();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui_WMain)
|
||||
{
|
||||
this->setWindowIcon(QIcon(":/icons/Qv2ray.ico"));
|
||||
ui->setupUi(this);
|
||||
UpdateConfigTable();
|
||||
// ui->configTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
// connect(ui->configTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||
this->vinstance = new Qv2ray::v2Instance(this);
|
||||
CreateTrayIcon();
|
||||
|
||||
if (QFileInfo("config.json").exists()) {
|
||||
vinstance->start();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui_MainWindow)
|
||||
{
|
||||
this->setWindowIcon(QIcon(":/icons/Qv2ray.ico"));
|
||||
ui->setupUi(this);
|
||||
UpdateConfigTable();
|
||||
// ui->configTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
// connect(ui->configTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||
this->vinstance = new v2Instance(this);
|
||||
CreateTrayIcon();
|
||||
// QAction *select = new QAction("Select", ui->configTable);
|
||||
// QAction *del = new QAction("Delete", ui->configTable);
|
||||
// QAction *rename = new QAction("Rename", ui->configTable);
|
||||
// popMenu->addAction(select);
|
||||
// popMenu->addAction(del);
|
||||
// popMenu->addAction(rename);
|
||||
// connect(select, SIGNAL(triggered()), this, SLOT(select_triggered()));
|
||||
// connect(del, SIGNAL(triggered()), this, SLOT(delConf()));
|
||||
// connect(rename, SIGNAL(triggered()), this, SLOT(renameRow()));
|
||||
// connect(ui->logText, SIGNAL(textChanged()), this, SLOT(scrollToBottom()));
|
||||
// bar = ui->logText->verticalScrollBar();
|
||||
}
|
||||
|
||||
if (QFileInfo("config.json").exists()) {
|
||||
vinstance->start();
|
||||
}
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
hTray->hide();
|
||||
delete this->hTray;
|
||||
delete this->vinstance;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
// QAction *select = new QAction("Select", ui->configTable);
|
||||
// QAction *del = new QAction("Delete", ui->configTable);
|
||||
// QAction *rename = new QAction("Rename", ui->configTable);
|
||||
// popMenu->addAction(select);
|
||||
// popMenu->addAction(del);
|
||||
// popMenu->addAction(rename);
|
||||
// connect(select, SIGNAL(triggered()), this, SLOT(select_triggered()));
|
||||
// connect(del, SIGNAL(triggered()), this, SLOT(delConf()));
|
||||
// connect(rename, SIGNAL(triggered()), this, SLOT(renameRow()));
|
||||
// connect(ui->logText, SIGNAL(textChanged()), this, SLOT(scrollToBottom()));
|
||||
// bar = ui->logText->verticalScrollBar();
|
||||
}
|
||||
void MainWindow::on_actionEdit_triggered()
|
||||
{
|
||||
ConnectionEditWindow *e = new ConnectionEditWindow(this);
|
||||
e->setAttribute(Qt::WA_DeleteOnClose);
|
||||
e->show();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
hTray->hide();
|
||||
delete this->hTray;
|
||||
delete this->vinstance;
|
||||
delete ui;
|
||||
}
|
||||
void MainWindow::on_actionExisting_config_triggered()
|
||||
{
|
||||
ImportConfig *f = new ImportConfig(this);
|
||||
f->setAttribute(Qt::WA_DeleteOnClose);
|
||||
f->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEdit_triggered()
|
||||
{
|
||||
ConnectionEditWindow *e = new ConnectionEditWindow(this);
|
||||
e->setAttribute(Qt::WA_DeleteOnClose);
|
||||
e->show();
|
||||
}
|
||||
void MainWindow::showMenu(QPoint pos)
|
||||
{
|
||||
Q_UNUSED(pos)
|
||||
// if(ui->configTable->indexAt(pos).column() != -1) {
|
||||
// popMenu->move(cursor().pos());
|
||||
// popMenu->show();
|
||||
// }
|
||||
}
|
||||
void MainWindow::select_triggered()
|
||||
{
|
||||
// int row = ui->configTable->selectionModel()->currentIndex().row();
|
||||
// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt();
|
||||
// this->geneConf(idIntable);
|
||||
// if(this->v2Inst->v2Process->state() == QProcess::Running) {
|
||||
// this->on_restartButton_clicked();
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExisting_config_triggered()
|
||||
{
|
||||
ImportConfig *f = new ImportConfig(this);
|
||||
f->setAttribute(Qt::WA_DeleteOnClose);
|
||||
f->show();
|
||||
}
|
||||
void MainWindow::DeleteConfig()
|
||||
{
|
||||
}
|
||||
void MainWindow::UpdateConfigTable()
|
||||
{
|
||||
}
|
||||
void MainWindow::GenerateConfig(int idIntable)
|
||||
{
|
||||
Q_UNUSED(idIntable)
|
||||
//Hv2Config tmpConf;
|
||||
//emit UpdateConfigTable();
|
||||
//if (tmpConf.isCustom == 1) {
|
||||
// QString src = "conf/" + QString::number(idIntable) + ".conf";
|
||||
// overrideInbounds(src);
|
||||
// if (QFile::exists("config.json")) {
|
||||
// QFile::remove("config.json");
|
||||
// }
|
||||
// QFile::copy(src, "config.json");
|
||||
//} else {
|
||||
// // TODO: Config generator
|
||||
//}
|
||||
}
|
||||
void MainWindow::UpdateLog()
|
||||
{
|
||||
ui->logText->insertPlainText(this->vinstance->vProcess->readAllStandardOutput());
|
||||
}
|
||||
|
||||
void MainWindow::showMenu(QPoint pos)
|
||||
{
|
||||
Q_UNUSED(pos)
|
||||
// if(ui->configTable->indexAt(pos).column() != -1) {
|
||||
// popMenu->move(cursor().pos());
|
||||
// popMenu->show();
|
||||
// }
|
||||
}
|
||||
void MainWindow::select_triggered()
|
||||
{
|
||||
// int row = ui->configTable->selectionModel()->currentIndex().row();
|
||||
// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt();
|
||||
// this->geneConf(idIntable);
|
||||
// if(this->v2Inst->v2Process->state() == QProcess::Running) {
|
||||
// this->on_restartButton_clicked();
|
||||
// }
|
||||
}
|
||||
void MainWindow::on_startButton_clicked()
|
||||
{
|
||||
ui->logText->clear();
|
||||
bool startFlag = this->vinstance->start();
|
||||
trayMenu->actions()[2]->setEnabled(!startFlag);
|
||||
trayMenu->actions()[3]->setEnabled(startFlag);
|
||||
trayMenu->actions()[4]->setEnabled(startFlag);
|
||||
}
|
||||
|
||||
void MainWindow::DeleteConfig()
|
||||
{
|
||||
}
|
||||
void MainWindow::UpdateConfigTable()
|
||||
{
|
||||
}
|
||||
void MainWindow::GenerateConfig(int idIntable)
|
||||
{
|
||||
Q_UNUSED(idIntable)
|
||||
//Hv2Config tmpConf;
|
||||
//emit UpdateConfigTable();
|
||||
//if (tmpConf.isCustom == 1) {
|
||||
// QString src = "conf/" + QString::number(idIntable) + ".conf";
|
||||
// overrideInbounds(src);
|
||||
// if (QFile::exists("config.json")) {
|
||||
// QFile::remove("config.json");
|
||||
// }
|
||||
// QFile::copy(src, "config.json");
|
||||
//} else {
|
||||
// // TODO: Config generator
|
||||
//}
|
||||
}
|
||||
void MainWindow::UpdateLog()
|
||||
{
|
||||
ui->logText->insertPlainText(this->vinstance->vProcess->readAllStandardOutput());
|
||||
}
|
||||
void MainWindow::on_stopButton_clicked()
|
||||
{
|
||||
this->vinstance->stop();
|
||||
ui->logText->clear();
|
||||
trayMenu->actions()[2]->setEnabled(true);
|
||||
trayMenu->actions()[3]->setEnabled(false);
|
||||
trayMenu->actions()[4]->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_startButton_clicked()
|
||||
{
|
||||
ui->logText->clear();
|
||||
bool startFlag = this->vinstance->start();
|
||||
trayMenu->actions()[2]->setEnabled(!startFlag);
|
||||
trayMenu->actions()[3]->setEnabled(startFlag);
|
||||
trayMenu->actions()[4]->setEnabled(startFlag);
|
||||
}
|
||||
void MainWindow::on_restartButton_clicked()
|
||||
{
|
||||
on_stopButton_clicked();
|
||||
on_startButton_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::on_stopButton_clicked()
|
||||
{
|
||||
this->vinstance->stop();
|
||||
ui->logText->clear();
|
||||
trayMenu->actions()[2]->setEnabled(true);
|
||||
trayMenu->actions()[3]->setEnabled(false);
|
||||
trayMenu->actions()[4]->setEnabled(false);
|
||||
}
|
||||
void MainWindow::on_clbutton_clicked()
|
||||
{
|
||||
ui->logText->clear();
|
||||
}
|
||||
|
||||
void MainWindow::on_restartButton_clicked()
|
||||
{
|
||||
on_stopButton_clicked();
|
||||
on_startButton_clicked();
|
||||
}
|
||||
void MainWindow::on_rtButton_clicked()
|
||||
{
|
||||
emit UpdateConfigTable();
|
||||
}
|
||||
|
||||
void MainWindow::on_clbutton_clicked()
|
||||
{
|
||||
ui->logText->clear();
|
||||
}
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
this->hide();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void MainWindow::on_rtButton_clicked()
|
||||
{
|
||||
emit UpdateConfigTable();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
this->hide();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void MainWindow::on_activatedTray(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
// Toggle Show/Hide
|
||||
void MainWindow::on_activatedTray(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
// Toggle Show/Hide
|
||||
#ifndef __APPLE__
|
||||
// Every single click will trigger the Show/Hide toggling.
|
||||
// So, as a hobby on common MacOS Apps, we 'don't toggle visibility on click'.
|
||||
toggleMainWindowVisibility();
|
||||
// Every single click will trigger the Show/Hide toggling.
|
||||
// So, as a hobby on common MacOS Apps, we 'don't toggle visibility on click'.
|
||||
toggleMainWindowVisibility();
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case QSystemTrayIcon::DoubleClick:
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
}
|
||||
case QSystemTrayIcon::DoubleClick:
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case QSystemTrayIcon::MiddleClick:
|
||||
case QSystemTrayIcon::MiddleClick:
|
||||
|
||||
// TODO: Check if an alert message box is present.
|
||||
// If so, do nothing but please wait for the message box to be closed.
|
||||
if (this->vinstance->vProcess->state() == QProcess::ProcessState::Running) {
|
||||
on_stopButton_clicked();
|
||||
} else {
|
||||
on_startButton_clicked();
|
||||
}
|
||||
// TODO: Check if an alert message box is present.
|
||||
// If so, do nothing but please wait for the message box to be closed.
|
||||
if (this->vinstance->vProcess->state() == QProcess::ProcessState::Running) {
|
||||
on_stopButton_clicked();
|
||||
} else {
|
||||
on_startButton_clicked();
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case QSystemTrayIcon::Unknown:
|
||||
break;
|
||||
case QSystemTrayIcon::Unknown:
|
||||
break;
|
||||
|
||||
case QSystemTrayIcon::Context:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleMainWindowVisibility()
|
||||
{
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
trayMenu->actions()[0]->setText(tr("#Hide"));
|
||||
} else {
|
||||
this->hide();
|
||||
trayMenu->actions()[0]->setText(tr("#Show"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::quit()
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
void MainWindow::renameRow()
|
||||
{
|
||||
// QString text = QInputDialog::getText(this, "Rename config", "New name:", QLineEdit::Normal);
|
||||
// int row = ui->configTable->currentIndex().row();
|
||||
// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt();
|
||||
// SQLiteDB mydb;
|
||||
// QString updateString = "update confs set alias = '" + text + "' where id = " + QString::number(idIntable);
|
||||
// mydb.DoQuery(updateString);
|
||||
// emit updateConfTable();
|
||||
}
|
||||
|
||||
void MainWindow::scrollToBottom()
|
||||
{
|
||||
bar->setValue(bar->maximum());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPreferences_triggered()
|
||||
{
|
||||
PrefrencesWindow *v = new PrefrencesWindow(this);
|
||||
v->setAttribute(Qt::WA_DeleteOnClose);
|
||||
v->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
auto confedit = new ConnectionEditWindow();
|
||||
confedit->show();
|
||||
case QSystemTrayIcon::Context:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleMainWindowVisibility()
|
||||
{
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
trayMenu->actions()[0]->setText(tr("#Hide"));
|
||||
} else {
|
||||
this->hide();
|
||||
trayMenu->actions()[0]->setText(tr("#Show"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::quit()
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
void MainWindow::renameRow()
|
||||
{
|
||||
// QString text = QInputDialog::getText(this, "Rename config", "New name:", QLineEdit::Normal);
|
||||
// int row = ui->configTable->currentIndex().row();
|
||||
// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt();
|
||||
// SQLiteDB mydb;
|
||||
// QString updateString = "update confs set alias = '" + text + "' where id = " + QString::number(idIntable);
|
||||
// mydb.DoQuery(updateString);
|
||||
// emit updateConfTable();
|
||||
}
|
||||
|
||||
void MainWindow::scrollToBottom()
|
||||
{
|
||||
bar->setValue(bar->maximum());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPreferences_triggered()
|
||||
{
|
||||
PrefrencesWindow *v = new PrefrencesWindow(this);
|
||||
v->setAttribute(Qt::WA_DeleteOnClose);
|
||||
v->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
auto confedit = new ConnectionEditWindow();
|
||||
confedit->show();
|
||||
}
|
||||
}
|
||||
|
@ -10,53 +10,51 @@
|
||||
#include "vinteract.hpp"
|
||||
#include "V2ConfigObjects.hpp"
|
||||
|
||||
namespace Qv2ray
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
v2Instance *vinstance;
|
||||
QSystemTrayIcon *hTray;
|
||||
QMenu *trayMenu = new QMenu(this);
|
||||
QMenu *popMenu = new QMenu(this);
|
||||
QScrollBar *bar;
|
||||
~MainWindow();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
Qv2ray::v2Instance *vinstance;
|
||||
QSystemTrayIcon *hTray;
|
||||
QMenu *trayMenu = new QMenu(this);
|
||||
QMenu *popMenu = new QMenu(this);
|
||||
QScrollBar *bar;
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_restartButton_clicked();
|
||||
void on_actionEdit_triggered();
|
||||
void on_actionExisting_config_triggered();
|
||||
void UpdateConfigTable();
|
||||
void DeleteConfig();
|
||||
void showMenu(QPoint pos);
|
||||
void UpdateLog();
|
||||
void on_startButton_clicked();
|
||||
void on_stopButton_clicked();
|
||||
void select_triggered();
|
||||
void on_clbutton_clicked();
|
||||
void on_rtButton_clicked();
|
||||
void GenerateConfig(int idIntable);
|
||||
void on_activatedTray(QSystemTrayIcon::ActivationReason reason);
|
||||
void toggleMainWindowVisibility();
|
||||
void quit();
|
||||
void on_actionExit_triggered();
|
||||
void renameRow();
|
||||
void scrollToBottom();
|
||||
void on_actionPreferences_triggered();
|
||||
private slots:
|
||||
void on_restartButton_clicked();
|
||||
void on_actionEdit_triggered();
|
||||
void on_actionExisting_config_triggered();
|
||||
void UpdateConfigTable();
|
||||
void DeleteConfig();
|
||||
void showMenu(QPoint pos);
|
||||
void UpdateLog();
|
||||
void on_startButton_clicked();
|
||||
void on_stopButton_clicked();
|
||||
void select_triggered();
|
||||
void on_clbutton_clicked();
|
||||
void on_rtButton_clicked();
|
||||
void GenerateConfig(int idIntable);
|
||||
void on_activatedTray(QSystemTrayIcon::ActivationReason reason);
|
||||
void toggleMainWindowVisibility();
|
||||
void quit();
|
||||
void on_actionExit_triggered();
|
||||
void renameRow();
|
||||
void scrollToBottom();
|
||||
void on_actionPreferences_triggered();
|
||||
|
||||
void on_pushButton_clicked();
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui_MainWindow *ui;
|
||||
void closeEvent(QCloseEvent *);
|
||||
void createTrayAction();
|
||||
void CreateTrayIcon();
|
||||
};
|
||||
}
|
||||
private:
|
||||
Ui_WMain *ui;
|
||||
void closeEvent(QCloseEvent *);
|
||||
void createTrayAction();
|
||||
void CreateTrayIcon();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<class>WMain</class>
|
||||
<widget class="QMainWindow" name="WMain">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
@ -16,104 +16,102 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using namespace Qv2ray;
|
||||
using namespace Utils;
|
||||
using namespace Qv2ray::Utils;
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent),
|
||||
CurrentConfig(),
|
||||
ui(new Ui_WPrefrences)
|
||||
{
|
||||
PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent), CurrentConfig(), ui(new Ui_PrefrencesWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CurrentConfig = GetGlobalConfig();
|
||||
ui->languageComboBox->setCurrentText(QString::fromStdString(CurrentConfig.language));
|
||||
ui->runAsRootCheckBox->setChecked(CurrentConfig.runAsRoot);
|
||||
ui->logLevelCheckBox->setCurrentText(QString::fromStdString(CurrentConfig.logLevel));
|
||||
//
|
||||
ui->httpCB->setChecked(CurrentConfig.httpSetting.enabled);
|
||||
ui->httpPortLE->setText(QString::fromStdString(to_string(CurrentConfig.httpSetting.port)));
|
||||
ui->httpAuthCB->setChecked(CurrentConfig.httpSetting.useAuthentication);
|
||||
ui->httpAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.httpSetting.authUsername));
|
||||
ui->httpAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.httpSetting.authPassword));
|
||||
ui->httpPortLE->setValidator(new QIntValidator());
|
||||
//
|
||||
ui->socksCB->setChecked(CurrentConfig.socksSetting.enabled);
|
||||
ui->socksPortLE->setText(QString::fromStdString(to_string(CurrentConfig.socksSetting.port)));
|
||||
ui->socksAuthCB->setChecked(CurrentConfig.socksSetting.useAuthentication);
|
||||
ui->socksAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.socksSetting.authUsername));
|
||||
ui->socksAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.socksSetting.authPassword));
|
||||
//
|
||||
ui->httpPortLE->setValidator(new QIntValidator());
|
||||
ui->socksPortLE->setValidator(new QIntValidator());
|
||||
parentMW = parent;
|
||||
}
|
||||
ui->setupUi(this);
|
||||
CurrentConfig = GetGlobalConfig();
|
||||
ui->languageComboBox->setCurrentText(QString::fromStdString(CurrentConfig.language));
|
||||
ui->runAsRootCheckBox->setChecked(CurrentConfig.runAsRoot);
|
||||
ui->logLevelCheckBox->setCurrentText(QString::fromStdString(CurrentConfig.logLevel));
|
||||
//
|
||||
ui->httpCB->setChecked(CurrentConfig.httpSetting.enabled);
|
||||
ui->httpPortLE->setText(QString::fromStdString(to_string(CurrentConfig.httpSetting.port)));
|
||||
ui->httpAuthCB->setChecked(CurrentConfig.httpSetting.useAuthentication);
|
||||
ui->httpAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.httpSetting.authUsername));
|
||||
ui->httpAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.httpSetting.authPassword));
|
||||
ui->httpPortLE->setValidator(new QIntValidator());
|
||||
//
|
||||
ui->socksCB->setChecked(CurrentConfig.socksSetting.enabled);
|
||||
ui->socksPortLE->setText(QString::fromStdString(to_string(CurrentConfig.socksSetting.port)));
|
||||
ui->socksAuthCB->setChecked(CurrentConfig.socksSetting.useAuthentication);
|
||||
ui->socksAuthUsernameTxt->setText(QString::fromStdString(CurrentConfig.socksSetting.authUsername));
|
||||
ui->socksAuthPasswordTxt->setText(QString::fromStdString(CurrentConfig.socksSetting.authPassword));
|
||||
//
|
||||
ui->httpPortLE->setValidator(new QIntValidator());
|
||||
ui->socksPortLE->setValidator(new QIntValidator());
|
||||
parentMW = parent;
|
||||
}
|
||||
|
||||
PrefrencesWindow::~PrefrencesWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
PrefrencesWindow::~PrefrencesWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_buttonBox_accepted()
|
||||
{
|
||||
if (v2Instance::checkVCoreExes()) {
|
||||
if (ui->httpPortLE->text().toInt() != ui->socksPortLE->text().toInt()) {
|
||||
void PrefrencesWindow::on_buttonBox_accepted()
|
||||
{
|
||||
if (Qv2ray::v2Instance::checkVCoreExes()) {
|
||||
if (ui->httpPortLE->text().toInt() != ui->socksPortLE->text().toInt()) {
|
||||
#ifndef _WIN32
|
||||
// Set UID and GID in *nix
|
||||
// The file is actually not here
|
||||
QFileInfo v2rayCoreExeFile("v2ray");
|
||||
// Set UID and GID in *nix
|
||||
// The file is actually not here
|
||||
QFileInfo v2rayCoreExeFile("v2ray");
|
||||
|
||||
if (ui->runAsRootCheckBox->isChecked() && v2rayCoreExeFile.ownerId() != 0) {
|
||||
QProcess::execute("pkexec", QStringList() << "bash"
|
||||
<< "-c"
|
||||
<< "chown root:root " + QCoreApplication::applicationDirPath() + "/v2ray" + ";chmod +s " + QCoreApplication::applicationDirPath() + "/v2ray");
|
||||
} else if (!ui->runAsRootCheckBox->isChecked() && v2rayCoreExeFile.ownerId() == 0) {
|
||||
uid_t uid = getuid();
|
||||
gid_t gid = getgid();
|
||||
QProcess::execute("pkexec", QStringList() << "chown" << QString::number(uid) + ":" + QString::number(gid) << QCoreApplication::applicationDirPath() + "/v2ray");
|
||||
}
|
||||
|
||||
v2rayCoreExeFile.refresh();
|
||||
//rootObj.insert("v2suidEnabled", v2rayCoreExeFile.ownerId() == 0);
|
||||
#else
|
||||
// No such uid gid thing on windows....
|
||||
#endif
|
||||
} else {
|
||||
showWarnMessageBox(this, tr("Prefrences"), tr("PortNumbersCannotBeSame"));
|
||||
if (ui->runAsRootCheckBox->isChecked() && v2rayCoreExeFile.ownerId() != 0) {
|
||||
QProcess::execute("pkexec", QStringList() << "bash"
|
||||
<< "-c"
|
||||
<< "chown root:root " + QCoreApplication::applicationDirPath() + "/v2ray" + ";chmod +s " + QCoreApplication::applicationDirPath() + "/v2ray");
|
||||
} else if (!ui->runAsRootCheckBox->isChecked() && v2rayCoreExeFile.ownerId() == 0) {
|
||||
uid_t uid = getuid();
|
||||
gid_t gid = getgid();
|
||||
QProcess::execute("pkexec", QStringList() << "chown" << QString::number(uid) + ":" + QString::number(gid) << QCoreApplication::applicationDirPath() + "/v2ray");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_httpCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked != Qt::Checked) {
|
||||
ui->httpPortLE->setDisabled(true);
|
||||
} else {
|
||||
ui->httpPortLE->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_socksCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked != Qt::Checked) {
|
||||
ui->socksPortLE->setEnabled(false);
|
||||
} else {
|
||||
ui->socksPortLE->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_httpAuthCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked) {
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_runAsRootCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
Q_UNUSED(arg1)
|
||||
#ifdef _WIN32
|
||||
showWarnMessageBox(this, tr("Prefrences"), tr("RunAsRootNotOnWindows"));
|
||||
v2rayCoreExeFile.refresh();
|
||||
//rootObj.insert("v2suidEnabled", v2rayCoreExeFile.ownerId() == 0);
|
||||
#else
|
||||
// No such uid gid thing on windows....
|
||||
#endif
|
||||
} else {
|
||||
showWarnMessageBox(this, tr("Prefrences"), tr("PortNumbersCannotBeSame"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_httpCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked != Qt::Checked) {
|
||||
ui->httpPortLE->setDisabled(true);
|
||||
} else {
|
||||
ui->httpPortLE->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_socksCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked != Qt::Checked) {
|
||||
ui->socksPortLE->setEnabled(false);
|
||||
} else {
|
||||
ui->socksPortLE->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_httpAuthCB_stateChanged(int checked)
|
||||
{
|
||||
if (checked) {
|
||||
}
|
||||
}
|
||||
|
||||
void PrefrencesWindow::on_runAsRootCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
Q_UNUSED(arg1)
|
||||
#ifdef _WIN32
|
||||
showWarnMessageBox(this, tr("Prefrences"), tr("RunAsRootNotOnWindows"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -5,32 +5,29 @@
|
||||
#include <ui_w_PrefrencesWindow.h>
|
||||
#include "HConfigObjects.hpp"
|
||||
|
||||
namespace Qv2ray
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui_Impl
|
||||
class PrefrencesWindow : public QDialog
|
||||
{
|
||||
class PrefrencesWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefrencesWindow(QWidget *parent = nullptr);
|
||||
~PrefrencesWindow();
|
||||
QWidget *parentMW;
|
||||
public:
|
||||
explicit PrefrencesWindow(QWidget *parent = nullptr);
|
||||
~PrefrencesWindow();
|
||||
QWidget *parentMW;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_httpCB_stateChanged(int arg1);
|
||||
void on_socksCB_stateChanged(int arg1);
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_httpCB_stateChanged(int arg1);
|
||||
void on_socksCB_stateChanged(int arg1);
|
||||
|
||||
void on_httpAuthCB_stateChanged(int arg1);
|
||||
void on_httpAuthCB_stateChanged(int arg1);
|
||||
|
||||
void on_runAsRootCheckBox_stateChanged(int arg1);
|
||||
void on_runAsRootCheckBox_stateChanged(int arg1);
|
||||
|
||||
private:
|
||||
Qv2ray::QvConfigModels::Qv2Config CurrentConfig;
|
||||
Ui_PrefrencesWindow *ui;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Qv2ray::QvConfigModels::Qv2Config CurrentConfig;
|
||||
Ui_WPrefrences *ui;
|
||||
};
|
||||
}
|
||||
#endif // HVCONF_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefrencesWindow</class>
|
||||
<widget class="QDialog" name="PrefrencesWindow">
|
||||
<class>WPrefrences</class>
|
||||
<widget class="QDialog" name="WPrefrences">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -345,7 +345,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PrefrencesWindow</receiver>
|
||||
<receiver>WPrefrences</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -361,7 +361,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PrefrencesWindow</receiver>
|
||||
<receiver>WPrefrences</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user