Skip to content

Commit

Permalink
Merge pull request #276 from jim-easterbrook/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
jim-easterbrook authored Sep 18, 2024
2 parents 8cb8285 + eca152c commit 86d108b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.

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.
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 = []
Expand Down
22 changes: 17 additions & 5 deletions src/photini/googlephotos.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import os
import urllib

import keyring
from oauthlib.oauth2.rfc6749.errors import InvalidGrantError
import requests
from requests_oauthlib import OAuth2Session

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
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
7 changes: 3 additions & 4 deletions src/photini/photinimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 86d108b

Please sign in to comment.