Share page refactoring part 1

This commit is contained in:
pokamest 2021-11-06 13:47:52 +03:00
parent ed26706ee7
commit a89104127a
32 changed files with 985 additions and 569 deletions

View file

@ -43,7 +43,7 @@ QVector<amnezia::Protocol> ContainerProps::protocolsForContainer(amnezia::Docker
return { Protocol::OpenVpn, Protocol::ShadowSocks, Protocol::Cloak }; return { Protocol::OpenVpn, Protocol::ShadowSocks, Protocol::Cloak };
case DockerContainer::Ipsec: case DockerContainer::Ipsec:
return { Protocol::Ikev2, Protocol::L2tp }; return { Protocol::Ikev2 /*, Protocol::L2tp */};
case DockerContainer::Dns: case DockerContainer::Dns:
return { }; return { };
@ -129,6 +129,7 @@ Protocol ContainerProps::defaultProtocol(DockerContainer c)
case DockerContainer::Dns : return Protocol::Dns; case DockerContainer::Dns : return Protocol::Dns;
case DockerContainer::FileShare : return Protocol::FileShare; case DockerContainer::FileShare : return Protocol::FileShare;
case DockerContainer::Sftp : return Protocol::Sftp; case DockerContainer::Sftp : return Protocol::Sftp;
default: return Protocol::Any;
} }
} }

View file

@ -136,6 +136,8 @@ int main(int argc, char *argv[])
declareQmlProtocolEnum(); declareQmlProtocolEnum();
declareQmlContainerEnum(); declareQmlContainerEnum();
qmlRegisterType<PageType>("PageType", 1, 0, "PageType");
QScopedPointer<ContainerProps> containerProps(new ContainerProps); QScopedPointer<ContainerProps> containerProps(new ContainerProps);
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get()); qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get());

View file

@ -73,6 +73,9 @@ QMap<amnezia::Protocol, QString> ProtocolProps::protocolHumanNames()
{Protocol::ShadowSocks, "ShadowSocks"}, {Protocol::ShadowSocks, "ShadowSocks"},
{Protocol::Cloak, "Cloak"}, {Protocol::Cloak, "Cloak"},
{Protocol::WireGuard, "WireGuard"}, {Protocol::WireGuard, "WireGuard"},
{Protocol::Ikev2, "IKEv2"},
{Protocol::L2tp, "L2TP"},
{Protocol::TorWebSite, "Web site in TOR network"}, {Protocol::TorWebSite, "Web site in TOR network"},
{Protocol::Dns, "DNS Service"}, {Protocol::Dns, "DNS Service"},
{Protocol::FileShare, "File Sharing Service"}, {Protocol::FileShare, "File Sharing Service"},

View file

@ -126,5 +126,13 @@
<file>server_scripts/ipsec/Dockerfile</file> <file>server_scripts/ipsec/Dockerfile</file>
<file>server_scripts/ipsec/run_container.sh</file> <file>server_scripts/ipsec/run_container.sh</file>
<file>server_scripts/ipsec/start.sh</file> <file>server_scripts/ipsec/start.sh</file>
<file>ui/qml/Pages/Share/PageShareProtoCloak.qml</file>
<file>ui/qml/Pages/Share/PageShareProtocolBase.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoOpenVPN.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoSftp.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoShadowSocks.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoTorWebSite.qml</file>
<file>ui/qml/Controls/TextAreaType.qml</file>
<file>ui/qml/Controls/ContextMenu.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -4,6 +4,19 @@
#include <QObject> #include <QObject>
#include <QQmlEngine> #include <QQmlEngine>
class PageType : public QObject
{
Q_GADGET
public:
enum Type {
Basic,
Proto,
ShareProto
};
Q_ENUM(Type)
};
namespace PageEnumNS namespace PageEnumNS
{ {
Q_NAMESPACE Q_NAMESPACE

View file

@ -2,6 +2,7 @@
#include "ShareConnectionLogic.h" #include "ShareConnectionLogic.h"
#include "../uilogic.h" #include "../uilogic.h"
#include "../models/protocols_model.h"
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent): GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
PageLogicBase(logic, parent) PageLogicBase(logic, parent)
@ -24,7 +25,9 @@ void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
{ {
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex(); uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex); uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedServerIndex(uiLogic()->selectedServerIndex);
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedDockerContainer(uiLogic()->selectedDockerContainer);
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer); //uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer);
uiLogic()->goToPage(Page::ShareConnection); uiLogic()->goToPage(Page::ShareConnection);
} }

View file

