C

Qt Quick Ultralite 热度计演示

/****************************************************************************** ** ** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
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" } } }