changed the way to create qml pages, now the page is created when you go to it

- added PageSetupWizardConfigSource, PageSetupWizardInstalling, PageSetupWizardProtocolSettings, PageSetupWizardTextKey
This commit is contained in:
vladimir.kuznetsov 2023-05-03 19:06:16 +03:00
parent 68b27451f2
commit 4f36349630
25 changed files with 503 additions and 158 deletions

View file

@ -99,6 +99,10 @@ void AmneziaApplication::init()
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
m_engine->rootContext()->setContextProperty("Debug", &Logger::Instance()); m_engine->rootContext()->setContextProperty("Debug", &Logger::Instance());
m_containersModel.reset(new ContainersModel(m_settings, this));
m_engine->rootContext()->setContextProperty("ContainersModel", m_containersModel.get());
m_uiLogic->registerPagesLogic(); m_uiLogic->registerPagesLogic();
#if defined(Q_OS_IOS) #if defined(Q_OS_IOS)
@ -180,6 +184,8 @@ void AmneziaApplication::loadFonts()
QFontDatabase::addApplicationFont(":/fonts/Lato-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/Lato-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf"); QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf");
QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf");
QFontDatabase::addApplicationFont(":/fonts/pt-root-ui_vf.ttf");
} }
void AmneziaApplication::loadTranslator() void AmneziaApplication::loadTranslator()

View file

@ -56,6 +56,8 @@ private:
QTranslator* m_translator; QTranslator* m_translator;
QCommandLineParser m_parser; QCommandLineParser m_parser;
QScopedPointer<ContainersModel> m_containersModel;
}; };
#endif // AMNEZIA_APPLICATION_H #endif // AMNEZIA_APPLICATION_H

View file

@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 14L7.45 11.1C7.61696 10.7687 7.87281 10.4903 8.18893 10.296C8.50504 10.1018 8.86897 9.99927 9.24 10H20C20.3055 9.99946 20.6071 10.0689 20.8816 10.2031C21.1561 10.3372 21.3963 10.5325 21.5836 10.7739C21.7709 11.0152 21.9004 11.2963 21.9622 11.5956C22.024 11.8948 22.0164 12.2042 21.94 12.5L20.39 18.5C20.279 18.9299 20.0281 19.3106 19.6769 19.5822C19.3256 19.8538 18.894 20.0008 18.45 20H4C3.46957 20 2.96086 19.7893 2.58579 19.4142C2.21071 19.0391 2 18.5304 2 18V5C2 3.9 2.9 3 4 3H7.93C8.25941 3.0017 8.58331 3.08475 8.8729 3.24176C9.1625 3.39877 9.40882 3.62488 9.59 3.9L10.41 5.1C10.5912 5.37512 10.8375 5.60123 11.1271 5.75824C11.4167 5.91525 11.7406 5.9983 12.07 6H18C18.5304 6 19.0391 6.21071 19.4142 6.58579C19.7893 6.96086 20 7.46957 20 8V10" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 948 B

View file

@ -0,0 +1,14 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 3H4C3.44772 3 3 3.44772 3 4V7C3 7.55228 3.44772 8 4 8H7C7.55228 8 8 7.55228 8 7V4C8 3.44772 7.55228 3 7 3Z" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M20 3H17C16.4477 3 16 3.44772 16 4V7C16 7.55228 16.4477 8 17 8H20C20.5523 8 21 7.55228 21 7V4C21 3.44772 20.5523 3 20 3Z" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M7 16H4C3.44772 16 3 16.4477 3 17V20C3 20.5523 3.44772 21 4 21H7C7.55228 21 8 20.5523 8 20V17C8 16.4477 7.55228 16 7 16Z" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M21 16H18C17.4696 16 16.9609 16.2107 16.5858 16.5858C16.2107 16.9609 16 17.4696 16 18V21" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M21 21V21.01" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 7V10C12 10.5304 11.7893 11.0391 11.4142 11.4142C11.0391 11.7893 10.5304 12 10 12H7" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 12H3.01" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 3H12.01" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 16V16.01" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 12H17" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M21 12V12.01" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 21V20" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17 22H16C14.9391 22 13.9217 21.5786 13.1716 20.8284C12.4214 20.0783 12 19.0609 12 18V6C12 4.93913 12.4214 3.92172 13.1716 3.17157C13.9217 2.42143 14.9391 2 16 2H17" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M7 22H8C9.06087 22 10.0783 21.5786 10.8284 20.8284C11.5786 20.0783 12 19.0609 12 18V17" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M7 2H8C9.06087 2 10.0783 2.42143 10.8284 3.17157C11.5786 3.92172 12 4.93913 12 6V7" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 717 B

