Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mask_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def paintEvent(self, event):
Qt.KeepAspectRatio,
Qt.SmoothTransformation
)
scaled_pixmap.setDevicePixelRatio(self.screen().devicePixelRatio() if self.screen() else 1.0)
painter.drawPixmap(0, 0, scaled_pixmap)

# マスクオーバーレイを描画
Expand Down Expand Up @@ -298,6 +299,8 @@ def _create_mask_overlay(self) -> QPixmap:
Qt.SmoothTransformation
)

scaled_pixmap.setDevicePixelRatio(self.screen().devicePixelRatio() if self.screen() else 1.0)

return scaled_pixmap

def mousePressEvent(self, event):
Expand Down
4 changes: 2 additions & 2 deletions mask_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ def _setup_ui(self):
# Undo/Redoボタン
undo_redo_layout = QHBoxLayout()
self.btn_undo = QPushButton('戻す')
self.btn_undo.setToolTip('Ctrl+Z')
self.btn_undo.setToolTip(QKeySequence(QKeySequence.StandardKey.Undo).toString(QKeySequence.SequenceFormat.NativeText))
self.btn_undo.clicked.connect(self._on_undo)
undo_redo_layout.addWidget(self.btn_undo)

self.btn_redo = QPushButton('やり直し')
self.btn_redo.setToolTip('Ctrl+Y')
self.btn_redo.setToolTip(QKeySequence(QKeySequence.StandardKey.Redo).toString(QKeySequence.SequenceFormat.NativeText))
self.btn_redo.clicked.connect(self._on_redo)
undo_redo_layout.addWidget(self.btn_redo)
brush_layout.addLayout(undo_redo_layout)
Expand Down
4 changes: 2 additions & 2 deletions parts_mixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ def _setup_ui(self):
# Undo/Redo
undo_layout = QHBoxLayout()
self.btn_undo = QPushButton('戻す')
self.btn_undo.setToolTip('Ctrl+Z')
self.btn_undo.setToolTip(QKeySequence(QKeySequence.StandardKey.Undo).toString(QKeySequence.SequenceFormat.NativeText))
self.btn_undo.clicked.connect(self._on_undo)
undo_layout.addWidget(self.btn_undo)

self.btn_redo = QPushButton('やり直し')
self.btn_redo.setToolTip('Ctrl+Y')
self.btn_redo.setToolTip(QKeySequence(QKeySequence.StandardKey.Redo).toString(QKeySequence.SequenceFormat.NativeText))
self.btn_redo.clicked.connect(self._on_redo)
undo_layout.addWidget(self.btn_redo)
brush_layout.addLayout(undo_layout)
Expand Down
17 changes: 14 additions & 3 deletions preview_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,20 @@ def update_display(self):
return

# スケール適用
if self.scale != 1.0:
# Apply scale and device pixel ratio for HiDPI displays
dpr = self._device_pixel_ratio()
effective_scale = self.scale * dpr
if effective_scale != 1.0:
h, w = display.shape[:2]
new_w = int(w * self.scale)
new_h = int(h * self.scale)
new_w = max(1, int(w * effective_scale))
new_h = max(1, int(h * effective_scale))
display = cv2.resize(display, (new_w, new_h), interpolation=cv2.INTER_NEAREST)

# QImageに変換
try:
qimage = convert_to_qimage(display)
pixmap = QPixmap.fromImage(qimage)
pixmap.setDevicePixelRatio(dpr)
self.label.setPixmap(pixmap)
except Exception as e:
print(f"Display error: {e}")
Expand Down Expand Up @@ -381,6 +385,13 @@ def mouseReleaseEvent(self, event: QMouseEvent):
# ブラシモード
self.mouse_released.emit(img_x, img_y)

def _device_pixel_ratio(self) -> float:
"""Get the device pixel ratio for HiDPI support."""
screen = self.screen()
if screen is not None:
return screen.devicePixelRatio()
return 1.0

def wheelEvent(self, event):
"""ホイールイベント(ズーム)"""
delta = event.angleDelta().y()
Expand Down