2020-09-27 18:38:33 +00:00
|
|
|
/*
|
|
|
|
Sailfin: a Jellyfin client written using Qt
|
|
|
|
Copyright (C) 2020 Chris Josten
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2020-09-15 14:53:13 +00:00
|
|
|
import QtQuick 2.6
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2020-09-25 13:21:08 +00:00
|
|
|
/**
|
|
|
|
* An image for "remote" images (loaded over e.g. http), with a spinner and a fallback image
|
|
|
|
*/
|
2020-10-26 21:29:07 +00:00
|
|
|
SilicaItem {
|
|
|
|
property string fallbackImage
|
|
|
|
property bool usingFallbackImage
|
2020-10-01 10:55:11 +00:00
|
|
|
property color fallbackColor: Theme.highlightColor
|
2020-10-26 21:29:07 +00:00
|
|
|
|
|
|
|
property alias source: realImage.source
|
|
|
|
property alias sourceSize: realImage.sourceSize
|
|
|
|
property alias fillMode: realImage.fillMode
|
|
|
|
implicitHeight: realImage.implicitHeight
|
|
|
|
implicitWidth: realImage.implicitWidth
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: realImage
|
|
|
|
anchors.fill: parent
|
|
|
|
asynchronous: true
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: fallbackBackground
|
|
|
|
anchors.fill: parent
|
|
|
|
gradient: Gradient {
|
2020-10-01 10:55:11 +00:00
|
|
|
GradientStop { position: 0.0; color: fallbackColor; }
|
|
|
|
GradientStop { position: 1.0; color: Theme.highlightDimmerFromColor(fallbackColor, Theme.colorScheme); }
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
2020-10-26 21:29:07 +00:00
|
|
|
visible: realImage.status === Image.Error || realImage.status === Image.Null || realImage.status === Image.Loading
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: highlightOverlay
|
|
|
|
anchors.fill: parent
|
|
|
|
color: Theme.rgba(Theme.highlightColor, Theme.opacityOverlay)
|
|
|
|
visible: parent.highlighted
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
2020-10-01 10:55:11 +00:00
|
|
|
|
|
|
|
BusyIndicator {
|
|
|
|
anchors.centerIn: parent
|
2020-10-26 21:29:07 +00:00
|
|
|
running: realImage.status === Image.Loading
|
2020-10-01 10:55:11 +00:00
|
|
|
}
|
|
|
|
|
2020-09-26 00:51:37 +00:00
|
|
|
HighlightImage {
|
2020-09-15 14:53:13 +00:00
|
|
|
id: fallbackImageItem
|
|
|
|
anchors.centerIn: parent
|
2020-10-26 21:29:07 +00:00
|
|
|
visible: realImage.status === Image.Error || realImage.status === Image.Null
|
2020-09-15 14:53:13 +00:00
|
|
|
source: fallbackImage ? fallbackImage : "image://theme/icon-m-question"
|
|
|
|
}
|
|
|
|
}
|