-
Notifications
You must be signed in to change notification settings - Fork 5
/
UI.py
1403 lines (1217 loc) · 62.8 KB
/
UI.py
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
Copyright 2023 by RicardoJackMC
Teaching Material Download Manager 使用 GPLv3 许可证
本文件是 Teaching Material Download Manager 的一部分
请自行前往
https://github.com/RicardoJackMC/Teaching-Material-Download-Manager
或
https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager
根据版本号校验本文件MD5
"""
# Form implementation generated from reading ui file 'UI.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import json
import os
import sys
import time
import webbrowser
import winreg
from functools import partial
import requests
import resources_rc
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QCoreApplication, QPoint, QEvent
from PyQt5.QtGui import QColor, QPainter, QIcon, QPixmap
from PyQt5.QtWidgets import QFileDialog, QTableWidgetItem, QListWidgetItem, QWidget, QPushButton, \
QVBoxLayout, QHBoxLayout, QLabel
from qfluentwidgets import BodyLabel, ComboBox, HyperlinkButton, IndeterminateProgressRing, LineEdit, ListWidget, \
ToolButton, ProgressRing, PushButton, SegmentedWidget, SpinBox, SwitchButton, TableWidget, TextEdit, FluentIcon, \
Dialog, InfoBarIcon, Flyout, InfoBarPosition, InfoBar, setThemeColor, RoundMenu, Action, MenuAnimationType, \
TransparentToolButton, CardWidget, IconWidget, CaptionLabel, SubtitleLabel, StateToolTip
DISPLAY_MODE = 0
class RoundWindow(QWidget):
def __init__(self, parent=None):
super(RoundWindow, self).__init__(parent)
self.border_width = 8
def paintEvent(self, event):
global DISPLAY_MODE
pat = QPainter(self)
pat.setRenderHint(pat.Antialiasing)
if DISPLAY_MODE == 1:
pat.setBrush(QColor(243, 243, 243, 255))
else:
pat.setBrush(QColor(32, 32, 32, 255))
pat.setPen(Qt.transparent)
rect = self.rect()
rect.setLeft(9)
rect.setTop(9)
rect.setWidth(rect.width() - 9)
rect.setHeight(rect.height() - 9)
pat.drawRoundedRect(rect, 15, 15)
class update_func(QThread):
return_result = pyqtSignal(str)
def __init__(self):
super().__init__()
self.version = 'Ver.1.1.0_202308281300'
self.api = None
self.result = 'False'
def run(self):
try:
response = requests.get(self.api)
data = response.json()
latest_version = data['tag_name']
if self.version != latest_version:
self.result = 'True'
else:
self.result = 'False'
except:
self.result = 'Error'
self.return_result.emit(self.result)
class normal_info(QThread):
# 负责与下载进程通讯的线程
get_info_signal = pyqtSignal() # 从主线程获取信息, 以及通知主线程完成下载所需的设置
update_state_signal = pyqtSignal(str) # 更新下载状态, 即基本信息里的state
update_progress_signal = pyqtSignal(int) # 更新下载进度, 即基本信息里的那个圈圈
update_download_data_signal = pyqtSignal(dict) # 更新下载日志
update_basic_info = pyqtSignal(dict) # 更新基本信息
def __init__(self):
super().__init__()
self.pre_KEY = []
self.Manager_start = False # 一个旗标变量, 目的是达到自动下载的效果
self.setting_finish = False # 同样是旗标变量, 确保从主线程获取完整的信息以及确保主进程已完成下载所需的设置
self.command = {} # 发送给下载进程的下载参数
self.queue = None
self.pre_progress = None
def run(self):
self.filter()
def producer(self, type_info, info):
data_info = {type_info: info}
self.queue.put(data_info)
def filter(self):
# 用于区分来自下载进程的命令
# 这是为了应对Queue的特性, 防止重复执行
while True:
print('queue running')
try:
info = self.queue.get()
if 'KEY' in info:
if info['KEY'] not in self.pre_KEY:
self.pre_KEY.append(info['KEY'])
if 'state' in info:
self.update_state_signal.emit(info['state'])
if 'progress' in info:
if info['progress'] != self.pre_progress:
self.update_progress_signal.emit(info['progress'])
self.pre_progress = info['progress']
if 'download_data' in info:
self.update_download_data_signal.emit(info['download_data'])
if 'basic_info' in info:
self.update_basic_info.emit(info['basic_info'])
except:
pass
class admin_info(QThread):
finish_signal = pyqtSignal(str) # 完成下载
return_download_url = pyqtSignal(dict) # 把pdf的下载链接更新到文本框
def __init__(self):
super().__init__()
self.Manager_start = False
self.queue_admin = None
self.finish = False
self.pre_KEY = []
def run(self):
while True:
print('admin running')
info_admin = self.queue_admin.get()
if 'KEY' in info_admin:
if info_admin['KEY'] not in self.pre_KEY:
if 'result' in info_admin:
self.finish_signal.emit(info_admin['result'])
self.finish = True
if 'download_url' in info_admin:
self.return_download_url.emit(info_admin['download_url'])
class AppCard(CardWidget):
""" App card """
def __init__(self, icon, title, content, state=None, parent=None):
super().__init__(parent)
self.parent_ = parent
self.update_api = [{'text': '通过GitHub检查更新',
'url': 'https://api.github.com/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest'},
{'text': '通过Gitee检查更新 (推荐)',
'url': 'https://gitee.com/api/v5/repos/RicardoJackMC/Teaching-Material-Download-Manager/releases/latest'}
]
self.feedback_url = [{'text': '前往GitHub上提出Issue',
'url': 'https://github.com/RicardoJackMC/Teaching-Material-Download-Manager/issues'},
{'text': '前往Gitee提出Issue (推荐)',
'url': 'https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager/issues'},
{'text': '通过邮件暴击作者 (推荐)',
'url': 'mailto:ricardojackmc@gmail.com'}
]
self.repos_url = [
{'text': '前往GitHub仓库',
'url': 'https://github.com/RicardoJackMC/Teaching-Material-Download-Manager'},
{'text': '前往Gitee仓库 (推荐)',
'url': 'https://gitee.com/RicardoJackMC/Teaching-Material-Download-Manager'}
]
self.dictionary = {'more_update': self.update_api,
'more_code': self.repos_url,
'more_feedback': self.feedback_url}
self.iconWidget = IconWidget(icon)
self.titleLabel = BodyLabel(title, self)
self.contentLabel = CaptionLabel(content, self)
self.tranparentToolButton = TransparentToolButton(FluentIcon.MORE, self)
self.hBoxLayout = QHBoxLayout(self)
self.vBoxLayout = QVBoxLayout()
self.setFixedHeight(73)
self.iconWidget.setFixedSize(20, 20)
self.contentLabel.setTextColor("#606060", "#d2d2d2")
self.tranparentToolButton.setFixedWidth(32)
self.hBoxLayout.addWidget(self.tranparentToolButton, 0, Qt.AlignRight)
self.hBoxLayout.setContentsMargins(20, 11, 11, 11)
self.hBoxLayout.setSpacing(15)
self.hBoxLayout.addWidget(self.iconWidget)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
self.vBoxLayout.setSpacing(0)
self.vBoxLayout.addWidget(self.titleLabel, 0, Qt.AlignVCenter)
self.vBoxLayout.addWidget(self.contentLabel, 0, Qt.AlignVCenter)
self.vBoxLayout.setAlignment(Qt.AlignVCenter)
self.hBoxLayout.addLayout(self.vBoxLayout)
self.hBoxLayout.addStretch(1)
self.hBoxLayout.addWidget(self.tranparentToolButton, 0, Qt.AlignRight)
self.tranparentToolButton.clicked.connect(partial(self.button_signal, state))
self.update_func = update_func()
self.update_func.return_result.connect(self.update_slot)
def button_signal(self, state):
if state in self.dictionary:
self.more_menu(state)
else:
self.open_url(state)
def open_url(self, url):
if 'latest' in url:
self.update_soft(url)
else:
webbrowser.open_new(url)
def update_soft(self, api):
self.update_func.api = api
self.parent_.state_tool_tip_func()
self.update_func.start()
def update_slot(self, result):
self.parent_.state_tool_tip_func()
self.parent_.analyze_result(result)
def more_menu(self, state):
menu = RoundMenu(parent=self)
for item in self.dictionary[state]:
action = Action(FluentIcon.SHARE, item['text'], self)
action.triggered.connect(partial(self.open_url, item['url']))
menu.addAction(action)
x = (self.tranparentToolButton.width() - menu.sizeHint().width()) // 2 + 10
pos = self.tranparentToolButton.mapToGlobal(QPoint(x, self.tranparentToolButton.height()))
menu.exec(pos)
class AboutWindow(RoundWindow, QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.stateTooltip = None
def setupUi(self, QWidget):
self.setObjectName("About")
self.setWindowTitle('About')
self.setWindowIcon(QIcon(':/recourse/logo.ico'))
self.resize(1010, 714)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.centralwidget = QtWidgets.QWidget(self)
QtCore.QMetaObject.connectSlotsByName(self)
ICON = QLabel(self.centralwidget)
ICON.setGeometry(QtCore.QRect(405, 40, 200, 200))
pixmap = QPixmap(':/recourse/logo.png')
ICON.setPixmap(pixmap)
ICON.setScaledContents(True)
title = SubtitleLabel('Teaching Material Download Manager', self.centralwidget)
title.setGeometry(QtCore.QRect(330, 230, 350, 30))
copyright_label = BodyLabel('Copyright 2023 by RicardoJackMC', self.centralwidget)
copyright_label.setGeometry(QtCore.QRect(397, 260, 211, 20))
version = CaptionLabel('Ver.1.1.0_202308281300', self.centralwidget)
version.setGeometry(QtCore.QRect(439, 284, 127, 10))
tip = CaptionLabel('请前往本项目GitHub仓库获取更新或根据版本号校验MD5', self.centralwidget)
tip.setGeometry(QtCore.QRect(348, 295, 310, 20))
fight = BodyLabel('!! 坚决反对日本排放福岛核污染水 !!', self.centralwidget)
fight.setGeometry(QtCore.QRect(395, 18, 220, 20))
Subtitle_1 = BodyLabel('关于本软件', self.centralwidget)
Subtitle_1.setGeometry(QtCore.QRect(41, 344, 460, 30))
card_about_update = AppCard(FluentIcon.CERTIFICATE, "检查更新",
"点击右侧“...”检查更新",
'more_update', self)
card_about_update.setGeometry(QtCore.QRect(40, 374, 460, 80))
card_about_gpl = AppCard(FluentIcon.CERTIFICATE, "本软件使用 GPLv3 许可证",
"点击右侧“...”阅读GPLv3许可证原文",
'https://www.gnu.org/licenses/gpl-3.0.html#license-text', self.centralwidget)
card_about_gpl.setGeometry(QtCore.QRect(40, 449, 460, 80))
card_source_code = AppCard(FluentIcon.CODE, "获取源代码",
"点击右侧“...”访问本软件仓库",
'more_code',
self.centralwidget)
card_source_code.setGeometry(QtCore.QRect(40, 524, 460, 80))
card_feedback = AppCard(FluentIcon.FEEDBACK, "反馈",
"点击右侧“...”联系作者",
state='more_feedback', parent=self.centralwidget)
card_feedback.setGeometry(QtCore.QRect(40, 599, 460, 80))
Subtitle_2 = BodyLabel('支持', self.centralwidget)
Subtitle_2.setGeometry(QtCore.QRect(510, 344, 460, 30))
card_website = AppCard(FluentIcon.HOME_FILL, "惰猫の小窝",
"点击右侧“...”前往作者的个人网站",
'https://ricardojackmc.github.io/', self.centralwidget)
card_website.setGeometry(QtCore.QRect(510, 374, 460, 80))
card_qfluentwidgets = AppCard(':/recourse/qfluentwidgets_logo.png', "PyQt-Fluent-Widgets",
'本软件界面基于此项目开发, 点击右侧“...”前往该项目GitHub仓库',
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets', self.centralwidget)
card_qfluentwidgets.setGeometry(QtCore.QRect(510, 449, 460, 30))
card_icon = AppCard(FluentIcon.GITHUB, "fluentui-system-icons",
"本软件图标基于此项目制作, 点击右侧“...”前往该项目GitHub仓库",
"https://github.com/microsoft/fluentui-system-icons", self.centralwidget)
card_icon.setGeometry(QtCore.QRect(510, 524, 460, 30))
pushButton_close = QPushButton(self.centralwidget)
pushButton_close.setGeometry(QtCore.QRect(20, 20, 15, 15))
pushButton_close.setMinimumSize(QtCore.QSize(15, 15))
pushButton_close.setMaximumSize(QtCore.QSize(15, 15))
pushButton_close.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
pushButton_close.setFocusPolicy(QtCore.Qt.NoFocus)
pushButton_close.setStyleSheet(
"QPushButton{background:#F76677;border-radius:7px;}\n"
"QPushButton:hover{background:red;}")
pushButton_close.setText("")
pushButton_close.setObjectName("pushButton_close")
pushButton_maximize = QPushButton(self.centralwidget)
pushButton_maximize.setGeometry(QtCore.QRect(40, 20, 15, 15))
pushButton_maximize.setMinimumSize(QtCore.QSize(15, 15))
pushButton_maximize.setMaximumSize(QtCore.QSize(15, 15))
pushButton_maximize.setFocusPolicy(QtCore.Qt.NoFocus)
pushButton_maximize.setStyleSheet(
"QPushButton{background:#F7D674;border-radius:7px;}\n"
"QPushButton:hover{background:yellow;}")
pushButton_maximize.setText("")
pushButton_maximize.setObjectName("pushButton_maximize")
pushButton_maximize.setEnabled(False)
pushButton_minimize = QPushButton(self.centralwidget)
pushButton_minimize.setGeometry(QtCore.QRect(60, 20, 15, 15))
pushButton_minimize.setMinimumSize(QtCore.QSize(15, 15))
pushButton_minimize.setMaximumSize(QtCore.QSize(15, 15))
pushButton_minimize.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
pushButton_minimize.setFocusPolicy(QtCore.Qt.NoFocus)
pushButton_minimize.setStyleSheet(
"QPushButton{background:#6DDF6D;border-radius:7px;}\n"
"QPushButton:hover{background:green;}")
pushButton_minimize.setText("")
pushButton_minimize.setObjectName("pushButton_minimize")
pushButton_close.clicked.connect(self.close)
pushButton_minimize.clicked.connect(self.showMinimized)
def state_tool_tip_func(self):
if self.stateTooltip:
self.stateTooltip.setContent('完成!!!')
self.stateTooltip.setState(True)
self.stateTooltip = None
else:
self.stateTooltip = StateToolTip('正在检查更新', '检查更新中...', self)
self.stateTooltip.move(700, 30)
self.stateTooltip.show()
def analyze_result(self, result):
if result == 'True':
title = '发现新版本!!!'
content = """可以前往本项目仓库或网盘下载新版本哦!"""
w = Dialog(title, content, self)
w.yesButton.setText('知道辣!')
w.cancelButton.setVisible(False)
if w.exec():
pass
elif result == 'False':
title = '当前版本是最新版!!!'
content = """当前版本是最新版呢!如果有bug记得告诉作者哦!"""
w = Dialog(title, content, self)
w.yesButton.setText('知道辣!')
w.cancelButton.setVisible(False)
if w.exec():
pass
elif result == 'Error':
title = '无法检查更新!!!'
content = """建议检查网络设置!如果发现bug记得告诉作者哦!"""
w = Dialog(title, content, self)
w.yesButton.setText('知道辣!')
w.cancelButton.setVisible(False)
if w.exec():
pass
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.mouse_flag = True
self.mouse_Position = event.globalPos() - self.pos()
event.accept()
def mouseMoveEvent(self, QMouseEvent):
if Qt.LeftButton and self.mouse_flag:
self.move(QMouseEvent.globalPos() - self.mouse_Position)
QMouseEvent.accept()
def mouseReleaseEvent(self, QMouseEvent):
self.mouse_flag = False
class Ui_MainWindow(RoundWindow):
def __init__(self):
super().__init__()
self.queue = None
self.queue_admin = None
self.queue_command = None
def setupUi(self, MainWindow):
print('setup')
if os.path.isfile('.\\config.json'):
with open('.\\config.json', 'r') as f:
self.config = json.load(f)
self.folder = self.config['folder']
self.save_mode = self.config['save_mode']
self.download_mode = self.config['download_mode']
self.IDM_path = self.config['IDM_path']
self.Aria2_url = self.config['Aria2_url']
self.chunk_size = self.config['chunk_size']
self.SegmentedWidget_show = self.config['SegmentedWidget_show']
self.open_folder = self.config['open_folder']
self.first_open = self.config['first_open']
self.download_data = {}
self.command = {}
self.list = []
self.Download_running = False
self.Task_running = False
self.download_url_display = "## 此项仅选择“获取下载链接”时可用"
self.title = None
self.list_finish = []
self.setObjectName("Main")
self.setWindowTitle("Teaching Material Download Manager")
self.setWindowIcon(QIcon(':/recourse/logo.ico'))
self.resize(1000, 540)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
theme_color = self.get_windows_theme_color()
if theme_color is not None:
setThemeColor(QColor(theme_color[0], theme_color[1], theme_color[2]))
self.SegmentedWidget = SegmentedWidget(self)
self.SegmentedWidget.setGeometry(QtCore.QRect(510, 40, 450, 35))
self.SegmentedWidget.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.SegmentedWidget.setObjectName("SegmentedWidget")
self.IndeterminateProgressRing = IndeterminateProgressRing(self)
self.IndeterminateProgressRing.setGeometry(QtCore.QRect(835, 95, 125, 125))
self.IndeterminateProgressRing.setMinimumSize(QtCore.QSize(125, 125))
self.IndeterminateProgressRing.setMaximumSize(QtCore.QSize(125, 125))
self.IndeterminateProgressRing.setProperty("value", 0)
self.IndeterminateProgressRing.setTextVisible(False)
self.IndeterminateProgressRing.setObjectName("IndeterminateProgressRing")
self.IndeterminateProgressRing.stop()
self.TableWidget_info = TableWidget(self)
self.TableWidget_info.setGeometry(QtCore.QRect(510, 95, 305, 125))
self.TableWidget_info.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.TableWidget_info.setAutoFillBackground(False)
self.TableWidget_info.setLineWidth(1)
self.TableWidget_info.setGridStyle(QtCore.Qt.SolidLine)
self.TableWidget_info.setWordWrap(True)
self.TableWidget_info.setObjectName("TableWidget_info")
self.TableWidget_info.setColumnCount(2)
self.TableWidget_info.setRowCount(5)
item = QtWidgets.QTableWidgetItem()
item.setText("title")
self.TableWidget_info.setVerticalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
item.setText("ID_A")
self.TableWidget_info.setVerticalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
item.setText("json_url")
self.TableWidget_info.setVerticalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
item.setText("ID_B")
self.TableWidget_info.setVerticalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
item.setText("state")
self.TableWidget_info.setVerticalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setItem(0, 0, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setItem(1, 0, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setItem(2, 0, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setItem(3, 0, item)
item = QtWidgets.QTableWidgetItem()
self.TableWidget_info.setItem(4, 0, item)
self.TableWidget_info.horizontalHeader().setVisible(False)
self.TableWidget_info.horizontalHeader().setDefaultSectionSize(82)
self.TableWidget_info.verticalHeader().setVisible(False)
self.TableWidget_info.verticalHeader().setDefaultSectionSize(25)
self.TableWidget_info.verticalHeader().setMinimumSectionSize(25)
self.TableWidget_info.verticalHeader().setMaximumSectionSize(25)
self.TableWidget_finished = TableWidget(self)
self.TableWidget_finished.setGeometry(QtCore.QRect(510, 225, 450, 238))
self.TableWidget_finished.setObjectName("TableWidget_finished")
self.TableWidget_finished.setColumnCount(8)
self.TableWidget_finished.setRowCount(1)
self.TableWidget_finished.horizontalHeader().hide()
self.TableWidget_finished.verticalHeader().hide()
self.TableWidget_finished.installEventFilter(self)
self.ProgressRing = ProgressRing(self)
self.ProgressRing.setGeometry(QtCore.QRect(835, 95, 125, 125))
self.ProgressRing.setMinimumSize(QtCore.QSize(125, 125))
self.ProgressRing.setMaximumSize(QtCore.QSize(125, 125))
self.ProgressRing.setMaximum(100)
self.ProgressRing.setTextVisible(False)
self.ProgressRing.setObjectName("ProgressRing")
self.HyperlinkButton_export = HyperlinkButton(self)
self.HyperlinkButton_export.setGeometry(QtCore.QRect(510, 95, 215, 31))
self.HyperlinkButton_export.setObjectName("HyperlinkButton_export")
self.HyperlinkButton_clear = HyperlinkButton(self)
self.HyperlinkButton_clear.setGeometry(QtCore.QRect(735, 95, 215, 31))
self.HyperlinkButton_clear.setObjectName("HyperlinkButton_clear")
self.HyperlinkButton_about = HyperlinkButton(self)
self.HyperlinkButton_about.setGeometry(QtCore.QRect(510, 463, 450, 32))
self.HyperlinkButton_about.setObjectName("HyperlinkButton_about")
self.ListWidget_data = ListWidget(self)
self.ListWidget_data.setGeometry(QtCore.QRect(510, 146, 450, 297))
self.ListWidget_data.setObjectName("ListWidget_data")
self.LineEdit_url = LineEdit(self)
self.LineEdit_url.setGeometry(QtCore.QRect(40, 40, 450, 33))
self.LineEdit_url.setObjectName("LineEdit_url")
self.PushButton_add = PushButton(self)
self.PushButton_add.setGeometry(QtCore.QRect(40, 285, 450, 32))
self.PushButton_add.setObjectName("PushButton_add")
self.ComboBox_mode = ComboBox(self)
self.ComboBox_mode.setGeometry(QtCore.QRect(40, 83, 450, 32))
self.ComboBox_mode.setObjectName("ComboBox_mode")
for i in range(4):
self.ComboBox_mode.addItem('')
self.SwitchButton_open = SwitchButton(self)
self.SwitchButton_open.setGeometry(QtCore.QRect(270, 210, 220, 22))
self.SwitchButton_open.setMinimumSize(QtCore.QSize(220, 22))
self.SwitchButton_open.setMaximumSize(QtCore.QSize(220, 33))
self.SwitchButton_open.setLayoutDirection(QtCore.Qt.RightToLeft)
self.SwitchButton_open.setAutoFillBackground(False)
self.SwitchButton_open.setChecked(True)
self.SwitchButton_open.setObjectName("SwitchButton_open")
self.BodyLabel_open = BodyLabel(self)
self.BodyLabel_open.setGeometry(QtCore.QRect(40, 210, 361, 22))
self.BodyLabel_open.setObjectName("BodyLabel_open")
self.SpinBox_size = SpinBox(self)
self.SpinBox_size.setGeometry(QtCore.QRect(270, 242, 177, 33))
self.SpinBox_size.setMaximum(1000000)
self.SpinBox_size.setSingleStep(1)
self.SpinBox_size.setProperty("value", 1024)
self.SpinBox_size.setObjectName("SpinBox_size")
self.BodyLabel_size = BodyLabel(self)
self.BodyLabel_size.setGeometry(QtCore.QRect(40, 242, 201, 33))
self.BodyLabel_size.setObjectName("BodyLabel_size")
self.LineEdit_path = LineEdit(self)
self.LineEdit_path.setGeometry(QtCore.QRect(40, 167, 364, 33))
self.LineEdit_path.setObjectName("LineEdit_path")
self.ToolButton_path_ok = ToolButton(FluentIcon.ACCEPT, self)
self.ToolButton_path_ok.setGeometry(QtCore.QRect(457, 167, 33, 33))
self.ToolButton_path_ok.setText("")
self.ToolButton_path_ok.setObjectName("ToolButton_path_ok")
self.ToolButton_path_find = ToolButton(FluentIcon.MORE, self)
self.ToolButton_path_find.setGeometry(QtCore.QRect(414, 167, 33, 33))
self.ToolButton_path_find.setText("")
self.ToolButton_path_find.setObjectName("ToolButton_path_find")
self.TextEdit = TextEdit(self)
self.TextEdit.setGeometry(QtCore.QRect(510, 95, 450, 348))
self.TextEdit.setObjectName("TextEdit")
self.TextEdit.setMarkdown(self.download_url_display)
self.TableWidget = TableWidget(self)
self.TableWidget.setGeometry(QtCore.QRect(40, 327, 450, 169))
self.TableWidget.setObjectName("TableWidget")
self.TableWidget.setColumnCount(8)
self.TableWidget.setRowCount(1)
self.TableWidget.horizontalHeader().hide()
self.TableWidget.verticalHeader().hide()
self.TableWidget.installEventFilter(self)
self.ToolButton_size = ToolButton(FluentIcon.QUESTION, self)
self.ToolButton_size.setGeometry(QtCore.QRect(457, 242, 33, 33))
self.ToolButton_size.setObjectName("ToolButton_size")
self.ComboBox_same = ComboBox(self)
self.ComboBox_same.setGeometry(QtCore.QRect(270, 125, 220, 32))
self.ComboBox_same.setObjectName("ComboBox_same")
for i in range(3):
self.ComboBox_same.addItem('')
self.BodyLabel_same = BodyLabel(self)
self.BodyLabel_same.setGeometry(QtCore.QRect(40, 125, 220, 32))
self.BodyLabel_same.setObjectName("BodyLabel_same")
self.ToolButton_path_find_IDM = ToolButton(FluentIcon.MORE, self)
self.ToolButton_path_find_IDM.setGeometry(QtCore.QRect(414, 210, 33, 33))
self.ToolButton_path_find_IDM.setText("")
self.ToolButton_path_find_IDM.setObjectName("ToolButton_path_find_IDM")
self.LineEdit_path_IDM = LineEdit(self)
self.LineEdit_path_IDM.setGeometry(QtCore.QRect(40, 210, 364, 33))
self.LineEdit_path_IDM.setObjectName("LineEdit_path_IDM")
self.ToolButton_path_ok_IDM = ToolButton(FluentIcon.ACCEPT, self)
self.ToolButton_path_ok_IDM.setGeometry(QtCore.QRect(457, 210, 33, 33))
self.ToolButton_path_ok_IDM.setText("")
self.ToolButton_path_ok_IDM.setObjectName("ToolButton_path_ok_IDM")
self.LineEdit_url_aria2 = LineEdit(self)
self.LineEdit_url_aria2.setGeometry(QtCore.QRect(40, 210, 407, 33))
self.LineEdit_url_aria2.setObjectName("LineEdit_url_aria2")
self.ToolButton_url_aria2_ok = ToolButton(FluentIcon.ACCEPT, self)
self.ToolButton_url_aria2_ok.setGeometry(QtCore.QRect(457, 210, 33, 33))
self.ToolButton_url_aria2_ok.setText("")
self.ToolButton_url_aria2_ok.setObjectName("ToolButton_url_aria2_ok")
self.pushButton_close = QPushButton(self)
self.pushButton_close.setGeometry(QtCore.QRect(20, 20, 15, 15))
self.pushButton_close.setMinimumSize(QtCore.QSize(15, 15))
self.pushButton_close.setMaximumSize(QtCore.QSize(15, 15))
self.pushButton_close.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.pushButton_close.setFocusPolicy(QtCore.Qt.NoFocus)
self.pushButton_close.setStyleSheet(
"QPushButton{background:#F76677;border-radius:7px;}\n"
"QPushButton:hover{background:red;}")
self.pushButton_close.setText("")
self.pushButton_close.setObjectName("pushButton_close")
self.pushButton_maximize = QPushButton(self)
self.pushButton_maximize.setGeometry(QtCore.QRect(40, 20, 15, 15))
self.pushButton_maximize.setMinimumSize(QtCore.QSize(15, 15))
self.pushButton_maximize.setMaximumSize(QtCore.QSize(15, 15))
self.pushButton_maximize.setFocusPolicy(QtCore.Qt.NoFocus)
self.pushButton_maximize.setStyleSheet(
"QPushButton{background:#F7D674;border-radius:7px;}\n"
"QPushButton:hover{background:yellow;}")
self.pushButton_maximize.setText("")
self.pushButton_maximize.setObjectName("pushButton_maximize")
self.pushButton_maximize.setEnabled(False)
self.pushButton_minimize = QPushButton(self)
self.pushButton_minimize.setGeometry(QtCore.QRect(60, 20, 15, 15))
self.pushButton_minimize.setMinimumSize(QtCore.QSize(15, 15))
self.pushButton_minimize.setMaximumSize(QtCore.QSize(15, 15))
self.pushButton_minimize.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.pushButton_minimize.setFocusPolicy(QtCore.Qt.NoFocus)
self.pushButton_minimize.setStyleSheet(
"QPushButton{background:#6DDF6D;border-radius:7px;}\n"
"QPushButton:hover{background:green;}")
self.pushButton_minimize.setText("")
self.pushButton_minimize.setObjectName("pushButton_minimize")
self.Normal_Info = normal_info()
self.Normal_Info.queue = self.queue
self.Normal_Info.update_state_signal.connect(self.update_state_slot)
self.Normal_Info.update_progress_signal.connect(self.update_progress_slot)
self.Normal_Info.update_download_data_signal.connect(self.update_download_data_slot)
self.Normal_Info.update_basic_info.connect(self.update_basic_info)
self.Normal_Info.start()
self.Admin_Info = admin_info()
self.Admin_Info.queue_admin = self.queue_admin
self.Admin_Info.finish_signal.connect(self.download_finish)
self.Admin_Info.return_download_url.connect(self.update_download_url)
self.Admin_Info.start()
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
self.ComboBox_mode.currentIndexChanged.connect(self.ComboBox_mode_change)
self.ComboBox_same.currentIndexChanged.connect(self.ComboBox_same_change)
self.LineEdit_path.textChanged.connect(self.LineEdit_path_change)
self.LineEdit_path.returnPressed.connect(self.confirm_folder)
self.ToolButton_path_ok.clicked.connect(self.confirm_folder)
self.ToolButton_path_find.clicked.connect(self.choose_folder)
self.SwitchButton_open.checkedChanged.connect(self.switch_change)
self.SpinBox_size.valueChanged[int].connect(self.chunk_size_change)
self.ToolButton_size.clicked.connect(self.chunk_size_dialog)
self.LineEdit_path_IDM.textChanged.connect(self.LineEdit_path_IDM_change)
self.LineEdit_path_IDM.returnPressed.connect(self.confirm_IDM_path)
self.ToolButton_path_ok_IDM.clicked.connect(self.confirm_IDM_path)
self.ToolButton_path_find_IDM.clicked.connect(self.choose_IDM_path)
self.LineEdit_url_aria2.returnPressed.connect(self.LineEdit_url_aria2_change)
self.ToolButton_url_aria2_ok.clicked.connect(self.LineEdit_url_aria2_change)
self.HyperlinkButton_clear.clicked.connect(self.clear_download_data)
self.HyperlinkButton_export.clicked.connect(self.export_download_data)
self.HyperlinkButton_about.clicked.connect(self.about)
self.PushButton_add.clicked.connect(self.add_command)
self.LineEdit_url.returnPressed.connect(self.add_command)
self.pushButton_close.clicked.connect(self.close)
self.pushButton_minimize.clicked.connect(self.showMinimized)
self.TableWidget.setContextMenuPolicy(Qt.CustomContextMenu)
self.TableWidget.customContextMenuRequested.connect(self.show_list_menu)
self.TableWidget_finished.setContextMenuPolicy(Qt.CustomContextMenu)
self.TableWidget_finished.customContextMenuRequested.connect(self.show_finish_menu)
self.SegmentedWidget.setCurrentItem(self.SegmentedWidget_show)
if self.SegmentedWidget_show == 'basic_info':
self.show_basic_info()
elif self.SegmentedWidget_show == 'download_link':
self.show_download_link()
elif self.SegmentedWidget_show == 'download_data':
self.show_download_data()
self.ComboBox_mode.setCurrentIndex(self.download_mode)
self.ComboBox_same.setCurrentIndex(self.save_mode)
self.confirm_folder(source='start')
self.SwitchButton_open.setChecked(self.open_folder)
self.SpinBox_size.setValue(self.chunk_size)
self.confirm_IDM_path(source='start')
self.LineEdit_url_aria2_change(source='start')
self.ComboBox_mode_change(self.download_mode)
self.ComboBox_same_change(self.save_mode)
def retranslateUi(self):
self._translate = QtCore.QCoreApplication.translate
self.setWindowTitle(self._translate("Teaching Material Download Manager", "Teaching Material Download Manager"))
header = ['链接', '下载模式', '保存路径', '当出现相同文件时', 'chunk_size', 'IDM位置', 'Aria2地址',
'完成下载后是否打开文件夹']
for index, i in enumerate(header):
self.TableWidget.setItem(0, index, QTableWidgetItem(i))
self.TableWidget_finished.setItem(0, index, QTableWidgetItem(i))
self.TableWidget.item(0, index).setFlags(self.TableWidget.item(0, index).flags() & ~Qt.ItemIsSelectable)
self.TableWidget_finished.item(0, index).setFlags(
self.TableWidget_finished.item(0, index).flags() & ~Qt.ItemIsSelectable)
item = self.TableWidget_info.horizontalHeaderItem(0)
item.setText(self._translate("MainWindow", "新建列"))
item = self.TableWidget_info.horizontalHeaderItem(1)
item.setText(self._translate("MainWindow", "新建列"))
__sortingEnabled = self.TableWidget_info.isSortingEnabled()
self.TableWidget_info.setSortingEnabled(False)
item = self.TableWidget_info.item(0, 0)
item.setText(self._translate("MainWindow", "title"))
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
item = self.TableWidget_info.item(1, 0)
item.setText(self._translate("MainWindow", "ID_A"))
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
item = self.TableWidget_info.item(2, 0)
item.setText(self._translate("MainWindow", "json_url"))
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
item = self.TableWidget_info.item(3, 0)
item.setText(self._translate("MainWindow", "ID_B"))
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
item = self.TableWidget_info.item(4, 0)
item.setText(self._translate("MainWindow", "state"))
item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
self.TableWidget_info.setSortingEnabled(__sortingEnabled)
for index in range(5):
self.TableWidget_info.item(index, 0).setFlags(
self.TableWidget_info.item(index, 0).flags() & ~Qt.ItemIsSelectable)
self.ProgressRing.setFormat(self._translate("MainWindow", ""))
self.HyperlinkButton_export.setText(self._translate("MainWindow", "导出下载日志"))
self.HyperlinkButton_clear.setText(self._translate("MainWindow", "清空下载日志"))
self.HyperlinkButton_about.setText(self._translate("MainWindow", "关于本软件"))
self.PushButton_add.setText(self._translate("MainWindow", "下载"))
self.SwitchButton_open.setOnText(self._translate("MainWindow", "打开"))
self.SwitchButton_open.setOffText(self._translate("MainWindow", "不打开"))
self.BodyLabel_open.setText(self._translate("MainWindow", "下载完成后是否打开文件夹: "))
self.BodyLabel_size.setText(self._translate("MainWindow", "设置chunk_size的大小(单位KB): "))
self.BodyLabel_same.setText(self._translate("MainWindow", "当出现同名文件时:"))
self.ComboBox_same.setItemText(0, self._translate("MainWindow", "覆盖"))
self.ComboBox_same.setItemText(1, self._translate("MainWindow", "添加数字后缀"))
self.ComboBox_same.setItemText(2, self._translate("MainWindow", "添加时间后缀"))
self.ComboBox_mode.setItemText(0, self._translate("MainWindow", "使用软件内建下载"))
self.ComboBox_mode.setItemText(1, self._translate("MainWindow", "调用IDM下载器下载"))
self.ComboBox_mode.setItemText(2, self._translate("MainWindow", "发送到Aria2服务器下载"))
self.ComboBox_mode.setItemText(3, self._translate("MainWindow", "仅获取下载链接"))
self.SegmentedWidget.addItem('basic_info', '基本信息', onClick=self.show_basic_info)
self.SegmentedWidget.addItem('download_link', '下载链接', onClick=self.show_download_link)
self.SegmentedWidget.addItem('download_data', '下载日志', onClick=self.show_download_data)
self.LineEdit_url.setPlaceholderText(self._translate("MainWindow", "输入教材的网址"))
self.LineEdit_path.setPlaceholderText(
self._translate("MainWindow", "在这里输入保存教材的文件夹地址,或点击...选择文件夹"))
self.LineEdit_path_IDM.setPlaceholderText(
self._translate("MainWindow", "在这里输入IDMan.exe的位置,或点击...选择"))
self.LineEdit_url_aria2.setPlaceholderText(self._translate("MainWindow", "在这里输入Aria2服务器地址"))
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.mouse_flag = True
self.mouse_Position = event.globalPos() - self.pos()
event.accept()
def mouseMoveEvent(self, QMouseEvent):
if Qt.LeftButton and self.mouse_flag:
self.move(QMouseEvent.globalPos() - self.mouse_Position)
QMouseEvent.accept()
def mouseReleaseEvent(self, QMouseEvent):
self.mouse_flag = False
def closeEvent(self, event):
title = '是否退出软件'
content = """请确认所有下载任务已完成, 否则可能会导致下载失败!!!"""
w = Dialog(title, content, self)
if w.exec():
self.queue_command.put('CLOSE')
event.accept()
QCoreApplication.quit()
sys.exit()
else:
event.ignore()
def welcome_dialog(self):
if self.first_open == 1:
title = '欢迎使用 Teaching Material Download Manager'
content = """请认真阅读以下内容, 如果您不同意以下任意内容, 请立即退出本软件:\n\n 1.本软件使用GPLv3许可证, 请根据GPLv3许可证正确行使您拥有的关于\n 本软件的权力以及您应履行的义务, 您可以点击“关于此软件”并在弹出
的窗口中阅读 GPLv3 的原文。\n\n 2.请尊重教材编者和作者的劳动果实, 在中华人民共和国的法律范围内\n 使用本软件及电子教材。"""
w = Dialog(title, content, self)
w.yesButton.setText('同意')
w.cancelButton.setText('不同意')
if w.exec():
self.first_open = False
self.save_config('first_open', self.first_open)
else:
self.queue_command.put('CLOSE')
QCoreApplication.quit()
sys.exit()
def download_finish(self, state):
self.Task_running = False
self.IndeterminateProgressRing.stop()
self.ProgressRing.setValue(0)
self.ProgressRing.setTextVisible(False)
self.display = self.title
if self.display is None:
self.display = self.list[0]['url_A']
self.TableWidget_finished.setRowCount(self.TableWidget_finished.rowCount() + 1)
for item in range(8):
i = self.TableWidget.item(1, item).text()
self.TableWidget_finished.setItem(self.TableWidget_finished.rowCount() - 1, item,
QTableWidgetItem(i))
self.TableWidget_finished.resizeColumnsToContents()
self.TableWidget_finished.resizeRowsToContents()
self.TableWidget.removeRow(1)
if self.list[0]['open_folder'] and self.list[0]['download_mode'] == 0:
os.startfile(self.list[0]['save_path'])
self.list_finish.append(self.list[0])
self.list.pop(0)
for i in range(5):
self.TableWidget_info.setItem(i, 1, QTableWidgetItem(''))
if state == 'normal':
self.successful_info(self.display)
elif state == 'warning':
self.warning_info(self.display)
elif state == 'error':
self.error_info(self.display)
elif state == 'ID_A error':
self.ID_A_ERROR_info(self.display)
if len(self.list) != 0:
self.start()
else:
self.Download_running = False
def successful_info(self, url):
InfoBar.success(
title='成功处理',
content="已成功处理:" + url,
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.BOTTOM_RIGHT,
duration=18000,
parent=self
)
def ID_A_ERROR_info(self, url):
InfoBar.error(
title='网址错误',
content="无法处理:" + url + "请输入正确的网址后再试一次",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.BOTTOM_RIGHT,
duration=20000,
parent=self
)
def error_info(self, url):
InfoBar.error(
title='处理失败',
content="无法处理:" + url + "建议检查网络连接, 并在试一次,\n若你想支持本软件的开发, 请导出下载日志并将其发送到 ricardojackmc@gmail.com",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.BOTTOM_RIGHT,
duration=20000,
parent=self
)
def warning_info(self, url):
InfoBar.warning(
title='成功处理, 但出现了一些问题',
content="处理 " + url + " 时出现了一些问题,\n但是如你所见, 文件应该已经成功保存到此电脑或成功发送至指定下载器,\n若你想支持本软件的开发, 请导出下载日志并将其发送到 ricardojackmc@gmail.com",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.BOTTOM_RIGHT,
duration=20000,
parent=self
)
def update_basic_info(self, info):
if 'title' in info:
self.TableWidget_info.setItem(0, 1, QTableWidgetItem(info['title']))
self.title = info['title']
elif 'ID_A' in info:
self.TableWidget_info.setItem(1, 1, QTableWidgetItem(info['ID_A']))
elif 'json_url' in info:
self.TableWidget_info.setItem(2, 1, QTableWidgetItem(info['json_url']))
elif 'ID_B' in info:
self.TableWidget_info.setItem(3, 1, QTableWidgetItem(info['ID_B']))
self.TableWidget_info.resizeColumnsToContents()
self.TableWidget_info.resizeRowsToContents()
def add_command(self):
element = {}
key = ['url_A', 'download_mode', 'save_path', 'save_mode', 'chunk_size', 'IDM_path', 'Aria2_url', 'open_folder']
value = [self.LineEdit_url.text(), self.download_mode, self.folder, self.save_mode, self.chunk_size,
self.IDM_path, self.Aria2_url, self.open_folder]
self.TableWidget.setRowCount(self.TableWidget.rowCount() + 1)
for index, item in enumerate(value):
self.TableWidget.setItem(self.TableWidget.rowCount() - 1, index, QTableWidgetItem(str(item)))
element[key[index]] = item
self.list.append(element)
self.LineEdit_url.clear()
self.TableWidget.resizeColumnsToContents()
self.TableWidget.resizeRowsToContents()
if not self.Download_running:
self.Download_running = True
self.start()
def start(self):
self.confirm_folder(source='chosen', state='force')
if self.list[0]['download_mode'] == 1:
self.confirm_IDM_path(source='chosen', state='force')
self.command = self.list[0]
self.TableWidget.selectRow(1)
self.IndeterminateProgressRing.start()
self.ProgressRing.setFormat('loading...')
self.ProgressRing.setTextVisible(True)
self.command['key'] = time.time()
data_info = {'command': self.command}
self.queue_command.put(data_info)
self.Task_running = True