2021-09-09 12:18:22 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Felix Weilbach <felix.weilbach@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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
2022-06-08 03:30:22 +03:00
|
|
|
import Style 1.0
|
2021-09-09 12:18:22 +03:00
|
|
|
import com.nextcloud.desktopclient 1.0 as NC
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
NC.EmojiModel {
|
|
|
|
id: emojiModel
|
|
|
|
}
|
|
|
|
|
|
|
|
signal chosen(string emoji)
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
FontMetrics {
|
|
|
|
id: metrics
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: headerLayout
|
|
|
|
Layout.fillWidth: true
|
2022-06-08 03:30:22 +03:00
|
|
|
Layout.margins: 1
|
2021-09-09 12:18:22 +03:00
|
|
|
implicitWidth: contentItem.childrenRect.width
|
|
|
|
implicitHeight: metrics.height * 2
|
|
|
|
|
|
|
|
orientation: ListView.Horizontal
|
|
|
|
|
|
|
|
model: emojiModel.emojiCategoriesModel
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
2022-06-08 03:30:22 +03:00
|
|
|
id: headerDelegate
|
2021-09-09 12:18:22 +03:00
|
|
|
width: metrics.height * 2
|
|
|
|
height: headerLayout.height
|
|
|
|
|
2022-06-08 03:30:22 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: Style.lightHover
|
|
|
|
visible: ListView.isCurrentItem || headerDelegate.highlighted || headerDelegate.checked || headerDelegate.down || headerDelegate.hovered
|
|
|
|
radius: Style.slightlyRoundedButtonRadius
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Label {
|
2021-09-09 12:18:22 +03:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
text: emoji
|
2022-06-08 03:30:22 +03:00
|
|
|
color: Style.ncTextColor
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
width: parent.width
|
2022-06-08 03:30:22 +03:00
|
|
|
height: Style.thickBorderWidth
|
2021-09-09 12:18:22 +03:00
|
|
|
|
|
|
|
visible: ListView.isCurrentItem
|
|
|
|
|
2022-06-08 03:30:22 +03:00
|
|
|
color: Style.menuBorder
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
emojiModel.setCategory(label)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2022-06-08 03:30:22 +03:00
|
|
|
height: Style.normalBorderWidth
|
2021-09-09 12:18:22 +03:00
|
|
|
Layout.fillWidth: true
|
2022-06-08 03:30:22 +03:00
|
|
|
color: Style.menuBorder
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.preferredHeight: metrics.height * 8
|
2022-06-08 03:30:22 +03:00
|
|
|
Layout.margins: Style.normalBorderWidth
|
2021-09-09 12:18:22 +03:00
|
|
|
|
|
|
|
cellWidth: metrics.height * 2
|
|
|
|
cellHeight: metrics.height * 2
|
|
|
|
|
|
|
|
boundsBehavior: Flickable.DragOverBounds
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
model: emojiModel.model
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
2022-06-08 03:30:22 +03:00
|
|
|
id: emojiDelegate
|
2021-09-09 12:18:22 +03:00
|
|
|
|
|
|
|
width: metrics.height * 2
|
|
|
|
height: metrics.height * 2
|
|
|
|
|
2022-06-08 03:30:22 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: Style.lightHover
|
|
|
|
visible: ListView.isCurrentItem || emojiDelegate.highlighted || emojiDelegate.checked || emojiDelegate.down || emojiDelegate.hovered
|
|
|
|
radius: Style.slightlyRoundedButtonRadius
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Label {
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-09-09 12:18:22 +03:00
|
|
|
text: modelData === undefined ? "" : modelData.unicode
|
2022-06-08 03:30:22 +03:00
|
|
|
color: Style.ncTextColor
|
2021-09-09 12:18:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
chosen(modelData.unicode);
|
|
|
|
emojiModel.emojiUsed(modelData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|