From 151890b7cc0dfba3f3b8064ccc846965e5527c89 Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Sun, 22 Dec 2019 10:52:42 +0800 Subject: [PATCH] [add] Added more VMess share options, fixed #162 --- Build.Counter | 2 +- src/Qv2rayBase.hpp | 1 - src/ui/w_ExportConfig.cpp | 23 +++++++---- src/ui/w_ExportConfig.hpp | 4 ++ src/ui/w_ExportConfig.ui | 84 +++++++++++++++++++++++++++++---------- 5 files changed, 82 insertions(+), 32 deletions(-) diff --git a/Build.Counter b/Build.Counter index 4fa06731..291e0b23 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -1939 +1954 diff --git a/src/Qv2rayBase.hpp b/src/Qv2rayBase.hpp index 06224f17..2047ddf5 100644 --- a/src/Qv2rayBase.hpp +++ b/src/Qv2rayBase.hpp @@ -29,7 +29,6 @@ #define QV2RAY_CONFIG_DIR (Qv2ray::Utils::GetConfigDirPath()) #define QV2RAY_CONFIG_FILE (QV2RAY_CONFIG_DIR + "Qv2ray.conf") #define QV2RAY_SUBSCRIPTION_DIR (QV2RAY_CONFIG_DIR + "subscriptions/") -#define QV2RAY_QRCODE_DIR (QV2RAY_CONFIG_DIR + "qr_images/") // Get GFWList and PAC file path. #define QV2RAY_RULES_DIR (QV2RAY_CONFIG_DIR + "rules/") diff --git a/src/ui/w_ExportConfig.cpp b/src/ui/w_ExportConfig.cpp index 16b03ddf..a93b5942 100644 --- a/src/ui/w_ExportConfig.cpp +++ b/src/ui/w_ExportConfig.cpp @@ -1,5 +1,6 @@ #include "w_ExportConfig.hpp" #include "QvUtils.hpp" +#include // Private initialiser ConfigExporter::ConfigExporter(QWidget *parent) : @@ -58,14 +59,20 @@ void ConfigExporter::on_closeBtn_clicked() void ConfigExporter::on_saveBtn_clicked() { // Save - if (!QDir(QV2RAY_QRCODE_DIR).exists()) { - QDir().mkpath(QV2RAY_QRCODE_DIR); - } - - auto filePath = QV2RAY_QRCODE_DIR + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss-z.png"); + auto filePath = QFileDialog().getSaveFileName(this, tr("Save Image"), "", "Images (*.png)"); auto result = image.save(filePath); - QDesktopServices::openUrl(QUrl(QV2RAY_QRCODE_DIR)); + QDesktopServices::openUrl(QUrl::fromUserInput(filePath)); LOG(MODULE_FILE, "Saving an image to: " + filePath.toStdString() + " result: " + (result ? "OK" : "Failed")) - // If succeed, we disable future save. - saveBtn->setEnabled(result); +} + +void ConfigExporter::on_copyImageBtn_clicked() +{ + QGuiApplication::clipboard()->setImage(image); + QvMessageBox(this, tr("Share Connection"), tr("Image has been copied to the clipboard.")); +} + +void ConfigExporter::on_copyVMessBtn_clicked() +{ + QGuiApplication::clipboard()->setText(message); + QvMessageBox(this, tr("Share Connection"), tr("VMess string has been copied to the clipboard.")); } diff --git a/src/ui/w_ExportConfig.hpp b/src/ui/w_ExportConfig.hpp index c28fd25b..33115896 100644 --- a/src/ui/w_ExportConfig.hpp +++ b/src/ui/w_ExportConfig.hpp @@ -19,6 +19,10 @@ class ConfigExporter : public QDialog, private Ui::ExportConfigWindow void on_saveBtn_clicked(); + void on_copyImageBtn_clicked(); + + void on_copyVMessBtn_clicked(); + private: explicit ConfigExporter(QWidget *parent); QZXing qzxing; diff --git a/src/ui/w_ExportConfig.ui b/src/ui/w_ExportConfig.ui index 13b27563..d403acce 100644 --- a/src/ui/w_ExportConfig.ui +++ b/src/ui/w_ExportConfig.ui @@ -6,16 +6,19 @@ 0 0 - 532 - 666 + 661 + 347 Export Config - - + + + + true + QFrame::Box @@ -31,23 +34,60 @@ Qt::AlignCenter - - - - - - Text Message + + Qt::NoTextInteraction - - - - true + + + + Share Options + + + + + VMess Connection String + + + + + + + true + + + + + + + + + Save Image + + + + + + + Copy Image + + + + + + + Copy VMess + + + + + + - + @@ -62,13 +102,6 @@ - - - - Save - - - @@ -80,6 +113,13 @@ + + messageTxt + saveBtn + copyImageBtn + copyVMessBtn + closeBtn +