moved ContainersPageHomeListView and ConnectionTypeSelectionDrawer to separate components

This commit is contained in:
vladimir.kuznetsov 2023-05-22 00:10:51 +08:00
parent acca85b99a
commit 0479113949
23 changed files with 443 additions and 294 deletions

View file

@ -18,6 +18,7 @@
#include "ui/models/containers_model.h" #include "ui/models/containers_model.h"
#include "ui/controllers/connectionController.h" #include "ui/controllers/connectionController.h"
#include "ui/controllers/pageController.h" #include "ui/controllers/pageController.h"
#include "ui/controllers/installController.h"
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance())) #define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
@ -69,6 +70,7 @@ private:
QScopedPointer<ConnectionController> m_connectionController; QScopedPointer<ConnectionController> m_connectionController;
QScopedPointer<PageController> m_pageController; QScopedPointer<PageController> m_pageController;
QScopedPointer<InstallController> m_installController;
}; };

View file

@ -188,3 +188,33 @@ QStringList ContainerProps::fixedPortsForContainer(DockerContainer c)
default: return {}; default: return {};
} }
} }
bool ContainerProps::isEasySetupContainer(DockerContainer container)
{
switch (container) {
case DockerContainer::OpenVpn : return true;
case DockerContainer::Cloak : return true;
case DockerContainer::ShadowSocks : return true;
default: return false;
}
}
QString ContainerProps::easySetupHeader(DockerContainer container)
{
switch (container) {
case DockerContainer::OpenVpn : return tr("Low");
case DockerContainer::Cloak : return tr("High");
case DockerContainer::ShadowSocks : return tr("Medium");
default: return "";
}
}
QString ContainerProps::easySetupDescription(DockerContainer container)
{
switch (container) {
case DockerContainer::OpenVpn : return tr("Many foreign websites and VPN providers are blocked");
case DockerContainer::Cloak : return tr("Some foreign sites are blocked, but VPN providers are not blocked");
case DockerContainer::ShadowSocks : return tr("I just want to increase the level of privacy");
default: return "";
}
}

View file

@ -57,6 +57,10 @@ public:
Q_INVOKABLE static bool isSupportedByCurrentPlatform(amnezia::DockerContainer c); Q_INVOKABLE static bool isSupportedByCurrentPlatform(amnezia::DockerContainer c);
Q_INVOKABLE static QStringList fixedPortsForContainer(amnezia::DockerContainer c); Q_INVOKABLE static QStringList fixedPortsForContainer(amnezia::DockerContainer c);
static bool isEasySetupContainer(amnezia::DockerContainer container);
static QString easySetupHeader(amnezia::DockerContainer container);
static QString easySetupDescription(amnezia::DockerContainer container);
}; };

View file

@ -12,10 +12,10 @@ struct ServerCredentials
{ {
QString hostName; QString hostName;
QString userName; QString userName;
QString password; QString secretData;
int port = 22; int port = 22;
bool isValid() const { return !hostName.isEmpty() && !userName.isEmpty() && !password.isEmpty() && port > 0; } bool isValid() const { return !hostName.isEmpty() && !userName.isEmpty() && !secretData.isEmpty() && port > 0; }
}; };
enum ErrorCode enum ErrorCode

View file

