166 lines
6.0 KiB
Python
166 lines
6.0 KiB
Python
|
# coding: gb2312
|
|||
|
import threading
|
|||
|
|
|||
|
from PyQt5.QtWidgets import *
|
|||
|
from LSZXPagesLibrary.consensus import *
|
|||
|
from LSZXPagesLibrary.pop_message_dialog import PopDialogMessage
|
|||
|
from LSZXPagesLibrary.running_config_layout_define import RunningConfigPageLayoutDefine
|
|||
|
from PureBackend.global_execrise_backend import GEB
|
|||
|
|
|||
|
|
|||
|
class RunningConfigPage(RunningConfigPageLayoutDefine):
|
|||
|
|
|||
|
def __init__(self):
|
|||
|
super(RunningConfigPage, self).__init__()
|
|||
|
self.eb = GEB().get_geb()
|
|||
|
|
|||
|
self.person_list = None
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һҳ
|
|||
|
self.back_pre_button.clicked.connect(self.back_pre_button_action)
|
|||
|
# ע<>᷵<EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>İ<EFBFBD>ť
|
|||
|
self.back_home_button.clicked.connect(self.back_home)
|
|||
|
# ע<>᳤<EFBFBD>ܿ<EFBFBD><DCBF>Խ<EFBFBD><D4BD>棨<EFBFBD>кܶ<D0BA><DCB6><EFBFBD>ԲȦ<D4B2><C8A6>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ing<6E><67><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
|||
|
self.start_button.clicked.connect(self.start_button_action)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
self.is_sound_report = False
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
self.sound_checkbox.clicked.connect(self.sound_reaction)
|
|||
|
# Ȧ<><C8A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
self.round_num = 3
|
|||
|
# Ȧ<><C8A6><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
self.round_down_button.clicked.connect(self.round_down_button_action)
|
|||
|
self.round_add_button.clicked.connect(self.round_up_button_action)
|
|||
|
# <20><>СȦʱ<C8A6><CAB1><EFBFBD><EFBFBD>
|
|||
|
self.round_time = 60
|
|||
|
# <20><>СȦʱ<C8A6>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
self.round_time_down_button.clicked.connect(self.round_time_down_button_action)
|
|||
|
self.round_time_add_button.clicked.connect(self.round_time_up_button_action)
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD>
|
|||
|
self.message_pop_windows = PopDialogMessage(self)
|
|||
|
self.message_pop_windows.connect(self.message_pop_commit)
|
|||
|
|
|||
|
def refresh(self) -> None:
|
|||
|
exercise_type = self.data.get(EXERCISE_TYPE)
|
|||
|
if exercise_type:
|
|||
|
exercise_name = EXERCISE_TYPE_TABLE[exercise_type]
|
|||
|
self.title_label.setText(exercise_name)
|
|||
|
# <20><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
self.round_num_widget.setText(f"{self.round_num}Ȧ")
|
|||
|
self.round_time_widget.setText(f"{self.round_time}<EFBFBD><EFBFBD>")
|
|||
|
self.sound_checkbox.setChecked(self.is_sound_report)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>б<EFBFBD>
|
|||
|
self.person_list = self.data.get(PERSON_LIST)
|
|||
|
self.redraw_person_list()
|
|||
|
|
|||
|
def back_pre_button_action(self):
|
|||
|
self.back2page(RUNNING_PICK_UP)
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳʱ<D2B3><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
def back_home(self):
|
|||
|
self.message_pop_windows.show("<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
|
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ť<EFBFBD>¼<EFBFBD>
|
|||
|
def message_pop_commit(self):
|
|||
|
# <20><>ת
|
|||
|
self.jump2(HOME_PAGE)
|
|||
|
|
|||
|
def start_button_action(self):
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if not self.eb.voice_play(self.is_sound_report):
|
|||
|
return
|
|||
|
# <20><><EFBFBD>ó<EFBFBD><C3B3>ܵ<EFBFBD>ȦʱȦ<CAB1><C8A6>
|
|||
|
if not self.eb.set_running_config(round_num=self.round_num, min_round_time=self.round_time):
|
|||
|
return
|
|||
|
# <20><><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ids = [person[ID] for person in self.person_list]
|
|||
|
if not self.eb.running_set_bands(ids=ids):
|
|||
|
return
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
threading.Thread(target=self.eb.start_running, daemon=True).start()
|
|||
|
# ҳ<><D2B3><EFBFBD><EFBFBD>ת
|
|||
|
pkg = {
|
|||
|
EXERCISE_TYPE: self.data[EXERCISE_TYPE],
|
|||
|
PERSON_LIST: self.person_list
|
|||
|
}
|
|||
|
self.jump2(RUNNING_TEST_PAGE, pkg)
|
|||
|
|
|||
|
def sound_reaction(self):
|
|||
|
self.is_sound_report = not self.is_sound_report
|
|||
|
self.sound_checkbox.setChecked(self.is_sound_report)
|
|||
|
|
|||
|
def round_down_button_action(self):
|
|||
|
self.round_num = int(self.round_num) - 1
|
|||
|
if self.round_num <= 0:
|
|||
|
self.round_num = 0
|
|||
|
self.round_num_widget.setText("<EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ\n(<28><><EFBFBD>T<EFBFBD><EFBCB4><EFBFBD><EFBFBD>)")
|
|||
|
else:
|
|||
|
self.round_num_widget.setText(f"{self.round_num}Ȧ")
|
|||
|
|
|||
|
def round_up_button_action(self):
|
|||
|
self.round_num = int(self.round_num) + 1
|
|||
|
self.round_num_widget.setText(f"{self.round_num}Ȧ")
|
|||
|
|
|||
|
def round_time_down_button_action(self):
|
|||
|
self.round_time = int(self.round_time) - 10
|
|||
|
if self.round_time <= 20:
|
|||
|
self.round_time = 20
|
|||
|
self.round_time_widget.setText(f"{self.round_time}<EFBFBD><EFBFBD>")
|
|||
|
|
|||
|
def round_time_up_button_action(self):
|
|||
|
self.round_time = int(self.round_time) + 10
|
|||
|
self.round_time_widget.setText(f"{self.round_time}<EFBFBD><EFBFBD>")
|
|||
|
|
|||
|
# ȷ<>ϲμӿ<CEBC><D3BF>ԵĿ<D4B5><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>Ƭ<EFBFBD><C6AC>һ<EFBFBD><D2BB>widget<65><74>
|
|||
|
def create_person_card(self, item):
|
|||
|
card_widget = self.init_person_card_widget()
|
|||
|
name_label = self.init_name_label_widget()
|
|||
|
id_label = self.init_id_label_widget()
|
|||
|
name_label.setText(item["name"])
|
|||
|
id_label.setText('<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>' + item["id"])
|
|||
|
person_card_layout = QVBoxLayout(card_widget)
|
|||
|
person_card_layout.addWidget(name_label, 50)
|
|||
|
person_card_layout.addWidget(id_label, 50)
|
|||
|
return card_widget
|
|||
|
|
|||
|
# <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
|
|||
|
def redraw_person_list(self):
|
|||
|
column_num = 8
|
|||
|
row_num = 6
|
|||
|
scroll_widget = QWidget()
|
|||
|
scroll_widget.setStyleSheet("border:none;")
|
|||
|
scroll_layout = QVBoxLayout(scroll_widget)
|
|||
|
row_layout = QHBoxLayout()
|
|||
|
for index, item in enumerate(self.person_list):
|
|||
|
card_widget = self.create_person_card(item)
|
|||
|
row_layout.addWidget(card_widget)
|
|||
|
|
|||
|
index += 1
|
|||
|
if index % column_num == 0:
|
|||
|
scroll_layout.addLayout(row_layout)
|
|||
|
row_layout = QHBoxLayout()
|
|||
|
|
|||
|
if row_layout.count() > 0:
|
|||
|
for _ in range(column_num - row_layout.count()):
|
|||
|
# <20>հ<D5B0>
|
|||
|
empty_box = QLabel()
|
|||
|
empty_box.setFrameShape(QFrame.Box)
|
|||
|
empty_box.setLineWidth(0)
|
|||
|
row_layout.addWidget(empty_box)
|
|||
|
scroll_layout.addLayout(row_layout)
|
|||
|
|
|||
|
if scroll_layout.count() < row_num:
|
|||
|
for _ in range(row_num - scroll_layout.count()):
|
|||
|
# <20>հ<D5B0>
|
|||
|
empty_box = QLabel()
|
|||
|
empty_box.setFrameShape(QFrame.Box)
|
|||
|
empty_box.setLineWidth(0)
|
|||
|
# <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
row_layout = QHBoxLayout()
|
|||
|
row_layout.addWidget(empty_box)
|
|||
|
scroll_layout.addStretch()
|
|||
|
scroll_layout.addLayout(row_layout)
|
|||
|
|
|||
|
self.scroll_area.setWidget(scroll_widget)
|
|||
|
|