-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathmain.qml
118 lines (101 loc) · 3.86 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/****************************************************************************
**
** Copyright (C) VCreate Logic Pvt. Ltd. Bengaluru
** Author: Prashanth N Udupa ([email protected])
**
** This code is distributed under GPL v3. Complete text of the license
** can be found here: https://www.gnu.org/licenses/gpl-3.0.txt
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
import QtQml 2.15
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import io.scrite.components 1.0
import "qrc:/qml"
import "qrc:/qml/globals"
import "qrc:/qml/helpers"
import "qrc:/qml/dialogs"
import "qrc:/qml/controls"
import "qrc:/qml/overlays"
import "qrc:/qml/notifications"
import "qrc:/qml/floatingdockpanels"
Rectangle {
id: scriteRoot
width: 1366
height: 700
color: Runtime.colors.primary.windowColor
Material.primary: Runtime.colors.primary.key
Material.accent: Runtime.colors.accent.key
Material.theme: Material.Light
Material.background: Runtime.colors.accent.c700.background
ScriteMainWindow {
anchors.fill: parent
enabled: !NotificationsView.visible && Runtime.allowAppUsage
}
// Private Section
Component.onCompleted: _private.initialize()
QtObject {
id: _private
function initialize() {
// Initialize runtime
Runtime.init(scriteRoot)
SubscriptionPlanOperations.init(scriteRoot)
// Determine font size provided by QML
determineDefaultFontSize()
// Initialize layers
SubscriptionDetailsDialog.init()
SubscriptionPlanComparisonDialog.init()
UserAccountDialog.init(scriteRoot)
FloatingDockLayer.init(scriteRoot)
OverlaysLayer.init(scriteRoot)
NotificationsLayer.init(scriteRoot)
// Raise window
Scrite.window.raise()
// Show initial UI
if(Scrite.user.loggedIn) {
if(Runtime.allowAppUsage)
showHomeScreenOrOpenFile()
else
UserAccountDialog.launch()
} else {
var splashScreen = SplashScreen.launch()
if(splashScreen)
splashScreen.closed.connect(_private.splashScreenWasClosed)
else
splashScreenWasClosed()
}
}
function determineDefaultFontSize() {
if( Scrite.app.customFontPointSize === 0) {
var textItem = Qt.createQmlObject("import QtQuick 2.15; Text { text: \"Welcome to Scrite\" }", scriteRoot)
if(textItem) {
Scrite.app.customFontPointSize = textItem.font.pointSize
textItem.destroy()
}
}
}
function splashScreenWasClosed() {
if(Scrite.app.isWindowsPlatform && Scrite.app.isNotWindows10) {
MessageBox.information("",
"The Windows version of Scrite works best on Windows 10 or higher. While it may work on earlier versions of Windows, we don't actively test on them. We recommend that you use Scrite on PCs with Windows 10 or higher.",
_private.showHomeScreenOrOpenFile
)
} else if(Runtime.allowAppUsage)
showHomeScreenOrOpenFile()
else
UserAccountDialog.launch()
}
function showHomeScreenOrOpenFile() {
if(Scrite.fileNameToOpen === "") {
if(!Scrite.app.maybeOpenAnonymously())
HomeScreen.launch()
} else
Scrite.document.open(Scrite.fileNameToOpen)
}
}
}