[fix] Fixed a vmess import error and redesigned ImportWindow #121

Former-commit-id: 381075cbbb
This commit is contained in:
Leroy.H.Y 2019-11-28 20:48:19 +08:00
parent 7a43973ff2
commit 86f4321565
4 changed files with 296 additions and 327 deletions

View File

@ -1 +1 @@
997
1006

View File

@ -33,11 +33,6 @@ QMap<QString, CONFIGROOT> ImportConfigWindow::OpenImport(bool outboundsOnly)
return this->result() == QDialog::Accepted ? connections : QMap<QString, CONFIGROOT>();
}
void ImportConfigWindow::on_importSourceCombo_currentIndexChanged(int index)
{
stackedWidget->setCurrentIndex(index);
}
void ImportConfigWindow::on_selectFileBtn_clicked()
{
QString dir = QFileDialog::getOpenFileName(this, tr("Select file to import"));
@ -68,7 +63,7 @@ void ImportConfigWindow::on_beginImportBtn_clicked()
CONFIGROOT config;
//auto conf = GetGlobalConfig();
switch (importSourceCombo->currentIndex()) {
switch (tabWidget->currentIndex()) {
case 0: {
// From File...
bool keepInBound = keepImportedInboundCheckBox->isChecked();
@ -96,7 +91,7 @@ void ImportConfigWindow::on_beginImportBtn_clicked()
vmessConnectionStringTxt->clear();
errorsList->clear();
//
LOG(MODULE_IMPORT, to_string(vmessList.count()) + " vmess connection found.")
LOG(MODULE_IMPORT, to_string(vmessList.count()) + " string found.")
while (!vmessList.isEmpty()) {
aliasPrefix = nameTxt->text();
@ -120,6 +115,10 @@ void ImportConfigWindow::on_beginImportBtn_clicked()
vmessConnectionStringTxt->appendPlainText(vmessErrors.key(item));
errorsList->addItem(item);
}
vmessConnectionStringTxt->setLineWidth(errorsList->lineWidth());
errorsList->sortItems();
return;
}
break;

View File

@ -16,7 +16,6 @@ class ImportConfigWindow : public QDialog, private Ui::ImportConfigWindow
~ImportConfigWindow() { }
QMap<QString, CONFIGROOT> OpenImport(bool outboundsOnly = false);
private slots:
void on_importSourceCombo_currentIndexChanged(int index);
void on_selectFileBtn_clicked();

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>675</width>
<height>485</height>
<width>470</width>
<height>460</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>370</width>
<height>420</height>
<width>470</width>
<height>460</height>
</size>
</property>
<property name="windowTitle">
@ -38,326 +38,299 @@
<item row="0" column="1">
<widget class="QLineEdit" name="nameTxt"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Import Source</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="importSourceCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Existing File</string>
</property>
</item>
<item>
<property name="text">
<string>VMess and QRCode</string>
</property>
</item>
<item>
<property name="text">
<string>Subscription Link</string>
</property>
</item>
<item>
<property name="text">
<string>Manually Input</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Import</string>
<widget class="QLabel" name="label">
<property name="text">
<string>Import Source</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="filePage">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="fileLabel">
<property name="text">
<string>Path</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="fileLineTxt">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectFileBtn">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Inbound</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="keepImportedInboundCheckBox">
<property name="text">
<string>Keep imported inbound settings</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Edit Config</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="editFileBtn">
<property name="text">
<string>Open in JSON Editor</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage1">
<attribute name="title">
<string>Existing File</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="fileLabel">
<property name="text">
<string>Path</string>
</property>
</widget>
<widget class="QWidget" name="vmessPage">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>VMess Connection String</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>From QRCode File</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="imageFileEdit">
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectImageBtn">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>From Screenshot</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="qrFromScreenBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Go</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>After</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<property name="maximum">
<double>5.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="stepType">
<enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>second(s).</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPlainTextEdit" name="vmessConnectionStringTxt">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="plainText">
<string/>
</property>
<property name="placeholderText">
<string>Place your vmess:// here, one line for each.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QListWidget" name="errorsList"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Error List</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>VMess</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="fileLineTxt">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectFileBtn">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Inbound</string>
</property>
</widget>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Subscription Link</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="subscriptionLinkTxt">
<property name="text">
<string>TO DO IN VERSION 2</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,1">
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>GroupBox</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="keepImportedInboundCheckBox">
<property name="text">
<string>Keep imported inbound settings</string>
</property>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QFormLayout" name="formLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Connection Editor</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="connectionEditBtn">
<property name="text">
<string>Open Connection Editor</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Maunally input connection details</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Edit Config</string>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="editFileBtn">
<property name="text">
<string>Open in JSON Editor</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage2">
<attribute name="title">
<string>VMess / QRCode</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>VMess Connection String</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>From QRCode File</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="imageFileEdit">
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectImageBtn">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>From Screenshot</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="qrFromScreenBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Go</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>After</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<property name="maximum">
<double>5.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="stepType">
<enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>second(s).</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPlainTextEdit" name="vmessConnectionStringTxt">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="plainText">
<string/>
</property>
<property name="placeholderText">
<string>Place your vmess:// here, one line for each.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QListWidget" name="errorsList"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Error List</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>VMess</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage3">
<attribute name="title">
<string>Subscription</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Subscription Link</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="subscriptionLinkTxt">
<property name="text">
<string>TO DO IN VERSION 2</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,1">
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>GroupBox</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage4">
<attribute name="title">
<string>Manually Input</string>
</attribute>
<layout class="QFormLayout" name="formLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Connection Editor</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="connectionEditBtn">
<property name="text">
<string>Open Connection Editor</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Maunally input connection details</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
@ -394,8 +367,6 @@
</layout>
</widget>
<tabstops>
<tabstop>nameTxt</tabstop>
<tabstop>importSourceCombo</tabstop>
<tabstop>fileLineTxt</tabstop>
<tabstop>keepImportedInboundCheckBox</tabstop>
<tabstop>editFileBtn</tabstop>