Files
amnezia-client/client/ui/qml/Pages2/PageStart.qml
T

263 lines
7.6 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2023-07-25 16:56:10 +09:00
import QtQuick.Shapes
import PageEnum 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
2023-10-09 20:19:22 +05:00
import "../Components"
PageType {
id: root
property bool isControlsDisabled: false
Connections {
target: PageController
function onGoToPageHome() {
2023-10-09 20:19:22 +05:00
tabBar.setCurrentIndex(0)
2023-08-09 18:17:29 +05:00
tabBarStackView.goToTabBarPage(PageEnum.PageHome)
}
function onGoToPageSettings() {
2023-10-09 20:19:22 +05:00
tabBar.setCurrentIndex(2)
2023-08-09 18:17:29 +05:00
tabBarStackView.goToTabBarPage(PageEnum.PageSettings)
}
function onGoToPageViewConfig() {
var pagePath = PageController.getPagePath(PageEnum.PageSetupWizardViewConfig)
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.PushTransition)
}
2024-02-28 19:39:28 +07:00
function onDisableControls(disabled) {
isControlsDisabled = disabled
2023-08-09 18:17:29 +05:00
}
function onClosePage() {
if (tabBarStackView.depth <= 1) {
return
}
tabBarStackView.pop()
}
2023-09-06 13:37:37 +05:00
function onGoToPage(page, slide) {
var pagePath = PageController.getPagePath(page)
2023-09-06 13:37:37 +05:00
if (slide) {
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.PushTransition)
} else {
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.Immediate)
}
}
function onGoToStartPage() {
2023-10-09 20:19:22 +05:00
connectionTypeSelection.close()
2023-09-06 13:37:37 +05:00
while (tabBarStackView.depth > 1) {
tabBarStackView.pop()
}
}
2024-02-28 19:39:28 +07:00
function onEscapePressed() {
if (root.isControlsDisabled) {
2024-02-28 19:39:28 +07:00
return
}
var pageName = tabBarStackView.currentItem.objectName
if ((pageName === PageController.getPagePath(PageEnum.PageShare)) ||
(pageName === PageController.getPagePath(PageEnum.PageSettings))) {
PageController.goToPageHome()
tabBar.previousIndex = 0
} else {
PageController.closePage()
}
}
}
Connections {
target: InstallController
function onInstallationErrorOccurred(errorMessage) {
PageController.showBusyIndicator(false)
PageController.showErrorMessage(errorMessage)
var needCloseCurrentPage = false
2023-08-02 20:37:43 +09:00
var currentPageName = tabBarStackView.currentItem.objectName
if (currentPageName === PageController.getPagePath(PageEnum.PageSetupWizardInstalling)) {
needCloseCurrentPage = true
} else if (currentPageName === PageController.getPagePath(PageEnum.PageDeinstalling)) {
needCloseCurrentPage = true
}
if (needCloseCurrentPage) {
PageController.closePage()
}
}
function onUpdateContainerFinished(message) {
PageController.showNotificationMessage(message)
PageController.closePage()
}
}
Connections {
target: ConnectionController
function onReconnectWithUpdatedContainer(message) {
PageController.showNotificationMessage(message)
PageController.closePage()
}
2024-02-09 23:23:26 +05:00
function onNoInstalledContainers() {
PageController.setTriggeredByConnectButton(true)
2024-02-09 23:23:26 +05:00
2024-02-19 19:54:15 +05:00
ServersModel.processedIndex = ServersModel.getDefaultServerIndex()
2024-02-09 23:23:26 +05:00
InstallController.setShouldCreateServer(false)
PageController.goToPage(PageEnum.PageSetupWizardEasy)
}
}
Connections {
target: ImportController
2024-03-21 23:29:40 +05:00
function onImportErrorOccurred(errorMessage, goToPageHome) {
PageController.showErrorMessage(errorMessage)
}
}
2024-03-20 21:22:29 +07:00
Connections {
target: SettingsController
function onLoggingDisableByWatcher() {
PageController.showNotificationMessage(qsTr("Logging was disabled after 14 days, log files were deleted"))
}
}
2023-06-01 11:25:33 +08:00
StackViewType {
id: tabBarStackView
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: tabBar.top
2023-05-14 21:11:19 +08:00
width: parent.width
height: root.height - tabBar.implicitHeight
enabled: !root.isControlsDisabled
2023-06-01 11:25:33 +08:00
function goToTabBarPage(page) {
2023-10-09 20:19:22 +05:00
connectionTypeSelection.close()
2023-06-01 11:25:33 +08:00
var pagePath = PageController.getPagePath(page)
tabBarStackView.clear(StackView.Immediate)
tabBarStackView.replace(pagePath, { "objectName" : pagePath }, StackView.Immediate)
}
2023-06-01 11:25:33 +08:00
Component.onCompleted: {
var pagePath = PageController.getPagePath(PageEnum.PageHome)
2024-02-19 19:54:15 +05:00
ServersModel.processedIndex = ServersModel.defaultIndex
tabBarStackView.push(pagePath, { "objectName" : pagePath })
}
}
TabBar {
id: tabBar
2023-10-09 20:19:22 +05:00
property int previousIndex: 0
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
topPadding: 8
2023-07-25 16:56:10 +09:00
bottomPadding: 8
2023-10-09 20:19:22 +05:00
leftPadding: 96
rightPadding: 96
enabled: !root.isControlsDisabled
2023-07-25 16:56:10 +09:00
background: Shape {
width: parent.width
height: parent.height
ShapePath {
startX: 0
startY: 0
PathLine { x: width; y: 0 }
PathLine { x: width; y: height - 1 }
PathLine { x: 0; y: height - 1 }
PathLine { x: 0; y: 0 }
strokeWidth: 1
strokeColor: "#2C2D30"
fillColor: "#1C1D21"
}
}
TabImageButtonType {
isSelected: tabBar.currentIndex === 0
image: "qrc:/images/controls/home.svg"
onClicked: {
tabBarStackView.goToTabBarPage(PageEnum.PageHome)
2024-02-19 19:54:15 +05:00
ServersModel.processedIndex = ServersModel.defaultIndex
2023-10-09 20:19:22 +05:00
tabBar.previousIndex = 0
}
}
2023-10-09 20:19:22 +05:00
TabImageButtonType {
id: shareTabButton
Connections {
target: ServersModel
function onModelReset() {
var hasServerWithWriteAccess = ServersModel.hasServerWithWriteAccess()
shareTabButton.visible = hasServerWithWriteAccess
shareTabButton.width = hasServerWithWriteAccess ? undefined : 0
}
}
visible: ServersModel.hasServerWithWriteAccess()
width: ServersModel.hasServerWithWriteAccess() ? undefined : 0
isSelected: tabBar.currentIndex === 1
image: "qrc:/images/controls/share-2.svg"
2023-06-13 20:03:20 +09:00
onClicked: {
tabBarStackView.goToTabBarPage(PageEnum.PageShare)
2023-10-09 20:19:22 +05:00
tabBar.previousIndex = 1
2023-06-13 20:03:20 +09:00
}
}
2023-10-09 20:19:22 +05:00
TabImageButtonType {
isSelected: tabBar.currentIndex === 2
image: "qrc:/images/controls/settings-2.svg"
onClicked: {
2023-06-01 11:25:33 +08:00
tabBarStackView.goToTabBarPage(PageEnum.PageSettings)
2023-10-09 20:19:22 +05:00
tabBar.previousIndex = 2
}
}
TabImageButtonType {
isSelected: tabBar.currentIndex === 3
image: "qrc:/images/controls/plus.svg"
onClicked: {
connectionTypeSelection.open()
}
}
}
2023-10-09 20:19:22 +05:00
ConnectionTypeSelectionDrawer {
id: connectionTypeSelection
onAboutToHide: {
2023-10-09 20:19:22 +05:00
tabBar.setCurrentIndex(tabBar.previousIndex)
}
}
}