@ -14,6 +14,8 @@ class PageLogicBase : public QObject
{ {
Q_OBJECT Q_OBJECT
AUTO_PROPERTY(bool, pageEnabled) AUTO_PROPERTY(bool, pageEnabled)
// AUTO_PROPERTY(int, serverIndex)
// AUTO_PROPERTY(DockerContainer, dockerContainer)
public: public:
explicit PageLogicBase(UiLogic *uiLogic, QObject *parent = nullptr); explicit PageLogicBase(UiLogic *uiLogic, QObject *parent = nullptr);

View file

@ -18,6 +18,11 @@ ServerConfiguringProgressLogic::ServerConfiguringProgressLogic(UiLogic *logic, Q
} }
void ServerConfiguringProgressLogic::onUpdatePage()
{
set_progressBarValue(0);
}
ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<ErrorCode()> &action) ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<ErrorCode()> &action)
{ {

View file

@ -22,6 +22,7 @@ public:
explicit ServerConfiguringProgressLogic(UiLogic *uiLogic, QObject *parent = nullptr); explicit ServerConfiguringProgressLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~ServerConfiguringProgressLogic() = default; ~ServerConfiguringProgressLogic() = default;
void onUpdatePage() override;
ErrorCode doInstallAction(const std::function<ErrorCode()> &action); ErrorCode doInstallAction(const std::function<ErrorCode()> &action);
private: private:

View file

@ -21,11 +21,6 @@
ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent): ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
PageLogicBase(logic, parent), PageLogicBase(logic, parent),
m_pageShareAmneziaVisible{true},
m_pageShareOpenVpnVisible{true},
m_pageShareShadowSocksVisible{true},
m_pageShareCloakVisible{true},
m_pageShareFullAccessVisible{true},
m_textEditShareOpenVpnCodeText{}, m_textEditShareOpenVpnCodeText{},
m_pushButtonShareOpenVpnCopyEnabled{false}, m_pushButtonShareOpenVpnCopyEnabled{false},
m_pushButtonShareOpenVpnSaveEnabled{false}, m_pushButtonShareOpenVpnSaveEnabled{false},
@ -222,12 +217,6 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container); //const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
set_pageShareAmneziaVisible(false);
set_pageShareOpenVpnVisible(false);
set_pageShareShadowSocksVisible(false);
set_pageShareCloakVisible(false);
set_pageShareFullAccessVisible(false);
enum currentWidget { enum currentWidget {
full_access = 0, full_access = 0,
share_amezia, share_amezia,
@ -237,8 +226,6 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
}; };
if (container == DockerContainer::OpenVpn) { if (container == DockerContainer::OpenVpn) {
set_pageShareAmneziaVisible(true);
set_pageShareOpenVpnVisible(true);
QString cfg = tr("Press Generate config"); QString cfg = tr("Press Generate config");
set_textEditShareOpenVpnCodeText(cfg); set_textEditShareOpenVpnCodeText(cfg);
@ -250,8 +237,6 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
if (container == DockerContainer::ShadowSocks || if (container == DockerContainer::ShadowSocks ||
container == DockerContainer::Cloak) { container == DockerContainer::Cloak) {
set_pageShareAmneziaVisible(true);
set_pageShareShadowSocksVisible(true);
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::ShadowSocks); QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::ShadowSocks);
QString cfg = protoConfig.value(config_key::last_config).toString(); QString cfg = protoConfig.value(config_key::last_config).toString();
@ -289,7 +274,6 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
if (container == DockerContainer::Cloak) { if (container == DockerContainer::Cloak) {
//ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client")); //ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client"));
set_pageShareCloakVisible(true);
set_plainTextEditShareCloakText(QString("")); set_plainTextEditShareCloakText(QString(""));
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak); QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak);
@ -313,7 +297,6 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
// Full access // Full access
if (container == DockerContainer::None) { if (container == DockerContainer::None) {
set_pageShareFullAccessVisible(true);
const QJsonObject &server = m_settings.server(uiLogic()->selectedServerIndex); const QJsonObject &server = m_settings.server(uiLogic()->selectedServerIndex);

View file

@ -11,11 +11,6 @@ class ShareConnectionLogic: public PageLogicBase
Q_OBJECT Q_OBJECT
public: public:
AUTO_PROPERTY(bool, pageShareAmneziaVisible)
AUTO_PROPERTY(bool, pageShareOpenVpnVisible)
AUTO_PROPERTY(bool, pageShareShadowSocksVisible)
AUTO_PROPERTY(bool, pageShareCloakVisible)
AUTO_PROPERTY(bool, pageShareFullAccessVisible)
AUTO_PROPERTY(QString, textEditShareOpenVpnCodeText) AUTO_PROPERTY(QString, textEditShareOpenVpnCodeText)
AUTO_PROPERTY(bool, pushButtonShareOpenVpnCopyEnabled) AUTO_PROPERTY(bool, pushButtonShareOpenVpnCopyEnabled)
AUTO_PROPERTY(bool, pushButtonShareOpenVpnSaveEnabled) AUTO_PROPERTY(bool, pushButtonShareOpenVpnSaveEnabled)

View file

@ -22,7 +22,7 @@ SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites)); sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites));
} }
void SitesLogic::updateSitesPage() void SitesLogic::onUpdatePage()
{ {
Settings::RouteMode m = m_settings.routeMode(); Settings::RouteMode m = m_settings.routeMode();
if (m == Settings::VpnAllSites) return; if (m == Settings::VpnAllSites) return;
@ -71,7 +71,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
uiLogic()->m_vpnConnection->flushDns(); uiLogic()->m_vpnConnection->flushDns();
} }
updateSitesPage(); onUpdatePage();
}; };
const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){ const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo){
@ -93,7 +93,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
} }
else { else {
cbProcess(newSite, ""); cbProcess(newSite, "");
updateSitesPage(); onUpdatePage();
QHostInfo::lookupHost(newSite, this, cbResolv); QHostInfo::lookupHost(newSite, this, cbResolv);
} }
} }
@ -123,7 +123,7 @@ void SitesLogic::onPushButtonSitesDeleteClicked(int row)
uiLogic()->m_vpnConnection->flushDns(); uiLogic()->m_vpnConnection->flushDns();
} }
updateSitesPage(); onUpdatePage();
} }
void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName) void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
@ -153,6 +153,6 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips); uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
uiLogic()->m_vpnConnection->flushDns(); uiLogic()->m_vpnConnection->flushDns();
updateSitesPage(); onUpdatePage();
} }

View file

@ -15,7 +15,7 @@ class SitesLogic : public PageLogicBase
AUTO_PROPERTY(QString, lineEditSitesAddCustomText) AUTO_PROPERTY(QString, lineEditSitesAddCustomText)
public: public:
Q_INVOKABLE void updateSitesPage(); Q_INVOKABLE void onUpdatePage() override;
Q_INVOKABLE void onPushButtonAddCustomSitesClicked(); Q_INVOKABLE void onPushButtonAddCustomSitesClicked();
Q_INVOKABLE void onPushButtonSitesDeleteClicked(int row); Q_INVOKABLE void onPushButtonSitesDeleteClicked(int row);

View file

@ -35,6 +35,8 @@ void StartPageLogic::onUpdatePage()
set_pushButtonConnectVisible(true); set_pushButtonConnectVisible(true);
set_pushButtonConnectKeyChecked(false); set_pushButtonConnectKeyChecked(false);
set_pushButtonBackFromStartVisible(uiLogic()->pagesStackDepth() > 0);
} }
void StartPageLogic::onPushButtonConnect() void StartPageLogic::onPushButtonConnect()

View file

@ -36,7 +36,7 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
} }
void VpnLogic::updateVpnPage() void VpnLogic::onUpdatePage()
{ {
Settings::RouteMode mode = m_settings.routeMode(); Settings::RouteMode mode = m_settings.routeMode();
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites); set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);

View file

@ -24,7 +24,7 @@ class VpnLogic : public PageLogicBase
AUTO_PROPERTY(bool, radioButtonVpnModeExceptSitesChecked) AUTO_PROPERTY(bool, radioButtonVpnModeExceptSitesChecked)
public: public:
Q_INVOKABLE void updateVpnPage(); Q_INVOKABLE void onUpdatePage() override;
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked); Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked); Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked);

View file

@ -15,6 +15,7 @@ WizardLogic::WizardLogic(UiLogic *logic, QObject *parent):
void WizardLogic::onUpdatePage() void WizardLogic::onUpdatePage()
{ {
set_lineEditHighWebsiteMaskingText(protocols::cloak::defaultRedirSite); set_lineEditHighWebsiteMaskingText(protocols::cloak::defaultRedirSite);
set_radioButtonMediumChecked(true);
} }
QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage() const QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage() const

View file

@ -0,0 +1,33 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import Qt.labs.platform 1.0
Menu {
property var textObj
MenuItem {
text: qsTr("C&ut")
shortcut: StandardKey.Cut
enabled: textObj.selectedText
onTriggered: textObj.cut()
}
MenuItem {
text: qsTr("&Copy")
shortcut: StandardKey.Copy
enabled: textObj.selectedText
onTriggered: textObj.copy()
}
MenuItem {
text: qsTr("&Paste")
shortcut: StandardKey.Paste
enabled: textObj.canPaste
onTriggered: textObj.paste()
}
MenuItem {
text: qsTr("&SelectAll")
shortcut: StandardKey.SelectAll
enabled: textObj.length > 0
onTriggered: textObj.selectAll()
}
}

View file

