Skip to content

Commit

Permalink
0.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVzs committed Mar 31, 2022
1 parent 70a58c2 commit 6b8fbc7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "muti-scrcpy-client"
version = "0.3.8"
version = "0.3.9"
description = "A muticlient of scrcpy"
authors = ["ianvzs <[email protected]>"]
readme = "README.md"
Expand Down
42 changes: 27 additions & 15 deletions scrcpy_ui/config_edit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
About UI
In this file, everyone can be adjusted according to your own needs.
But should't submit changed code.
"""
import json
import os

Expand All @@ -9,6 +14,8 @@


class ConfigEditWindow(QDialog):
root_dir = ".config"

def __init__(
self, name, row, serial_no, signal_config_edit_close=None, *args, **kwargs
):
Expand All @@ -27,7 +34,6 @@ def __init__(
# self.ui.buttonBox.accepted.connect(self.save_config_info)
# self.ui.buttonBox.rejected.connect(self.cancel_config_info)

self.root_dir = ".config"
self.make_config_file_sure()
for i in [
self.ui.combobox_ai_level,
Expand All @@ -38,11 +44,20 @@ def __init__(
self.show_config_info()
self.show()

def make_config_file_sure(self):
if os.path.exists(self.root_dir):
@staticmethod
def make_config_file_sure():
if os.path.exists(ConfigEditWindow.root_dir):
pass
else:
os.mkdir(self.root_dir)
os.mkdir(ConfigEditWindow.root_dir)

@staticmethod
def get_config_info_from_file(path):
data = {}
if os.path.exists(path):
with open(path, "r") as f:
data = json.load(f)
return data

def get_confg_info(self):
"""
Expand Down Expand Up @@ -70,17 +85,14 @@ def set_combobox(self, combo_widget, text):

def show_config_info(self):
path = os.path.join(self.root_dir, self.serial_no)
if not os.path.exists(path):
return
with open(path, "r") as f:
data = json.load(f)
if data:
self.set_combobox(self.ui.combobox_team, data["team"])
self.set_combobox(self.ui.combobox_ai_level, data["ai_level"])
self.set_combobox(self.ui.combobox_run_mode, data["run_mode"])
self.ui.lineedit_axie_ids.setText(data["axie_ids"])
self.ui.lineedit_nickname.setText(data["nickname"])
self.ui.textedit_ronin.setText(data["ronin_addr"])
data = self.get_config_info_from_file(path)
if data:
self.set_combobox(self.ui.combobox_team, data["team"])
self.set_combobox(self.ui.combobox_ai_level, data["ai_level"])
self.set_combobox(self.ui.combobox_run_mode, data["run_mode"])
self.ui.lineedit_axie_ids.setText(data["axie_ids"])
self.ui.lineedit_nickname.setText(data["nickname"])
self.ui.textedit_ronin.setText(data["ronin_addr"])

def accept(self):
print("I'm alive!!!!!")
Expand Down
14 changes: 10 additions & 4 deletions scrcpy_ui/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys
from tabnanny import check

from adbutils import adb
from PySide6.QtCore import Signal
Expand Down Expand Up @@ -72,14 +72,20 @@ def __init__(self, account_info=None):
self.signal_config_edit_close.connect(self.close_all_about_edit_show)
self.show()

def get_device_nick_name(self, serial):
data = ConfigEditWindow.get_config_info_from_file(
os.path.join(ConfigEditWindow.root_dir, serial)
)
return data.get("nickname") if data else ""

def get_table_data(self):
data = []
for i in adb.device_list():
serial = i.serial
data.append(
[
self.check_box_widget,
self.dict_ui_text["device_nick_name"].get(serial, serial),
self.get_device_nick_name(serial=serial),
serial,
"pvp",
self.operate_button_widget,
Expand All @@ -90,9 +96,9 @@ def get_table_data(self):
[
self.check_box_widget,
"常驻测试",
"niubideyipi_000",
"fake_device",
"pvp",
self.operate_button_widget,
"无法启动",
self.others_buttons_widget,
]
)
Expand Down
4 changes: 4 additions & 0 deletions scrcpy_ui/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def handler(evt: QMouseEvent):

return handler

def reject(self):
print("reject~&close~")
self.close()

def closeEvent(self, _):
print("close~~~~")
self.tworker.stop()
Expand Down

0 comments on commit 6b8fbc7

Please sign in to comment.