Skip to content

Commit

Permalink
Fixup image page
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Jan 1, 2025
1 parent 1492042 commit 5d75cd2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/gallery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ void Gallery::acquireVideoResources()
m_resources->update();
m_resources->acquire();
}
bool Gallery::isVideo(QString url)
{
return false;
}
1 change: 1 addition & 0 deletions src/gallery.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Gallery : public QObject {

public:
explicit Gallery(QObject* parent = 0);
Q_INVOKABLE bool isVideo(QString url);

public slots:
void acquireVideoResources();
Expand Down
14 changes: 14 additions & 0 deletions src/plugin/gallerymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,17 @@ bool GalleryModel::isVideo(int index)
}
return false;
}

QVariant GalleryModel::get(const int idx)
{
if (idx >= m_files.size()) {
return QVariant();
}

QMap<QString, QVariant> itemData;
QString item = m_files.at(idx);

itemData.insert("url", item);

return QVariant(itemData);
}
3 changes: 3 additions & 0 deletions src/plugin/gallerymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class GalleryModel : public QAbstractListModel {
Q_INVOKABLE QString sizeTotext(float size);
Q_INVOKABLE bool isVideo(int index);

public slots:
QVariant get(const int idx);

signals:
void sortPropertiesChanged();
void loadingChanged();
Expand Down
7 changes: 5 additions & 2 deletions src/plugin/qml/GalleryDelegate.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 John Brooks <[email protected]>
* Copyright (C) 2017-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2017-2025 Chupligin Sergey <[email protected]>
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -42,6 +42,9 @@ Image {

asynchronous: true
//index is -1 when filters the model is reinitialized (e.g. filters change) so we have to treat that case too
source: (index == -1) ? "" : (GridView.view.model.isVideo(index) ? "file:///usr/share/glacier-gallery/images/GridVideoThumbnail.jpg" : "image://nemoThumbnail/" + url)
source: (url == undefined) ? "file:///usr/share/glacier-gallery/images/GridVideoThumbnail.jpg"
: (index == -1) ? ""
: (GridView.view.model.isVideo(index) ? "file:///usr/share/glacier-gallery/images/GridVideoThumbnail.jpg"
: "image://nemoThumbnail/" + url)
}

4 changes: 2 additions & 2 deletions src/qml/components/DownListView.qml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2022-2025 Chupligin Sergey <[email protected]>
*
* You may use this file under the terms of the BSD license as follows:
*
Expand Down Expand Up @@ -63,7 +63,7 @@ Item{
anchors.centerIn: parent
sourceSize.width: Theme.itemHeightLarge
sourceSize.height: Theme.itemHeightLarge
source: gallery.isVideo(url) ? "file:///usr/share/glacier-gallery/images/DefaultVideoThumbnail.jpg" : url
source: gallery.isVideo(url) ? "file:///usr/share/glacier-gallery/images/DefaultVideoThumbnail.jpg" : "file://"+url
fillMode: Image.PreserveAspectFit
height: index === currentIndex ? parent.width : parent.width*0.8
width: parent.height
Expand Down
4 changes: 2 additions & 2 deletions src/qml/components/ImageContainer.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 Andrea Bernabei <[email protected]>
* Copyright (C) 2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2023-2025 Chupligin Sergey <[email protected]>
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -95,7 +95,7 @@ Item {
height: imgContainer.height
fillMode: Image.PreserveAspectFit

source: isVideo ? "file:///usr/share/glacier-gallery/images/DefaultVideoThumbnail.jpg" : imgContainer.source
source: isVideo ? "file:///usr/share/glacier-gallery/images/DefaultVideoThumbnail.jpg" : "file://"+ imgContainer.source

MouseArea {
anchors.fill: parent
Expand Down

0 comments on commit 5d75cd2

Please sign in to comment.