@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
BasicButtonType { BasicButtonType {
id: root id: root
height: 40
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4 radius: 4

View file

@ -5,9 +5,7 @@ import QtGraphicalEffects 1.12
Item { Item {
id: root id: root
property bool active: false property bool active: false
property Component content: undefined
property string text: "" property string text: ""
width: 360
height: active ? contentLoader.item.height + 40 + 5 * 2 : 40 height: active ? contentLoader.item.height + 40 + 5 * 2 : 40
signal clicked() signal clicked()
@ -64,12 +62,5 @@ Item {
onClicked: root.clicked() onClicked: root.clicked()
} }
} }
Loader {
x: 0
y: 40 + 5
id: contentLoader
sourceComponent: root.content
visible: root.active
}
} }

View file

@ -0,0 +1,51 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import Qt.labs.platform 1.0
Flickable
{
property alias textArea: root
id: flickable
flickableDirection: Flickable.VerticalFlick
clip: true
TextArea.flickable:
TextArea {
id: root
property bool error: false
width: parent.width - 80
height: 40
anchors.topMargin: 5
selectByMouse: false
selectionColor: "darkgray"
font.pixelSize: 16
color: "#333333"
background: Rectangle {
implicitWidth: 200
implicitHeight: 40
border.width: 1
color: {
if (root.error) {
return Qt.rgba(213, 40, 60, 255)
}
return root.enabled ? "#F4F4F4" : Qt.rgba(127, 127, 127, 255)
}
border.color: {
if (!root.enabled) {
return Qt.rgba(127, 127, 127, 255)
}
if (root.error) {
return Qt.rgba(213, 40, 60, 255)
}
if (root.focus) {
return "#A7A7A7"
}
return "#A7A7A7"
}
}
}
}

View file

@ -44,29 +44,8 @@ TextField {
onClicked: contextMenu.open() onClicked: contextMenu.open()
} }
Menu { ContextMenu {
id: contextMenu id: contextMenu
textObj: root
onAboutToShow: console.log("aboutToShow")
onAboutToHide: console.log("aboutToHide")
MenuItem {
text: qsTr("C&ut")
shortcut: StandardKey.Cut
enabled: root.selectedText
onTriggered: root.cut()
}
MenuItem {
text: qsTr("&Copy")
shortcut: StandardKey.Copy
enabled: root.selectedText
onTriggered: root.copy()
}
MenuItem {
text: qsTr("&Paste")
shortcut: StandardKey.Paste
enabled: root.canPaste
onTriggered: root.paste()
}
} }
} }

View file