View file

@ -202,5 +202,12 @@
<file>ui/qml/Controls2/SwitcherType.qml</file> <file>ui/qml/Controls2/SwitcherType.qml</file>
<file>ui/qml/Pages2/PageTest.qml</file> <file>ui/qml/Pages2/PageTest.qml</file>
<file>ui/qml/Controls2/TabButtonType.qml</file> <file>ui/qml/Controls2/TabButtonType.qml</file>
<file>ui/qml/Pages2/PageSetupWizardProtocolSettings.qml</file>
<file>ui/qml/Pages2/PageSetupWizardInstalling.qml</file>
<file>ui/qml/Pages2/PageSetupWizardConfigSource.qml</file>
<file>images/controls/folder-open.svg</file>
<file>images/controls/qr-code.svg</file>
<file>images/controls/text-cursor.svg</file>
<file>ui/qml/Pages2/PageSetupWizardTextKey.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -56,4 +56,14 @@ void ContainersModel::setSelectedServerIndex(int index)
endResetModel(); endResetModel();
} }
void ContainersModel::setCurrentlyInstalledContainerIndex(int index)
{
// beginResetModel();
m_currentlyInstalledContainerIndex = createIndex(index, 0);
// endResetModel();
}
QString ContainersModel::getCurrentlyInstalledContainerName()
{
return data(m_currentlyInstalledContainerIndex, NameRole).toString();
}

View file

@ -27,12 +27,16 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Q_INVOKABLE void setSelectedServerIndex(int index); Q_INVOKABLE void setSelectedServerIndex(int index);
Q_INVOKABLE void setCurrentlyInstalledContainerIndex(int index);
Q_INVOKABLE QString getCurrentlyInstalledContainerName();
protected: protected:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
private: private:
int m_selectedServerIndex; int m_selectedServerIndex;
QModelIndex m_currentlyInstalledContainerIndex;
std::shared_ptr<Settings> m_settings; std::shared_ptr<Settings> m_settings;
}; };

View file

@ -28,7 +28,9 @@ enum class Page {Start = 0, NewServer, NewServerProtocols, Vpn,
ProtocolSettings, ProtocolShare, QrDecoder, QrDecoderIos, About, ViewConfig, ProtocolSettings, ProtocolShare, QrDecoder, QrDecoderIos, About, ViewConfig,
AdvancedServerSettings, ClientManagement, ClientInfo, AdvancedServerSettings, ClientManagement, ClientInfo,
Test, WizardCredentials, WizardProtocols, WizardEasySetup}; PageStart, PageTest, PageSetupWizardCredentials, PageSetupWizardProtocols, PageSetupWizardEasy,
PageSetupWizardProtocolSettings, PageSetupWizardInstalling, PageSetupWizardConfigSource,
PageSetupWizardTextKey};
Q_ENUM_NS(Page) Q_ENUM_NS(Page)
static void declareQmlPageEnum() { static void declareQmlPageEnum() {

View file

@ -22,8 +22,8 @@ ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent):
void ServerContainersLogic::onUpdatePage() void ServerContainersLogic::onUpdatePage()
{ {
ContainersModel *c_model = qobject_cast<ContainersModel *>(uiLogic()->containersModel()); // ContainersModel *c_model = qobject_cast<ContainersModel *>(uiLogic()->containersModel());
c_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex); // c_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex);
ProtocolsModel *p_model = qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel()); ProtocolsModel *p_model = qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel());
p_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex); p_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex);

View file

