mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 06:38:07 +00:00
55 lines
1.4 KiB
QML
55 lines
1.4 KiB
QML
import QtQuick 2.7
|
|
import QtGraphicalEffects 1.12
|
|
|
|
import Common 1.0
|
|
import Utils 1.0
|
|
|
|
// =============================================================================
|
|
// An icon image properly resized.
|
|
// =============================================================================
|
|
|
|
Item {
|
|
id: mainItem
|
|
property var iconSize // Required.
|
|
property string icon
|
|
property color overwriteColor
|
|
// Use this slot because of testing overwriteColor in layer doesn't seem to work
|
|
onOverwriteColorChanged: if(overwriteColor)
|
|
image.colorOverwriteEnabled = true
|
|
else
|
|
image.colorOverwriteEnabled = false
|
|
height: iconSize
|
|
width: iconSize
|
|
|
|
Image {
|
|
id:image
|
|
property bool colorOverwriteEnabled : false
|
|
mipmap: Qt.platform.os === 'osx'
|
|
cache: Images.areReadOnlyImages
|
|
function getIconSize () {
|
|
Utils.assert(
|
|
(icon == null || icon == '' || iconSize != null && iconSize >= 0),
|
|
'`iconSize` must be defined and must be positive. (icon=`' +
|
|
icon + '`, iconSize=' + iconSize + ')'
|
|
)
|
|
|
|
return iconSize
|
|
}
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: iconSize
|
|
height: iconSize
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
source: Utils.resolveImageUri(icon)
|
|
sourceSize.width: getIconSize()
|
|
sourceSize.height: getIconSize()
|
|
layer {
|
|
enabled: image.colorOverwriteEnabled
|
|
effect: ColorOverlay {
|
|
color: mainItem.overwriteColor
|
|
}
|
|
}
|
|
}
|
|
}
|