@ -1,6 +1,13 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.12
import SortFilterProxyModel 0.2
import ContainerProps 1.0
import ProtocolProps 1.0
import PageEnum 1.0 import PageEnum 1.0
import ProtocolEnum 1.0
import "./" import "./"
import "../Controls" import "../Controls"
import "../Config" import "../Config"
@ -13,403 +20,543 @@ PageBase {
BackButton { BackButton {
id: back id: back
} }
ScrollView {
x: 10 Caption {
y: 40 id: caption
width: 360 text: qsTr("Share protocol config")
height: 580 width: undefined
Item { }
id: ct
Flickable {
clip: true
width: parent.width width: parent.width
height: childrenRect.height + 10 anchors.top: caption.bottom
property var contentList: [ anchors.bottom: root.bottom
full_access, contentHeight: col.height
share_amezia,
share_openvpn, Column {
share_shadowshock, id: col
share_cloak anchors {
] left: parent.left;
property int currentIndex: ShareConnectionLogic.toolBoxShareConnectionCurrentIndex right: parent.right;
onCurrentIndexChanged: { }
ShareConnectionLogic.toolBoxShareConnectionCurrentIndex = currentIndex topPadding: 20
for (let i = 0; i < contentList.length; ++i) { spacing: 10
if (i == currentIndex) {
contentList[i].active = true // Caption {
} else { // id: cap1
contentList[i].active = false // text: qsTr("Installed Protocols and Services")
// font.pixelSize: 20
// }
SortFilterProxyModel {
id: proxyProtocolsModel
sourceModel: UiLogic.protocolsModel
filters: ValueFilter {
roleName: "is_installed_role"
value: true
}
}
ShareConnectionContent {
x: 10
text: qsTr("Share for Amnezia")
height: 40
width: tb_c.width - 10
}
ListView {
id: tb_c
x: 10
width: parent.width - 10
height: tb_c.contentItem.height
currentIndex: -1
spacing: 10
clip: true
interactive: false
model: proxyProtocolsModel
delegate: Item {
implicitWidth: tb_c.width - 10
implicitHeight: c_item.height
ShareConnectionContent {
id: c_item
text: qsTr("Share for ") + name_role
height: 40
width: tb_c.width - 10
onClicked: UiLogic.onGotoShareProtocolPage(proxyProtocolsModel.mapToSource(index))
}
// Rectangle {
// id: c_item
// x: 0
// y: 0
// width: parent.width
// height: 40
// color: "transparent"
// clip: true
// radius: 2
// LinearGradient {
// anchors.fill: parent
// start: Qt.point(0, 0)
// end: Qt.point(0, height)
// gradient: Gradient {
// GradientStop { position: 0.0; color: "#E1E1E1" }
// GradientStop { position: 0.4; color: "#DDDDDD" }
// GradientStop { position: 0.5; color: "#D8D8D8" }
// GradientStop { position: 1.0; color: "#D3D3D3" }
// }
// }
// Image {
// anchors.verticalCenter: parent.verticalCenter
// anchors.left: parent.left
// anchors.leftMargin: 10
// source: "qrc:/images/share.png"
// }
// Rectangle {
// anchors.left: parent.left
// anchors.right: parent.right
// anchors.bottom: parent.bottom
// height: 2
// color: "#148CD2"
// visible: ms.containsMouse ? true : false
// }
// Text {
// x: 40
// anchors.verticalCenter: parent.verticalCenter
// font.family: "Lato"
// font.styleName: "normal"
// font.pixelSize: 18
// color: "#100A44"
// font.bold: true
// text: name_role
// horizontalAlignment: Text.AlignLeft
// verticalAlignment: Text.AlignVCenter
// wrapMode: Text.Wrap
// }
// MouseArea {
// id: ms
// anchors.fill: parent
// hoverEnabled: true
// onClicked: UiLogic.onGotoShareProtocolPage(proxyProtocolsModel.mapToSource(index))
// }
// }
// Item {
// id: c_item
// width: parent.width
// height: row_container.height
// anchors.left: parent.left
// Rectangle {
// anchors.top: parent.top
// width: parent.width
// height: 1
// color: "lightgray"
// visible: index !== tb_c.currentIndex
// }
// Rectangle {
// anchors.top: row_container.top
// anchors.bottom: row_container.bottom
// anchors.left: parent.left
// anchors.right: parent.right
// color: "#63B4FB"
// visible: index === tb_c.currentIndex
// }
// RowLayout {
// id: row_container
// //width: parent.width
// anchors.left: parent.left
// anchors.right: parent.right
//// anchors.top: lb_container_name.top
//// anchors.bottom: lb_container_name.bottom
// Text {
// id: lb_container_name
// text: name_role
// font.pixelSize: 17
// //font.bold: true
// color: "#100A44"
// topPadding: 5
// bottomPadding: 5
// leftPadding: 10
// verticalAlignment: Text.AlignVCenter
// wrapMode: Text.WordWrap
// Layout.fillWidth: true
// MouseArea {
// enabled: col.visible
// anchors.top: lb_container_name.top
// anchors.bottom: lb_container_name.bottom
// anchors.left: parent.left
// anchors.right: parent.right
// propagateComposedEvents: true
// onClicked: {
// if (tb_c.currentIndex === index) tb_c.currentIndex = -1
// else tb_c.currentIndex = index
// UiLogic.protocolsModel.setSelectedDockerContainer(proxyContainersModel.mapToSource(index))
// }
// }
// }
// }
// }
}
} }
} }
} }
function clearActive() {
for (let i = 0; i < contentList.length; ++i) {
contentList[i].active = false
}
currentIndex = -1;
}
Column {
spacing: 5
ShareConnectionContent {
id: full_access
x: 0
text: qsTr("Full access")
visible: ShareConnectionLogic.pageShareFullAccessVisible
content: Component {
Item {
width: 360 // ScrollView {
height: 380 // x: 10
Text { // y: 40
x: 10 // width: 360
y: 250 // height: 580
width: 341 // Item {
height: 111 // id: ct
font.family: "Lato" // width: parent.width
font.styleName: "normal" // height: childrenRect.height + 10
font.pixelSize: 16 // property var contentList: [
color: "#181922" // full_access,
horizontalAlignment: Text.AlignLeft // share_amezia,
verticalAlignment: Text.AlignVCenter // share_openvpn,
wrapMode: Text.Wrap // share_shadowshock,
text: qsTr("Anyone who logs in with this code will have the same permissions to use VPN and your server as you. \nThis code includes your server credentials!\nProvide this code only to TRUSTED users.") // share_cloak
} // ]
ShareConnectionButtonType { // property int currentIndex: ShareConnectionLogic.toolBoxShareConnectionCurrentIndex
x: 10 // onCurrentIndexChanged: {
y: 130 // ShareConnectionLogic.toolBoxShareConnectionCurrentIndex = currentIndex
width: 341 // for (let i = 0; i < contentList.length; ++i) {
height: 40 // if (i == currentIndex) {
text: ShareConnectionLogic.pushButtonShareFullCopyText // contentList[i].active = true
onClicked: { // } else {
ShareConnectionLogic.onPushButtonShareFullCopyClicked() // contentList[i].active = false
} // }
} // }
ShareConnectionButtonType { // }
x: 10
y: 180 // function clearActive() {
width: 341 // for (let i = 0; i < contentList.length; ++i) {
height: 40 // contentList[i].active = false
text: qsTr("Save file") // }
onClicked: { // currentIndex = -1;
ShareConnectionLogic.onPushButtonShareFullSaveClicked() // }
} // Column {
} // spacing: 5
TextFieldType { // ShareConnectionContent {
x: 10 // id: full_access
y: 10 // x: 0
width: 341 // text: qsTr("Full access")
height: 100 // visible: ShareConnectionLogic.pageShareFullAccessVisible
verticalAlignment: Text.AlignTop // content: Component {
text: ShareConnectionLogic.textEditShareFullCodeText // Item {
onEditingFinished: { // width: 360
ShareConnectionLogic.textEditShareFullCodeText = text // height: 380
} // Text {
} // x: 10
} // y: 250
} // width: 341
onClicked: { // height: 111
if (active) { // font.family: "Lato"
ct.currentIndex = -1 // font.styleName: "normal"
} else { // font.pixelSize: 16
ct.clearActive() // color: "#181922"
ct.currentIndex = 0 // horizontalAlignment: Text.AlignLeft
} // verticalAlignment: Text.AlignVCenter
} // wrapMode: Text.Wrap
} // text: qsTr("Anyone who logs in with this code will have the same permissions to use VPN and your server as you. \nThis code includes your server credentials!\nProvide this code only to TRUSTED users.")
ShareConnectionContent { // }
id: share_amezia // ShareConnectionButtonType {
x: 0 // x: 10
text: qsTr("Share for Amnezia client") // y: 130
visible: ShareConnectionLogic.pageShareAmneziaVisible // width: 341
content: Component { // height: 40
Item { // text: ShareConnectionLogic.pushButtonShareFullCopyText
width: 360 // onClicked: {
height: 380 // ShareConnectionLogic.onPushButtonShareFullCopyClicked()
Text { // }
x: 10 // }
y: 280 // ShareConnectionButtonType {
width: 341 // x: 10
height: 111 // y: 180
font.family: "Lato" // width: 341
font.styleName: "normal" // height: 40
font.pixelSize: 16 // text: qsTr("Save file")
color: "#181922" // onClicked: {
horizontalAlignment: Text.AlignLeft // ShareConnectionLogic.onPushButtonShareFullSaveClicked()
verticalAlignment: Text.AlignVCenter // }
wrapMode: Text.Wrap // }
text: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \nThis code does not include server credentials.") // TextFieldType {
} // x: 10
ShareConnectionButtonType { // y: 10
x: 10 // width: 341
y: 180 // height: 100
width: 341 // verticalAlignment: Text.AlignTop
height: 40 // text: ShareConnectionLogic.textEditShareFullCodeText
text: ShareConnectionLogic.pushButtonShareAmneziaCopyText // onEditingFinished: {
onClicked: { // ShareConnectionLogic.textEditShareFullCodeText = text
ShareConnectionLogic.onPushButtonShareAmneziaCopyClicked() // }
} // }
enabled: ShareConnectionLogic.pushButtonShareAmneziaCopyEnabled // }
} // }
ShareConnectionButtonType { // onClicked: {
x: 10 // if (active) {
y: 130 // ct.currentIndex = -1
width: 341 // } else {
height: 40 // ct.clearActive()
text: ShareConnectionLogic.pushButtonShareAmneziaGenerateText // ct.currentIndex = 0
enabled: ShareConnectionLogic.pushButtonShareAmneziaGenerateEnabled // }
onClicked: { // }
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked() // }
} // ShareConnectionContent {
} // id: share_amezia
ShareConnectionButtonType { // x: 0
x: 10 // text: qsTr("Share for Amnezia client")
y: 230 // visible: ShareConnectionLogic.pageShareAmneziaVisible
width: 341 // content: Component {
height: 40 // Item {
text: qsTr("Save file") // width: 360
onClicked: { // height: 380
ShareConnectionLogic.onPushButtonShareAmneziaSaveClicked() // Text {
} // x: 10
} // y: 280
TextFieldType { // width: 341
x: 10 // height: 111
y: 10 // font.family: "Lato"
width: 341 // font.styleName: "normal"
height: 100 // font.pixelSize: 16
verticalAlignment: Text.AlignTop // color: "#181922"
text: ShareConnectionLogic.textEditShareAmneziaCodeText // horizontalAlignment: Text.AlignLeft
onEditingFinished: { // verticalAlignment: Text.AlignVCenter
ShareConnectionLogic.textEditShareAmneziaCodeText = text // wrapMode: Text.Wrap
} // text: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \nThis code does not include server credentials.")
} // }
} // ShareConnectionButtonType {
} // x: 10
onClicked: { // y: 180
if (active) { // width: 341
ct.currentIndex = -1 // height: 40
} else { // text: ShareConnectionLogic.pushButtonShareAmneziaCopyText
ct.clearActive() // onClicked: {
ct.currentIndex = 1 // ShareConnectionLogic.onPushButtonShareAmneziaCopyClicked()
} // }
} // enabled: ShareConnectionLogic.pushButtonShareAmneziaCopyEnabled
} // }
ShareConnectionContent { // ShareConnectionButtonType {
id: share_openvpn // x: 10
x: 0 // y: 130
text: qsTr("Share for OpenVPN client") // width: 341
visible: ShareConnectionLogic.pageShareOpenVpnVisible // height: 40
content: Component { // text: ShareConnectionLogic.pushButtonShareAmneziaGenerateText
Item { // enabled: ShareConnectionLogic.pushButtonShareAmneziaGenerateEnabled
width: 360 // onClicked: {
height: 380 // ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
ShareConnectionButtonType { // }
x: 10 // }
y: 180 // ShareConnectionButtonType {
width: 341 // x: 10
height: 40 // y: 230
text: ShareConnectionLogic.pushButtonShareOpenVpnCopyText // width: 341
enabled: ShareConnectionLogic.pushButtonShareOpenVpnCopyEnabled // height: 40
onClicked: { // text: qsTr("Save file")
ShareConnectionLogic.onPushButtonShareOpenVpnCopyClicked() // onClicked: {
} // ShareConnectionLogic.onPushButtonShareAmneziaSaveClicked()
} // }
ShareConnectionButtonType { // }
x: 10 // TextFieldType {
y: 130 // x: 10
width: 341 // y: 10
height: 40 // width: 341
text: ShareConnectionLogic.pushButtonShareOpenVpnGenerateText // height: 100
onClicked: { // verticalAlignment: Text.AlignTop
ShareConnectionLogic.onPushButtonShareOpenVpnGenerateClicked() // text: ShareConnectionLogic.textEditShareAmneziaCodeText
} // onEditingFinished: {
enabled: ShareConnectionLogic.pushButtonShareOpenVpnGenerateEnabled // ShareConnectionLogic.textEditShareAmneziaCodeText = text
} // }
ShareConnectionButtonType { // }
x: 10 // }
y: 230 // }
width: 341 // onClicked: {
height: 40 // if (active) {
text: qsTr("Save file") // ct.currentIndex = -1
enabled: ShareConnectionLogic.pushButtonShareOpenVpnSaveEnabled // } else {
onClicked: { // ct.clearActive()
ShareConnectionLogic.onPushButtonShareOpenVpnSaveClicked() // ct.currentIndex = 1
} // }
} // }
TextFieldType { // }
x: 10
y: 10 // ShareConnectionContent {
width: 341 // id: share_shadowshock
height: 100 // x: 0
verticalAlignment: Text.AlignTop // text: qsTr("Share for ShadowSocks client")
text: ShareConnectionLogic.textEditShareOpenVpnCodeText // visible: ShareConnectionLogic.pageShareShadowSocksVisible
onEditingFinished: { // content: Component {
ShareConnectionLogic.textEditShareOpenVpnCodeText = text // Item {
} // width: 360
} // height: 380
} // LabelType {
} // x: 10
onClicked: { // y: 70
if (active) { // width: 100
ct.currentIndex = -1 // height: 20
} else { // text: qsTr("Password")
ct.clearActive() // }
ct.currentIndex = 2 // LabelType {
} // x: 10
} // y: 10
} // width: 100
ShareConnectionContent { // height: 20
id: share_shadowshock // text: qsTr("Server:")
x: 0 // }
text: qsTr("Share for ShadowSocks client") // LabelType {
visible: ShareConnectionLogic.pageShareShadowSocksVisible // x: 10
content: Component { // y: 50
Item { // width: 100
width: 360 // height: 20
height: 380 // text: qsTr("Encryption:")
LabelType { // }
x: 10 // LabelType {
y: 70 // x: 10
width: 100 // y: 30
height: 20 // width: 100
text: qsTr("Password") // height: 20
} // text: qsTr("Port:")
LabelType { // }
x: 10 // LabelType {
y: 10 // x: 10
width: 100 // y: 100
height: 20 // width: 191
text: qsTr("Server:") // height: 20
} // text: qsTr("Connection string")
LabelType { // }
x: 10 // LabelType {
y: 50 // x: 130
width: 100 // y: 70
height: 20 // width: 100
text: qsTr("Encryption:") // height: 20
} // text: ShareConnectionLogic.labelShareShadowSocksPasswordText
LabelType { // }
x: 10 // LabelType {
y: 30 // x: 130
width: 100 // y: 10
height: 20 // width: 100
text: qsTr("Port:") // height: 20
} // text: ShareConnectionLogic.labelShareShadowSocksServerText
LabelType { // }
x: 10 // LabelType {
y: 100 // x: 130
width: 191 // y: 50
height: 20 // width: 100
text: qsTr("Connection string") // height: 20
} // text: ShareConnectionLogic.labelShareShadowSocksMethodText
LabelType { // }
x: 130 // LabelType {
y: 70 // x: 130
width: 100 // y: 30
height: 20 // width: 100
text: ShareConnectionLogic.labelShareShadowSocksPasswordText // height: 20
} // text: ShareConnectionLogic.labelShareShadowSocksPortText
LabelType { // }
x: 130 // Image {
y: 10 // id: label_share_ss_qr_code
width: 100 // x: 85
height: 20 // y: 235
text: ShareConnectionLogic.labelShareShadowSocksServerText // width: 200
} // height: 200
LabelType { // source: ShareConnectionLogic.labelShareShadowSocksQrCodeText === "" ? "" : "data:image/png;base64," + UiLogic.labelShareShadowSocksQrCodeText
x: 130 // }
y: 50 // ShareConnectionButtonType {
width: 100 // x: 10
height: 20 // y: 180
text: ShareConnectionLogic.labelShareShadowSocksMethodText // width: 331
} // height: 40
LabelType { // text: ShareConnectionLogic.pushButtonShareShadowSocksCopyText
x: 130 // enabled: ShareConnectionLogic.pushButtonShareShadowSocksCopyEnabled
y: 30 // onClicked: {
width: 100 // ShareConnectionLogic.onPushButtonShareShadowSocksCopyClicked()
height: 20 // }
text: ShareConnectionLogic.labelShareShadowSocksPortText // }
} // TextFieldType {
Image { // x: 10
id: label_share_ss_qr_code // y: 130
x: 85 // width: 331
y: 235 // height: 100
width: 200 // horizontalAlignment: Text.AlignHCenter
height: 200 // text: ShareConnectionLogic.lineEditShareShadowSocksStringText
source: ShareConnectionLogic.labelShareShadowSocksQrCodeText === "" ? "" : "data:image/png;base64," + UiLogic.labelShareShadowSocksQrCodeText // onEditingFinished: {
} // ShareConnectionLogic.lineEditShareShadowSocksStringText = text
ShareConnectionButtonType { // }
x: 10 // }
y: 180 // }
width: 331 // }
height: 40 // onClicked: {
text: ShareConnectionLogic.pushButtonShareShadowSocksCopyText // if (active) {
enabled: ShareConnectionLogic.pushButtonShareShadowSocksCopyEnabled // ct.currentIndex = -1
onClicked: { // } else {
ShareConnectionLogic.onPushButtonShareShadowSocksCopyClicked() // ct.clearActive()
} // ct.currentIndex = 3
} // }
TextFieldType { // }
x: 10 // }
y: 130 // ShareConnectionContent {
width: 331 // id: share_cloak
height: 100 // x: 0
horizontalAlignment: Text.AlignHCenter // text: qsTr("Share for Cloak client")
text: ShareConnectionLogic.lineEditShareShadowSocksStringText // visible: ShareConnectionLogic.pageShareCloakVisible
onEditingFinished: { // content: Component {
ShareConnectionLogic.lineEditShareShadowSocksStringText = text // Item {
} // width: 360
} // height: 380
}
} // }
onClicked: { // }
if (active) { // onClicked: {
ct.currentIndex = -1 // if (active) {
} else { // ct.currentIndex = -1
ct.clearActive() // } else {
ct.currentIndex = 3 // ct.clearActive()
} // ct.currentIndex = 4
} // }
} // }
ShareConnectionContent { // }
id: share_cloak // }
x: 0 // }
text: qsTr("Share for Cloak client") // }
visible: ShareConnectionLogic.pageShareCloakVisible
content: Component {
Item {
width: 360
height: 380
ShareConnectionButtonType {
x: 10
y: 290
width: 331
height: 40
text: ShareConnectionLogic.pushButtonShareCloakCopyText
enabled: ShareConnectionLogic.pushButtonShareCloakCopyEnabled
onClicked: {
ShareConnectionLogic.onPushButtonShareCloakCopyClicked()
}
}
TextInput {
x: 10
y: 30
width: 331
height: 100
text: ShareConnectionLogic.plainTextEditShareCloakText
onEditingFinished: {
ShareConnectionLogic.plainTextEditShareCloakText = text
}
}
}
}
onClicked: {
if (active) {
ct.currentIndex = -1
} else {
ct.clearActive()
ct.currentIndex = 4
}
}
}
}
}
}
} }

