mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 07:23:03 +08:00
refactor(style): 统一项目代码风格,整理导入顺序、间距规范与方法排列
- GUI 模块统一 QtCore → QtGui → QtWidgets 导入排列,各类独占一行按字母排序 - 统一类间两空行、类内方法间一空行、函数间一空行的间距规范 - 统一方法排列顺序:__init__ → setupUi → connectSignals → public → Slot → private - 统一 _widgets 中 ConditionRowFrame/ActionStepFrame 方法命名(populate* / toScript / updateValueWidget) - LibTimeSelector 迁入 operators/abs 抽象层 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,6 @@ class ConditionalBlock(QGroupBox):
|
||||
self.connectSignals()
|
||||
self.addInitialConditionRow()
|
||||
|
||||
|
||||
def setupUi(
|
||||
self
|
||||
):
|
||||
@@ -103,7 +102,6 @@ class ConditionalBlock(QGroupBox):
|
||||
mainLayout.addWidget(self.addActionBtn)
|
||||
self.setUpdatesEnabled(True)
|
||||
|
||||
|
||||
def connectSignals(
|
||||
self
|
||||
):
|
||||
@@ -112,7 +110,6 @@ class ConditionalBlock(QGroupBox):
|
||||
self.addCondBtn.clicked.connect(self.addConditionRow)
|
||||
self.addActionBtn.clicked.connect(self.addActionStep)
|
||||
|
||||
|
||||
def addInitialConditionRow(
|
||||
self
|
||||
):
|
||||
@@ -124,7 +121,6 @@ class ConditionalBlock(QGroupBox):
|
||||
self._conditionRows.append(row)
|
||||
self.condRowsLayout.addWidget(row)
|
||||
|
||||
|
||||
def addConditionRow(
|
||||
self
|
||||
):
|
||||
@@ -137,7 +133,6 @@ class ConditionalBlock(QGroupBox):
|
||||
self._conditionRows.append(row)
|
||||
self.condRowsLayout.addWidget(row)
|
||||
|
||||
|
||||
def removeConditionRow(
|
||||
self,
|
||||
row: ConditionRowFrame
|
||||
@@ -149,7 +144,6 @@ class ConditionalBlock(QGroupBox):
|
||||
row.hide()
|
||||
row.deleteLater()
|
||||
|
||||
|
||||
def addActionStep(
|
||||
self
|
||||
):
|
||||
@@ -159,7 +153,6 @@ class ConditionalBlock(QGroupBox):
|
||||
self._actionWidgets.append(step)
|
||||
self.actionsLayout.addWidget(step)
|
||||
|
||||
|
||||
def removeActionStep(
|
||||
self,
|
||||
step: ActionStepFrame
|
||||
@@ -171,48 +164,31 @@ class ConditionalBlock(QGroupBox):
|
||||
step.hide()
|
||||
step.deleteLater()
|
||||
|
||||
@Slot(int)
|
||||
def onTypeChanged(
|
||||
self,
|
||||
_idx
|
||||
):
|
||||
|
||||
isCond = self.typeCombo.currentData() in ("IF", "ELSE IF")
|
||||
self.conditionWidget.setVisible(isCond)
|
||||
self.actionLabel.setText(
|
||||
"执行步骤:" if isCond else "ELSE 执行步骤:"
|
||||
)
|
||||
|
||||
|
||||
def getBlockType(
|
||||
self
|
||||
) -> str:
|
||||
|
||||
return self.typeCombo.currentData()
|
||||
|
||||
|
||||
def getConditionRows(
|
||||
self
|
||||
):
|
||||
|
||||
return list(self._conditionRows)
|
||||
|
||||
|
||||
def getActionSteps(
|
||||
self
|
||||
):
|
||||
|
||||
return list(self._actionWidgets)
|
||||
|
||||
|
||||
def countActionSteps(
|
||||
self
|
||||
) -> int:
|
||||
|
||||
return len(self._actionWidgets)
|
||||
|
||||
|
||||
def toScriptLines(
|
||||
def toScript(
|
||||
self
|
||||
) -> list:
|
||||
"""
|
||||
@@ -223,7 +199,7 @@ class ConditionalBlock(QGroupBox):
|
||||
lines = []
|
||||
if blockType in ("IF", "ELSE IF"):
|
||||
condTexts = [
|
||||
r.toConditionText() for r in self._conditionRows if r.toConditionText()
|
||||
r.toScript() for r in self._conditionRows if r.toScript()
|
||||
]
|
||||
if not condTexts:
|
||||
condTexts = ["true"]
|
||||
@@ -245,12 +221,11 @@ class ConditionalBlock(QGroupBox):
|
||||
else:
|
||||
lines.append("else")
|
||||
for step in self._actionWidgets:
|
||||
scriptLine = step.toScriptLine()
|
||||
scriptLine = step.toScript()
|
||||
if scriptLine:
|
||||
lines.append(scriptLine)
|
||||
return lines
|
||||
|
||||
|
||||
def refreshVarCombos(
|
||||
self
|
||||
):
|
||||
@@ -260,7 +235,6 @@ class ConditionalBlock(QGroupBox):
|
||||
for step in self._actionWidgets:
|
||||
step.refreshVarCombos()
|
||||
|
||||
|
||||
def setPrevBlockType(
|
||||
self,
|
||||
prevType: str | None
|
||||
@@ -278,3 +252,15 @@ class ConditionalBlock(QGroupBox):
|
||||
item.setEnabled(shouldEnable)
|
||||
if prevType == "ELSE" and self.typeCombo.currentData() in ("ELSE IF", "ELSE"):
|
||||
self.typeCombo.setCurrentIndex(0)
|
||||
|
||||
@Slot(int)
|
||||
def onTypeChanged(
|
||||
self,
|
||||
_idx
|
||||
):
|
||||
|
||||
isCond = self.typeCombo.currentData() in ("IF", "ELSE IF")
|
||||
self.conditionWidget.setVisible(isCond)
|
||||
self.actionLabel.setText(
|
||||
"执行步骤:" if isCond else "ELSE 执行步骤:"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user