Skip to content

Commit f7f0624

Browse files
committed
chore: 清理未使用的导入和变量,修复 QGraphicsScene 未定义错误
1 parent dcff5a2 commit f7f0624

9 files changed

Lines changed: 4 additions & 31 deletions

File tree

desktop_qt_ui/app_logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
from manga_translator.save import OUTPUT_FORMATS
2525
from PyQt6.QtCore import QObject, QThread, pyqtSignal, pyqtSlot
26-
from PyQt6.QtWidgets import QFileDialog, QListView, QTreeView
26+
from PyQt6.QtWidgets import QFileDialog
2727

2828
from services import (
2929
get_config_service,

desktop_qt_ui/editor/desktop_ui_geometry.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
替换 Qt 的坐标系统,使用 desktop-ui 的数据结构和算法
44
"""
55
import math
6-
import time
76
from typing import List, Tuple, Optional, Dict, Any
8-
9-
# 全局变量,用于限制调试信息的刷新频率
10-
last_debug_print_time = 0
117
import numpy as np
128
import cv2
139
from PyQt6.QtCore import QPointF

desktop_qt_ui/editor/editor_controller.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,6 @@ async def _async_incremental_inpaint(self, current_mask, original_mask):
690690
x_min = max(0, x_min - padding)
691691
x_max = min(w, x_max + padding + 1)
692692

693-
bbox_w = x_max - x_min
694-
bbox_h = y_max - y_min
695-
696693
# 裁剪原图和当前蒙版的对应区域
697694
image_np = np.array(image.convert("RGB"))
698695
bbox_image = image_np[y_min:y_max, x_min:x_max]

desktop_qt_ui/editor/graphics_items.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11

2-
import math
32
import time
43
from typing import List
54

6-
import cv2
75
import numpy as np
86
from PyQt6.QtCore import QPointF, QRectF, Qt
97
from PyQt6.QtGui import QBrush, QColor, QPainter, QPainterPath, QPen, QPolygonF
108
from PyQt6.QtWidgets import (
119
QGraphicsItem,
1210
QGraphicsItemGroup,
1311
QGraphicsPixmapItem,
12+
QGraphicsScene,
1413
QGraphicsSceneMouseEvent,
1514
QStyle,
1615
)
@@ -20,8 +19,6 @@
2019
handle_white_frame_edit,
2120
handle_vertex_edit,
2221
handle_edge_edit,
23-
rotate_point,
24-
get_polygon_center
2522
)
2623

2724

desktop_qt_ui/editor/graphics_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
QTransform,
2020
)
2121
from PyQt6.QtCore import QRectF
22-
from PyQt6.QtWidgets import QGraphicsItem, QGraphicsPixmapItem, QGraphicsScene, QGraphicsView, QMenu
22+
from PyQt6.QtWidgets import QGraphicsPixmapItem, QGraphicsScene, QGraphicsView, QMenu
2323

2424
# --- 新增Imports for Refactoring ---
2525
from editor import text_renderer_backend

desktop_qt_ui/editor_view.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from PyQt6.QtGui import QKeySequence, QShortcut
66
from PyQt6.QtWidgets import (
77
QHBoxLayout,
8-
QLabel,
98
QLineEdit,
109
QPushButton,
1110
QSplitter,
@@ -405,8 +404,6 @@ def _create_right_panel(self) -> QWidget:
405404
@pyqtSlot(str)
406405
def _on_file_remove_requested(self, file_path: str):
407406
"""处理文件移除请求:只处理编辑器自己的文件列表"""
408-
import os
409-
410407
# 先在视图中移除(避免重建列表)
411408
self.file_list.remove_file(file_path)
412409

desktop_qt_ui/main.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ def global_exception_handler(exc_type, exc_value, exc_traceback):
6969
# 设置全局异常处理器
7070
sys.excepthook = global_exception_handler
7171

72-
def print_memory_snapshot():
73-
"""打印内存快照(前100行)"""
74-
snapshot = tracemalloc.take_snapshot()
75-
top_stats = snapshot.statistics('lineno')
76-
print("\n" + "="*80)
77-
print("📊 内存占用 TOP 100:")
78-
print("="*80)
79-
for i, stat in enumerate(top_stats[:100], 1):
80-
print(f"{i}. {stat}")
81-
print("="*80 + "\n")
82-
8372
def main():
8473
"""
8574
应用主入口
@@ -171,7 +160,7 @@ def close(self):
171160
# 设置AppUserModelID,让Windows识别这是独立应用
172161
myappid = 'manga.translator.ui.1.0'
173162
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
174-
except Exception as e:
163+
except Exception:
175164
pass
176165

177166
# 1. 创建 QApplication 实例

desktop_qt_ui/main_view.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
QLineEdit,
1515
QPushButton,
1616
QScrollArea,
17-
QSizePolicy,
1817
QSplitter,
1918
QTabWidget,
20-
QTextEdit,
2119
QVBoxLayout,
2220
QWidget,
2321
)

desktop_qt_ui/main_window.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ def _refresh_ui_texts(self):
304304

305305
# 更新菜单文本
306306
menu_bar = self.menuBar()
307-
menus = menu_bar.findChildren(QAction)
308307

309308
# 由于菜单已经创建,我们需要重新设置文本
310309
# 这里简单地重新创建菜单栏

0 commit comments

Comments
 (0)