-
Notifications
You must be signed in to change notification settings - Fork 13
/
FilesList.qml
724 lines (644 loc) · 20 KB
/
FilesList.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import per.pqy.sysinfo 1.0
ApplicationWindow {
id: mainwindow
visible: true
width: 480
height: 800
title: qsTr("Apktool")
property color textColor: mc.colorValue("user/textColor")
onClosing: {
close.accepted = false;
if(dialogLoader.source!=""&&dialogLoader.source!="qrc:/CopyDialog.qml"){
hideDialogLoader();
}
else if(mc.currentPath != "/"){
mc.singlePress(0);
}
}
function hideAll(){
hidebtmMenu();
hideselectMenu();
hideSettings();
}
function showbtmMenu(type){
//1:copy 2:search 3:delete 4:rename 5:decompile 6:recompile 7:sign 8:open 9: import 10:oat2dex 11:new 12:edit
btmMenu.btn1 = true;
btmMenu.btn2 = false;
btmMenu.btn3 = true;
btmMenu.btn4 = true;
btmMenu.btn5 = true;
btmMenu.btn6 = true;
btmMenu.btn7 = true;
btmMenu.btn8 = true;
btmMenu.btn9 = true;
btmMenu.btn10 = true;
btmMenu.btn11 = true;
btmMenu.btn12 = true;
if(type==="apk"){
btmMenu.btn6 = false;
btmMenu.btn10 = false;
btmMenu.btn12 = false;
}
else if(type==="jar"){
btmMenu.btn6 = false;
btmMenu.btn7 = false;
btmMenu.btn9 = false;
btmMenu.btn10 = false;
btmMenu.btn12 = false;
}
else if(type==="odex"){
btmMenu.btn6 = false;
btmMenu.btn7 = false;
btmMenu.btn9 = false;
btmMenu.btn5 = false;
btmMenu.btn12 = false;
}
else if(type==="@dir@"){
btmMenu.btn2 = true;
btmMenu.btn5 = false;
btmMenu.btn7 = false;
btmMenu.btn8 = false;
btmMenu.btn9 = false;
btmMenu.btn10 = false;
btmMenu.btn12 = false;
}
else if(type==="MultiSelect"){
btmMenu.btn4 = false;
btmMenu.btn5 = false;
btmMenu.btn6 = false;
btmMenu.btn7 = false;
btmMenu.btn8 = false;
btmMenu.btn9 = false;
btmMenu.btn10 = false;
btmMenu.btn11 = false;
btmMenu.btn12 = false;
}
else {
btmMenu.btn6 = false;
btmMenu.btn7 = false;
btmMenu.btn9 = false;
btmMenu.btn5 = false;
btmMenu.btn10 = false;
}
btmMenu.y = root.height - btmMenu.height;
virtualRect.y = 0;
}
function hidebtmMenu(){
virtualRect.y = root.height;
btmMenu.y = root.height;
}
function showMsg(msg){
msgBox.msgStr = msg;
msgBox.txtOpacity = 1.0;
if(msgBoxTimer.running)
msgBoxTimer.stop();
msgBoxTimer.start();
}
function showselectMenu(){
selectMenu.y = 0;
}
function hideselectMenu(){
selectMenu.y = -selectMenu.height;
}
function showhideSettings(){
if(settings.width==0){
settings.opacity = 1;
settings.x = root.width/2;
settings.width = root.width/2-seticon.width;
settings.height = root.height*7/15;
}
else{
settings.x = seticon.x;
settings.width = 0;
settings.height = 0;
settings.opacity = 0;
}
}
function hideSettings(){
settings.x = seticon.x;
settings.width = 0;
settings.height = 0;
settings.opacity = 0;
}
function menuFunction(num){
var _copy = 1;
var _search = 2;
var _delete = 3;
var _rename = 4;
var _decompile = 5;
var _recompile = 6;
var _sign = 7;
var _open = 8;
var _import = 9;
var _oat2dex = 10;
var _new = 11;
var _edit = 12;
if(num===_copy){
mc.saveSelected();
dialogLoader.setSource("qrc:/CopyDialog.qml");
}
else if(num ===_delete){
dialogLoader.setSource("qrc:/DeleteDialog.qml");
}
else if(num ===_rename){
dialogLoader.setSource("qrc:/RenameDialog.qml", {"text":dialogLoader.origName});
}
else if(num ===_decompile){
dialogLoader.setSource("qrc:/DecApk.qml");
}
else if(num ===_recompile){
dialogLoader.setSource("qrc:/RecApk.qml");
}
else if(num === _sign){
mc.signApk(dialogLoader.origName);
}
else if(num === _open){
mc.openFile(dialogLoader.origName);
}
else if(num === _import){
mc.importFramework(dialogLoader.origName);
}
else if(num === _oat2dex){
mc.oat2dex(dialogLoader.origName);
}
else if(num === _new){
dialogLoader.setSource("qrc:/NewDialog.qml");
}
else if(num===_search){
dialogLoader.setSource("qrc:/SearchDialog.qml",{"parentDir":dialogLoader.origName});
}
else if(num===_edit){
// dialogLoader.setSource("qrc:/TxtEditor.qml",{"file": dialogLoader.origName});
}
hidebtmMenu();
}
function hideDialogLoader(){
dialogLoader.setSource("");
}
function settingFunctions(btn){
hideSettings();
if(btn===1)
dialogLoader.setSource("qrc:/TasksList.qml");
else if(btn===2){
if(key.isRegisterd()){
dialogLoader.setSource("qrc:/RegisterInfo.qml");
}
else{
dialogLoader.setSource("qrc:/Register.qml");
}
}
else if(btn===3){
dialogLoader.setSource("qrc:/HelpPage.qml");
}
else if(btn===4){
dialogLoader.setSource("qrc:/Themes.qml");
}
else if(btn===5){
dialogLoader.setSource("qrc:/Options.qml");
}
else if(btn===6){
Qt.quit();
}
else if(btn===7){
dialogLoader.setSource("qrc:/ProcList.qml");
}
}
function registerApp(regKey){
if(regKey.length!==12){
showMsg(qsTr("Invalid length of your key!"));
}
else{
key.verifyKey(regKey);
}
}
function showcopyMenu(){
copyMenu.y = root.height-copyMenu.height;
}
function hidecopyMenu(){
copyMenu.y = root.height;
}
function deleteFiles(){
mc.deleteSelected();
hideDialogLoader();
}
function copyFiles(cover){
if(mc.copySelected(cover)){
hideDialogLoader();
}
else{
showMsg(qsTr("Can not copy to same path!"))
}
}
function cutFiles(cover){
if(mc.cutSelected(cover)){
hideDialogLoader();
}
else{
showMsg(qsTr("Can not cut to same path!"))
}
}
function renameFile(oldName, newName){
mc.rename(oldName, newName);
hideDialogLoader();
}
function newFile(name, type){
mc.createNewFile(name, type);
hideDialogLoader();
}
function decApk(name, options, rootPerm){
hideDialogLoader();
showMsg(qsTr("Added to task list!"));
mc.decApk(name, options, rootPerm);
}
function recApk(name, options, aapt, rootPerm){
hideDialogLoader();
showMsg(qsTr("Added to task list!"));
mc.recApk(name, options, aapt, rootPerm);
}
function createOutput(cmd, output, duration){
var compoment = Qt.createComponent("qrc:/OutPut.qml");
var obj = compoment.createObject(dialogLoader, {"x":0, "y":100, "width": mainwindow.width, "height": mainwindow.height-200,
"cmdText": cmd, "outputText": output, "durationText": qsTr("cost time: %1").arg(duration)});
}
function bugReport(){
hideDialogLoader();
if(!key.isRegisterd())
createOutput("", qsTr("This page is showed because of register bug.\n%1").arg(key.genBugMsg()),"");
}
SysInfo {
id: sysinfo
onMeminfo:{
meminfo.totaltext = total;
meminfo.freetext = free;
meminfo.rectHei = meminfo.height*ratio;
}
onCpuinfo: {
cpuinfo.text = info;
}
}
Connections {
target: mc
onNoPerm: showMsg(qsTr("No access permission!"))
onClickFile: showbtmMenu(type)
onClickDir: showbtmMenu("@dir@")
onFileModelChanged: hideAll()
onDeleteFinished: showMsg(qsTr("Files has been deleted!"))
onGotKey: createOutput("",key,"")
onCopyFinished: showMsg(qsTr("Files has been copied!"))
onCutFinished: showMsg(qsTr("Files has been cut!"))
onSameNameExist: showMsg(qsTr("File with same name exists!"))
// onEditorClosed: dialogLoader.setSource("")
onTaskFinished: createOutput(cmd, output, duration)
onNoBootClass: showMsg(qsTr("Copy boot.oat file to current path first, please. "))
onCombineHelp: showMsg(qsTr("Unsupported operation."))
}
Connections {
target: key
onVerifySuccess: {
showMsg(qsTr("Congratulations! You have registered this app!"));
hideDialogLoader();
}
onVerifyFail: {
showMsg(qsTr("Oops! Your key is invalid! Check it, please."));
}
onVerifyTimeout: {
showMsg(qsTr("Verify timeout! Please try again."));
}
onRegisterBug: {
bugReport();
}
}
Loader {
id: dialogLoader
z: 5
anchors.fill: parent
property string origName
}
Connections {
ignoreUnknownSignals: true
target: dialogLoader.item
onDeletebtn: deleteFiles();
onNobtn: hideDialogLoader();
onRgst: registerApp(regKey);
onCpbtn: copyFiles(cover);
onCutbtn: cutFiles(cover);
onRenamebtn: renameFile(dialogLoader.origName, newName);
onNewfilebtn: newFile(newName, type);
onDecapk: decApk(dialogLoader.origName, options, rootPerm);
onRecapk: recApk(dialogLoader.origName, options, aapt, rootPerm);
onSwitchMem: meminfo.visible = on;
onSwitchCpu: cpuinfo.visible = on;
// onBugreport: bugReport();
}
Rectangle {
id: msgBox
z: 99
anchors.centerIn: parent
property alias msgStr: msg.text
property alias txtOpacity: msg.opacity
Text {
id: msg
color: mainwindow.textColor
opacity: 0
anchors.centerIn: parent
wrapMode: Text.WrapAnywhere
Behavior on opacity {
NumberAnimation {from: 1.0; to: 0.0; duration: 3000; easing.type: Easing.InExpo}
}
}
Timer {
id: msgBoxTimer
interval: 3000;
onTriggered: msgBox.txtOpacity = 0.0
}
}
Image {
id: seticon
source: "qrc:/icons/settings.png"
width: root.height/15
height: width
z: 1
x: root.width-width
y: 0
opacity: 0.7
Behavior on rotation {
NumberAnimation { duration: 990 }
}
MouseArea {
anchors.fill: parent
onClicked: showhideSettings()
onPressAndHold: {mc.genKey();}
}
}
Timer {
id: settingTimer
interval: 1000
repeat: true
running: true
triggeredOnStart: true;
onTriggered: { seticon.rotation+=mc.taskNum*18;}
}
Settings {
id: settings
opacity: 0
width: 0
height: 0
x: seticon.x
y: seticon.y+seticon.height
z: seticon.z
onClicked: settingFunctions(btn);
Behavior on x {
NumberAnimation {
duration: 100
easing.type: Easing.Linear
}
}
Behavior on width {
NumberAnimation {
duration: 100
easing.type: Easing.Linear
}
}
Behavior on height {
NumberAnimation {
duration: 100
easing.type: Easing.Linear
}
}
Behavior on opacity {
NumberAnimation {
duration: 100
easing.type: Easing.Linear
}
}
}
MemInfo {
id: meminfo
width: parent.width/7
height: parent.height/3
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: width
z: 99
visible: mc.boolValue("user/memInfo")
}
Text {
id: cpuinfo
z: 99
opacity: 0.5
width: meminfo.width
anchors.bottom: root.bottom
anchors.top: meminfo.bottom
anchors.topMargin: 20
anchors.left: meminfo.left
visible: mc.boolValue("user/cpuInfo")
}
Image {
id: root
anchors.fill: parent
// color: "#dddddd"
source: "image://ThemeProvider/bg"
opacity: 0.7
property real scrollPos: 0
focus: true
Keys.onPressed: {
if(event.key ==16777301){
showhideSettings();
}
}
ListView {
id: list
anchors.fill: parent
flickDeceleration: 3000
maximumFlickVelocity: 8000
spacing: 0
clip: true
onModelChanged: list.contentY = root.scrollPos;
onFlickEnded: root.scrollPos = contentY;
property bool selectMode: false
model: mc.fileModel
delegate: Image {
id: listItem
height: root.height/mc.intValue("user/itemNum");
width: root.width
//source: "image://ThemeProvider/itembg"
opacity: mouseArea.pressed?0.9:1.0
property alias checked: checkItem.checked
MouseArea {
id:mouseArea
anchors.fill: parent
onClicked: {
if(list.selectMode)
model.modelData.setChecked(!checkItem.checked);
else{
mc.unselectAll();
model.modelData.setChecked(true);
dialogLoader.origName = model.modelData.name;
mc.singlePress(index);
}
}
onPressAndHold: {
mc.unselectAll();
model.modelData.setChecked(true);
dialogLoader.origName = model.modelData.name;
mc.longPress(index);
}
}
Image {
id: icon
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: listItem.height/10
width: height
asynchronous: true
cache: false
source: "image://FileImageProvider/"+mc.currentPath+model.modelData.name
}
CheckBox {
id: checkItem
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: listItem.height/10
anchors.bottomMargin: listItem.height/10
width: height
Component.onCompleted: checked=model.modelData.checked
style: CheckBoxStyle {
indicator: Rectangle {
implicitWidth: checkItem.width/2
implicitHeight: checkItem.height/2
radius: 32
color: "#00000000"
border.color: control.activeFocus ? "darkblue" : "black"
border.width: 1
Rectangle {
visible: control.checked
color: "#555"
border.color: "#333"
radius: 32
// anchors.margins: 4
anchors.fill: parent
}
}
}
onClicked: {
model.modelData.setChecked(checked);
list.selectMode = true;
showselectMenu();
}
Connections {
target: model.modelData
onCheckedChanged: checkItem.checked = model.modelData.checked
}
}
Text {
id: t1
text: model.modelData.name
color: mainwindow.textColor
height: parent.height*2/3
font.pixelSize: height*4/7
anchors.left: icon.right
}
Text {
anchors.top: t1.bottom
anchors.bottom: parent.bottom
anchors.left: icon.right
text: model.modelData.info
color: mainwindow.textColor
height: parent.height*1/3
font.pixelSize: height*5/7
}
}
}
ScrollBar {
flickable: list
}
}
BtmMenu {
id: btmMenu
width:parent.width
height: root.height/3
y: root.height
z: 1
Behavior on y {
NumberAnimation {
duration: 500
easing.type: Easing.OutExpo
}
}
onClicked: menuFunction(num)
}
Rectangle {
id: virtualRect
width: parent.width
height: root.height - btmMenu.height
y: root.height
z: 1
opacity: 0
MouseArea {
anchors.fill: parent
onClicked:{
hidebtmMenu();
}
}
}
Rectangle {
id: selectMenu
width: root.width/3
height: root.height*4/15+3
anchors.horizontalCenter: parent.horizontalCenter
opacity: 0.8
y: -height
z:2
color: "#999999"
Behavior on y {
NumberAnimation {
duration: 500
easing.type: Easing.OutExpo
}
}
Column {
anchors.fill: parent
spacing: 1
property int btnWid: parent.width
property int btnHei: (parent.height-3)/4
MyButton {
id: button1
text: qsTr("Select All")
width: parent.btnWid
height: parent.btnHei
onClicked: mc.selectAll()
}
MyButton {
id: button2
text: qsTr("Reverse Selection")
width: parent.btnWid
height: parent.btnHei
onClicked: mc.reverseSelect()
}
MyButton {
id: button4
text: qsTr("Combine")
width: parent.btnWid
height: parent.btnHei
onClicked: {hideselectMenu();mc.combineApkDex();}
}
MyButton {
id: button3
text: qsTr("Finish Selection")
width: parent.btnWid
height: parent.btnHei
onClicked: {
hideselectMenu();
list.selectMode = false;
if(!mc.noItemSelected())
showbtmMenu("MultiSelect");
}
}
}
}
}