diff --git a/photobash_images/photobash_images_docker.py b/photobash_images/photobash_images_docker.py index 97d16a4..ab50a12 100644 --- a/photobash_images/photobash_images_docker.py +++ b/photobash_images/photobash_images_docker.py @@ -104,6 +104,7 @@ def setupInterface(self): self.layout.previousButton.clicked.connect(lambda: self.updateCurrentPage(-1)) self.layout.nextButton.clicked.connect(lambda: self.updateCurrentPage(1)) self.layout.scaleSlider.valueChanged.connect(self.updateScale) + self.layout.paginationSlider.setMinimum(0) self.layout.paginationSlider.valueChanged.connect(self.updatePage) self.layout.fitCanvasCheckBox.stateChanged.connect(self.changedFitCanvas) @@ -148,16 +149,21 @@ def initialize(self): self.updateImages() def reorganizeImages(self): - for fav in self.favouriteImages: - if fav in self.foundImages: - self.foundImages.remove(fav) + # organize images, taking into account favourites + # and their respective order + favouriteFoundImages = [] + for image in self.favouriteImages: + if image in self.foundImages: + self.foundImages.remove(image) + favouriteFoundImages.append(image) - self.foundImages = self.favouriteImages + self.foundImages + self.foundImages = favouriteFoundImages + self.foundImages def textFilterChanged(self): stringsInText = self.layout.filterTextEdit.text().lower().split(" ") if self.layout.filterTextEdit.text().lower() == "": self.foundImages = copy.deepcopy(self.allImages) + self.reorganizeImages() self.updateImages() return @@ -165,10 +171,11 @@ def textFilterChanged(self): for word in stringsInText: for path in self.allImages: # exclude path outside from search - if word in path.replace(self.directoryPath, "").lower() and not path in newImages: + if word in path.replace(self.directoryPath, "").lower() and not path in newImages and word != "" and word != " ": newImages.append(path) self.foundImages = newImages + self.reorganizeImages() self.updateImages() def getImagesFromDirectory(self): @@ -220,7 +227,7 @@ def updateScale(self, value): def updatePage(self, value): maxNumPage = math.ceil(len(self.foundImages) / len(self.layoutButtons)) - self.currPage = max(0, min(self.currPage, maxNumPage - 1)) + self.currPage = max(0, min(value, maxNumPage - 1)) self.updateImages() def changedFitCanvas(self, state): @@ -421,8 +428,14 @@ def unpinFromFavourites(self, path): Application.writeSetting(self.applicationName, self.foundFavouritesSetting, str(self.favouriteImages)) - # resets order to the default - self.foundImages = copy.deepcopy(self.allImages) + # resets order to the default, but checks if foundImages is only a subset + # in case it is searching + orderedImages = [] + for image in self.allImages: + if image in self.foundImages: + orderedImages.append(image) + + self.foundImages = orderedImages self.reorganizeImages() self.updateImages() @@ -452,5 +465,8 @@ def changePath(self): Application.writeSetting(self.applicationName, self.foundFavouritesSetting, "") - self.layout.changePathButton.setText("Change References Folder") + if self.directoryPath == "": + self.layout.changePathButton.setText("Set References Folder") + else: + self.layout.changePathButton.setText("Change References Folder") self.getImagesFromDirectory() \ No newline at end of file diff --git a/photobash_images/photobash_images_docker.ui b/photobash_images/photobash_images_docker.ui index c6ee130..f61b09c 100644 --- a/photobash_images/photobash_images_docker.ui +++ b/photobash_images/photobash_images_docker.ui @@ -138,7 +138,7 @@ 0 - 4 + 0 diff --git a/photobash_images/photobash_images_modulo.py b/photobash_images/photobash_images_modulo.py index 13183cd..058272e 100644 --- a/photobash_images/photobash_images_modulo.py +++ b/photobash_images/photobash_images_modulo.py @@ -19,7 +19,7 @@ from PyQt5 import QtWidgets, QtCore DRAG_DELTA = 30 -TRIANGLE_SIZE = 30 +TRIANGLE_SIZE = 20 FAVOURITE_TRIANGLE = QPolygon([ QPoint(0, 0), @@ -67,10 +67,11 @@ def customPaintEvent(instance, event): painter.translate(offset_x, offset_y) painter.scale(size, size) painter.drawImage(0,0,instance.qimage) - # paint something if it is a favourite if hasattr(instance, 'isFavourite'): if instance.isFavourite: + # reset scale to draw favourite triangle + painter.scale(1/size, 1/size) painter.drawPolygon(FAVOURITE_TRIANGLE) # Restore Space @@ -83,7 +84,7 @@ def customSetImage(instance, image): instance.update() def customMouseMoveEvent(self, event): - if event.modifiers() != QtCore.Qt.ShiftModifier and event.modifiers() != QtCore.Qt.ControlModifier and event.modifiers() != QtCore.Qt.AltModifier: + if event.modifiers() != QtCore.Qt.ShiftModifier and event.modifiers() != QtCore.Qt.AltModifier: self.PREVIOUS_DRAG_X = None return