Skip to content

Commit

Permalink
[ImageItem/SmartImage/SettingsManager] Fix image display, remove opti…
Browse files Browse the repository at this point in the history
…on for storing zoom/level/mirror per image, add option to keep stuff in general
  • Loading branch information
luspi committed Nov 18, 2016
1 parent da02949 commit 5ba6682
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 251 deletions.
4 changes: 2 additions & 2 deletions CMake/ListFilesCPlusPlus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/loaddir.cpp)

SET(d "cplusplus/imageprovider")
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/imageproviderfull.cpp ${d}/imageproviderthumbnail.cpp ${d}/imageprovidericon.h)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/pixmapcache.h)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/pixmapcache.h ${d}/imageproviderempty.h)

SET(d "cplusplus/imageprovider/loader")
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/loadimage_qt.h ${d}/loadimage_gm.h ${d}/loadimage_xcf.h ${d}/loadimage_raw.h)
Expand Down Expand Up @@ -58,7 +58,7 @@ SET(photoqt_HEADERS ${photoqt_HEADERS} ${d}/loaddir.h)

SET(d "cplusplus/imageprovider")
SET(photoqt_HEADERS ${photoqt_HEADERS} ${d}/imageproviderthumbnail.h ${d}/imageproviderfull.h ${d}/imageprovidericon.h)
SET(photoqt_HEADERS ${photoqt_HEADERS} ${d}/pixmapcache.h)
SET(photoqt_HEADERS ${photoqt_HEADERS} ${d}/pixmapcache.h ${d}/imageproviderempty.h)

SET(d "cplusplus/imageprovider/loader")
SET(photoqt_HEADERS ${photoqt_HEADERS} ${d}/loadimage_qt.h ${d}/loadimage_gm.h ${d}/loadimage_xcf.h ${d}/loadimage_raw.h)
Expand Down
2 changes: 1 addition & 1 deletion CMake/ListFilesQML.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ SET(d "qml/settingsmanager/tabs/lookandfeel")
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/SortBy.qml ${d}/WindowMode.qml ${d}/TrayIcon.qml ${d}/ClosingX.qml ${d}/FitInWindow.qml)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/OverlayColor.qml ${d}/Quickinfo.qml ${d}/Background.qml ${d}/BorderAroundImage.qml)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/CloseOnClick.qml ${d}/Loop.qml ${d}/Transition.qml ${d}/HotEdge.qml ${d}/Blur.qml)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/MouseWheelSensitivity.qml ${d}/Interpolation.qml ${d}/Remember.qml ${d}/Animation.qml)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/MouseWheelSensitivity.qml ${d}/Interpolation.qml ${d}/Keep.qml ${d}/Animation.qml)
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/TouchScreen.qml ${d}/PixmapCache.qml)
SET(d "qml/settingsmanager/tabs/thumbnails")
SET(photoqt_SOURCES ${photoqt_SOURCES} ${d}/ThumbnailSize.qml ${d}/Spacing.qml ${d}/LiftUp.qml ${d}/KeepVisible.qml ${d}/Dynamic.qml)
Expand Down
31 changes: 31 additions & 0 deletions cplusplus/imageprovider/imageproviderempty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef IMAGEPROVIDEREMPTY_H
#define IMAGEPROVIDEREMPTY_H

#include <QQuickImageProvider>

class ImageProviderEmpty : public QQuickImageProvider {

public:
explicit ImageProviderEmpty() : QQuickImageProvider(QQuickImageProvider::Image) { }
~ImageProviderEmpty() { }

QImage requestImage(const QString &filename_encoded, QSize *size, const QSize &requestedSize) {

int w = filename_encoded.split("x").at(0).toInt();
int h = filename_encoded.split("x").at(1).toInt();

if(w < 5) w = 100;
if(h < 5) h = 100;

QImage ret(w, h, QImage::Format_ARGB32);
ret.fill(Qt::transparent);

return ret;

}


};


