Debian Codegraph @

qml/generic/Title.qml

raw
1 import QtQuick 2.2
2 import QtQuick.Controls 1.1
3 import QtQuick.Window 2.1
4 import Qt.labs.settings 1.0
5 import "UI" 1.0
6
7 ApplicationWindow {
8 id: window
9 title: "Sachesi " + version
10 width: 820
11 height: 680
12 minimumHeight: 540
13 minimumWidth: 640
14 function isNewer(newV, oldV){
15
16 var result=false;
17
18 if(typeof newV !== 'object'){ newV=newV.toString().split('.'); }
19 if(typeof oldV !== 'object'){ oldV=oldV.toString().split('.'); }
20
21 for(var i=0; i<(Math.max(newV.length, oldV.length)); i++){
22 if(newV[i] == undefined){ newV[i]=0; }
23 if(oldV[i] == undefined){ oldV[i]=0; }
24
25 if(Number(newV[i])>Number(oldV[i])){
26 result=true;
27 break;
28 }
29 if(newV[i] != oldV[i]){
30 break;
31 }
32 }
33 return(result);
34 }
35
36 Component.onCompleted: {
37 var http = new XMLHttpRequest()
38 var url = "https://raw.githubusercontent.com/xsacha/Sachesi/master/Sachesi.pro";
39 http.open("GET", url, true);
40 http.send(null)
41 http.onreadystatechange = function() {
42 if(http.readyState == 4 && http.status == 200) {
43 var array = http.responseText.split('\n');
44 array = array.filter(function(e){return e});
45 for (var i = 1; i < 10; i++) {
46 if (array[i].substring(0, 7) === "VERSION") {
47 var newVer = array[i].split(' ').pop()
48 if (isNewer(newVer, version)) {
49 console.log("NEW VERSION FOUND. DO STUFF HERE")
50 }
51
52 break;
53 }
54 }
55 }
56 }
57 }
58
59 Settings {
60 id: settings
61 property alias x: window.x
62 property alias y: window.y
63 property alias width: window.width
64 property alias height: window.height
65 property url installFolder
66 property url backupFolder
67 property bool advanced: false
68 property bool nativelang: true
69 }
70
71 Label {
72 visible: !mobile
73 id: title
74 font.pointSize: 18
75 text: "SACHESI"
76 font.letterSpacing: (parent.width / 2) / text.length
77 font.weight: Font.DemiBold
78 smooth: true
79 anchors.horizontalCenter: parent.horizontalCenter
80 anchors.horizontalCenterOffset: font.letterSpacing / 2
81 }
82
83 Button {
84 anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 1 }
85 height: title.height + 7; width: height
86 checkable: true
87 checked: settings.advanced
88 onClicked: settings.advanced = !settings.advanced
89 text: checked ? "+H+" : "H"
90 tooltip: qsTr("Advanced") + translator.lang
91 }
92
93 ComboBox {
94 model: [ Qt.locale().nativeLanguageName, "English" ]
95 anchors { right: parent.right; top: parent.top; topMargin: 1 }
96 visible: translator.exists
97 currentIndex: settings.nativelang ? 0 : 1
98
99 onCurrentIndexChanged: {
100 if (currentIndex === 0) {
101 translator.load();
102 settings.nativelang = true;
103 } else {
104 translator.remove();
105 settings.nativelang = false;
106 }
107 }
108 }
109
110 TabView {
111 id: titleRow
112 width: parent.width
113 // Qt5.2 bug requires timer to redraw layout correctly
114 Timer {
115 interval: 10 // Any number works
116 running: true
117 onTriggered: titleRow.currentIndex = 4
118 }
119
120 anchors {top: title.bottom; bottom: parent.bottom }
121
122 Tab {
123 title: qsTr("Device") + translator.lang
124 Device { anchors.fill: parent }
125 }
126 Tab {
127 title: qsTr("Extract") + translator.lang
128 Extract { anchors.fill: parent }
129 }
130 Tab {
131 title: qsTr("Search") + translator.lang
132 Search { anchors.fill: parent }
133 }
134 Tab {
135 title: qsTr("Backup") + translator.lang
136 Backup { anchors.fill: parent }
137 }
138 Tab {
139 title: qsTr("Install") + translator.lang
140 Installer { anchors.fill: parent }
141 }
142
143 USBConnect { anchors.fill: parent }
144 }
145 }