feat: add Production ID input widget and UI configuration
- Add ProductionIdInput widget with placeholder and multi-line support - Add UIConfig class for font family, font size, and input width settings - Refactor data extraction tab to use horizontal PanedWindow layout - Left panel: Production ID text input (draggable width) - Right panel: control panel and log output - Share Production IDs between data extraction and material validation tabs - Add UI settings group in settings page (font selection, size, input width) - For User users: automatically use shared Production IDs, simplified UI - Apply font settings to input and log widgets - Use sashpos() to set initial pane width correctly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -269,6 +269,34 @@ class ValidationConfig:
|
||||
return errors
|
||||
|
||||
|
||||
@dataclass
|
||||
class UIConfig:
|
||||
"""用户界面配置"""
|
||||
|
||||
font_family: str = "Microsoft YaHei UI"
|
||||
font_size: int = 10
|
||||
production_id_input_width: int = 20
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "UIConfig":
|
||||
"""从环境变量创建配置"""
|
||||
from config.env_loader import get_env, get_env_int
|
||||
return cls(
|
||||
font_family=get_env("UI_FONT_FAMILY", "Microsoft YaHei UI"),
|
||||
font_size=get_env_int("UI_FONT_SIZE", 10),
|
||||
production_id_input_width=get_env_int("UI_PRODUCTION_ID_INPUT_WIDTH", 20),
|
||||
)
|
||||
|
||||
def validate(self) -> list[str]:
|
||||
"""验证配置,返回错误列表"""
|
||||
errors = []
|
||||
if self.font_size < 8 or self.font_size > 24:
|
||||
errors.append("字号必须在 8-24 之间")
|
||||
if self.production_id_input_width < 10 or self.production_id_input_width > 100:
|
||||
errors.append("输入框宽度必须在 10-100 之间")
|
||||
return errors
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppConfig:
|
||||
"""应用总配置"""
|
||||
@@ -278,6 +306,7 @@ class AppConfig:
|
||||
paths: PathConfig
|
||||
extraction: ExtractionConfig
|
||||
validation: ValidationConfig
|
||||
ui: UIConfig
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "AppConfig":
|
||||
@@ -288,6 +317,7 @@ class AppConfig:
|
||||
paths=PathConfig.from_env(),
|
||||
extraction=ExtractionConfig.from_env(),
|
||||
validation=ValidationConfig.from_env(),
|
||||
ui=UIConfig.from_env(),
|
||||
)
|
||||
|
||||
def validate(self) -> list[str]:
|
||||
@@ -298,6 +328,7 @@ class AppConfig:
|
||||
errors.extend(self.paths.validate())
|
||||
errors.extend(self.extraction.validate())
|
||||
errors.extend(self.validation.validate())
|
||||
errors.extend(self.ui.validate())
|
||||
return errors
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
@@ -348,4 +379,9 @@ class AppConfig:
|
||||
"default_manager": self.validation.default_manager,
|
||||
"match_mode": self.validation.match_mode,
|
||||
},
|
||||
"ui": {
|
||||
"font_family": self.ui.font_family,
|
||||
"font_size": self.ui.font_size,
|
||||
"production_id_input_width": self.ui.production_id_input_width,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user