Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
修复GUI操作bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangxufeng committed Aug 17, 2019
1 parent 735c181 commit 635f5ce
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
4 changes: 3 additions & 1 deletion v2rayL-GUI/sub2conf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def add_conf_by_uri(self):
self.b642conf("ss", 0, op[1])
else:
raise MyException("无法解析的链接格式")
except Exception:
except Exception as e:
if e.args[0] == "无法解析的链接格式":
raise MyException("无法解析的链接格式")
raise MyException("解析失败,请在github提交错误")

self.conf = dict(self.saved_conf['local'], **self.saved_conf['subs'])
Expand Down
1 change: 0 additions & 1 deletion v2rayL-GUI/v2rayL_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def run(self):
self.sinOut.emit(("addr", "@@OK@@", "订阅地址更新成功!", None))
else:
url = self.v2rayL.url
print(url)
if not url:
self.sinOut.emit(("update", "@@Fail@@", "不存在订阅地址,无法更新", None))
else:
Expand Down
49 changes: 44 additions & 5 deletions v2rayL-GUI/v2rayLui.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ def change_subs_addr(self):
self.update_addr_start.start()

def update_subs(self):
"""
手动更新订阅
:return:
"""
self.update_subs_start.v2rayL = self.v2rayL
self.update_subs_start.subs_child_ui = None
self.update_subs_start.start()
Expand All @@ -505,6 +509,7 @@ def get_conf_from_uri(self):
self.v2rayL.addconf(uri)
except MyException as e:
QMessageBox.critical(self, "错误", self.tr(e.args[0]))
self.confs_child_ui.lineEdit.setText("")
else:
QMessageBox.information(self, "完成", self.tr("配置添加成功!"))
self.confs_ui_hide()
Expand All @@ -513,6 +518,10 @@ def get_conf_from_uri(self):
self.confs_child_ui.lineEdit.setText("")

def del_conf(self):
"""
移除一个配置
:return:
"""
row = self.tableView.currentIndex().row()
region = self.tableView.model().item(row, 0).text()
if self.v2rayL.current == region:
Expand All @@ -526,7 +535,9 @@ def del_conf(self):
self.display_all_conf()

def start_conn_th(self):
"""开启连接线程"""
"""
开启连接线程
"""
self.connect_ui.setDisabled(True)
self.disconnect_ui.setEnabled(True)
self.statusbar.showMessage("正在连接.......")
Expand All @@ -535,7 +546,9 @@ def start_conn_th(self):
self.conn_start.start()

def end_conn_th(self):
"""开启断开连接线程"""
"""
开启断开连接线程
"""
self.connect_ui.setEnabled(True)
self.disconnect_ui.setDisabled(True)
self.statusbar.showMessage("正在断开连接.......")
Expand All @@ -544,7 +557,9 @@ def end_conn_th(self):
self.disconn_start.start()

def alert(self, tp):
"""操作反馈"""
"""
操作反馈
"""
tp, rs, ret, row = tp
if rs == "@@OK@@":
if tp == "conn":
Expand Down Expand Up @@ -585,9 +600,13 @@ def alert(self, tp):
self.statusbar.showMessage(self.status)
else:
QMessageBox.critical(self, "错误", self.tr(ret))
if tp == "addr":
self.subs_child_ui.lineEdit.setText(self.v2rayL.url)

def output_conf(self):
"""导出配置文件"""
"""
导出配置文件
"""
fileName, ok2 = QFileDialog.getSaveFileName(self,
"文件保存",
"/home",
Expand All @@ -600,30 +619,50 @@ def output_conf(self):
QMessageBox.information(self, "导出成功", self.tr("保存为: "+fileName))

def enable_auto_update(self):
"""
开启自动更新
:return:
"""
self.action_8.setChecked(True)
self.action_9.setChecked(False)
self.v2rayL.subscribe(True)
self.status = self.status_format.format(self.v2rayL.current, ("开启"))
self.statusbar.showMessage(self.status)

def disable_auto_update(self):
"""
关闭自动更新
:return:
"""
self.action_8.setChecked(False)
self.action_9.setChecked(True)
self.v2rayL.subscribe(False)
self.status = self.status_format.format(self.v2rayL.current, ("关闭"))
self.statusbar.showMessage(self.status)

def start_ping_th(self):
"""
开始ping测延时
:return:
"""
self.ping_start.start()

def output_conf_by_uri(self):
"""
输出分享链接
:return:
"""
row = self.tableView.currentIndex().row()
region = self.tableView.model().item(row, 0).text()
ret = self.v2rayL.subs.conf2b64(region)
QMessageBox.information(self, "分享链接", self.tr(ret))


def event(self, QEvent):
"""
使得statusbar始终显示内容
:param QEvent:
:return:
"""
if QEvent.type() == QEvent.StatusTip:
if QEvent.tip() == "":
QEvent = QStatusTipEvent(self.status) # 此处为要始终显示的内容
Expand Down

0 comments on commit 635f5ce

Please sign in to comment.