main.qml (2225B)
1 import QtQuick 2 import QtQuick.Window 3 4 Window { 5 id: mainWindow 6 visible: true 7 width: 900 8 height: 700 9 minimumWidth: 800 10 minimumHeight: 600 11 title: "Beegram" 12 13 // Simple stack-based navigation using Loader 14 property var navigationStack: [] 15 property var stackView: stackViewItem // Expose for child views 16 property bool credentialsChecked: false 17 18 Component.onCompleted: { 19 // Check for saved credentials on startup 20 NetworkManager.checkSavedCredentials() 21 } 22 23 // Handle auto-login result 24 Connections { 25 target: NetworkManager 26 27 function onAutoLoginSuccess() { 28 credentialsChecked = true 29 stackViewItem.replace("qrc:/qml/views/ChatListView.qml") 30 } 31 32 function onAutoLoginFailed(reason) { 33 credentialsChecked = true 34 // Show "Get Started" button on splash screen 35 if (contentLoader.item) { 36 contentLoader.item.showGetStartedButton = true 37 } 38 } 39 } 40 41 Item { 42 id: stackViewItem 43 anchors.fill: parent 44 45 Loader { 46 id: contentLoader 47 anchors.fill: parent 48 source: "qrc:/qml/views/SplashView.qml" 49 50 onLoaded: { 51 if (item) { 52 item.anchors.fill = contentLoader 53 } 54 } 55 } 56 57 // Navigation functions 58 function push(source, properties) { 59 // Save current state 60 if (contentLoader.source != "") { 61 navigationStack.push({ 62 source: contentLoader.source, 63 properties: {} 64 }) 65 } 66 67 // Load new page 68 contentLoader.setSource(source, properties || {}) 69 } 70 71 function pop() { 72 if (navigationStack.length > 0) { 73 var prev = navigationStack.pop() 74 contentLoader.setSource(prev.source, prev.properties) 75 } 76 } 77 78 function replace(source, properties) { 79 // Clear navigation stack and load new page 80 navigationStack = [] 81 contentLoader.setSource(source, properties || {}) 82 } 83 } 84 }