@ -55,10 +55,10 @@ namespace libssh {
std::string authUsername = credentials.userName.toStdString(); std::string authUsername = credentials.userName.toStdString();
int authResult = SSH_ERROR; int authResult = SSH_ERROR;
if (credentials.password.contains("BEGIN") && credentials.password.contains("PRIVATE KEY")) { if (credentials.secretData.contains("BEGIN") && credentials.secretData.contains("PRIVATE KEY")) {
ssh_key privateKey = nullptr; ssh_key privateKey = nullptr;
ssh_key publicKey = nullptr; ssh_key publicKey = nullptr;
authResult = ssh_pki_import_privkey_base64(credentials.password.toStdString().c_str(), nullptr, callback, nullptr, &privateKey); authResult = ssh_pki_import_privkey_base64(credentials.secretData.toStdString().c_str(), nullptr, callback, nullptr, &privateKey);
if (authResult == SSH_OK) { if (authResult == SSH_OK) {
authResult = ssh_pki_export_privkey_to_pubkey(privateKey, &publicKey); authResult = ssh_pki_export_privkey_to_pubkey(privateKey, &publicKey);
} }
@ -86,7 +86,7 @@ namespace libssh {
return errorCode; return errorCode;
} }
} else { } else {
authResult = ssh_userauth_password(m_session, authUsername.c_str(), credentials.password.toStdString().c_str()); authResult = ssh_userauth_password(m_session, authUsername.c_str(), credentials.secretData.toStdString().c_str());
if (authResult != SSH_OK) { if (authResult != SSH_OK) {
qDebug() << ssh_get_error(m_session); qDebug() << ssh_get_error(m_session);
return fromLibsshErrorCode(ssh_get_error_code(m_session)); return fromLibsshErrorCode(ssh_get_error_code(m_session));
@ -354,7 +354,7 @@ namespace libssh {
ssh_key privateKey = nullptr; ssh_key privateKey = nullptr;
m_passphraseCallback = passphraseCallback; m_passphraseCallback = passphraseCallback;
authResult = ssh_pki_import_privkey_base64(credentials.password.toStdString().c_str(), nullptr, callback, nullptr, &privateKey); authResult = ssh_pki_import_privkey_base64(credentials.secretData.toStdString().c_str(), nullptr, callback, nullptr, &privateKey);
if (authResult == SSH_OK) { if (authResult == SSH_OK) {
char* key = new char[65535]; char* key = new char[65535];

View file

@ -228,5 +228,7 @@
<file>images/connectionOn.svg</file> <file>images/connectionOn.svg</file>
<file>images/controls/download.svg</file> <file>images/controls/download.svg</file>
<file>ui/qml/Controls2/ProgressBarType.qml</file> <file>ui/qml/Controls2/ProgressBarType.qml</file>
<file>ui/qml/Components/ConnectionTypeSelectionDrawer.qml</file>
<file>ui/qml/Components/ContainersPageHomeListView.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -185,7 +185,7 @@ bool Settings::haveAuthData(int serverIndex) const
{ {
if (serverIndex < 0) return false; if (serverIndex < 0) return false;
ServerCredentials cred = serverCredentials(serverIndex); ServerCredentials cred = serverCredentials(serverIndex);
return (!cred.hostName.isEmpty() && !cred.userName.isEmpty() && !cred.password.isEmpty()); return (!cred.hostName.isEmpty() && !cred.userName.isEmpty() && !cred.secretData.isEmpty());
} }
QString Settings::nextAvailableServerName() const QString Settings::nextAvailableServerName() const
@ -321,7 +321,7 @@ ServerCredentials Settings::serverCredentials(int index) const
ServerCredentials credentials; ServerCredentials credentials;
credentials.hostName = s.value(config_key::hostName).toString(); credentials.hostName = s.value(config_key::hostName).toString();
credentials.userName = s.value(config_key::userName).toString(); credentials.userName = s.value(config_key::userName).toString();
credentials.password = s.value(config_key::password).toString(); credentials.secretData = s.value(config_key::password).toString();
credentials.port = s.value(config_key::port).toInt(); credentials.port = s.value(config_key::port).toInt();
return credentials; return credentials;

View file

@ -41,7 +41,7 @@ ErrorCode InstallController::installServer(DockerContainer container, QJsonObjec
QJsonObject server; QJsonObject server;
server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName); server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName);
server.insert(config_key::userName, m_currentlyInstalledServerCredentials.userName); server.insert(config_key::userName, m_currentlyInstalledServerCredentials.userName);
server.insert(config_key::password, m_currentlyInstalledServerCredentials.password); server.insert(config_key::password, m_currentlyInstalledServerCredentials.secretData);
server.insert(config_key::port, m_currentlyInstalledServerCredentials.port); server.insert(config_key::port, m_currentlyInstalledServerCredentials.port);
server.insert(config_key::description, m_settings->nextAvailableServerName()); server.insert(config_key::description, m_settings->nextAvailableServerName());
@ -50,8 +50,12 @@ ErrorCode InstallController::installServer(DockerContainer container, QJsonObjec
m_settings->addServer(server); m_settings->addServer(server);
m_settings->setDefaultServer(m_settings->serversCount() - 1); m_settings->setDefaultServer(m_settings->serversCount() - 1);
//todo change to server finished
emit installContainerFinished();
} }
//todo error processing
return errorCode; return errorCode;
} }
@ -71,9 +75,15 @@ ErrorCode InstallController::installContainer(DockerContainer container, QJsonOb
return errorCode; return errorCode;
} }
void InstallController::setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &password, const int &port) void InstallController::setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &secretData)
{ {
m_currentlyInstalledServerCredentials = { hostName, userName, password, port }; m_currentlyInstalledServerCredentials.hostName = hostName;
if (m_currentlyInstalledServerCredentials.hostName.contains(":")) {
m_currentlyInstalledServerCredentials.port = m_currentlyInstalledServerCredentials.hostName.split(":").at(1).toInt();
m_currentlyInstalledServerCredentials.hostName = m_currentlyInstalledServerCredentials.hostName.split(":").at(0);
}
m_currentlyInstalledServerCredentials.userName = userName;
m_currentlyInstalledServerCredentials.secretData = secretData;
} }
void InstallController::setShouldCreateServer(bool shouldCreateServer) void InstallController::setShouldCreateServer(bool shouldCreateServer)