View file

@ -0,0 +1,50 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.Cloak
logic: UiLogic.protocolLogic(protocol)
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share Cloak Settings")
}
TextAreaType {
anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: pb_save.top
anchors.bottomMargin: 20
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
textArea.readOnly: true
textArea.text: ShareConnectionLogic.plainTextEditShareCloakText
}
ShareConnectionButtonType {
id: pb_save
anchors.bottom: root.bottom
anchors.bottomMargin: 10
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
text: ShareConnectionLogic.pushButtonShareCloakCopyText
enabled: ShareConnectionLogic.pushButtonShareCloakCopyEnabled
onClicked: {
ShareConnectionLogic.onPushButtonShareCloakCopyClicked()
}
}
}

View file

@ -0,0 +1,80 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.OpenVpn
logic: ShareConnectionLogic
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share OpenVPN Settings")
}
TextAreaType {
anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: pb_gen.top
anchors.bottomMargin: 20
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
textArea.readOnly: true
textArea.verticalAlignment: Text.AlignTop
textArea.text: ShareConnectionLogic.textEditShareOpenVpnCodeText
}
ShareConnectionButtonType {
id: pb_gen
anchors.bottom: pb_copy.top
anchors.bottomMargin: 10
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
text: ShareConnectionLogic.pushButtonShareOpenVpnGenerateText
onClicked: {
ShareConnectionLogic.onPushButtonShareOpenVpnGenerateClicked()
}
enabled: ShareConnectionLogic.pushButtonShareOpenVpnGenerateEnabled
}
ShareConnectionButtonType {
id: pb_copy
anchors.bottom: pb_save.top
anchors.bottomMargin: 10
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
text: ShareConnectionLogic.pushButtonShareOpenVpnCopyText
enabled: ShareConnectionLogic.pushButtonShareOpenVpnCopyEnabled
onClicked: {
ShareConnectionLogic.onPushButtonShareOpenVpnCopyClicked()
}
}
ShareConnectionButtonType {
id: pb_save
anchors.bottom: root.bottom
anchors.bottomMargin: 10
anchors.horizontalCenter: root.horizontalCenter
width: parent.width - 60
text: qsTr("Save file")
enabled: ShareConnectionLogic.pushButtonShareOpenVpnSaveEnabled
onClicked: {
ShareConnectionLogic.onPushButtonShareOpenVpnSaveClicked()
}
}
}

