Skip to content

Commit

Permalink
Simplify drag icon hotspot setting
Browse files Browse the repository at this point in the history
Having a non-computed hotspot is a hangover from when each map had its
own icons.
  • Loading branch information
jim-easterbrook committed Sep 18, 2024
1 parent 46b4b41 commit 62ab309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/photini/imagelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,7 @@ def mouseMoveEvent(self, event):
finally:
del paint
drag.setPixmap(icon)
if self.app.image_list.drag_hotspot:
x, y = self.app.image_list.drag_hotspot
else:
x, y = src_w // 2, src_h
drag.setHotSpot(QtCore.QPoint(x, y + margin))
drag.setHotSpot(QtCore.QPoint(src_w // 2, src_h + margin))
mimeData = QtCore.QMimeData()
mimeData.setData(DRAG_MIMETYPE, repr(paths).encode('utf-8'))
drag.setMimeData(mimeData)
Expand Down Expand Up @@ -565,9 +561,8 @@ def __init__(self, parent=None):
self.size_slider.valueChanged.connect(self._new_thumb_size)
bottom_bar.addWidget(self.size_slider)

def set_drag_to_map(self, icon, hotspot=None):
def set_drag_to_map(self, icon):
self.drag_icon = icon
self.drag_hotspot = hotspot

def get_image(self, path):
for image in self.images:
Expand Down
6 changes: 3 additions & 3 deletions src/photini/photinimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ def __init__(self, parent=None):
self.app = QtWidgets.QApplication.instance()
self.app.loggerwindow.hide_word(self.api_key)
self.script_dir = os.path.join(os.path.dirname(__file__), 'data', 'map')
self.drag_icon = self.app.map_icon_factory.get_pin_as_pixmap(True, False)
self.drag_icon = self.app.map_icon_factory.get_pin_as_pixmap(
True, False)
w, h = self.app.map_icon_factory.get_pin_size(True)
self.drag_hotspot = w // 2, h
self.search_string = None
self.map_loaded = 0 # not loaded
self.marker_info = {}
Expand Down Expand Up @@ -446,7 +446,7 @@ def set_icon_data(self):
self.redraw_markers(force=True)

def refresh(self):
self.app.image_list.set_drag_to_map(self.drag_icon, self.drag_hotspot)
self.app.image_list.set_drag_to_map(self.drag_icon)
selection = self.app.image_list.get_selected_images()
self.update_display(selection, adjust_map=False)
if self.map_loaded < 1:
Expand Down

0 comments on commit 62ab309

Please sign in to comment.