View file

@ -19,7 +19,7 @@ public:
public slots: public slots:
ErrorCode install(DockerContainer container, int port, TransportProto transportProto); ErrorCode install(DockerContainer container, int port, TransportProto transportProto);
void setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &password, const int &port); void setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &secretData);
void setShouldCreateServer(bool shouldCreateServer); void setShouldCreateServer(bool shouldCreateServer);
signals: signals:

View file

@ -33,6 +33,7 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container); // return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
case IsDefaultRole: case IsDefaultRole:
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container); m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
emit defaultContainerChanged();
} }
emit dataChanged(index, index); emit dataChanged(index, index);
@ -59,12 +60,20 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
return ContainerProps::containerService(container); return ContainerProps::containerService(container);
case DockerContainerRole: case DockerContainerRole:
return container; return container;
case IsEasySetupContainerRole:
return ContainerProps::isEasySetupContainer(container);
case EasySetupHeaderRole:
return ContainerProps::easySetupHeader(container);
case EasySetupDescriptionRole:
return ContainerProps::easySetupDescription(container);
case IsInstalledRole: case IsInstalledRole:
return m_settings->containers(m_currentlyProcessedServerIndex).contains(container); return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
case IsCurrentlyInstalled: case IsCurrentlyInstalledRole:
return container == static_cast<DockerContainer>(m_currentlyInstalledContainerIndex); return container == static_cast<DockerContainer>(m_currentlyInstalledContainerIndex);
case IsDefaultRole: case IsDefaultRole:
return container == m_settings->defaultContainer(m_currentlyProcessedServerIndex); return container == m_settings->defaultContainer(m_currentlyProcessedServerIndex);
case IsSupportedRole:
return ContainerProps::isSupportedByCurrentPlatform(container);
} }
return QVariant(); return QVariant();
@ -87,6 +96,11 @@ DockerContainer ContainersModel::getDefaultContainer()
return m_settings->defaultContainer(m_currentlyProcessedServerIndex); return m_settings->defaultContainer(m_currentlyProcessedServerIndex);
} }
QString ContainersModel::getDefaultContainerName()
{
return ContainerProps::containerHumanNames().value(getDefaultContainer());
}
int ContainersModel::getCurrentlyInstalledContainerIndex() int ContainersModel::getCurrentlyInstalledContainerIndex()
{ {
return m_currentlyInstalledContainerIndex; return m_currentlyInstalledContainerIndex;
@ -98,8 +112,14 @@ QHash<int, QByteArray> ContainersModel::roleNames() const {
roles[DescRole] = "description"; roles[DescRole] = "description";
roles[ServiceTypeRole] = "serviceType"; roles[ServiceTypeRole] = "serviceType";
roles[DockerContainerRole] = "dockerContainer"; roles[DockerContainerRole] = "dockerContainer";
roles[IsEasySetupContainerRole] = "isEasySetupContainer";
roles[EasySetupHeaderRole] = "easySetupHeader";
roles[EasySetupDescriptionRole] = "easySetupDescription";
roles[IsInstalledRole] = "isInstalled"; roles[IsInstalledRole] = "isInstalled";
roles[IsCurrentlyInstalled] = "isCurrentlyInstalled"; roles[IsCurrentlyInstalledRole] = "isCurrentlyInstalled";
roles[IsDefaultRole] = "isDefault"; roles[IsDefaultRole] = "isDefault";
roles[IsSupportedRole] = "isSupported";
return roles; return roles;
} }

View file

@ -14,16 +14,22 @@ class ContainersModel : public QAbstractListModel
Q_OBJECT Q_OBJECT
public: public:
ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr); ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
public:
enum Roles { enum Roles {
NameRole = Qt::UserRole + 1, NameRole = Qt::UserRole + 1,
DescRole, DescRole,
ServiceTypeRole, ServiceTypeRole,
ConfigRole, ConfigRole,
DockerContainerRole, DockerContainerRole,
IsEasySetupContainerRole,
EasySetupHeaderRole,
EasySetupDescriptionRole,
IsInstalledRole, IsInstalledRole,
IsCurrentlyInstalled, IsCurrentlyInstalledRole,
IsDefaultRole IsDefaultRole,
IsSupportedRole
}; };
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@ -31,8 +37,12 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
signals:
void defaultContainerChanged();
public slots: public slots:
DockerContainer getDefaultContainer(); DockerContainer getDefaultContainer();
QString getDefaultContainerName();
void setCurrentlyProcessedServerIndex(int index); void setCurrentlyProcessedServerIndex(int index);
void setCurrentlyInstalledContainerIndex(int index); void setCurrentlyInstalledContainerIndex(int index);