View file

@ -0,0 +1,22 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.Sftp
logic: UiLogic.protocolLogic(protocol)
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share SFTF settings")
}
}

View file

@ -0,0 +1,48 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.ShadowSocks
logic: UiLogic.protocolLogic(protocol)
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share ShadowSocks Settings")
}
Flickable {
id: fl
width: root.width
anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height
clip: true
ColumnLayout {
id: content
enabled: logic.pageEnabled
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
}
}
}

View file

@ -0,0 +1,21 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageShareProtocolBase {
id: root
protocol: ProtocolEnum.TorWebSite
logic: UiLogic.protocolLogic(protocol)
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("Share TOR Web site")
}
}

View file

@ -0,0 +1,13 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import PageEnum 1.0
import ProtocolEnum 1.0
import "./.."
import "../../Controls"
import "../../Config"
PageBase {
id: root
property var protocol: ProtocolEnum.Any
page: PageEnum.ProtocolSettings
}

View file

@ -3,17 +3,20 @@ import QtQuick.Window 2.14
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12 import QtQuick.Controls.Material 2.12
import PageEnum 1.0 import PageEnum 1.0
import PageType 1.0
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import Qt.labs.folderlistmodel 2.12 import Qt.labs.folderlistmodel 2.12
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import "./" import "./"
import "Pages" import "Pages"
import "Pages/Protocols" import "Pages/Protocols"
import "Pages/Share"
import "Config" import "Config"
Window { Window {
property var pages: ({}) property var pages: ({})
property var protocolPages: ({}) property var protocolPages: ({})
property var sharePages: ({})
id: root id: root
visible: true visible: true
@ -28,73 +31,28 @@ Window {
//flags: Qt.FramelessWindowHint //flags: Qt.FramelessWindowHint
title: "AmneziaVPN" title: "AmneziaVPN"
function gotoPage(page, reset, slide) { function gotoPage(type, page, reset, slide) {
let p_obj;
if (type === PageType.Basic) p_obj = pages[page]
else if (type === PageType.Proto) p_obj = protocolPages[page]
else if (type === PageType.ShareProto) p_obj = sharePages[page]
else return
console.debug("QML gotoPage " + type + " " + page + " " + p_obj)
if (slide) {
pageLoader.push(p_obj, {}, StackView.PushTransition)
} else {
pageLoader.push(p_obj, {}, StackView.Immediate)
}
if (reset) { if (reset) {
if (page === PageEnum.ServerSettings) { p_obj.logic.onUpdatePage();
ServerSettingsLogic.onUpdatePage();
}
if (page === PageEnum.ShareConnection) {
}
if (page === PageEnum.Wizard) {
WizardLogic.radioButtonMediumChecked = true
}
if (page === PageEnum.WizardHigh) {
WizardLogic.onUpdatePage();
}
if (page === PageEnum.ServerConfiguringProgress) {
ServerConfiguringProgressLogic.progressBarValue = 0;
}
if (page === PageEnum.GeneralSettings) {
GeneralSettingsLogic.onUpdatePage();
}
if (page === PageEnum.ServersList) {
ServerListLogic.onUpdatePage();
}
if (page === PageEnum.Start) {
StartPageLogic.pushButtonBackFromStartVisible = !pageLoader.empty
StartPageLogic.onUpdatePage();
}
if (page === PageEnum.NewServerProtocols) {
NewServerProtocolsLogic.onUpdatePage()
}
if (page === PageEnum.ServerContainers) {
ServerContainersLogic.onUpdatePage()
}
if (page === PageEnum.AppSettings) {
AppSettingsLogic.onUpdatePage()
}
if (page === PageEnum.NetworkSettings) {
NetworkSettingsLogic.onUpdatePage()
}
if (page === PageEnum.Sites) {
SitesLogic.updateSitesPage()
}
if (page === PageEnum.Vpn) {
VpnLogic.updateVpnPage()
}
} }
if (slide) { p_obj.activated(reset)
pageLoader.push(pages[page], {}, StackView.PushTransition)
} else {
pageLoader.push(pages[page], {}, StackView.Immediate)
}
pages[page].activated(reset)
}
function gotoProtocolPage(protocol, reset, slide) {
if (reset && protocolPages[protocol] !== "undefined") {
protocolPages[protocol].logic.onUpdatePage();
}
if (slide) {
pageLoader.push(protocolPages[protocol], {}, StackView.PushTransition)
} else {
pageLoader.push(protocolPages[protocol], {}, StackView.Immediate)
}
protocolPages[protocol].activated(reset)
} }
function close_page() { function close_page() {
@ -146,6 +104,8 @@ Window {
color: "white" color: "white"
} }
//PageShareProtoCloak {}
StackView { StackView {
id: pageLoader id: pageLoader
y: GC.isDesktop() ? titleBar.height : 0 y: GC.isDesktop() ? titleBar.height : 0
@ -157,6 +117,10 @@ Window {
UiLogic.currentPageValue = currentItem.page UiLogic.currentPageValue = currentItem.page
} }
onDepthChanged: {
UiLogic.pagesStackDepth = depth
}
Keys.onPressed: { Keys.onPressed: {
UiLogic.keyPressEvent(event.key) UiLogic.keyPressEvent(event.key)
event.accepted = true event.accepted = true
@ -171,7 +135,7 @@ Window {
onStatusChanged: if (status == FolderListModel.Ready) { onStatusChanged: if (status == FolderListModel.Ready) {
for (var i=0; i<folderModelPages.count; i++) { for (var i=0; i<folderModelPages.count; i++) {
createPagesObjects(folderModelPages.get(i, "filePath"), false); createPagesObjects(folderModelPages.get(i, "filePath"), PageType.Basic);
} }
UiLogic.initalizeUiLogic() UiLogic.initalizeUiLogic()
} }
@ -185,40 +149,56 @@ Window {
onStatusChanged: if (status == FolderListModel.Ready) { onStatusChanged: if (status == FolderListModel.Ready) {
for (var i=0; i<folderModelProtocols.count; i++) { for (var i=0; i<folderModelProtocols.count; i++) {
createPagesObjects(folderModelProtocols.get(i, "filePath"), true); createPagesObjects(folderModelProtocols.get(i, "filePath"), PageType.Proto);
} }
} }
} }
function createPagesObjects(file, isProtocol) { FolderListModel {
id: folderModelShareProtocols
folder: "qrc:/ui/qml/Pages/Share/"
nameFilters: ["*.qml"]
showDirs: false
onStatusChanged: if (status == FolderListModel.Ready) {
for (var i=0; i<folderModelShareProtocols.count; i++) {
createPagesObjects(folderModelShareProtocols.get(i, "filePath"), PageType.ShareProto);
}
}
}
function createPagesObjects(file, type) {
if (file.indexOf("Base") !== -1) return; // skip Base Pages if (file.indexOf("Base") !== -1) return; // skip Base Pages
//console.debug("Creating compenent " + file + " for " + type);
var c = Qt.createComponent("qrc" + file); var c = Qt.createComponent("qrc" + file);
var finishCreation = function (component){ var finishCreation = function (component){
if (component.status == Component.Ready) { if (component.status === Component.Ready) {
var obj = component.createObject(root); var obj = component.createObject(root);
if (obj == null) { if (obj === null) {
console.debug("Error creating object " + component.url); console.debug("Error creating object " + component.url);
} }
else { else {
obj.visible = false obj.visible = false
if (isProtocol) { if (type === PageType.Basic) {
protocolPages[obj.protocol] = obj
}
else {
pages[obj.page] = obj pages[obj.page] = obj
} }
else if (type === PageType.Proto) {
protocolPages[obj.protocol] = obj
} }
} else if (component.status == Component.Error) { else if (type === PageType.ShareProto) {
sharePages[obj.protocol] = obj
}
//console.debug("Created compenent " + component.url + " for " + type);
}
} else if (component.status === Component.Error) {
console.debug("Error loading component:", component.errorString()); console.debug("Error loading component:", component.errorString());
} }
} }
if (c.status == Component.Ready) if (c.status === Component.Ready)
finishCreation(c); finishCreation(c);
else { else {
console.debug("Warning: Pages components are not ready"); console.debug("Warning: Pages components are not ready");
@ -228,13 +208,19 @@ Window {
Connections { Connections {
target: UiLogic target: UiLogic
function onGoToPage(page, reset, slide) { function onGoToPage(page, reset, slide) {
console.debug("Connections onGoToPage " + page); console.debug("Qml Connections onGoToPage " + page);
root.gotoPage(page, reset, slide) root.gotoPage(PageType.Basic, page, reset, slide)
} }
function onGoToProtocolPage(protocol, reset, slide) { function onGoToProtocolPage(protocol, reset, slide) {
console.debug("Connections onGoToProtocolPage " + protocol); console.debug("Qml Connections onGoToProtocolPage " + protocol);
root.gotoProtocolPage(protocol, reset, slide) root.gotoPage(PageType.Proto, protocol, reset, slide)
} }
function onGoToShareProtocolPage(protocol, reset, slide) {
console.debug("Qml Connections onGoToShareProtocolPage " + protocol);
root.gotoPage(PageType.ShareProto, protocol, reset, slide)
}
function onClosePage() { function onClosePage() {
root.close_page() root.close_page()
} }

View file

@ -69,7 +69,6 @@ using namespace PageEnumNS;
UiLogic::UiLogic(QObject *parent) : UiLogic::UiLogic(QObject *parent) :
QObject(parent), QObject(parent),
m_currentPageValue{0},
m_trayIconUrl{}, m_trayIconUrl{},
m_trayActionDisconnectEnabled{true}, m_trayActionDisconnectEnabled{true},
m_trayActionConnectEnabled{true}, m_trayActionConnectEnabled{true},
@ -170,32 +169,6 @@ void UiLogic::initalizeUiLogic()
// ui->lineEdit_proto_shadowsocks_port->setValidator(&m_ipPortValidator); // ui->lineEdit_proto_shadowsocks_port->setValidator(&m_ipPortValidator);
// ui->lineEdit_proto_cloak_port->setValidator(&m_ipPortValidator); // ui->lineEdit_proto_cloak_port->setValidator(&m_ipPortValidator);
}
int UiLogic::getCurrentPageValue() const
{
return m_currentPageValue;
}
void UiLogic::setCurrentPageValue(int currentPageValue)
{
if (m_currentPageValue != currentPageValue) {
m_currentPageValue = currentPageValue;
emit currentPageValueChanged();
}
} }
QString UiLogic::getTrayIconUrl() const QString UiLogic::getTrayIconUrl() const
@ -676,7 +649,7 @@ PageProtocolLogicBase *UiLogic::protocolLogic(Protocol p) {
PageEnumNS::Page UiLogic::currentPage() PageEnumNS::Page UiLogic::currentPage()
{ {
return static_cast<PageEnumNS::Page>(getCurrentPageValue()); return static_cast<PageEnumNS::Page>(currentPageValue());
} }
void UiLogic::setTrayState(VpnProtocol::ConnectionState state) void UiLogic::setTrayState(VpnProtocol::ConnectionState state)

View file

@ -46,15 +46,16 @@ class UiLogic : public QObject
Q_OBJECT Q_OBJECT
AUTO_PROPERTY(bool, pageEnabled) AUTO_PROPERTY(bool, pageEnabled)
AUTO_PROPERTY(int, pagesStackDepth)
AUTO_PROPERTY(int, currentPageValue)
READONLY_PROPERTY(QObject *, containersModel) READONLY_PROPERTY(QObject *, containersModel)
READONLY_PROPERTY(QObject *, protocolsModel) READONLY_PROPERTY(QObject *, protocolsModel)
Q_PROPERTY(int currentPageValue READ getCurrentPageValue WRITE setCurrentPageValue NOTIFY currentPageValueChanged) // TODO: review
Q_PROPERTY(QString trayIconUrl READ getTrayIconUrl WRITE setTrayIconUrl NOTIFY trayIconUrlChanged) Q_PROPERTY(QString trayIconUrl READ getTrayIconUrl WRITE setTrayIconUrl NOTIFY trayIconUrlChanged)
Q_PROPERTY(bool trayActionDisconnectEnabled READ getTrayActionDisconnectEnabled WRITE setTrayActionDisconnectEnabled NOTIFY trayActionDisconnectEnabledChanged) Q_PROPERTY(bool trayActionDisconnectEnabled READ getTrayActionDisconnectEnabled WRITE setTrayActionDisconnectEnabled NOTIFY trayActionDisconnectEnabledChanged)
Q_PROPERTY(bool trayActionConnectEnabled READ getTrayActionConnectEnabled WRITE setTrayActionConnectEnabled NOTIFY trayActionConnectEnabledChanged) Q_PROPERTY(bool trayActionConnectEnabled READ getTrayActionConnectEnabled WRITE setTrayActionConnectEnabled NOTIFY trayActionConnectEnabledChanged)
Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged) Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
public: public:
@ -83,6 +84,8 @@ public:
friend class OtherProtocolsLogic; friend class OtherProtocolsLogic;
Q_INVOKABLE virtual void onUpdatePage() {} // UiLogic is set as logic class for some qml pages
Q_INVOKABLE void initalizeUiLogic(); Q_INVOKABLE void initalizeUiLogic();
Q_INVOKABLE void onCloseWindow(); Q_INVOKABLE void onCloseWindow();
@ -91,12 +94,11 @@ public:
Q_INVOKABLE void onGotoPage(PageEnumNS::Page p, bool reset = true, bool slide = true) { emit goToPage(p, reset, slide); } Q_INVOKABLE void onGotoPage(PageEnumNS::Page p, bool reset = true, bool slide = true) { emit goToPage(p, reset, slide); }
Q_INVOKABLE void onGotoProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToProtocolPage(p, reset, slide); } Q_INVOKABLE void onGotoProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToProtocolPage(p, reset, slide); }
Q_INVOKABLE void onGotoShareProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToShareProtocolPage(p, reset, slide); }
Q_INVOKABLE void keyPressEvent(Qt::Key key); Q_INVOKABLE void keyPressEvent(Qt::Key key);
int getCurrentPageValue() const;
void setCurrentPageValue(int currentPageValue);
QString getTrayIconUrl() const; QString getTrayIconUrl() const;
void setTrayIconUrl(const QString &trayIconUrl); void setTrayIconUrl(const QString &trayIconUrl);
bool getTrayActionDisconnectEnabled() const; bool getTrayActionDisconnectEnabled() const;
@ -108,7 +110,6 @@ public:
void setDialogConnectErrorText(const QString &dialogConnectErrorText); void setDialogConnectErrorText(const QString &dialogConnectErrorText);
signals: signals:
void currentPageValueChanged();
void trayIconUrlChanged(); void trayIconUrlChanged();
void trayActionDisconnectEnabledChanged(); void trayActionDisconnectEnabledChanged();
void trayActionConnectEnabledChanged(); void trayActionConnectEnabledChanged();
@ -117,6 +118,8 @@ signals:
void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true); void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true);
void goToProtocolPage(Protocol protocol, bool reset = true, bool slide = true); void goToProtocolPage(Protocol protocol, bool reset = true, bool slide = true);
void goToShareProtocolPage(Protocol protocol, bool reset = true, bool slide = true);
void closePage(); void closePage();
void setStartPage(PageEnumNS::Page page, bool slide = true); void setStartPage(PageEnumNS::Page page, bool slide = true);
void showPublicKeyWarning(); void showPublicKeyWarning();
@ -125,7 +128,6 @@ signals:
void hide(); void hide();
private: private:
int m_currentPageValue;
QString m_trayIconUrl; QString m_trayIconUrl;
bool m_trayActionDisconnectEnabled; bool m_trayActionDisconnectEnabled;
bool m_trayActionConnectEnabled; bool m_trayActionConnectEnabled;