Fix clipped combo boxes and preserve native popup layouts

This commit is contained in:
AttilaNet
2026-11-08 10:06:23 +08:00
parent 9611a3413f
commit 10610e7b6e
6 changed files with 191 additions and 12 deletions
+5 -4
View File
@@ -3,7 +3,7 @@ import copy
from dataclasses import asdict
from PySide6 import QtCore as C, QtWidgets as W
from .model import EggRule, duration
from .native_widgets import IntegerInput, RowBatch
from .native_widgets import ComboBox, IntegerInput, RowBatch
class EggTable(W.QTableWidget):
@@ -20,7 +20,7 @@ class EggTable(W.QTableWidget):
self.setEditTriggers(W.QAbstractItemView.EditTrigger.NoEditTriggers)
self.setSelectionBehavior(W.QAbstractItemView.SelectionBehavior.SelectRows)
self.horizontalHeader().setSectionResizeMode(W.QHeaderView.ResizeMode.Interactive)
for column, width in enumerate((130, 45, 65, 65, 90, 95, 95, 95, 160, 95, 90, 90, 100, 100, 160)):
for column, width in enumerate((130, 45, 65, 65, 90, 135, 95, 95, 220, 95, 90, 90, 100, 100, 160)):
self.setColumnWidth(column, width)
self.verticalHeader().setDefaultSectionSize(24)
@@ -89,7 +89,7 @@ class EggTable(W.QTableWidget):
priority.setToolTip("数字越小,孵化优先级越高")
below.setToolTip("可用蛋少于此数量时补货;0表示不自动补货")
target.setToolTip("补货希望达到的可用蛋数量;市场随机出蛋,实际结果由服务器决定")
action, market = W.QComboBox(), W.QComboBox()
action, market = ComboBox(), ComboBox()
for name, value in (("派遣", "sell"), ("喂养", "feed"), ("保留", "keep")):
action.addItem(name, value)
action.setCurrentIndex(max(0, action.findData(rule["action"])))
@@ -99,7 +99,8 @@ class EggTable(W.QTableWidget):
if not market.count():
market.addItem("金币市场无此蛋", "")
market.setCurrentIndex(max(0, market.findData(rule["market_id"])))
market.setMaximumWidth(135)
self.setColumnWidth(5, max(self.columnWidth(5), action.minimumSizeHint().width()))
self.setColumnWidth(8, max(self.columnWidth(8), market.minimumSizeHint().width()))
controls = {"enabled": enabled, "priority": priority, "action": action, "refill_below": below,
"refill_target": target, "market_id": market}
for column, control in zip(range(3, 9), controls.values()):