C
Qt Quick Ultralite Thermostat Demo
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial import QtQuick 2.15 import Thermo 1.0 Item { id: window width: Theme.screenWidth height: Theme.screenHeight function handleViewSwitched(selectedIndex : int) { bottomBar.selected = selectedIndex GlobalState.previousSelectedIndex = GlobalState.selectedIndex GlobalState.selectedIndex = selectedIndex } Image { id: topBarShadow source: "top-bar-shadow.png" anchors.top: topBar.bottom } Rectangle { id: centerBg color: "#F5F7F8" anchors.top: topBarShadow.bottom width: parent.width height: window.height - bottomBar.height - topBarShadow.height } TopBar { id: topBar width: parent.width height: Theme.topBarHeight z: 11 showBackButton: !GlobalState.showMain title: GlobalState.selectedRoom.name onBackClicked: { GlobalState.showMain = true } onSettingsClicked: { languageDialog.show() } } Item { id: mainItem width: parent.width anchors.top: topBar.bottom height: parent.height - topBar.height - bottomBar.height Loader { id: mainView anchors.fill: parent source: "../../PlacesView.qml" Connections { target: GlobalState function onShowMainChanged(showMain: bool) { if (GlobalState.showMain) { GlobalState.selectedIndex = 0 GlobalState.previousSelectedIndex = GlobalState.currentViewIndex GlobalState.selectedRoom.tempChanger.running = true mainItem.height = window.height - topBar.height - bottomBar.height } else { GlobalState.selectedIndex = 3 GlobalState.previousSelectedIndex = GlobalState.currentViewIndex GlobalState.selectedRoom.tempChanger.running = false mainItem.height = window.height - topBar.height } } function onLoadNext() { if (GlobalState.selectedIndex !== GlobalState.currentViewIndex) { switch(GlobalState.selectedIndex) { case 1: GlobalState.scheduleViewLoaded = false mainView.source = "../../ScheduleView.qml" break; case 2: mainView.source = "../../StatsView.qml" break; case 3: mainView.source = "../../RoomView.qml" break; default: GlobalState.placesLoaded = false mainView.source = "../../PlacesView.qml" } GlobalState.currentViewIndex = GlobalState.selectedIndex } } } } } BottomBar { id:bottomBar z: 10 // give precedence to bottom bar touch areas width: parent.width height: Theme.bottomBarHeight anchors.bottom: parent.bottom property int shift: !GlobalState.showMain ? -height : 0 visible: shift > -height Behavior on shift { NumberAnimation { } } anchors.bottomMargin: shift onViewSwitched: handleViewSwitched(index) } LanguageDialog { id: languageDialog anchors.fill: parent z: 11 } Component.onCompleted: { if(Qt.uiLanguage == "") { Qt.uiLanguage = "en_GB" } } }