moved ContainersPageHomeListView and ConnectionTypeSelectionDrawer to separate components
This commit is contained in:
parent
acca85b99a
commit
0479113949
23 changed files with 443 additions and 294 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include "ui/models/containers_model.h"
|
||||
#include "ui/controllers/connectionController.h"
|
||||
#include "ui/controllers/pageController.h"
|
||||
#include "ui/controllers/installController.h"
|
||||
|
||||
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ private:
|
|||
|
||||
QScopedPointer<ConnectionController> m_connectionController;
|
||||
QScopedPointer<PageController> m_pageController;
|
||||
QScopedPointer<InstallController> m_installController;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -188,3 +188,33 @@ QStringList ContainerProps::fixedPortsForContainer(DockerContainer c)
|
|||
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 "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public:
|
|||
|
||||
Q_INVOKABLE static bool isSupportedByCurrentPlatform(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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ struct ServerCredentials
|
|||
{
|
||||
QString hostName;
|
||||
QString userName;
|
||||
QString password;
|
||||
QString secretData;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ namespace libssh {
|
|||
std::string authUsername = credentials.userName.toStdString();
|
||||
|
||||
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 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) {
|
||||
authResult = ssh_pki_export_privkey_to_pubkey(privateKey, &publicKey);
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ namespace libssh {
|
|||
return errorCode;
|
||||
}
|
||||
} 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) {
|
||||
qDebug() << ssh_get_error(m_session);
|
||||
return fromLibsshErrorCode(ssh_get_error_code(m_session));
|
||||
|
|
@ -354,7 +354,7 @@ namespace libssh {
|
|||
|
||||
ssh_key privateKey = nullptr;
|
||||
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) {
|
||||
char* key = new char[65535];
|
||||
|
||||
|
|
|
|||
|
|
@ -228,5 +228,7 @@
|
|||
<file>images/connectionOn.svg</file>
|
||||
<file>images/controls/download.svg</file>
|
||||
<file>ui/qml/Controls2/ProgressBarType.qml</file>
|
||||
<file>ui/qml/Components/ConnectionTypeSelectionDrawer.qml</file>
|
||||
<file>ui/qml/Components/ContainersPageHomeListView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ bool Settings::haveAuthData(int serverIndex) const
|
|||
{
|
||||
if (serverIndex < 0) return false;
|
||||
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
|
||||
|
|
@ -321,7 +321,7 @@ ServerCredentials Settings::serverCredentials(int index) const
|
|||
ServerCredentials credentials;
|
||||
credentials.hostName = s.value(config_key::hostName).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();
|
||||
|
||||
return credentials;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ ErrorCode InstallController::installServer(DockerContainer container, QJsonObjec
|
|||
QJsonObject server;
|
||||
server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName);
|
||||
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::description, m_settings->nextAvailableServerName());
|
||||
|
||||
|
|
@ -50,8 +50,12 @@ ErrorCode InstallController::installServer(DockerContainer container, QJsonObjec
|
|||
|
||||
m_settings->addServer(server);
|
||||
m_settings->setDefaultServer(m_settings->serversCount() - 1);
|
||||
|
||||
//todo change to server finished
|
||||
emit installContainerFinished();
|
||||
}
|
||||
|
||||
//todo error processing
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
|
|
@ -71,9 +75,15 @@ ErrorCode InstallController::installContainer(DockerContainer container, QJsonOb
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
public slots:
|
||||
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);
|
||||
|
||||
signals:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
|||
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||
case IsDefaultRole:
|
||||
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
|
||||
emit defaultContainerChanged();
|
||||
}
|
||||
|
||||
emit dataChanged(index, index);
|
||||
|
|
@ -59,12 +60,20 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
|||
return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
return container;
|
||||
case IsEasySetupContainerRole:
|
||||
return ContainerProps::isEasySetupContainer(container);
|
||||
case EasySetupHeaderRole:
|
||||
return ContainerProps::easySetupHeader(container);
|
||||
case EasySetupDescriptionRole:
|
||||
return ContainerProps::easySetupDescription(container);
|
||||
case IsInstalledRole:
|
||||
return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||
case IsCurrentlyInstalled:
|
||||
case IsCurrentlyInstalledRole:
|
||||
return container == static_cast<DockerContainer>(m_currentlyInstalledContainerIndex);
|
||||
case IsDefaultRole:
|
||||
return container == m_settings->defaultContainer(m_currentlyProcessedServerIndex);
|
||||
case IsSupportedRole:
|
||||
return ContainerProps::isSupportedByCurrentPlatform(container);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
|
@ -87,6 +96,11 @@ DockerContainer ContainersModel::getDefaultContainer()
|
|||
return m_settings->defaultContainer(m_currentlyProcessedServerIndex);
|
||||
}
|
||||
|
||||
QString ContainersModel::getDefaultContainerName()
|
||||
{
|
||||
return ContainerProps::containerHumanNames().value(getDefaultContainer());
|
||||
}
|
||||
|
||||
int ContainersModel::getCurrentlyInstalledContainerIndex()
|
||||
{
|
||||
return m_currentlyInstalledContainerIndex;
|
||||
|
|
@ -98,8 +112,14 @@ QHash<int, QByteArray> ContainersModel::roleNames() const {
|
|||
roles[DescRole] = "description";
|
||||
roles[ServiceTypeRole] = "serviceType";
|
||||
roles[DockerContainerRole] = "dockerContainer";
|
||||
|
||||
roles[IsEasySetupContainerRole] = "isEasySetupContainer";
|
||||
roles[EasySetupHeaderRole] = "easySetupHeader";
|
||||
roles[EasySetupDescriptionRole] = "easySetupDescription";
|
||||
|
||||
roles[IsInstalledRole] = "isInstalled";
|
||||
roles[IsCurrentlyInstalled] = "isCurrentlyInstalled";
|
||||
roles[IsCurrentlyInstalledRole] = "isCurrentlyInstalled";
|
||||
roles[IsDefaultRole] = "isDefault";
|
||||
roles[IsSupportedRole] = "isSupported";
|
||||
return roles;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,16 +14,22 @@ class ContainersModel : public QAbstractListModel
|
|||
Q_OBJECT
|
||||
public:
|
||||
ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
public:
|
||||
|
||||
enum Roles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
ServiceTypeRole,
|
||||
ConfigRole,
|
||||
DockerContainerRole,
|
||||
|
||||
IsEasySetupContainerRole,
|
||||
EasySetupHeaderRole,
|
||||
EasySetupDescriptionRole,
|
||||
|
||||
IsInstalledRole,
|
||||
IsCurrentlyInstalled,
|
||||
IsDefaultRole
|
||||
IsCurrentlyInstalledRole,
|
||||
IsDefaultRole,
|
||||
IsSupportedRole
|
||||
};
|
||||
|
||||
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;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
signals:
|
||||
void defaultContainerChanged();
|
||||
|
||||
public slots:
|
||||
DockerContainer getDefaultContainer();
|
||||
QString getDefaultContainerName();
|
||||
|
||||
void setCurrentlyProcessedServerIndex(int index);
|
||||
void setCurrentlyInstalledContainerIndex(int index);
|
||||
|
|
|
|||
|
|
@ -123,9 +123,9 @@ void StartPageLogic::onPushButtonConnect()
|
|||
key = m_configurator->sshConfigurator->convertOpenSShKey(key);
|
||||
}
|
||||
|
||||
serverCredentials.password = key;
|
||||
serverCredentials.secretData = key;
|
||||
} else {
|
||||
serverCredentials.password = lineEditPasswordText();
|
||||
serverCredentials.secretData = lineEditPasswordText();
|
||||
}
|
||||
|
||||
set_pushButtonConnectEnabled(false);
|
||||
|
|
@ -147,7 +147,7 @@ void StartPageLogic::onPushButtonConnect()
|
|||
QString decryptedPrivateKey;
|
||||
errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback);
|
||||
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.port = profile.value(config_key::port).toInt();
|
||||
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)) {
|
||||
// check config
|
||||
|
|
|
|||
87
client/ui/qml/Components/ConnectionTypeSelectionDrawer.qml
Normal file
87
client/ui/qml/Components/ConnectionTypeSelectionDrawer.qml
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
119
client/ui/qml/Components/ContainersPageHomeListView.qml
Normal file
119
client/ui/qml/Components/ContainersPageHomeListView.qml
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,8 +24,7 @@ Item {
|
|||
property string rootButtonBorderColor: "#494B50"
|
||||
property int rootButtonBorderWidth: 1
|
||||
|
||||
property Component menuDelegate
|
||||
property variant menuModel
|
||||
property Component listView
|
||||
|
||||
property alias menuVisible: menu.visible
|
||||
|
||||
|
|
@ -169,30 +168,9 @@ Item {
|
|||
|
||||
spacing: 16
|
||||
|
||||
ButtonGroup {
|
||||
id: radioButtonGroup
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
id: listViewLoader
|
||||
sourceComponent: root.listView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import SortFilterProxyModel 0.2
|
|||
|
||||
import PageEnum 1.0
|
||||
import ProtocolEnum 1.0
|
||||
import ContainerProps 1.0
|
||||
|
||||
import "./"
|
||||
import "../Controls2"
|
||||
|
|
@ -22,21 +23,28 @@ Item {
|
|||
|
||||
property string currentServerName: serversMenuContent.currentItem.delegateData.name
|
||||
property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName
|
||||
|
||||
property string currentContainerName
|
||||
|
||||
ConnectButton {
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ContainersModel
|
||||
|
||||
function onDefaultContainerChanged() {
|
||||
root.currentContainerName = ContainersModel.getDefaultContainerName()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: buttonBackground
|
||||
anchors.fill: buttonContent
|
||||
anchors.bottomMargin: -radius
|
||||
|
||||
radius: 16
|
||||
color: defaultColor
|
||||
border.color: borderColor
|
||||
color: root.defaultColor
|
||||
border.color: root.borderColor
|
||||
border.width: 1
|
||||
|
||||
Rectangle {
|
||||
|
|
@ -44,7 +52,7 @@ Item {
|
|||
height: 1
|
||||
y: parent.height - height - parent.radius
|
||||
|
||||
color: borderColor
|
||||
color: root.borderColor
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +67,7 @@ Item {
|
|||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
Header1TextType {
|
||||
text: currentServerName
|
||||
text: root.currentServerName
|
||||
}
|
||||
|
||||
Image {
|
||||
|
|
@ -74,7 +82,7 @@ Item {
|
|||
Layout.bottomMargin: 44
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
text: currentContainerName + " | " + currentServerHostName
|
||||
text: root.currentContainerName + " | " + root.currentServerHostName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +112,7 @@ Item {
|
|||
radius: 16
|
||||
|
||||
color: "#1C1D21"
|
||||
border.color: borderColor
|
||||
border.color: root.borderColor
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
|
|
@ -122,14 +130,14 @@ Item {
|
|||
Layout.topMargin: 24
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
text: currentServerName
|
||||
text: root.currentServerName
|
||||
}
|
||||
|
||||
LabelTextType {
|
||||
Layout.bottomMargin: 24
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
text: currentServerHostName
|
||||
text: root.currentServerHostName
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
|
@ -157,6 +165,7 @@ Item {
|
|||
rootButtonMaximumWidth: 150 //todo make it dynamic
|
||||
rootButtonDefaultColor: "#D7D8DB"
|
||||
|
||||
text: root.currentContainerName
|
||||
textColor: "#0E0E11"
|
||||
headerText: "Протокол подключения"
|
||||
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
|
||||
|
|
@ -167,134 +176,11 @@ Item {
|
|||
containersDropDown.menuVisible = true
|
||||
}
|
||||
|
||||
menuModel: proxyContainersModel
|
||||
listView: ContainersPageHomeListView {
|
||||
rootWidth: root.width
|
||||
|
||||
ButtonGroup {
|
||||
id: containersRadioButtonGroup
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
model: proxyContainersModel
|
||||
currentIndex: ContainersModel.getDefaultContainer()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -318,9 +204,14 @@ Item {
|
|||
headerText: "Серверы"
|
||||
|
||||
actionButtonFunction: function() {
|
||||
PageController.goToPage(PageEnum.PageSetupWizardStart)
|
||||
menu.visible = false
|
||||
connectionTypeSelection.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionTypeSelectionDrawer {
|
||||
id: connectionTypeSelection
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
|
|
@ -416,10 +307,9 @@ Item {
|
|||
|
||||
onClicked: {
|
||||
serversMenuContent.currentIndex = index
|
||||
root.currentServerName = name
|
||||
root.currentServerHostName = hostName
|
||||
|
||||
ServersModel.setDefaultServerIndex(index)
|
||||
ContainersModel.setCurrentlyProcessedServerIndex(index)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Item {
|
|||
id: hostname
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: "Server IP adress [:port]"
|
||||
headerText: "Server IP address [:port]"
|
||||
}
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
|
|
@ -66,6 +66,9 @@ Item {
|
|||
text: qsTr("Настроить сервер простым образом")
|
||||
|
||||
onClicked: function() {
|
||||
InstallController.setShouldCreateServer(true)
|
||||
InstallController.setCurrentlyInstalledServerCredentials(hostname.textField.text, username.textField.text, secretData.textField.text)
|
||||
|
||||
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import PageEnum 1.0
|
||||
import ContainerProps 1.0
|
||||
import ProtocolProps 1.0
|
||||
|
||||
import "./"
|
||||
import "../Controls2"
|
||||
|
|
@ -11,13 +15,28 @@ import "../Config"
|
|||
Item {
|
||||
id: root
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
filters: [
|
||||
ValueFilter {
|
||||
roleName: "isEasySetupContainer"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
sorters: RoleSorter {
|
||||
roleName: "dockerContainer"
|
||||
sortOrder: Qt.DescendingOrder
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
anchors.top: root.top
|
||||
anchors.bottom: root.bottom
|
||||
contentHeight: content.height
|
||||
|
||||
ColumnLayout {
|
||||
Column {
|
||||
id: content
|
||||
|
||||
anchors.top: parent.top
|
||||
|
|
@ -25,47 +44,91 @@ Item {
|
|||
anchors.right: parent.right
|
||||
anchors.rightMargin: 16
|
||||
anchors.leftMargin: 16
|
||||
anchors.topMargin: 20
|
||||
|
||||
spacing: 16
|
||||
|
||||
HeaderType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
implicitWidth: parent.width
|
||||
anchors.topMargin: 20
|
||||
|
||||
backButtonImage: "qrc:/images/controls/arrow-left.svg"
|
||||
|
||||
headerText: "Какой уровень контроля интернета в вашем регионе?"
|
||||
headerText: qsTr("What is the level of Internet control in your region?")
|
||||
}
|
||||
|
||||
CardType {
|
||||
Layout.fillWidth: true
|
||||
ListView {
|
||||
id: containers
|
||||
width: parent.width
|
||||
height: containers.contentItem.height
|
||||
spacing: 16
|
||||
|
||||
headerText: "Высокий"
|
||||
bodyText: "Многие иностранные сайты и VPN-провайдеры заблокированы"
|
||||
}
|
||||
currentIndex: 1
|
||||
clip: true
|
||||
interactive: false
|
||||
model: proxyContainersModel
|
||||
|
||||
CardType {
|
||||
Layout.fillWidth: true
|
||||
property int dockerContainer
|
||||
property int containerDefaultPort
|
||||
property int containerDefaultTransportProto
|
||||
|
||||
checked: true
|
||||
delegate: Item {
|
||||
implicitWidth: containers.width
|
||||
implicitHeight: delegateContent.implicitHeight
|
||||
|
||||
headerText: "Средний"
|
||||
bodyText: "Некоторые иностранные сайты заблокированы, но VPN-провайдеры не блокируются"
|
||||
}
|
||||
ColumnLayout {
|
||||
id: delegateContent
|
||||
|
||||
CardType {
|
||||
Layout.fillWidth: true
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
headerText: "Низкий"
|
||||
bodyText: "Хочу просто повысить уровень приватности"
|
||||
CardType {
|
||||
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 {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
Layout.bottomMargin: 32
|
||||
implicitWidth: parent.width
|
||||
anchors.topMargin: 24
|
||||
anchors.bottomMargin: 32
|
||||
|
||||
text: qsTr("Продолжить")
|
||||
text: qsTr("Continue")
|
||||
|
||||
onClicked: function() {
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||
InstallController.install(containers.dockerContainer,
|
||||
containers.containerDefaultPort,
|
||||
containers.containerDefaultTransportProto)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ Item {
|
|||
running: false
|
||||
onTriggered: {
|
||||
// todo go to root installing page
|
||||
PageController.goToPage(PageEnum.PageHome)
|
||||
PageController.goToPage(PageEnum.PageStart)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,6 @@ Item {
|
|||
|
||||
onClicked: function() {
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||
|
||||
InstallController.install(dockerContainer, port.textFieldText, transportProtoButtonGroup.currentIndex)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,14 @@ Item {
|
|||
sourceModel: ContainersModel
|
||||
filters: [
|
||||
ValueFilter {
|
||||
roleName: "service_type_role"
|
||||
roleName: "serviceType"
|
||||
value: ProtocolEnum.Vpn
|
||||
},
|
||||
ValueFilter {
|
||||
roleName: "isSupported"
|
||||
value: true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +82,8 @@ Item {
|
|||
Layout.topMargin: 16
|
||||
Layout.bottomMargin: 16
|
||||
|
||||
text: name_role
|
||||
descriptionText: desc_role
|
||||
text: name
|
||||
descriptionText: description
|
||||
buttonImage: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import "./"
|
|||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Components"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
|
@ -55,7 +56,7 @@ Item {
|
|||
text: qsTr("У меня есть данные для подключения")
|
||||
|
||||
onClicked: {
|
||||
drawer.visible = true
|
||||
connectionTypeSelection.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,82 +81,8 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Drawer {
|
||||
id: drawer
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
ConnectionTypeSelectionDrawer {
|
||||
id: connectionTypeSelection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ void UiLogic::installServer(QPair<DockerContainer, QJsonObject> &container)
|
|||
QJsonObject server;
|
||||
server.insert(config_key::hostName, m_installCredentials.hostName);
|
||||
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::description, m_settings->nextAvailableServerName());
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool &isServerCreated)
|
|||
if (createNewServer) {
|
||||
server.insert(config_key::hostName, installCredentials.hostName);
|
||||
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::description, m_settings->nextAvailableServerName());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue