You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following from the discussion in #127, the idea to load the images of a new directory immediately in image/thumbnail mode after the working directory was changed came up. Ideally this would:
Clear the filelist if the new directory contains no images.
Load the new images into image and thumbnail mode in async to keep the library responsive.
Focus the image which is selected in the library in both image and thumbnail mode. If the library focus is on a directory, the first image should be a safe fallback.
Implementing this without performance hit is a bit tricky, a first naive diff (attached later for reference) leads to rather bad performance. We would also have to take care how to handle cases like opening only parts of a directory in image mode, e.g. all marks in a tag. Certainly requires more careful thinking and planning, any help or idea is very welcome.
diff --git a/vimiv/api/__init__.py b/vimiv/api/__init__.py
index af3a563..b592d1b 100644
--- a/vimiv/api/__init__.py+++ b/vimiv/api/__init__.py@@ -68,12 +68,11 @@ def open(paths: Iterable[str]) -> None: # pylint: disable=redefined-builtin
"""
images, directories = files.supported(paths)
if images:
- working_directory.handler.chdir(os.path.dirname(images[0]))
signals.load_images.emit(images)
- mode = modes.IMAGE+ working_directory.handler.chdir(os.path.dirname(images[0]))+ modes.IMAGE.enter()
elif directories:
working_directory.handler.chdir(directories[0])
- mode = modes.LIBRARY+ modes.LIBRARY.enter()
else:
raise commands.CommandError("No valid paths")
- mode.enter()diff --git a/vimiv/gui/image.py b/vimiv/gui/image.py
index f7e9e36..cb28f67 100644
--- a/vimiv/gui/image.py+++ b/vimiv/gui/image.py@@ -293,8 +293,9 @@ class ScrollableImage(KeyHandler, QGraphicsView):
def resizeEvent(self, event):
"""Rescale the child image and update statusbar on resize event."""
super().resizeEvent(event)
- self.scale(self._scale)- api.status.update() # Zoom level changes+ if self.scene().items():+ self.scale(self._scale)+ api.status.update() # Zoom level changes
def mousePressEvent(self, event):
"""Update mouse press event to start panning on left button."""
diff --git a/vimiv/imutils/_file_handler.py b/vimiv/imutils/_file_handler.py
index 2162daa..2141b9f 100644
--- a/vimiv/imutils/_file_handler.py+++ b/vimiv/imutils/_file_handler.py@@ -172,6 +172,7 @@ class ImageFileHandler(QObject):
def _init_manipulate(self):
self.manipulate = immanipulate.Manipulator(self)
+ @utils.asyncfunc()
def _load(self, path: str, reload_only: bool):
"""Load proper displayable QWidget for a path.
diff --git a/vimiv/imutils/filelist.py b/vimiv/imutils/filelist.py
index b35458e..9579c27 100644
--- a/vimiv/imutils/filelist.py+++ b/vimiv/imutils/filelist.py@@ -134,6 +134,7 @@ class SignalHandler(QObject):
api.signals.load_images.connect(self._on_load_images)
api.working_directory.handler.images_changed.connect(self._on_images_changed)
+ api.working_directory.handler.loaded.connect(self._on_directory_loaded)
@pyqtSlot(list)
def _on_load_images(self, paths: List[str]):
@@ -147,8 +148,11 @@ class SignalHandler(QObject):
Args:
paths: List of paths to load into filelist.
"""
- if not paths:- _logger.debug("Image filelist: no paths to load")+ if paths == _paths:+ _logger.debug("Image filelist: nothing new load")+ elif not paths:+ _logger.debug("Image filelist: no paths to load, clearing")+ api.signals.all_images_cleared.emit()
elif len(paths) == 1:
_logger.debug("Image filelist: loading single path %s", paths[0])
_load_single(*paths)
@@ -156,6 +160,10 @@ class SignalHandler(QObject):
_logger.debug("Image filelist: loading %d paths", len(paths))
_load_paths(paths, paths[0])
+ @pyqtSlot(list, list)+ def _on_directory_loaded(self, images: List[str], _directories: List[str]):+ self._on_load_images(images)+
@pyqtSlot(int, list, api.modes.Mode, bool)
def _on_new_search(
self, index: int, _matches: List[str], mode: api.modes.Mode, incremental: bool
The text was updated successfully, but these errors were encountered:
An interesting mid-ground proposed in #694 by @mcp292 could be to allow --open-selected for :scroll left and :scroll right as well, in this case loading the directory.
1) The stored path is an image => load images and select this one
2) There are images in the directory => load images and select the first
image, overriding any stored directory
3) There are no images in the new directory => clear images
This comes very close to the preferred behaviour in #132, except for the
async part which we are omitting, in favour of the *optional*
--open-selected flag.
Following from the discussion in #127, the idea to load the images of a new directory immediately in image/thumbnail mode after the working directory was changed came up. Ideally this would:
Implementing this without performance hit is a bit tricky, a first naive diff (attached later for reference) leads to rather bad performance. We would also have to take care how to handle cases like opening only parts of a directory in image mode, e.g. all marks in a tag. Certainly requires more careful thinking and planning, any help or idea is very welcome.
The text was updated successfully, but these errors were encountered: