Skip to content

Commit

Permalink
Fix: The port select cause IP change
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiramei committed Aug 23, 2024
1 parent 5869d53 commit d777d33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 17 additions & 2 deletions gui/components/expand/expandTemplate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from functools import partial
from typing import Union

Expand All @@ -24,6 +25,19 @@ def __init__(self, **kwargs):
self.type = kwargs.get('type')


def parsePatch(func, key: str, raw_sig: str) -> None:
"""
Parse the patch signal and call the function with the value
:param func: The function to call
:param key: The key to check
:param raw_sig: The raw signal
:return: None
"""
parsed_obj = json.loads(raw_sig)
if parsed_obj['name'] == key:
func(parsed_obj['value'])


class TemplateLayout(QWidget):
patch_signal = pyqtSignal(str)

Expand Down Expand Up @@ -70,7 +84,7 @@ def __init__(self, configItems: Union[list[ConfigItem], list[dict]], parent=None
currentKey = cfg.key
inputComponent = LineEdit(self)
inputComponent.setText(str(self.config.get(currentKey)))
self.patch_signal.connect(inputComponent.setText)
self.patch_signal.connect(partial(parsePatch, inputComponent.setText, currentKey))
confirmButton = PushButton(self.tr('确定'), self)
confirmButton.clicked.connect(partial(self._commit, currentKey, inputComponent, labelComponent))
elif cfg.type == 'label':
Expand Down Expand Up @@ -141,7 +155,8 @@ def addItems(self, texts: list[list[str]]):


class TemplateLayoutV2(QWidget):
def __init__(self, configItems: list[dict], parent=None, config=None, all_label_list: list = None, cs: ConfigSet=None):
def __init__(self, configItems: list[dict], parent=None, config=None, all_label_list: list = None,
cs: ConfigSet = None):
super().__init__(parent=parent)

_all_label_list = []
Expand Down
8 changes: 7 additions & 1 deletion gui/components/expand/serverConfig.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from PyQt5.QtCore import QObject
from PyQt5.QtWidgets import QHeaderView, QTableWidgetItem
from qfluentwidgets import TableWidget
Expand Down Expand Up @@ -78,5 +80,9 @@ def _commit_port_change(self, x):
addr = x.text()
if addr.find(':') != -1:
port = x.text().split(':')[1]
self.patch_signal.emit(port)
port_sig_str = json.dumps({
"name": "adbPort",
"value": port
})
self.patch_signal.emit(port_sig_str)
self.config.set('adbPort', port)

0 comments on commit d777d33

Please sign in to comment.