#endif // IMAGEPROVIDEREMPTY_H
1 change: 1 addition & 0 deletions cplusplus/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ MainWindow::MainWindow(bool verbose, QWindow *parent) : QQuickView(parent) {
this->engine()->addImageProvider("thumb",new ImageProviderThumbnail);
this->engine()->addImageProvider("full",new ImageProviderFull);
this->engine()->addImageProvider("icon",new ImageProviderIcon);
this->engine()->addImageProvider("empty", new ImageProviderEmpty);

// Add settings access to QML
qmlRegisterType<Settings>("Settings", 1, 0, "Settings");
Expand Down
1 change: 1 addition & 0 deletions cplusplus/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "handlefiles/loaddir.h"
#include "imageprovider/imageproviderthumbnail.h"
#include "imageprovider/imageproviderfull.h"
#include "imageprovider/imageproviderempty.h"
#include "imageprovider/imageprovidericon.h"
#include "settings/settings.h"
#include "settings/fileformats.h"
Expand Down
33 changes: 11 additions & 22 deletions cplusplus/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class Settings : public QObject {
connect(this, SIGNAL(sortbyChanged(QString)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(sortbyAscendingChanged(bool)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(mouseWheelSensitivityChanged(int)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(rememberRotationChanged(bool)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(rememberZoomChanged(bool)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(keepZoomRotationMirrorChanged(bool)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(fitInWindowChanged(bool)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(interpolationNearestNeighbourThresholdChanged(int)), saveSettingsTimer, SLOT(start()));
connect(this, SIGNAL(interpolationNearestNeighbourUpscaleChanged(bool)), saveSettingsTimer, SLOT(start()));
Expand Down Expand Up @@ -249,9 +248,8 @@ class Settings : public QObject {
bool sortbyAscending;
// Mouse Wheel sensitivity
int mouseWheelSensitivity;
// Remember per session
bool rememberRotation;
bool rememberZoom;
// Keep for new image
bool keepZoomRotationMirror;
// If image is too small, zoom to fit in window
bool fitInWindow;
// 'Nearest Neighbour' interpolation size threshold
Expand Down Expand Up @@ -410,8 +408,7 @@ class Settings : public QObject {
Q_PROPERTY(QString sortby MEMBER sortby NOTIFY sortbyChanged)
Q_PROPERTY(bool sortbyAscending MEMBER sortbyAscending NOTIFY sortbyAscendingChanged)
Q_PROPERTY(int mouseWheelSensitivity MEMBER mouseWheelSensitivity NOTIFY mouseWheelSensitivityChanged)
Q_PROPERTY(bool rememberRotation MEMBER rememberRotation NOTIFY rememberRotationChanged)
Q_PROPERTY(bool rememberZoom MEMBER rememberZoom NOTIFY rememberZoomChanged)
Q_PROPERTY(bool keepZoomRotationMirror MEMBER keepZoomRotationMirror NOTIFY keepZoomRotationMirrorChanged)
Q_PROPERTY(bool fitInWindow MEMBER fitInWindow NOTIFY fitInWindowChanged)
Q_PROPERTY(int interpolationNearestNeighbourThreshold MEMBER interpolationNearestNeighbourThreshold NOTIFY interpolationNearestNeighbourThresholdChanged)
Q_PROPERTY(bool interpolationNearestNeighbourUpscale MEMBER interpolationNearestNeighbourUpscale NOTIFY interpolationNearestNeighbourUpscaleChanged)
Expand Down Expand Up @@ -556,8 +553,7 @@ class Settings : public QObject {
borderAroundImg = 5;
quickSettings = true;
mouseWheelSensitivity = 1;
rememberRotation = false;
rememberZoom = false;
keepZoomRotationMirror = false;
fitInWindow= false;
interpolationNearestNeighbourThreshold = 100;
interpolationNearestNeighbourUpscale = false;
Expand Down Expand Up @@ -719,8 +715,7 @@ public slots:
cont += QString("SortImagesBy=%1\n").arg(sortby);
cont += QString("SortImagesAscending=%1\n").arg(int(sortbyAscending));
cont += QString("MouseWheelSensitivity=%1\n").arg(mouseWheelSensitivity);
cont += QString("RememberRotation=%1\n").arg(int(rememberRotation));
cont += QString("RememberZoom=%1\n").arg(int(rememberZoom));
cont += QString("KeepZoomRotationMirror=%1\n").arg(int(keepZoomRotationMirror));
cont += QString("FitInWindow=%1\n").arg(int(fitInWindow));
cont += QString("InterpolationNearestNeighbourThreshold=%1\n").arg(interpolationNearestNeighbourThreshold);
cont += QString("InterpolationNearestNeighbourUpscale=%1\n").arg(int(interpolationNearestNeighbourUpscale));
Expand Down Expand Up @@ -966,15 +961,10 @@ public slots:
if(mouseWheelSensitivity < 1) mouseWheelSensitivity = 1;
}

if(all.contains("RememberRotation=1"))
rememberRotation = true;
else if(all.contains("RememberRotation=0"))
rememberRotation = false;

if(all.contains("RememberZoom=1"))
rememberZoom = true;
else if(all.contains("RememberZoom=0"))
rememberZoom = false;
if(all.contains("KeepZoomRotationMirror=1"))
keepZoomRotationMirror = true;
else if(all.contains("KeepZoomRotationMirror=0"))
keepZoomRotationMirror = false;

if(all.contains("FitInWindow=1"))
fitInWindow = true;
Expand Down Expand Up @@ -1363,8 +1353,7 @@ public slots:
void sortbyChanged(QString val);
void sortbyAscendingChanged(bool val);
void mouseWheelSensitivityChanged(int val);
void rememberRotationChanged(bool val);
void rememberZoomChanged(bool val);
void keepZoomRotationMirrorChanged(bool val);
void fitInWindowChanged(bool val);
void interpolationNearestNeighbourThresholdChanged(int val);
void interpolationNearestNeighbourUpscaleChanged(bool val);
Expand Down
161 changes: 81 additions & 80 deletions img.qrc
Original file line number Diff line number Diff line change
@@ -1,85 +1,86 @@
<RCC>
<qresource prefix="/">
<file>img/emptythumb.png</file>
<file>img/nothumb.png</file>
<file>img/closingx.png</file>
<file>img/mainmenu/about.png</file>
<file>img/mainmenu/filter.png</file>
<file>img/mainmenu/metadata.png</file>
<file>img/mainmenu/open.png</file>
<file>img/mainmenu/quit.png</file>
<file>img/mainmenu/settings.png</file>
<file>img/mainmenu/slideshow.png</file>
<file>img/logo.png</file>
<file>img/settings/sortascending.png</file>
<file>img/settings/sortdescending.png</file>
<file>img/settings/emptybackground.png</file>
<file>img/transparent.png</file>
<file>img/settings/addshortcut.png</file>
<file>img/contextmenu/first.png</file>
<file>img/contextmenu/last.png</file>
<file>img/contextmenu/rotateLeft.png</file>
<file>img/contextmenu/rotateRight.png</file>
<file>img/contextmenu/flipH.png</file>
<file>img/contextmenu/flipV.png</file>
<file>img/contextmenu/delete.png</file>
<file>img/contextmenu/open.png</file>
<file>img/contextmenu/rename.png</file>
<file>img/contextmenu/scale.png</file>
<file>img/icon.png</file>
<file>img/ratioKeep.png</file>
<file>img/ratioDontKeep.png</file>
<file>img/contextmenu/copy.png</file>
<file>img/contextmenu/move.png</file>
<file>img/startup/exif.png</file>
<file>img/startup/fileformats.png</file>
<file>img/startup/localisation.png</file>
<file>img/startup/settings.png</file>
<file>img/startup/shortcuts.png</file>
<file>img/startup/slideshow.png</file>
<file>img/startup/thumbnails.png</file>
<file>img/mainview/arrowdown.png</file>
<file>img/mainview/arrowleft.png</file>
<file>img/mainview/arrowright.png</file>
<file>img/mainview/arrowup.png</file>
<file>img/empty.png</file>
<file>img/openfile/folder.png</file>
<file>img/openfile/image.png</file>
<file>img/openfile/iconview.png</file>
<file>img/openfile/listview.png</file>
<file>img/plainerrorimg.png</file>
<file>img/mainmenu/zoomin.png</file>
<file>img/mainmenu/zoomout.png</file>
<file>img/mainmenu/zoom.png</file>
<file>img/mainmenu/hide.png</file>
<file>img/mainmenu/rotate.png</file>
<file>img/mainmenu/flip.png</file>
<file>img/mainmenu/scale.png</file>
<file>img/mainmenu/copy.png</file>
<file>img/mainmenu/delete.png</file>
<file>img/mainmenu/move.png</file>
<file>img/mainmenu/rename.png</file>
<file>img/mainmenu/goto.png</file>
<file>img/openfile/thumbnail.png</file>
<file>img/openfile/hoverpreview.png</file>
<file>img/openfile/backupicons/folder.svg</file>
<file>img/openfile/backupicons/folder-red.svg</file>
<file>img/openfile/backupicons/folder-pictures.svg</file>
<file>img/openfile/backupicons/image-bmp.svg</file>
<file>img/openfile/backupicons/image-gif.svg</file>
<file>img/openfile/backupicons/image-jpeg.svg</file>
<file>img/openfile/backupicons/image-png.svg</file>
<file>img/openfile/backupicons/image-tiff.svg</file>
<file>img/openfile/backupicons/image.svg</file>
<file>img/openfile/backupicons/unknown.svg</file>
<file>img/openfile/backupicons/user-home.svg</file>
<file>img/openfile/backupicons/user-desktop.svg</file>
<file>img/openfile/backupicons/drive-harddisk.svg</file>
<file>img/loading.gif</file>
<file>img/settings/shortcuts/categorykeyboard.png</file>
<file>img/settings/shortcuts/categorymouse.png</file>
<file>img/settings/shortcuts/categorytouch.png</file>
<file>img/mainmenu/histogram.png</file>
<file>img/switchHistogramVersion.png</file>
<file>img/nothumb.png</file>
<file>img/closingx.png</file>
<file>img/mainmenu/about.png</file>
<file>img/mainmenu/filter.png</file>
<file>img/mainmenu/metadata.png</file>
<file>img/mainmenu/open.png</file>
<file>img/mainmenu/quit.png</file>
<file>img/mainmenu/settings.png</file>
<file>img/mainmenu/slideshow.png</file>
<file>img/logo.png</file>
<file>img/settings/sortascending.png</file>
<file>img/settings/sortdescending.png</file>
<file>img/settings/emptybackground.png</file>
<file>img/transparent.png</file>
<file>img/settings/addshortcut.png</file>
<file>img/contextmenu/first.png</file>
<file>img/contextmenu/last.png</file>
<file>img/contextmenu/rotateLeft.png</file>
<file>img/contextmenu/rotateRight.png</file>
<file>img/contextmenu/flipH.png</file>
<file>img/contextmenu/flipV.png</file>
<file>img/contextmenu/delete.png</file>
<file>img/contextmenu/open.png</file>
<file>img/contextmenu/rename.png</file>
<file>img/contextmenu/scale.png</file>
<file>img/icon.png</file>
<file>img/ratioKeep.png</file>
<file>img/ratioDontKeep.png</file>
<file>img/contextmenu/copy.png</file>
<file>img/contextmenu/move.png</file>
<file>img/startup/exif.png</file>
<file>img/startup/fileformats.png</file>
<file>img/startup/localisation.png</file>
<file>img/startup/settings.png</file>
<file>img/startup/shortcuts.png</file>
<file>img/startup/slideshow.png</file>
<file>img/startup/thumbnails.png</file>
<file>img/mainview/arrowdown.png</file>
<file>img/mainview/arrowleft.png</file>
<file>img/mainview/arrowright.png</file>
<file>img/mainview/arrowup.png</file>
<file>img/empty.png</file>
<file>img/bigempty.png</file>
<file>img/openfile/folder.png</file>
<file>img/openfile/image.png</file>
<file>img/openfile/iconview.png</file>
<file>img/openfile/listview.png</file>
<file>img/plainerrorimg.png</file>
<file>img/mainmenu/zoomin.png</file>
<file>img/mainmenu/zoomout.png</file>
<file>img/mainmenu/zoom.png</file>
<file>img/mainmenu/hide.png</file>
<file>img/mainmenu/rotate.png</file>
<file>img/mainmenu/flip.png</file>
<file>img/mainmenu/scale.png</file>
<file>img/mainmenu/copy.png</file>
<file>img/mainmenu/delete.png</file>
<file>img/mainmenu/move.png</file>
<file>img/mainmenu/rename.png</file>
<file>img/mainmenu/goto.png</file>
<file>img/openfile/thumbnail.png</file>
<file>img/openfile/hoverpreview.png</file>
<file>img/openfile/backupicons/folder.svg</file>
<file>img/openfile/backupicons/folder-red.svg</file>
<file>img/openfile/backupicons/folder-pictures.svg</file>
<file>img/openfile/backupicons/image-bmp.svg</file>
<file>img/openfile/backupicons/image-gif.svg</file>
<file>img/openfile/backupicons/image-jpeg.svg</file>
<file>img/openfile/backupicons/image-png.svg</file>
<file>img/openfile/backupicons/image-tiff.svg</file>
<file>img/openfile/backupicons/image.svg</file>
<file>img/openfile/backupicons/unknown.svg</file>
<file>img/openfile/backupicons/user-home.svg</file>
<file>img/openfile/backupicons/user-desktop.svg</file>
<file>img/openfile/backupicons/drive-harddisk.svg</file>
<file>img/loading.gif</file>
<file>img/settings/shortcuts/categorykeyboard.png</file>
<file>img/settings/shortcuts/categorymouse.png</file>
<file>img/settings/shortcuts/categorytouch.png</file>
<file>img/mainmenu/histogram.png</file>
<file>img/switchHistogramVersion.png</file>
</qresource>
</RCC>
Binary file added img/bigempty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion qml/mainview/ImageItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Rectangle {
property int _interval: 0

// The opacity property
opacity: 1
opacity: 0
Behavior on opacity { NumberAnimation { duration: _fadeDurationNextImage; } }
onOpacityChanged: {
if(opacity == 1) {
Expand All @@ -69,6 +69,7 @@ Rectangle {
anchors.fill: parent
cache: false
mipmap: true
source: "image://empty/" + rect_top.width + "x" + rect_top.height
fillMode: Image.PreserveAspectFit
asynchronous: true
visible: true
Expand All @@ -88,6 +89,7 @@ Rectangle {
anchors.fill: parent
cache: false
mipmap: true
source: "image://empty/" + rect_top.width + "x" + rect_top.height
fillMode: Image.PreserveAspectFit
asynchronous: true
mirror: false
Expand Down
3 changes: 2 additions & 1 deletion qml/mainview/MainView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Item {
verboseMessage("Display::setImage()", path)

// LOAD IMAGE
image.loadImage(path, 0)
image.loadImage(path)

// Hide 'nothing loaded' message and arrows
nofileloaded.visible = false
Expand Down Expand Up @@ -66,6 +66,7 @@ Item {
fitInWindow: settings.fitInWindow
interpolationNearestNeighbourThreshold: settings.interpolationNearestNeighbourThreshold
interpolationNearestNeighbourUpscale: settings.interpolationNearestNeighbourUpscale
resetZoomRotationMirrorForNewImage: !settings.keepZoomRotationMirror

}

Expand Down
Loading

0 comments on commit 5ba6682

Please sign in to comment.