-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.qml
executable file
·235 lines (210 loc) · 7.34 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.LocalStorage 2.0
Window {
id: main
visible: true
width: 320
height: 480
title: qsTr("Mr Noplay Blacklist")
property string toAddName: "appname.app";
onToAddNameChanged: {
listnames.append({name: toAddName})
for (var i = 0; i <= listnames.count; i++) {
if(listnames.get(i).name === toAddName) {
listnames.remove(i);
}
}
listnames.append({name: toAddName})
}
//way: 0=false=blacklist, 1=true=whitelist
property int way: 0;
property var db;
function initDatabase() {
db = LocalStorage.openDatabaseSync("mrnoplay-blacklist", "1.0", "The Blacklist", 100000);
db.transaction( function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS blacklist(name TEXT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS way(selection INTEGER)');
});
}
function readData() {
if(!db) { return; }
db.transaction(function(tx) {
var result = tx.executeSql('select * from blacklist');
for(var i = 0; i < result.rows.length; i++) {
listnames.append({name: result.rows[i].name});
}
var wayresult = tx.executeSql('select * from way');
way = wayresult.rows[0].selection;
combo.currentIndex = way;
});
}
function storeData() {
if(!db) { return; }
db.transaction(function(tx) {
tx.executeSql('DROP TABLE blacklist');
tx.executeSql('CREATE TABLE IF NOT EXISTS blacklist(name TEXT)');
for (var i = 0; i < listnames.count; i++) {
tx.executeSql("INSERT INTO blacklist VALUES ('" + listnames.get(i).name + "')");
}
tx.executeSql('DROP TABLE way');
tx.executeSql('CREATE TABLE IF NOT EXISTS way(selection INTEGER)');
tx.executeSql("INSERT INTO way VALUES ('" + way + "')");
});
}
function cut(original) {
var result = original;
if (Qt.platform.os !== "osx") {
result = ".." + original.slice((original.length - 32) > 0 ? (original.length - 32) : 1 ,original.length);
}
return result;
}
Component.onCompleted: {
initDatabase();
readData();
}
Component.onDestruction: {
storeData();
}
Column {
id: container
width: 320
height: 400
visible: true
anchors.top: parent.top
anchors.topMargin: 15
Row {
id: titlebar
width: 320
height: 20
anchors.top: parent.top
anchors.topMargin: 0
Text {
id: label01
height: 20
text: qsTr("Only Selected Apps are: ")
anchors.top: parent.top
anchors.topMargin: 5
rightPadding: 4
topPadding: 0
leftPadding: 15
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
font.pixelSize: 14
}
ComboBox {
id: combo
width: 110
height: 30
font.pointSize: 9
model: (Qt.platform.os == "mac" || Qt.platform.os == "osx") ? [qsTr("Forbidden"), qsTr("Allowed")] : [qsTr("Forbidden")]
onActivated: {
way = index;
}
}
}
Column {
id: listfather
width: 320
height: 380
anchors.top: parent.top
anchors.topMargin: 40
ListView {
id: list
width: 290
height: 320
anchors.left: parent.left
anchors.leftMargin: 10
anchors.top: parent.top
anchors.topMargin: 20
model: ListModel {
id: listnames
}
delegate: Item {
x: 5
width: 290
height: 30
Row {
id: rowinlist
Column {
id: lefttextsinlist
Text {
text: cut(lefttextsinlist.children[1].text)
font.bold: Qt.platform.os !== "osx" ? true : false;
font.pixelSize: Qt.platform.os == "osx" ? 1 : 11;
color: Qt.platform.os == "osx" ? "white" : "black";
}
Text {
text: name
font.bold: Qt.platform.os == "osx" ? true : false;
font.pixelSize: Qt.platform.os !== "osx" ? 5 : 13;
color: Qt.platform.os !== "osx" ? "grey" : "black";
anchors.top: parent.top;
anchors.topMargin: Qt.platform.os !== "osx" ? 12 : 0;
}
height: 20
width: 250
anchors.verticalCenter: parent.verticalCenter
}
Button {
height: 20
width: 20
Image {
id: imgdelete
source: "assets/delete.png"
height: 12
width: 12
anchors.left: parent.left
anchors.leftMargin: 4
anchors.top: parent.top
anchors.topMargin: 4
}
onClicked: {
for (var i = 0; i < listnames.count; i++) {
if(listnames.get(i).name === name) {
listnames.remove(i);
}
}
}
}
spacing: 20
}
}
}
}
Row {
id: addfather
x: 15
y: 400
width: 290
height: 60
Button {
id: add
width: 90
height: 30
text: qsTr("Add an App")
anchors.bottom: parent.bottom
anchors.bottomMargin: 30
onClicked: {
var component = Qt.createComponent("add.qml");
component.createObject(add).show();
}
}
Text {
id: label02
text: qsTr("Blocks are on only when Mr Noplay is running in workmode.")
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
anchors.left: parent.left
anchors.leftMargin: 0
font.pixelSize: 10
}
}
}
}
/*##^##
Designer {
D{i:2;anchors_y:10}D{i:5;anchors_y:60}D{i:1;anchors_y:15}
}
##^##*/