View file

@ -123,9 +123,9 @@ void StartPageLogic::onPushButtonConnect()
key = m_configurator->sshConfigurator->convertOpenSShKey(key); key = m_configurator->sshConfigurator->convertOpenSShKey(key);
} }
serverCredentials.password = key; serverCredentials.secretData = key;
} else { } else {
serverCredentials.password = lineEditPasswordText(); serverCredentials.secretData = lineEditPasswordText();
} }
set_pushButtonConnectEnabled(false); set_pushButtonConnectEnabled(false);
@ -147,7 +147,7 @@ void StartPageLogic::onPushButtonConnect()
QString decryptedPrivateKey; QString decryptedPrivateKey;
errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback); errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback);
if (errorCode == ErrorCode::NoError) { if (errorCode == ErrorCode::NoError) {
serverCredentials.password = decryptedPrivateKey; serverCredentials.secretData = decryptedPrivateKey;
} }
} }
@ -220,7 +220,7 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
credentials.hostName = profile.value(config_key::hostName).toString(); credentials.hostName = profile.value(config_key::hostName).toString();
credentials.port = profile.value(config_key::port).toInt(); credentials.port = profile.value(config_key::port).toInt();
credentials.userName = profile.value(config_key::userName).toString(); credentials.userName = profile.value(config_key::userName).toString();
credentials.password = profile.value(config_key::password).toString(); credentials.secretData = profile.value(config_key::password).toString();
if (credentials.isValid() || profile.contains(config_key::containers)) { if (credentials.isValid() || profile.contains(config_key::containers)) {
// check config // check config

View file

@ -0,0 +1,87 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Drawer {
id: root
edge: Qt.BottomEdge
width: parent.width
height: parent.height * 0.4375
clip: true
modal: true
background: Rectangle {
anchors.fill: parent
anchors.bottomMargin: -radius
radius: 16
color: "#1C1D21"
border.color: "#2C2D30"
border.width: 1
}
Overlay.modal: Rectangle {
color: Qt.rgba(14/255, 14/255, 17/255, 0.8)
}
ColumnLayout {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter
text: "Данные для подключения"
wrapMode: Text.WordWrap
}
LabelWithButtonType {
id: ip
Layout.fillWidth: true
Layout.topMargin: 32
text: "IP, логин и пароль от сервера"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
root.visible = false
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
LabelWithButtonType {
Layout.fillWidth: true
text: "QR-код, ключ или файл настроек"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
root.visible = false
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
}
}

View file

@ -0,0 +1,119 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import "../Controls2"
import "../Controls2/TextTypes"
ListView {
id: menuContent
property var rootWidth
width: rootWidth
height: menuContent.contentItem.height
clip: true
ButtonGroup {
id: containersRadioButtonGroup
}
delegate: Item {
implicitWidth: rootWidth
implicitHeight: containerRadioButton.implicitHeight
RadioButton {
id: containerRadioButton
implicitWidth: parent.width
implicitHeight: containerRadioButtonContent.implicitHeight
hoverEnabled: true
ButtonGroup.group: containersRadioButtonGroup
checked: isDefault
indicator: Rectangle {
anchors.fill: parent
color: containerRadioButton.hovered ? "#2C2D30" : "#1C1D21"
Behavior on color {
PropertyAnimation { duration: 200 }
}
}
checkable: isInstalled
RowLayout {
id: containerRadioButtonContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
z: 1
Image {
source: isInstalled ? "qrc:/images/controls/check.svg" : "qrc:/images/controls/download.svg"
visible: isInstalled ? containerRadioButton.checked : true
width: 24
height: 24
Layout.rightMargin: 8
}
Text {
id: containerRadioButtonText
text: name
color: "#D7D8DB"
font.pixelSize: 16
font.weight: 400
font.family: "PT Root UI VF"
height: 24
Layout.fillWidth: true
Layout.topMargin: 20
Layout.bottomMargin: 20
}
}
onClicked: {
if (checked) {
isDefault = true
menuContent.currentIndex = index
containersDropDown.menuVisible = false
} else {
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
InstallController.setShouldCreateServer(false)
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
containersDropDown.menuVisible = false
menu.visible = false
}
}
MouseArea {
anchors.fill: containerRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
Component.onCompleted: {
if (isDefault) {
root.currentContainerName = name
}
}
}
}

View file

@ -24,8 +24,7 @@ Item {
property string rootButtonBorderColor: "#494B50" property string rootButtonBorderColor: "#494B50"
property int rootButtonBorderWidth: 1 property int rootButtonBorderWidth: 1
property Component menuDelegate property Component listView
property variant menuModel
property alias menuVisible: menu.visible property alias menuVisible: menu.visible
@ -169,30 +168,9 @@ Item {
spacing: 16 spacing: 16
ButtonGroup { Loader {
id: radioButtonGroup id: listViewLoader
} sourceComponent: root.listView
ListView {
id: menuContent
width: parent.width
height: menuContent.contentItem.height
currentIndex: -1
clip: true
interactive: false
model: root.menuModel
delegate: Row {
Loader {
id: loader
sourceComponent: root.menuDelegate
property QtObject modelData: model
property var delegateIndex: index
}
}
} }
} }
} }

View file

@ -6,6 +6,7 @@ import SortFilterProxyModel 0.2
import PageEnum 1.0 import PageEnum 1.0
import ProtocolEnum 1.0 import ProtocolEnum 1.0
import ContainerProps 1.0
import "./" import "./"
import "../Controls2" import "../Controls2"
@ -22,21 +23,28 @@ Item {
property string currentServerName: serversMenuContent.currentItem.delegateData.name property string currentServerName: serversMenuContent.currentItem.delegateData.name
property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName
property string currentContainerName property string currentContainerName
ConnectButton { ConnectButton {
anchors.centerIn: parent anchors.centerIn: parent
} }
Connections {
target: ContainersModel
function onDefaultContainerChanged() {
root.currentContainerName = ContainersModel.getDefaultContainerName()
}
}
Rectangle { Rectangle {
id: buttonBackground id: buttonBackground
anchors.fill: buttonContent anchors.fill: buttonContent
anchors.bottomMargin: -radius anchors.bottomMargin: -radius
radius: 16 radius: 16
color: defaultColor color: root.defaultColor
border.color: borderColor border.color: root.borderColor
border.width: 1 border.width: 1
Rectangle { Rectangle {
@ -44,7 +52,7 @@ Item {
height: 1 height: 1
y: parent.height - height - parent.radius y: parent.height - height - parent.radius
color: borderColor color: root.borderColor
} }
} }
@ -59,7 +67,7 @@ Item {
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Header1TextType { Header1TextType {
text: currentServerName text: root.currentServerName
} }
Image { Image {
@ -74,7 +82,7 @@ Item {
Layout.bottomMargin: 44 Layout.bottomMargin: 44
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: currentContainerName + " | " + currentServerHostName text: root.currentContainerName + " | " + root.currentServerHostName
} }
} }
@ -104,7 +112,7 @@ Item {
radius: 16 radius: 16
color: "#1C1D21" color: "#1C1D21"
border.color: borderColor border.color: root.borderColor
border.width: 1 border.width: 1
} }
@ -122,14 +130,14 @@ Item {
Layout.topMargin: 24 Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: currentServerName text: root.currentServerName
} }
LabelTextType { LabelTextType {
Layout.bottomMargin: 24 Layout.bottomMargin: 24
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
text: currentServerHostName text: root.currentServerHostName
} }
RowLayout { RowLayout {
@ -157,6 +165,7 @@ Item {
rootButtonMaximumWidth: 150 //todo make it dynamic rootButtonMaximumWidth: 150 //todo make it dynamic
rootButtonDefaultColor: "#D7D8DB" rootButtonDefaultColor: "#D7D8DB"
text: root.currentContainerName
textColor: "#0E0E11" textColor: "#0E0E11"
headerText: "Протокол подключения" headerText: "Протокол подключения"
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg" headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
@ -167,134 +176,11 @@ Item {
containersDropDown.menuVisible = true containersDropDown.menuVisible = true
} }
menuModel: proxyContainersModel listView: ContainersPageHomeListView {
rootWidth: root.width
ButtonGroup { model: proxyContainersModel
id: containersRadioButtonGroup currentIndex: ContainersModel.getDefaultContainer()
}
menuDelegate: Item {
implicitWidth: root.width
implicitHeight: containerRadioButton.implicitHeight
RadioButton {
id: containerRadioButton
implicitWidth: parent.width
implicitHeight: containerRadioButtonContent.implicitHeight
hoverEnabled: true
ButtonGroup.group: containersRadioButtonGroup
checked: {
if (modelData !== null) {
return modelData.isDefault
}
return false
}
indicator: Rectangle {
anchors.fill: parent
color: containerRadioButton.hovered ? "#2C2D30" : "#1C1D21"
Behavior on color {
PropertyAnimation { duration: 200 }
}
}
checkable: {
if (modelData !== null) {
if (modelData.isInstalled) {
return true
}
}
return false
}
RowLayout {
id: containerRadioButtonContent
anchors.fill: parent
anchors.rightMargin: 16
anchors.leftMargin: 16
z: 1
Image {
source: {
if (modelData !== null) {
if (modelData.isInstalled) {
return "qrc:/images/controls/check.svg"
}
}
return "qrc:/images/controls/download.svg"
}
visible: {
if (modelData !== null) {
if (modelData.isInstalled) {
return containerRadioButton.checked
}
}
return true
}
width: 24
height: 24
Layout.rightMargin: 8
}
Text {
id: containerRadioButtonText
text: {
if (modelData !== null) {
return modelData.name
} else
return ""
}
color: "#D7D8DB"
font.pixelSize: 16
font.weight: 400
font.family: "PT Root UI VF"
height: 24
Layout.fillWidth: true
Layout.topMargin: 20
Layout.bottomMargin: 20
}
}
onClicked: {
if (checked) {
modelData.isDefault = true
containersDropDown.text = containerRadioButtonText.text
root.currentContainerName = containerRadioButtonText.text
containersDropDown.menuVisible = false
} else {
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(delegateIndex))
InstallController.setShouldCreateServer(false)
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
containersDropDown.menuVisible = false
menu.visible = false
}
}
MouseArea {
anchors.fill: containerRadioButton
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
Component.onCompleted: {
if (modelData !== null && modelData.isDefault) {
containersDropDown.text = modelData.name
}
}
} }
} }
@ -318,9 +204,14 @@ Item {
headerText: "Серверы" headerText: "Серверы"
actionButtonFunction: function() { actionButtonFunction: function() {
PageController.goToPage(PageEnum.PageSetupWizardStart) menu.visible = false
connectionTypeSelection.visible = true
} }
} }
ConnectionTypeSelectionDrawer {
id: connectionTypeSelection
}
} }
FlickableType { FlickableType {
@ -416,10 +307,9 @@ Item {
onClicked: { onClicked: {
serversMenuContent.currentIndex = index serversMenuContent.currentIndex = index
root.currentServerName = name
root.currentServerHostName = hostName
ServersModel.setDefaultServerIndex(index) ServersModel.setDefaultServerIndex(index)
ContainersModel.setCurrentlyProcessedServerIndex(index)
} }
MouseArea { MouseArea {

View file

@ -41,7 +41,7 @@ Item {
id: hostname id: hostname
Layout.fillWidth: true Layout.fillWidth: true
headerText: "Server IP adress [:port]" headerText: "Server IP address [:port]"
} }
TextFieldWithHeaderType { TextFieldWithHeaderType {
@ -66,6 +66,9 @@ Item {
text: qsTr("Настроить сервер простым образом") text: qsTr("Настроить сервер простым образом")
onClicked: function() { onClicked: function() {
InstallController.setShouldCreateServer(true)
InstallController.setCurrentlyInstalledServerCredentials(hostname.textField.text, username.textField.text, secretData.textField.text)
PageController.goToPage(PageEnum.PageSetupWizardEasy) PageController.goToPage(PageEnum.PageSetupWizardEasy)
} }
} }

View file

@ -2,7 +2,11 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0 import PageEnum 1.0
import ContainerProps 1.0
import ProtocolProps 1.0
import "./" import "./"
import "../Controls2" import "../Controls2"
@ -11,13 +15,28 @@ import "../Config"
Item { Item {
id: root id: root
SortFilterProxyModel {
id: proxyContainersModel
sourceModel: ContainersModel
filters: [
ValueFilter {
roleName: "isEasySetupContainer"
value: true
}
]
sorters: RoleSorter {
roleName: "dockerContainer"
sortOrder: Qt.DescendingOrder
}
}
FlickableType { FlickableType {
id: fl id: fl
anchors.top: root.top anchors.top: root.top
anchors.bottom: root.bottom anchors.bottom: root.bottom
contentHeight: content.height contentHeight: content.height
ColumnLayout { Column {
id: content id: content
anchors.top: parent.top anchors.top: parent.top
@ -25,47 +44,91 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 16 anchors.rightMargin: 16
anchors.leftMargin: 16 anchors.leftMargin: 16
anchors.topMargin: 20
spacing: 16 spacing: 16
HeaderType { HeaderType {
Layout.fillWidth: true implicitWidth: parent.width
Layout.topMargin: 20 anchors.topMargin: 20
backButtonImage: "qrc:/images/controls/arrow-left.svg" backButtonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Какой уровень контроля интернета в вашем регионе?" headerText: qsTr("What is the level of Internet control in your region?")
} }
CardType { ListView {
Layout.fillWidth: true id: containers
width: parent.width
height: containers.contentItem.height
spacing: 16
headerText: "Высокий" currentIndex: 1
bodyText: "Многие иностранные сайты и VPN-провайдеры заблокированы" clip: true
} interactive: false
model: proxyContainersModel
CardType { property int dockerContainer
Layout.fillWidth: true property int containerDefaultPort
property int containerDefaultTransportProto
checked: true delegate: Item {
implicitWidth: containers.width
implicitHeight: delegateContent.implicitHeight
headerText: "Средний" ColumnLayout {
bodyText: "Некоторые иностранные сайты заблокированы, но VPN-провайдеры не блокируются" id: delegateContent
}
CardType { anchors.top: parent.top
Layout.fillWidth: true anchors.left: parent.left
anchors.right: parent.right
headerText: "Низкий" CardType {
bodyText: "Хочу просто повысить уровень приватности" id: card
Layout.fillWidth: true
headerText: easySetupHeader
bodyText: easySetupDescription
ButtonGroup.group: buttonGroup
onClicked: function() {
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
containers.dockerContainer = dockerContainer
containers.containerDefaultPort = ProtocolProps.defaultPort(defaultContainerProto)
containers.containerDefaultTransportProto = ProtocolProps.defaultTransportProto(defaultContainerProto)
}
}
}
Component.onCompleted: {
if (index === containers.currentIndex) {
card.checked = true
card.clicked()
}
}
}
ButtonGroup {
id: buttonGroup
}
} }
BasicButtonType { BasicButtonType {
Layout.fillWidth: true implicitWidth: parent.width
Layout.topMargin: 24 anchors.topMargin: 24
Layout.bottomMargin: 32 anchors.bottomMargin: 32
text: qsTr("Продолжить") text: qsTr("Continue")
onClicked: function() {
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.install(containers.dockerContainer,
containers.containerDefaultPort,
containers.containerDefaultTransportProto)
}
} }
} }
} }

View file

@ -109,7 +109,7 @@ Item {
running: false running: false
onTriggered: { onTriggered: {
// todo go to root installing page // todo go to root installing page
PageController.goToPage(PageEnum.PageHome) PageController.goToPage(PageEnum.PageStart)
} }
} }

View file

@ -157,7 +157,6 @@ Item {
onClicked: function() { onClicked: function() {
PageController.goToPage(PageEnum.PageSetupWizardInstalling); PageController.goToPage(PageEnum.PageSetupWizardInstalling);
InstallController.install(dockerContainer, port.textFieldText, transportProtoButtonGroup.currentIndex) InstallController.install(dockerContainer, port.textFieldText, transportProtoButtonGroup.currentIndex)
} }
} }

View file

@ -19,9 +19,14 @@ Item {
sourceModel: ContainersModel sourceModel: ContainersModel
filters: [ filters: [
ValueFilter { ValueFilter {
roleName: "service_type_role" roleName: "serviceType"
value: ProtocolEnum.Vpn value: ProtocolEnum.Vpn
},
ValueFilter {
roleName: "isSupported"
value: true
} }
] ]
} }
@ -77,8 +82,8 @@ Item {
Layout.topMargin: 16 Layout.topMargin: 16
Layout.bottomMargin: 16 Layout.bottomMargin: 16
text: name_role text: name
descriptionText: desc_role descriptionText: description
buttonImage: "qrc:/images/controls/chevron-right.svg" buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() { onClickedFunc: function() {

View file

@ -8,6 +8,7 @@ import "./"
import "../Controls2" import "../Controls2"
import "../Config" import "../Config"
import "../Controls2/TextTypes" import "../Controls2/TextTypes"
import "../Components"
Item { Item {
id: root id: root
@ -55,7 +56,7 @@ Item {
text: qsTr("У меня есть данные для подключения") text: qsTr("У меня есть данные для подключения")
onClicked: { onClicked: {
drawer.visible = true connectionTypeSelection.visible = true
} }
} }
@ -80,82 +81,8 @@ Item {
} }
} }
Drawer { ConnectionTypeSelectionDrawer {
id: drawer id: connectionTypeSelection
edge: Qt.BottomEdge
width: parent.width
height: parent.height * 0.4375
clip: true
modal: true
background: Rectangle {
anchors.fill: parent
anchors.bottomMargin: -radius
radius: 16
color: "#1C1D21"
border.color: "#2C2D30"
border.width: 1
}
Overlay.modal: Rectangle {
color: Qt.rgba(14/255, 14/255, 17/255, 0.8)
}
ColumnLayout {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 24
Layout.alignment: Qt.AlignHCenter
text: "Данные для подключения"
wrapMode: Text.WordWrap
}
LabelWithButtonType {
id: ip
Layout.fillWidth: true
Layout.topMargin: 32
text: "IP, логин и пароль от сервера"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
drawer.visible = false
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
LabelWithButtonType {
Layout.fillWidth: true
text: "QR-код, ключ или файл настроек"
buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
drawer.visible = false
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
}
} }
} }
} }

View file

@ -350,7 +350,7 @@ void UiLogic::installServer(QPair<DockerContainer, QJsonObject> &container)
QJsonObject server; QJsonObject server;
server.insert(config_key::hostName, m_installCredentials.hostName); server.insert(config_key::hostName, m_installCredentials.hostName);
server.insert(config_key::userName, m_installCredentials.userName); server.insert(config_key::userName, m_installCredentials.userName);
server.insert(config_key::password, m_installCredentials.password); server.insert(config_key::password, m_installCredentials.secretData);
server.insert(config_key::port, m_installCredentials.port); server.insert(config_key::port, m_installCredentials.port);
server.insert(config_key::description, m_settings->nextAvailableServerName()); server.insert(config_key::description, m_settings->nextAvailableServerName());
@ -574,7 +574,7 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool &isServerCreated)
if (createNewServer) { if (createNewServer) {
server.insert(config_key::hostName, installCredentials.hostName); server.insert(config_key::hostName, installCredentials.hostName);
server.insert(config_key::userName, installCredentials.userName); server.insert(config_key::userName, installCredentials.userName);
server.insert(config_key::password, installCredentials.password); server.insert(config_key::password, installCredentials.secretData);
server.insert(config_key::port, installCredentials.port); server.insert(config_key::port, installCredentials.port);
server.insert(config_key::description, m_settings->nextAvailableServerName()); server.insert(config_key::description, m_settings->nextAvailableServerName());
} }