Verified Commit b243744a authored by Melvin Keskin's avatar Melvin Keskin Committed by Linus Jahn

Refactor usage of images with rounded corners

Signed-off-by: Linus Jahn's avatarLinus Jahn <lnj@kaidan.im>
parent d71fe8aa
...@@ -28,31 +28,27 @@ ...@@ -28,31 +28,27 @@
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>. * along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.8 as Kirigami
Item { Item {
id: avatar id: avatar
property string avatarUrl property string avatarUrl
property string name property string name
RoundImage { RoundImage {
id: imageAvatar id: imageAvatar
visible: avatarUrl visible: avatarUrl
source: avatarUrl source: avatarUrl
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
mipmap: true mipmap: true
height: width height: width
anchors.fill: parent anchors.fill: parent
isRound: true }
}
TextAvatar { TextAvatar {
id: textAvatar id: textAvatar
visible: !avatarUrl visible: !avatarUrl
name: avatar.name name: avatar.name
anchors.fill: parent anchors.fill: parent
} }
} }
...@@ -45,7 +45,7 @@ MediaPreview { ...@@ -45,7 +45,7 @@ MediaPreview {
Layout.preferredWidth: Kirigami.Units.gridUnit * 32 Layout.preferredWidth: Kirigami.Units.gridUnit * 32
Layout.maximumWidth: message ? messageSize : -1 Layout.maximumWidth: message ? messageSize : -1
AnimatedImage { RoundedImage {
id: image id: image
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
......
...@@ -29,24 +29,8 @@ ...@@ -29,24 +29,8 @@
*/ */
import QtQuick 2.7 import QtQuick 2.7
import QtGraphicalEffects 1.0
Image { RoundedImage {
id: img id: img
property bool isRound: true radius: Math.min(width, height)
layer.enabled: isRound
layer.effect: OpacityMask {
maskSource: Item {
width: img.paintedWidth
height: img.paintedHeight
Rectangle {
anchors.centerIn: parent
width: Math.min(img.width, img.height)
height: width
radius: Math.min(width, height)
}
}
}
} }
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.6
import QtGraphicalEffects 1.0
AnimatedImage {
id: img
property int radius: roundedCornersRadius
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: img.paintedWidth
height: img.paintedHeight
Rectangle {
anchors.centerIn: parent
width: Math.min(img.width, img.height)
height: width
radius: img.radius
}
}
}
}
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<file>elements/RosterListItem.qml</file> <file>elements/RosterListItem.qml</file>
<file>elements/MessageCounter.qml</file> <file>elements/MessageCounter.qml</file>
<file>elements/ChatMessage.qml</file> <file>elements/ChatMessage.qml</file>
<file>elements/RoundedImage.qml</file>
<file>elements/RoundImage.qml</file> <file>elements/RoundImage.qml</file>
<file>elements/IconButton.qml</file> <file>elements/IconButton.qml</file>
<file>elements/FileChooser.qml</file> <file>elements/FileChooser.qml</file>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment