Skip to content

Commit

Permalink
按钮显示中文
Browse files Browse the repository at this point in the history
修复设置无法保存
  • Loading branch information
rachpt committed Feb 20, 2020
1 parent 7854461 commit b3a26d6
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def initUI(self):
self.btn_chooseMutiFile.setIcon(QIcon("./icon/file.ico"))

# btn 3
self.btn_deleteSelect = QPushButton("删除", self)
self.btn_deleteSelect = QPushButton("移除", self)
self.btn_deleteSelect.setObjectName("btn_deleteSelect")
self.btn_deleteSelect.setIcon(QIcon("./icon/delete.ico"))

Expand All @@ -250,6 +250,8 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("确定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")

grid = QGridLayout()
grid.setSpacing(10)
Expand Down Expand Up @@ -338,6 +340,7 @@ def __init__(self, infos, parent=None):
self.setStyleSheet(dialog_qss_style)

def initUI(self):
self.buttonBox.button(QDialogButtonBox.Close).setText("关闭")
self.setWindowTitle("文件信息" if self.infos[2] else "文件夹信息")
self.setWindowIcon(QIcon("./icon/share.ico"))
self.logo.setPixmap(QPixmap("./icon/q9.gif"))
Expand Down Expand Up @@ -426,6 +429,8 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("确定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")

self.grid = QGridLayout()
self.grid.setSpacing(10)
Expand All @@ -441,6 +446,8 @@ def initUI(self):

def update_text(self):
if self.infos:
self.buttonBox.button(QDialogButtonBox.Ok).setToolTip("") # 去除新建文件夹影响
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True) # 去除新建文件夹影响
self.setWindowTitle("修改文件夹名与描述")
self.tx_name.setText(str(self.infos[1]))
if self.infos[6]:
Expand All @@ -460,6 +467,9 @@ def update_text(self):
else:
self.setWindowTitle("新建文件夹")
self.tx_name.setText("")
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
self.buttonBox.button(QDialogButtonBox.Ok).setToolTip("请先输入文件名!")
self.tx_name.textChanged.connect(self.slot_new_ok_btn)
self.tx_name.setPlaceholderText("不支持空格,如有会被自动替换成 _")
self.tx_name.setFocusPolicy(Qt.StrongFocus)
self.tx_name.setReadOnly(False)
Expand All @@ -468,6 +478,11 @@ def update_text(self):
self.min_width = 400
self.resize(self.min_width, 200)

def slot_new_ok_btn(self):
"""新建文件夹槽函数"""
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
self.buttonBox.button(QDialogButtonBox.Ok).setToolTip("")

def btn_ok(self):
new_name = self.tx_name.text()
new_desc = self.tx_desc.toPlainText()
Expand Down Expand Up @@ -518,6 +533,8 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("确定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")

self.grid = QGridLayout()
self.grid.setSpacing(10)
Expand Down Expand Up @@ -601,6 +618,8 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("确定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")

self.grid = QGridLayout()
self.grid.setSpacing(10)
Expand Down Expand Up @@ -664,6 +683,8 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("确定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")

self.layout.addWidget(self.lb_name)
self.layout.addWidget(self.list_view)
Expand Down Expand Up @@ -723,6 +744,7 @@ def initUI(self):
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
self.buttonBox.button(QDialogButtonBox.Close).setText("关闭")
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)

Expand Down Expand Up @@ -855,7 +877,11 @@ def initUI(self):
buttonBox = QDialogButtonBox()
buttonBox.setOrientation(Qt.Horizontal)
buttonBox.setStandardButtons(QDialogButtonBox.Reset | QDialogButtonBox.Save | QDialogButtonBox.Cancel)
buttonBox.clicked.connect(self.buttonBoxClicked)
buttonBox.button(QDialogButtonBox.Reset).setText("重置")
buttonBox.button(QDialogButtonBox.Save).setText("保存")
buttonBox.button(QDialogButtonBox.Cancel).setText("取消")
buttonBox.button(QDialogButtonBox.Reset).clicked.connect(lambda: self.set_values(reset=True))
buttonBox.button(QDialogButtonBox.Save).clicked.connect(self.slot_save)
buttonBox.rejected.connect(self.reject)

form = QFormLayout()
Expand Down Expand Up @@ -903,11 +929,8 @@ def set_download_path(self):
self.dl_path_var.setText(dl_path)
self.dl_path = dl_path

def buttonBoxClicked(self, btn):
btn_name = btn.text()
if btn_name == "Reset": # 重置
self.set_values(reset=True)
elif btn_name == "Save": # 保存
update_settings(self._config_file, self.get_values(), is_settings=True)
self.saved.emit()
self.close()
def slot_save(self):
"""保存槽函数"""
update_settings(self._config_file, self.get_values(), is_settings=True)
self.saved.emit()
self.close()

0 comments on commit b3a26d6

Please sign in to comment.