Unify selection for newly created annotations
This commit is contained in:
@@ -1911,9 +1911,9 @@ class MainWindow(QMainWindow):
|
||||
text, ok = QInputDialog.getMultiLineText(self, "批注", "批注内容:")
|
||||
if not ok or not text.strip():
|
||||
return
|
||||
self.document.add_note(self.viewer.page_index, text)
|
||||
annotation = self.document.add_note(self.viewer.page_index, text)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("批注已添加,记得保存", 3000)
|
||||
|
||||
def add_text_stamp(self) -> None:
|
||||
@@ -1926,9 +1926,9 @@ class MainWindow(QMainWindow):
|
||||
if not ok or not text.strip():
|
||||
return
|
||||
try:
|
||||
self.document.add_text_stamp(self.viewer.page_index, text.strip())
|
||||
annotation = self.document.add_text_stamp(self.viewer.page_index, text.strip())
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("文字图章已添加,记得保存", 3000)
|
||||
except Exception as exc:
|
||||
QMessageBox.critical(self, "图章失败", f"无法添加文字图章:\n{exc}")
|
||||
@@ -2645,9 +2645,12 @@ class MainWindow(QMainWindow):
|
||||
def add_ink_stroke(self, page_index: int, points: list[tuple[float, float]]) -> None:
|
||||
try:
|
||||
color, line_width, opacity = self._annotation_style()
|
||||
self.document.add_ink(page_index, points, color, line_width, opacity)
|
||||
annotation = self.document.add_ink(page_index, points, color, line_width, opacity)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
if annotation:
|
||||
self._select_annotation_object(annotation)
|
||||
else:
|
||||
self._refresh_annotation_panel()
|
||||
self.freehand_action.setChecked(False)
|
||||
self.statusBar().showMessage("画笔注释已添加,记得保存", 3000)
|
||||
except Exception as exc:
|
||||
@@ -2944,9 +2947,9 @@ class MainWindow(QMainWindow):
|
||||
if not self._ensure_can_edit("矩形"):
|
||||
return
|
||||
color, line_width, opacity = self._annotation_style()
|
||||
self.document.add_rectangle(self.viewer.page_index, color, line_width, opacity)
|
||||
annotation = self.document.add_rectangle(self.viewer.page_index, color, line_width, opacity)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("矩形已添加,记得保存", 3000)
|
||||
|
||||
def add_circle(self) -> None:
|
||||
@@ -2955,9 +2958,9 @@ class MainWindow(QMainWindow):
|
||||
if not self._ensure_can_edit("圆形"):
|
||||
return
|
||||
color, line_width, opacity = self._annotation_style()
|
||||
self.document.add_circle(self.viewer.page_index, color, line_width, opacity)
|
||||
annotation = self.document.add_circle(self.viewer.page_index, color, line_width, opacity)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("圆形已添加,记得保存", 3000)
|
||||
|
||||
def add_line(self) -> None:
|
||||
@@ -2966,9 +2969,9 @@ class MainWindow(QMainWindow):
|
||||
if not self._ensure_can_edit("线条"):
|
||||
return
|
||||
color, line_width, opacity = self._annotation_style()
|
||||
self.document.add_line(self.viewer.page_index, False, color, line_width, opacity)
|
||||
annotation = self.document.add_line(self.viewer.page_index, False, color, line_width, opacity)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("线条已添加,记得保存", 3000)
|
||||
|
||||
def add_arrow(self) -> None:
|
||||
@@ -2977,9 +2980,9 @@ class MainWindow(QMainWindow):
|
||||
if not self._ensure_can_edit("箭头"):
|
||||
return
|
||||
color, line_width, opacity = self._annotation_style()
|
||||
self.document.add_line(self.viewer.page_index, True, color, line_width, opacity)
|
||||
annotation = self.document.add_line(self.viewer.page_index, True, color, line_width, opacity)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("箭头已添加,记得保存", 3000)
|
||||
|
||||
def add_cover_area(self) -> None:
|
||||
@@ -3038,14 +3041,14 @@ class MainWindow(QMainWindow):
|
||||
self.settings.setValue("coverStyle/color", self.cover_color.name())
|
||||
self.settings.setValue("coverStyle/opacity", self.cover_opacity)
|
||||
try:
|
||||
self.document.add_cover_area(
|
||||
annotation = self.document.add_cover_area(
|
||||
self.viewer.page_index,
|
||||
(self.cover_color.redF(), self.cover_color.greenF(), self.cover_color.blueF()),
|
||||
self.cover_opacity,
|
||||
text_input.text(),
|
||||
)
|
||||
self.viewer.render()
|
||||
self._refresh_annotation_panel()
|
||||
self._select_annotation_object(annotation)
|
||||
self.statusBar().showMessage("遮盖区域已添加,记得保存", 3000)
|
||||
except Exception as exc:
|
||||
QMessageBox.critical(self, "遮盖失败", f"无法添加遮盖区域:\n{exc}")
|
||||
|
||||
Reference in New Issue
Block a user