style(gui): 进一步压缩全局控件尺寸和间距

This commit is contained in:
2026-07-28 11:40:44 +08:00
parent 2d86a3fa0d
commit e204ce145e
+23 -23
View File
@@ -155,8 +155,8 @@ class SuccessToast(QLabel):
color: #183f22;
border: 3px solid #2e7d32;
border-radius: 8px;
padding: 20px 32px;
font-size: 18px;
padding: 14px 24px;
font-size: 16px;
font-weight: 700;
}
"""
@@ -340,7 +340,7 @@ class MainWindow(QMainWindow):
"""初始化主窗口:创建 UI、加载设置、连接信号。"""
super().__init__()
self.setWindowTitle(APP_TITLE)
self.resize(960, 680)
self.resize(960, 640)
self.setAcceptDrops(True)
self._updating_table = False # 防重入标记:表格正在批量更新中
self._loading_settings = True # 防重入标记:正在从设置恢复 UI 状态
@@ -390,7 +390,7 @@ class MainWindow(QMainWindow):
"""
central = QWidget(self)
root = QVBoxLayout(central)
root.setSpacing(6)
root.setSpacing(4)
self.root_layout = root
# =====================================================================
@@ -411,10 +411,10 @@ class MainWindow(QMainWindow):
self.table.horizontalHeader().setSectionResizeMode(COPIES_COLUMN, QHeaderView.ResizeToContents)
self.table.horizontalHeader().setSectionResizeMode(TIME_COLUMN, QHeaderView.ResizeToContents)
self.table.horizontalHeader().setSectionResizeMode(FILAMENT_COLUMN, QHeaderView.ResizeToContents)
self.table.setColumnWidth(ORDER_COLUMN, 84)
self.table.verticalHeader().setDefaultSectionSize(30)
self.table.setColumnWidth(ORDER_COLUMN, 78)
self.table.verticalHeader().setDefaultSectionSize(26)
self.table.verticalHeader().hide()
self.table.setMinimumHeight(140)
self.table.setMinimumHeight(120)
self.table.setSelectionBehavior(QTableWidget.SelectRows)
self.table.setAlternatingRowColors(True)
self.table.setToolTip("将 .3mf 文件或文件夹拖放到此处。文件夹将添加所有顶层 .3mf 文件。")
@@ -432,7 +432,7 @@ class MainWindow(QMainWindow):
preview_layout = QVBoxLayout(preview_group)
self.thumbnail_label = QLabel("选择一个输入文件")
self.thumbnail_label.setAlignment(Qt.AlignCenter)
self.thumbnail_label.setFixedSize(260, 190)
self.thumbnail_label.setFixedSize(240, 170)
self.thumbnail_label.setStyleSheet(
"""
QLabel {
@@ -458,8 +458,8 @@ class MainWindow(QMainWindow):
remove_all_button = QPushButton("全部移除")
apply_default_copies_button = QPushButton("应用默认份数至选中行")
self.build_button = QPushButton("构建 3MF")
self.build_button.setMinimumHeight(56)
self.build_button.setMinimumWidth(180)
self.build_button.setMinimumHeight(48)
self.build_button.setMinimumWidth(160)
build_font = self.build_button.font()
build_font.setPointSize(build_font.pointSize() + 2)
build_font.setBold(True)
@@ -472,7 +472,7 @@ class MainWindow(QMainWindow):
self.build_button.clicked.connect(self.build_output)
for button in (add_button, remove_button, remove_all_button, apply_default_copies_button):
button.setMinimumHeight(38)
button.setMinimumHeight(32)
file_buttons.addWidget(button)
file_buttons.addStretch(1)
file_buttons.addWidget(self.build_button)
@@ -486,13 +486,13 @@ class MainWindow(QMainWindow):
grid = QGridLayout(options_group)
grid.setColumnStretch(1, 1)
grid.setColumnStretch(3, 1)
grid.setHorizontalSpacing(20)
grid.setVerticalSpacing(6)
grid.setHorizontalSpacing(16)
grid.setVerticalSpacing(4)
# ---- 控件创建 ----
# 换盘 G-code 选择
self.swap_gcode_combo = QComboBox()
self.swap_gcode_combo.setMinimumWidth(260)
self.swap_gcode_combo.setMinimumWidth(240)
self.swap_gcode_combo.setMaximumWidth(440)
refresh_button = QPushButton("刷新")
open_folder_button = QPushButton("打开文件夹")
@@ -555,7 +555,7 @@ class MainWindow(QMainWindow):
self.metadata_combo = QComboBox()
self.metadata_combo.addItem("保留原始预测和重量", "source")
self.metadata_combo.addItem("累加预测和耗材用量", "sum")
self.metadata_combo.setFixedWidth(260)
self.metadata_combo.setFixedWidth(220)
# ZIP 压缩级别
self.zip_level_combo = QComboBox()
@@ -578,8 +578,8 @@ class MainWindow(QMainWindow):
self.skip_duplicates_check.setChecked(True)
# 标签列固定宽度(左对齐),控件列自动对齐(stretch=1 平分空间)
grid.setColumnMinimumWidth(0, 140)
grid.setColumnMinimumWidth(2, 100)
grid.setColumnMinimumWidth(0, 120)
grid.setColumnMinimumWidth(2, 90)
for label_text, row, col in [
("换盘 G-code", 0, 0),
("新输入的默认份数", 1, 0),
@@ -640,8 +640,8 @@ class MainWindow(QMainWindow):
output_dir_row = QHBoxLayout()
self.output_dir_edit = QLineEdit()
self.output_dir_edit.setPlaceholderText("留空则写入输入文件所在目录")
self.output_dir_edit.setMinimumWidth(280)
self.output_dir_edit.setMaximumWidth(560)
self.output_dir_edit.setMinimumWidth(240)
self.output_dir_edit.setMaximumWidth(520)
browse_output_dir_button = QPushButton("浏览")
browse_output_dir_button.setFixedWidth(browse_output_dir_button.sizeHint().width())
browse_output_dir_button.clicked.connect(self.choose_output_dir)
@@ -652,8 +652,8 @@ class MainWindow(QMainWindow):
# 输出文件名规则
self.output_name_edit = QLineEdit(DEFAULT_OUTPUT_PATTERN)
self.output_name_edit.setPlaceholderText("可使用 {source}{sources}{plates}{copies}{date}{time} 等标记")
self.output_name_edit.setMinimumWidth(280)
self.output_name_edit.setMaximumWidth(560)
self.output_name_edit.setMinimumWidth(240)
self.output_name_edit.setMaximumWidth(520)
filename_rule_row = QHBoxLayout()
output_rule_help_button = QPushButton("?")
output_rule_help_button.setFixedWidth(34)
@@ -673,7 +673,7 @@ class MainWindow(QMainWindow):
# =====================================================================
self.log = QTextEdit()
self.log.setReadOnly(True)
self.log.setMinimumHeight(100)
self.log.setMinimumHeight(80)
root.addWidget(self.log, 0)
self.setCentralWidget(central)
@@ -934,7 +934,7 @@ class MainWindow(QMainWindow):
"""创建份数微调框控件,绑定值变更信号。"""
spin = QSpinBox()
spin.setRange(1, 9999)
spin.setFixedWidth(64)
spin.setFixedWidth(60)
spin.setAlignment(Qt.AlignCenter)
spin.setValue(max(1, int(copies)))
spin.valueChanged.connect(lambda value, current_row=row: self.on_row_copies_changed(current_row, value))