@ -14,7 +14,6 @@ Button {
property string borderColor: "#D7D8DB" property string borderColor: "#D7D8DB"
property int borderWidth: 0 property int borderWidth: 0
implicitWidth: 328
implicitHeight: 56 implicitHeight: 56
hoverEnabled: true hoverEnabled: true

View file

@ -9,7 +9,9 @@ Item {
property string descriptionText property string descriptionText
property var onClickedFunc property var onClickedFunc
property alias buttonImage: button.image property alias buttonImage: button.image
property string iconImage
implicitWidth: content.implicitWidth implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight implicitHeight: content.implicitHeight
@ -18,6 +20,13 @@ Item {
id: content id: content
anchors.fill: parent anchors.fill: parent
Image {
id: icon
source: iconImage
visible: iconImage ? true : false
Layout.rightMargin: visible ? 16 : 0
}
ColumnLayout { ColumnLayout {
Text { Text {
font.family: "PT Root UI" font.family: "PT Root UI"
@ -25,6 +34,7 @@ Item {
font.pixelSize: 18 font.pixelSize: 18
color: "#d7d8db" color: "#d7d8db"
text: root.text text: root.text
wrapMode: Text.WordWrap
Layout.fillWidth: true Layout.fillWidth: true
height: 22 height: 22

View file

@ -10,7 +10,11 @@ Item {
property string textFieldPlaceholderText property string textFieldPlaceholderText
property bool textFieldEditable: true property bool textFieldEditable: true
implicitWidth: 328 property string buttonText
property var clickedFunc
property alias textField: textField
implicitHeight: 74 implicitHeight: 74
Rectangle { Rectangle {
@ -26,50 +30,77 @@ Item {
} }
} }
ColumnLayout { RowLayout {
anchors.fill: backgroud anchors.fill: backgroud
ColumnLayout {
Text { Text {
text: root.headerText text: root.headerText
color: "#878b91" color: "#878b91"
font.pixelSize: 13 font.pixelSize: 13
font.weight: 400 font.weight: 400
font.family: "PT Root UI VF" font.family: "PT Root UI VF"
font.letterSpacing: 0.02 font.letterSpacing: 0.02
height: 16 height: 16
Layout.fillWidth: true Layout.fillWidth: true
Layout.rightMargin: 16 Layout.rightMargin: 16
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.topMargin: 16 Layout.topMargin: 16
}
TextField {
id: textField
enabled: root.textFieldEditable
text: root.textFieldText
color: "#d7d8db"
placeholderText: textFieldPlaceholderText
placeholderTextColor: "#494B50"
selectionColor: "#412102"
selectedTextColor: "#D7D8DB"
font.pixelSize: 16
font.weight: 400
font.family: "PT Root UI VF"
height: 24
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.bottomMargin: 16
topPadding: 0
rightPadding: 0
leftPadding: 0
bottomPadding: 0
background: Rectangle {
anchors.fill: parent
color: "#1c1d21"
}
}
} }
TextField { BasicButtonType {
id: textField visible: root.buttonText !== ""
enabled: root.textFieldEditable defaultColor: "transparent"
text: root.textFieldText hoveredColor: Qt.rgba(1, 1, 1, 0.08)
color: "#d7d8db" pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 0
placeholderText: textFieldPlaceholderText text: buttonText
font.pixelSize: 16 Layout.rightMargin: 24
font.weight: 400
font.family: "PT Root UI VF"
height: 24 onClicked: {
Layout.fillWidth: true if (clickedFunc && typeof clickedFunc === "function") {
Layout.rightMargin: 16 clickedFunc()
Layout.leftMargin: 16 }
Layout.bottomMargin: 16
topPadding: 0
rightPadding: 0
leftPadding: 0
bottomPadding: 0
background: Rectangle {
anchors.fill: parent
color: "#1c1d21"
} }
} }
} }

View file

@ -1,57 +1,7 @@
import QtQuick import QtQuick
import QtQuick.Controls
import Qt.labs.folderlistmodel StackView {
id: stackView
import PageType 1.0 initialItem: "PageStart"
Item {
property var pages: ({})
signal finished()
FolderListModel {
id: folderModelPages
folder: "qrc:/ui/qml/Pages2/"
nameFilters: ["*.qml"]
showDirs: false
onStatusChanged: {
if (status == FolderListModel.Ready) {
for (var i = 0; i < folderModelPages.count; i++) {
createPagesObjects(folderModelPages.get(i, "filePath"), PageType.Basic);
}
finished()
}
}
function createPagesObjects(file, type) {
if (file.indexOf("Base") !== -1) {
return; // skip Base Pages
}
var c = Qt.createComponent("qrc" + file);
var finishCreation = function(component) {
if (component.status === Component.Ready) {
var obj = component.createObject(root);
if (obj === null) {
console.debug("Error creating object " + component.url);
} else {
obj.visible = false
if (type === PageType.Basic) {
pages[obj.page] = obj
}
}
} else if (component.status === Component.Error) {
console.debug("Error loading component:", component.errorString());
}
}
if (c.status === Component.Ready) {
finishCreation(c);
} else {
console.debug("Warning: " + file + " page components are not ready " + c.errorString());
}
}
}
} }

View file

@ -0,0 +1,114 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import PageEnum 1.0
import "./"
import "../Pages"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageBase {
id: root
page: PageEnum.PageSetupWizardInstalling
FlickableType {
id: fl
anchors.top: root.top
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
buttonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Подключение к серверу"
descriptionText: "Не используйте код подключения из публичных источников. Его могли создать, чтобы перехватывать ваши данные.\n
Всё в порядке, если код передал друг."
}
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 32
text: "Что у вас есть?"
}
LabelWithButtonType {
Layout.fillWidth: true
Layout.topMargin: 16
text: "Файл с настройками подключения"
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/folder-open.svg"
onClickedFunc: function() {
onClicked: fileDialog.open()
}
FileDialog {
id: fileDialog
// currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
onAccepted: {
}
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
//todo ifdef mobile platforms>
LabelWithButtonType {
Layout.fillWidth: true
text: "QR-код"
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/qr-code.svg"
onClickedFunc: function() {
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
LabelWithButtonType {
Layout.fillWidth: true
text: "Ключ в виде текста"
buttonImage: "qrc:/images/controls/chevron-right.svg"
iconImage: "qrc:/images/controls/text-cursor.svg"
onClickedFunc: function() {
UiLogic.goToPage(PageEnum.PageSetupWizardTextKey)
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#2C2D30"
}
}
}
}

View file

@ -11,7 +11,7 @@ import "../Config"
PageBase { PageBase {
id: root id: root
page: PageEnum.WizardCredentials page: PageEnum.PageSetupWizardCredentials
FlickableType { FlickableType {
id: fl id: fl
@ -61,7 +61,7 @@ PageBase {
text: qsTr("Настроить сервер простым образом") text: qsTr("Настроить сервер простым образом")
onClicked: function() { onClicked: function() {
UiLogic.goToPage(PageEnum.WizardEasySetup) UiLogic.goToPage(PageEnum.PageSetupWizardEasy)
} }
} }
@ -79,7 +79,7 @@ PageBase {
text: qsTr("Выбрать протокол для установки") text: qsTr("Выбрать протокол для установки")
onClicked: function() { onClicked: function() {
UiLogic.goToPage(PageEnum.WizardProtocols) UiLogic.goToPage(PageEnum.PageSetupWizardProtocols)
} }
} }
} }

View file

@ -11,7 +11,7 @@ import "../Config"
PageBase { PageBase {
id: root id: root
page: PageEnum.WizardEasySetup page: PageEnum.PageSetupWizardEasy
FlickableType { FlickableType {
id: fl id: fl

View file

@ -0,0 +1,46 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Pages"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageBase {
id: root
page: PageEnum.PageSetupWizardInstalling
FlickableType {
id: fl
anchors.top: root.top
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
//TODO remove later
buttonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Установка"
descriptionText: ContainersModel.getCurrentlyInstalledContainerName()
}
}
}
}

View file

@ -0,0 +1,96 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Pages"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageBase {
id: root
page: PageEnum.PageSetupWizardProtocolSettings
FlickableType {
id: fl
anchors.top: root.top
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
buttonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Установка " + ContainersModel.getCurrentlyInstalledContainerName()
descriptionText: "Эти настройки можно будет изменить позже"
}
BodyTextType {
Layout.topMargin: 16
text: "Network protocol"
}
//TODO move to separete control
Rectangle {
implicitWidth: buttonGroup.implicitWidth
implicitHeight: buttonGroup.implicitHeight
color: "#1C1D21"
radius: 16
RowLayout {
id: buttonGroup
spacing: 0
HorizontalRadioButton {
implicitWidth: (root.width - 32) / 2
text: "UDP"
}
HorizontalRadioButton {
implicitWidth: (root.width - 32) / 2
text: "TCP"
}
}
}
TextFieldWithHeaderType {
Layout.fillWidth: true
headerText: "Port"
}
}
}
BasicButtonType {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.bottomMargin: 32
text: qsTr("Установить")
onClicked: function() {
UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
}
}
}

View file

@ -14,11 +14,11 @@ import "../Config"
PageBase { PageBase {
id: root id: root
page: PageEnum.WizardProtocols page: PageEnum.PageSetupWizardProtocols
SortFilterProxyModel { SortFilterProxyModel {
id: containersModel id: proxyContainersModel
sourceModel: UiLogic.containersModel sourceModel: ContainersModel
filters: [ filters: [
ValueFilter { ValueFilter {
roleName: "is_installed_role" roleName: "is_installed_role"
@ -64,7 +64,7 @@ PageBase {
currentIndex: -1 currentIndex: -1
clip: true clip: true
interactive: false interactive: false
model: containersModel model: proxyContainersModel
delegate: Item { delegate: Item {
implicitWidth: containers.width implicitWidth: containers.width
@ -87,6 +87,10 @@ PageBase {
descriptionText: desc_role descriptionText: desc_role
buttonImage: "qrc:/images/controls/chevron-right.svg" buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() {
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
UiLogic.goToPage(PageEnum.PageSetupWizardProtocolSettings)
}
} }
Rectangle { Rectangle {

View file

@ -0,0 +1,74 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import "./"
import "../Pages"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
PageBase {
id: root
page: PageEnum.PageSetupWizardInstalling
FlickableType {
id: fl
anchors.top: root.top
anchors.bottom: root.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
spacing: 16
HeaderType {
Layout.fillWidth: true
Layout.topMargin: 20
buttonImage: "qrc:/images/controls/arrow-left.svg"
headerText: "Ключ для подключения"
descriptionText: "Строка, которая начинается с vpn://..."
}
TextFieldWithHeaderType {
Layout.fillWidth: true
Layout.topMargin: 32
headerText: "Ключ"
textFieldPlaceholderText: "vpn://"
buttonText: "Вставить"
clickedFunc: function() {
textField.text = ""
textField.paste()
}
}
}
}
BasicButtonType {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 16
anchors.leftMargin: 16
anchors.bottomMargin: 32
text: qsTr("Подключиться")
onClicked: function() {
// UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
}
}
}

View file

@ -12,7 +12,7 @@ import "../Controls2/TextTypes"
PageBase { PageBase {
id: root id: root
page: PageEnum.Start page: PageEnum.PageStart
FlickableType { FlickableType {
id: fl id: fl
@ -77,7 +77,7 @@ PageBase {
text: qsTr("У меня ничего нет") text: qsTr("У меня ничего нет")
onClicked: { onClicked: {
UiLogic.goToPage(PageEnum.Test) UiLogic.goToPage(PageEnum.PageTest)
} }
} }
} }
@ -129,7 +129,7 @@ PageBase {
buttonImage: "qrc:/images/controls/chevron-right.svg" buttonImage: "qrc:/images/controls/chevron-right.svg"
onClickedFunc: function() { onClickedFunc: function() {
UiLogic.goToPage(PageEnum.WizardCredentials) UiLogic.goToPage(PageEnum.PageSetupWizardCredentials)
drawer.visible = false drawer.visible = false
} }
} }
@ -144,9 +144,10 @@ PageBase {
text: "QR-код, ключ или файл настроек" text: "QR-код, ключ или файл настроек"
buttonImage: "qrc:/images/controls/chevron-right.svg" buttonImage: "qrc:/images/controls/chevron-right.svg"
// onClickedFunc: function() { onClickedFunc: function() {
// UiLogic.goToPage(PageEnum.Start) UiLogic.goToPage(PageEnum.PageSetupWizardConfigSource)
// } drawer.visible = false
}
} }
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true

View file

@ -14,6 +14,7 @@ Window {
height: GC.screenHeight height: GC.screenHeight
minimumWidth: GC.isDesktop() ? 360 : 0 minimumWidth: GC.isDesktop() ? 360 : 0
minimumHeight: GC.isDesktop() ? 640 : 0 minimumHeight: GC.isDesktop() ? 640 : 0
onClosing: function() { onClosing: function() {
console.debug("QML onClosing signal") console.debug("QML onClosing signal")
UiLogic.onCloseWindow() UiLogic.onCloseWindow()
@ -21,28 +22,18 @@ Window {
title: "AmneziaVPN" title: "AmneziaVPN"
function gotoPage(type, page, reset, slide) { function gotoPage(page, reset, slide) {
let p_obj;
if (type === PageType.Basic) p_obj = pageLoader.pages[page]
else if (type === PageType.Proto) p_obj = protocolPages[page]
else if (type === PageType.ShareProto) p_obj = sharePages[page]
else return
if (pageStackView.depth > 0) { if (pageStackView.depth > 0) {
pageStackView.currentItem.deactivated() pageStackView.currentItem.deactivated()
} }
if (slide) { if (slide) {
pageStackView.push(p_obj, {}, StackView.PushTransition) pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
} else { } else {
pageStackView.push(p_obj, {}, StackView.Immediate) pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
} }
// if (reset) { pageStackView.currentItem.activated(reset)
// p_obj.logic.onUpdatePage();
// }
p_obj.activated(reset)
} }
function closePage() { function closePage() {
@ -60,9 +51,9 @@ Window {
pageStackView.clear() pageStackView.clear()
if (slide) { if (slide) {
pageStackView.push(pages[page], {}, StackView.PushTransition) pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
} else { } else {
pageStackView.push(pages[page], {}, StackView.Immediate) pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
} }
if (page === PageEnum.Start) { if (page === PageEnum.Start) {
UiLogic.pushButtonBackFromStartVisible = !pageStackView.empty UiLogic.pushButtonBackFromStartVisible = !pageStackView.empty
@ -79,33 +70,12 @@ Window {
id: pageStackView id: pageStackView
anchors.fill: parent anchors.fill: parent
focus: true focus: true
onCurrentItemChanged: function() {
UiLogic.currentPageValue = currentItem.page
}
onDepthChanged: function() {
UiLogic.pagesStackDepth = depth
}
Keys.onPressed: function(event) {
UiLogic.keyPressEvent(event.key)
event.accepted = true
}
} }
Connections { Connections {
target: UiLogic target: UiLogic
function onGoToPage(page, reset, slide) { function onGoToPage(page, reset, slide) {
root.gotoPage(PageType.Basic, page, reset, slide) root.gotoPage(page, reset, slide)
}
function onGoToProtocolPage(protocol, reset, slide) {
root.gotoPage(PageType.Proto, protocol, reset, slide)
}
function onGoToShareProtocolPage(protocol, reset, slide) {
root.gotoPage(PageType.ShareProto, protocol, reset, slide)
} }
function onClosePage() { function onClosePage() {
@ -118,6 +88,7 @@ Window {
function onShow() { function onShow() {
root.show() root.show()
UiLogic.initializeUiLogic()
} }
function onHide() { function onHide() {
@ -130,13 +101,4 @@ Window {
root.requestActivate() root.requestActivate()
} }
} }
PageLoader {
id: pageLoader
onFinished: {
UiLogic.initializeUiLogic()
}
}
} }

View file

@ -84,7 +84,6 @@ UiLogic::UiLogic(std::shared_ptr<Settings> settings, std::shared_ptr<VpnConfigur
m_settings(settings), m_settings(settings),
m_configurator(configurator) m_configurator(configurator)
{ {
m_containersModel = new ContainersModel(settings, this);
m_protocolsModel = new ProtocolsModel(settings, this); m_protocolsModel = new ProtocolsModel(settings, this);
m_clientManagementModel = new ClientManagementModel(this); m_clientManagementModel = new ClientManagementModel(this);
m_vpnConnection = new VpnConnection(settings, configurator); m_vpnConnection = new VpnConnection(settings, configurator);
@ -155,7 +154,7 @@ void UiLogic::initializeUiLogic()
emit goToPage(Page::Vpn, true, false); emit goToPage(Page::Vpn, true, false);
} }
else { else {
emit goToPage(Page::Start, true, false); emit goToPage(Page::PageStart, true, false);
} }
m_selectedServerIndex = m_settings->defaultServerIndex(); m_selectedServerIndex = m_settings->defaultServerIndex();
@ -619,3 +618,8 @@ bool UiLogic::isContainerAlreadyAddedToGui(DockerContainer container)
return false; return false;
} }
QString UiLogic::pageEnumToString(Page page) {
QMetaEnum metaEnum = QMetaEnum::fromType<Page>();
QString pageName = metaEnum.valueToKey(static_cast<int>(page));
return "Pages2/" + pageName + ".qml";
}

View file

@ -67,7 +67,6 @@ class UiLogic : public QObject
AUTO_PROPERTY(int, pagesStackDepth) AUTO_PROPERTY(int, pagesStackDepth)
AUTO_PROPERTY(int, currentPageValue) AUTO_PROPERTY(int, currentPageValue)
READONLY_PROPERTY(QObject *, containersModel)
READONLY_PROPERTY(QObject *, protocolsModel) READONLY_PROPERTY(QObject *, protocolsModel)
READONLY_PROPERTY(QObject *, clientManagementModel) READONLY_PROPERTY(QObject *, clientManagementModel)
@ -124,6 +123,8 @@ public:
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated); Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
Q_INVOKABLE QString pageEnumToString(PageEnumNS::Page page);
void shareTempFile(const QString &suggestedName, QString ext, const QString& data); void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
static QString getOpenFileName(QWidget *parent = nullptr, static QString getOpenFileName(QWidget *parent = nullptr,
const QString &caption = QString(), const QString &caption = QString(),