diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 43af016f..657cd50f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . +Changes in v2024.9.1: + 1/ Fix problem dragging onto map with some Python/Qt combinations. + Changes in v2024.9.0: 1/ Regions tab image display is zoomable and draggable. 2/ Qt package preference can be changed in settings dialog. diff --git a/pyproject.toml b/pyproject.toml index c67d0c68..c2d3768b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,8 +80,8 @@ PyQt6-linux = [ "PyQt6-WebEngine-Qt6 < 6.3; python_version == '3.6.*'", ] PyQt6-windows = [ - "PyQt6 >= 6.2; platform_release != '7'", - "PyQt6-WebEngine >= 6.2; platform_release != '7'", + "PyQt6 >= 6.2; platform_release not in '7'", + "PyQt6-WebEngine >= 6.2; platform_release not in '7'", ] PyQt6-darwin = [ "PyQt6-Qt6 >= 6.2, != 6.6.1", @@ -97,7 +97,7 @@ PySide6 = [ "photini[PySide6-darwin]; platform_system == 'Darwin'", ] PySide6-linux = ["PySide6 >= 6.2"] -PySide6-windows = ["PySide6 >= 6.2; platform_release != '7'"] +PySide6-windows = ["PySide6 >= 6.2; platform_release not in '7'"] PySide6-darwin = ["PySide6 >= 6.2, != 6.6.1"] gpxpy = ["gpxpy >= 1.3.5, != 1.6.0"] Pillow = [] diff --git a/src/photini/googlephotos.py b/src/photini/googlephotos.py index 73c8ff0f..9e59a4c6 100644 --- a/src/photini/googlephotos.py +++ b/src/photini/googlephotos.py @@ -20,6 +20,8 @@ import os import urllib +import keyring +from oauthlib.oauth2.rfc6749.errors import InvalidGrantError import requests from requests_oauthlib import OAuth2Session @@ -52,10 +54,17 @@ def save_token(self, token): def api_call(self, url, post=False, **params): self.open_connection() - if post: - rsp = self.api.post(url, timeout=5, **params) - else: - rsp = self.api.get(url, timeout=5, **params) + try: + if post: + rsp = self.api.post(url, timeout=5, **params) + else: + rsp = self.api.get(url, timeout=5, **params) + except InvalidGrantError as ex: + # probably an expired token, force new login + self.close_connection() + if keyring.get_password('photini', 'googlephotos'): + keyring.delete_password('photini', 'googlephotos') + return {} rsp = self.check_response(rsp) if not rsp: self.close_connection() @@ -139,7 +148,10 @@ def on_connect(self, widgets): rsp = session.api_call(session.oauth_url + 'v2/userinfo') if not rsp: yield 'connected', False - self.user_data['lang'] = rsp['locale'] + if 'locale' in rsp: + self.user_data['lang'] = rsp['locale'] + else: + self.user_data['lang'] = None name = rsp['name'] rsp = session.check_response( session.api.get(rsp['picture']), decode=False) diff --git a/src/photini/imagelist.py b/src/photini/imagelist.py index 0e4b9d25..f4fa8a25 100644 --- a/src/photini/imagelist.py +++ b/src/photini/imagelist.py @@ -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) @@ -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: diff --git a/src/photini/photinimap.py b/src/photini/photinimap.py index 83ae51aa..20211988 100644 --- a/src/photini/photinimap.py +++ b/src/photini/photinimap.py @@ -82,7 +82,6 @@ def new_colours(self): 'RGB', alpha.size, colour) self._icons[False][active].putalpha(alpha) self._icons[False][active] = self._icons[False][active].copy() -## self._icons[False][active].resize((100, 100), PIL.Image.NEAREST).show() self.icons_changed.emit() def get_pin_as_pixmap(self, pin, active): @@ -270,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 = {} @@ -447,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: