2023-05-16 17:48:30 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 by Oleksandr Zolotov <alex@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*/
|
|
|
|
|
2024-08-07 22:54:37 +03:00
|
|
|
import QtQml
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
2022-11-23 20:58:14 +03:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2024-08-07 22:54:37 +03:00
|
|
|
import Style
|
2022-08-09 00:40:19 +03:00
|
|
|
|
2021-09-09 14:33:57 +03:00
|
|
|
RowLayout {
|
|
|
|
id: unifiedSearchResultItemDetails
|
|
|
|
|
|
|
|
property string title: ""
|
|
|
|
property string subline: ""
|
|
|
|
property string icons: ""
|
|
|
|
property string iconPlaceholder: ""
|
|
|
|
|
2022-08-09 00:40:19 +03:00
|
|
|
property bool iconsIsThumbnail: false
|
|
|
|
property bool isRounded: false
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2022-08-09 00:40:19 +03:00
|
|
|
property int iconWidth: iconsIsThumbnail && icons !== "" ? Style.unifiedSearchResultIconWidth : Style.unifiedSearchResultSmallIconWidth
|
2022-07-11 19:56:35 +03:00
|
|
|
property int titleFontSize: Style.unifiedSearchResultTitleFontSize
|
|
|
|
property int sublineFontSize: Style.unifiedSearchResultSublineFontSize
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2023-05-25 06:51:51 +03:00
|
|
|
property color titleColor: palette.buttonText
|
|
|
|
property color sublineColor: palette.midlight
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2023-04-21 18:48:44 +03:00
|
|
|
|
2021-09-09 14:33:57 +03:00
|
|
|
Accessible.role: Accessible.ListItem
|
|
|
|
Accessible.name: resultTitle
|
|
|
|
Accessible.onPressAction: unifiedSearchResultMouseArea.clicked()
|
|
|
|
|
2022-08-09 00:40:19 +03:00
|
|
|
spacing: Style.trayHorizontalMargin
|
|
|
|
|
|
|
|
Item {
|
2021-09-09 14:33:57 +03:00
|
|
|
id: unifiedSearchResultImageContainer
|
2022-08-09 00:40:19 +03:00
|
|
|
|
|
|
|
property int whiteSpace: (Style.trayListItemIconSize - unifiedSearchResultItemDetails.iconWidth)
|
|
|
|
|
|
|
|
Layout.preferredWidth: unifiedSearchResultItemDetails.iconWidth
|
|
|
|
Layout.preferredHeight: unifiedSearchResultItemDetails.iconWidth
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
|
|
|
Layout.leftMargin: Style.trayHorizontalMargin + (whiteSpace * (0.5 - Style.thumbnailImageSizeReduction))
|
|
|
|
Layout.rightMargin: whiteSpace * (0.5 + Style.thumbnailImageSizeReduction)
|
|
|
|
|
2021-09-09 14:33:57 +03:00
|
|
|
Image {
|
|
|
|
id: unifiedSearchResultThumbnail
|
2022-08-09 00:40:19 +03:00
|
|
|
anchors.fill: parent
|
2021-09-09 14:33:57 +03:00
|
|
|
visible: false
|
|
|
|
asynchronous: true
|
2022-08-09 00:40:19 +03:00
|
|
|
source: "image://tray-image-provider/" + unifiedSearchResultItemDetails.icons
|
2021-09-09 14:33:57 +03:00
|
|
|
cache: true
|
2022-08-09 00:40:19 +03:00
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
sourceSize.width: width
|
|
|
|
sourceSize.height: height
|
2021-09-09 14:33:57 +03:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
id: mask
|
2022-08-09 00:40:19 +03:00
|
|
|
anchors.fill: unifiedSearchResultThumbnail
|
2021-09-09 14:33:57 +03:00
|
|
|
visible: false
|
2022-08-09 00:40:19 +03:00
|
|
|
radius: unifiedSearchResultItemDetails.isRounded ? width / 2 : 3
|
2021-09-09 14:33:57 +03:00
|
|
|
}
|
|
|
|
OpacityMask {
|
|
|
|
id: imageData
|
2022-08-09 00:40:19 +03:00
|
|
|
anchors.fill: unifiedSearchResultThumbnail
|
|
|
|
visible: unifiedSearchResultItemDetails.icons !== ""
|
2021-09-09 14:33:57 +03:00
|
|
|
source: unifiedSearchResultThumbnail
|
|
|
|
maskSource: mask
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: unifiedSearchResultThumbnailPlaceholder
|
2022-08-09 00:40:19 +03:00
|
|
|
anchors.fill: parent
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2021-09-09 14:33:57 +03:00
|
|
|
cache: true
|
2022-08-09 00:40:19 +03:00
|
|
|
source: "image://tray-image-provider/" + unifiedSearchResultItemDetails.iconPlaceholder
|
|
|
|
visible: unifiedSearchResultItemDetails.iconPlaceholder !== "" && unifiedSearchResultItemDetails.icons === ""
|
2021-09-09 14:33:57 +03:00
|
|
|
sourceSize.height: unifiedSearchResultItemDetails.iconWidth
|
|
|
|
sourceSize.width: unifiedSearchResultItemDetails.iconWidth
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-21 18:48:44 +03:00
|
|
|
ListItemLineAndSubline {
|
2021-09-09 14:33:57 +03:00
|
|
|
id: unifiedSearchResultTextContainer
|
2022-08-09 00:40:19 +03:00
|
|
|
|
2023-04-21 18:48:44 +03:00
|
|
|
spacing: Style.standardSpacing
|
|
|
|
|
2021-09-09 14:33:57 +03:00
|
|
|
Layout.fillWidth: true
|
2022-08-09 00:40:19 +03:00
|
|
|
Layout.rightMargin: Style.trayHorizontalMargin
|
2021-09-09 14:33:57 +03:00
|
|
|
|
2023-04-21 18:48:44 +03:00
|
|
|
lineText: unifiedSearchResultItemDetails.title.replace(/[\r\n]+/g, " ")
|
|
|
|
sublineText: unifiedSearchResultItemDetails.subline.replace(/[\r\n]+/g, " ")
|
2021-09-09 14:33:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|