added PageLoader and pageController
This commit is contained in:
parent
116fa6777b
commit
03a0e2084a
27 changed files with 265 additions and 193 deletions
|
@ -118,6 +118,9 @@ void AmneziaApplication::init()
|
|||
m_vpnConnection.get(), &VpnConnection::disconnectFromVpn, Qt::QueuedConnection);
|
||||
m_engine->rootContext()->setContextProperty("ConnectionController", m_connectionController.get());
|
||||
|
||||
m_pageController.reset(new PageController(m_serversModel));
|
||||
m_engine->rootContext()->setContextProperty("PageController", m_pageController.get());
|
||||
|
||||
//
|
||||
m_uiLogic->registerPagesLogic();
|
||||
|
||||
|
@ -185,6 +188,7 @@ void AmneziaApplication::registerTypes()
|
|||
|
||||
//
|
||||
Vpn::declareQmlVpnConnectionStateEnum();
|
||||
PageLoader::declareQmlPageEnum();
|
||||
}
|
||||
|
||||
void AmneziaApplication::loadFonts()
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
|
||||
#include "ui/uilogic.h"
|
||||
#include "configurators/vpn_configurator.h"
|
||||
|
||||
#include "ui/models/servers_model.h"
|
||||
#include "ui/models/containers_model.h"
|
||||
#include "ui/controllers/connectionController.h"
|
||||
#include "ui/controllers/pageController.h"
|
||||
|
||||
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
||||
|
||||
|
@ -66,6 +68,7 @@ private:
|
|||
QScopedPointer<VpnConnection> m_vpnConnection;
|
||||
|
||||
QScopedPointer<ConnectionController> m_connectionController;
|
||||
QScopedPointer<PageController> m_pageController;
|
||||
|
||||
};
|
||||
|
||||
|
|
5
client/images/controls/download.svg
Normal file
5
client/images/controls/download.svg
Normal 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="M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M7 10L12 15L17 10" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M12 15V3" stroke="#CBCBCB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 574 B |
|
@ -226,5 +226,6 @@
|
|||
<file>images/connectionProgress.svg</file>
|
||||
<file>images/connectionOff.svg</file>
|
||||
<file>images/connectionOn.svg</file>
|
||||
<file>images/controls/download.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
25
client/ui/controllers/pageController.cpp
Normal file
25
client/ui/controllers/pageController.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "pageController.h"
|
||||
|
||||
PageController::PageController(const QSharedPointer<ServersModel> &serversModel,
|
||||
QObject *parent) : QObject(parent), m_serversModel(serversModel)
|
||||
{
|
||||
}
|
||||
|
||||
void PageController::setStartPage()
|
||||
{
|
||||
if (m_serversModel->getServersCount()) {
|
||||
if (m_serversModel->getDefaultServerIndex() < 0) {
|
||||
m_serversModel->setDefaultServerIndex(0);
|
||||
}
|
||||
emit goToPage(PageLoader::PageEnum::PageStart, false);
|
||||
} else {
|
||||
emit goToPage(PageLoader::PageEnum::PageSetupWizardStart, false);
|
||||
}
|
||||
}
|
||||
|
||||
QString PageController::getPagePath(PageLoader::PageEnum page)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<PageLoader::PageEnum>();
|
||||
QString pageName = metaEnum.valueToKey(static_cast<int>(page));
|
||||
return "Pages2/" + pageName + ".qml";
|
||||
}
|
50
client/ui/controllers/pageController.h
Normal file
50
client/ui/controllers/pageController.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#ifndef PAGECONTROLLER_H
|
||||
#define PAGECONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
|
||||
#include "ui/models/servers_model.h"
|
||||
|
||||
namespace PageLoader
|
||||
{
|
||||
Q_NAMESPACE
|
||||
enum class PageEnum { PageStart = 0, PageHome, PageSettings, PageShare,
|
||||
|
||||
PageSetupWizardStart, PageTest, PageSetupWizardCredentials, PageSetupWizardProtocols, PageSetupWizardEasy,
|
||||
PageSetupWizardProtocolSettings, PageSetupWizardInstalling, PageSetupWizardConfigSource,
|
||||
PageSetupWizardTextKey
|
||||
};
|
||||
Q_ENUM_NS(PageEnum)
|
||||
|
||||
static void declareQmlPageEnum() {
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
PageLoader::staticMetaObject,
|
||||
"PageEnum",
|
||||
1, 0,
|
||||
"PageEnum",
|
||||
"Error: only enums"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PageController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PageController(const QSharedPointer<ServersModel> &serversModel,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void setStartPage();
|
||||
QString getPagePath(PageLoader::PageEnum page);
|
||||
|
||||
signals:
|
||||
void goToPage(PageLoader::PageEnum page, bool slide = true);
|
||||
void closePage();
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
};
|
||||
|
||||
#endif // PAGECONTROLLER_H
|
|
@ -56,6 +56,7 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
//todo mode to setData?
|
||||
void ServersModel::setDefaultServerIndex(int index)
|
||||
{
|
||||
// beginResetModel();
|
||||
|
@ -63,11 +64,16 @@ void ServersModel::setDefaultServerIndex(int index)
|
|||
// endResetModel();
|
||||
}
|
||||
|
||||
int ServersModel::getDefaultServerIndex()
|
||||
const int ServersModel::getDefaultServerIndex()
|
||||
{
|
||||
return m_settings->defaultServerIndex();
|
||||
}
|
||||
|
||||
const int ServersModel::getServersCount()
|
||||
{
|
||||
return m_settings->serversCount();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ServersModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[DescRole] = "desc";
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
|
||||
public slots:
|
||||
void setDefaultServerIndex(int index);
|
||||
int getDefaultServerIndex();
|
||||
const int getDefaultServerIndex();
|
||||
const int getServersCount();
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
|
|
@ -7,15 +7,8 @@ import ConnectionState 1.0
|
|||
Button {
|
||||
id: root
|
||||
|
||||
property var isConnected: ConnectionController.isConnected
|
||||
|
||||
text: "Подключиться"
|
||||
|
||||
// implicitHeight: 190
|
||||
// implicitWidth: 190
|
||||
|
||||
// color: "transparent"
|
||||
|
||||
background: Image {
|
||||
id: border
|
||||
|
||||
|
@ -54,7 +47,6 @@ Button {
|
|||
|
||||
onClicked: {
|
||||
ConnectionController.onConnectionButtonClicked()
|
||||
console.log(connectionProccess.from)
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
|
@ -154,6 +154,10 @@ Item {
|
|||
anchors.topMargin: 16
|
||||
anchors.leftMargin: 16
|
||||
anchors.rightMargin: 16
|
||||
|
||||
backButtonFunction: function() {
|
||||
root.menuVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
|
@ -190,6 +194,7 @@ Item {
|
|||
id: loader
|
||||
sourceComponent: root.menuDelegate
|
||||
property QtObject modelData: model
|
||||
property var delegateIndex: index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ Item {
|
|||
onClicked: {
|
||||
if (backButtonFunction && typeof backButtonFunction === "function") {
|
||||
backButtonFunction()
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ Item {
|
|||
onClicked: {
|
||||
if (backButtonFunction && typeof backButtonFunction === "function") {
|
||||
backButtonFunction()
|
||||
} else {
|
||||
PageController.closePage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,5 +3,35 @@ import QtQuick.Controls
|
|||
|
||||
StackView {
|
||||
id: stackView
|
||||
initialItem: "PageSetupWizardStart"
|
||||
|
||||
function gotoPage(page, slide) {
|
||||
if (slide) {
|
||||
stackView.push(PageController.getPagePath(page), {}, StackView.PushTransition)
|
||||
} else {
|
||||
stackView.push(PageController.getPagePath(page), {}, StackView.Immediate)
|
||||
}
|
||||
}
|
||||
|
||||
function closePage() {
|
||||
if (stackView.depth <= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
stackView.pop()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PageController
|
||||
function onGoToPage(page, slide) {
|
||||
stackView.gotoPage(page, slide)
|
||||
}
|
||||
|
||||
function onClosePage() {
|
||||
stackView.closePage()
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
PageController.setStartPage()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,13 @@ import PageEnum 1.0
|
|||
import ProtocolEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
import "../Components"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageHome
|
||||
|
||||
property string defaultColor: "#1C1D21"
|
||||
|
||||
|
@ -143,10 +141,6 @@ PageBase {
|
|||
ValueFilter {
|
||||
roleName: "serviceType"
|
||||
value: ProtocolEnum.Vpn
|
||||
},
|
||||
ValueFilter {
|
||||
roleName: "isInstalled"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -196,6 +190,19 @@ PageBase {
|
|||
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 {
|
||||
|
@ -207,10 +214,33 @@ PageBase {
|
|||
|
||||
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
|
||||
|
||||
// todo remove dirty hack?
|
||||
text: {
|
||||
if (modelData !== null) {
|
||||
return modelData.name
|
||||
|
@ -228,22 +258,26 @@ PageBase {
|
|||
Layout.topMargin: 20
|
||||
Layout.bottomMargin: 20
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "qrc:/images/controls/check.svg"
|
||||
visible: containerRadioButton.checked
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
Layout.rightMargin: 8
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
modelData.isDefault = true
|
||||
|
||||
containersDropDown.text = containerRadioButtonText.text
|
||||
containersDropDown.menuVisible = false
|
||||
} else {
|
||||
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(delegateIndex))
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
containersDropDown.menuVisible = false
|
||||
menu.visible = false
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: containerRadioButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,6 +360,10 @@ PageBase {
|
|||
indicator: Rectangle {
|
||||
anchors.fill: parent
|
||||
color: serverRadioButton.hovered ? "#2C2D30" : "#1C1D21"
|
||||
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
@ -370,6 +408,12 @@ PageBase {
|
|||
ServersModel.setDefaultServerIndex(index)
|
||||
ContainersModel.setSelectedServerIndex(index)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: serverRadioButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,12 @@ import QtQuick.Dialogs
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
@ -100,7 +98,7 @@ PageBase {
|
|||
iconImage: "qrc:/images/controls/text-cursor.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardTextKey)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardTextKey)
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
|
|
|
@ -5,13 +5,11 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardCredentials
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
@ -61,7 +59,7 @@ PageBase {
|
|||
text: qsTr("Настроить сервер простым образом")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +77,7 @@ PageBase {
|
|||
text: qsTr("Выбрать протокол для установки")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardProtocols)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocols)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,11 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardEasy
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardProtocolSettings
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
@ -90,7 +88,7 @@ PageBase {
|
|||
text: qsTr("Установить")
|
||||
|
||||
onClicked: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,11 @@ import PageEnum 1.0
|
|||
import ProtocolEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardProtocols
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
|
@ -89,7 +87,7 @@ PageBase {
|
|||
|
||||
onClickedFunc: function() {
|
||||
ContainersModel.setCurrentlyInstalledContainerIndex(proxyContainersModel.mapToSource(index))
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardStart
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
@ -77,7 +75,7 @@ PageBase {
|
|||
text: qsTr("У меня ничего нет")
|
||||
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.PageTest)
|
||||
PageController.goToPage(PageEnum.PageTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +130,7 @@ PageBase {
|
|||
buttonImage: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardCredentials)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardCredentials)
|
||||
drawer.visible = false
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +146,7 @@ PageBase {
|
|||
buttonImage: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
onClickedFunc: function() {
|
||||
UiLogic.goToPage(PageEnum.PageSetupWizardConfigSource)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardConfigSource)
|
||||
drawer.visible = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageSetupWizardInstalling
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
|
@ -68,7 +66,7 @@ PageBase {
|
|||
text: qsTr("Подключиться")
|
||||
|
||||
onClicked: function() {
|
||||
// UiLogic.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
// PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.PageStart
|
||||
|
||||
StackLayout {
|
||||
id: stackLayout
|
||||
|
|
|
@ -4,15 +4,12 @@ import QtQuick.Layouts
|
|||
import PageEnum 1.0
|
||||
|
||||
import "./"
|
||||
import "../Pages"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
PageBase {
|
||||
Item {
|
||||
id: root
|
||||
page: PageEnum.Test
|
||||
logic: ViewConfigLogic
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
|
|
|
@ -22,83 +22,14 @@ Window {
|
|||
|
||||
title: "AmneziaVPN"
|
||||
|
||||
function gotoPage(page, reset, slide) {
|
||||
if (pageStackView.depth > 0) {
|
||||
pageStackView.currentItem.deactivated()
|
||||
}
|
||||
|
||||
if (slide) {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
|
||||
} else {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
|
||||
}
|
||||
|
||||
pageStackView.currentItem.activated(reset)
|
||||
}
|
||||
|
||||
function closePage() {
|
||||
if (pageStackView.depth <= 1) {
|
||||
return
|
||||
}
|
||||
pageStackView.currentItem.deactivated()
|
||||
pageStackView.pop()
|
||||
}
|
||||
|
||||
function setStartPage(page, slide) {
|
||||
if (pageStackView.depth > 0) {
|
||||
pageStackView.currentItem.deactivated()
|
||||
}
|
||||
|
||||
pageStackView.clear()
|
||||
if (slide) {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.PushTransition)
|
||||
} else {
|
||||
pageStackView.push(UiLogic.pageEnumToString(page), {}, StackView.Immediate)
|
||||
}
|
||||
if (page === PageEnum.Start) {
|
||||
UiLogic.pushButtonBackFromStartVisible = !pageStackView.empty
|
||||
UiLogic.onUpdatePage();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#0E0E11"
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: pageStackView
|
||||
PageLoader {
|
||||
id: pageLoader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: UiLogic
|
||||
function onGoToPage(page, reset, slide) {
|
||||
root.gotoPage(page, reset, slide)
|
||||
}
|
||||
|
||||
function onClosePage() {
|
||||
root.closePage()
|
||||
}
|
||||
|
||||
function onSetStartPage(page, slide) {
|
||||
root.setStartPage(page, slide)
|
||||
}
|
||||
|
||||
function onShow() {
|
||||
root.show()
|
||||
UiLogic.initializeUiLogic()
|
||||
}
|
||||
|
||||
function onHide() {
|
||||
root.hide()
|
||||
}
|
||||
|
||||
function onRaise() {
|
||||
root.show()
|
||||
root.raise()
|
||||
root.requestActivate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -617,9 +617,3 @@ bool UiLogic::isContainerAlreadyAddedToGui(DockerContainer container)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString UiLogic::pageEnumToString(Page page) {
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Page>();
|
||||
QString pageName = metaEnum.valueToKey(static_cast<int>(page));
|
||||
return "Pages2/" + pageName + ".qml";
|
||||
}
|
||||
|
|
|
@ -123,8 +123,6 @@ public:
|
|||
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
|
||||
|
||||
Q_INVOKABLE QString pageEnumToString(PageEnumNS::Page page);
|
||||
|
||||
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
||||
static QString getOpenFileName(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue