Commit 57dc99f1 authored by Jonah Brüchert's avatar Jonah Brüchert Committed by Linus Jahn

Add Emoji Picker from spectral

parent 2292904b
Pipeline #331 passed with stages
in 4 minutes and 58 seconds
......@@ -5,9 +5,9 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: src/*
utils/*
misc/*
Copyright: 2016-2018, Linus Jahn <lnj@kaidan.im>
2016-2018, Jonah Brüchert <jbb@kaidan.im>
2017-2018, Ilya Bizyaev <bizyaev@zoho.com>
Copyright: 2016-2019, Linus Jahn <lnj@kaidan.im>
2016-2019, Jonah Brüchert <jbb@kaidan.im>
2017-2019, Ilya Bizyaev <bizyaev@zoho.com>
2018, Allan Nordhøy <epost@anotheragency.no>
2018, Nicolas Fella <nicolas.fella@gmx.de>
2018, Bjarne Roß <ross.b@freenet.de>
......@@ -43,6 +43,12 @@ Copyright: 2016, J-P Nurmi <jpnurmi@gmail.com>
2015-2018, Itay Grudev <itay+github.com@grudev.com>
License: MIT
Files: src/EmojiModel.cpp
src/EmojiModel.h
qml/elements/EmojiPicker.qml
Copyright: 2017, Konstantinos Sideris <siderisk@auth.gr>
License: GPL-3+
Files: data/images/message_checkmark.svg
data/images/diaspora.svg
Copyright: 2014, Michael Kurz <betheg@bitcloner.org>
......
......@@ -22,6 +22,7 @@
<file alias="qml/elements/SendMediaSheet.qml">src/qml/elements/SendMediaSheet.qml</file>
<file alias="qml/elements/MediaPreviewImage.qml">src/qml/elements/MediaPreviewImage.qml</file>
<file alias="qml/elements/MediaPreviewOther.qml">src/qml/elements/MediaPreviewOther.qml</file>
<file alias="qml/elements/EmojiPicker.qml">src/qml/elements/EmojiPicker.qml</file>
<file alias="qtquickcontrols2.conf">misc/qtquickcontrols2.conf</file>
</qresource>
......
......@@ -46,4 +46,8 @@
<qresource prefix="/icons/breeze/mimetypes/22">
<file alias="text-x-plain.svg">3rdparty/breeze-icons/icons/mimetypes/22/text-x-plain.svg</file>
</qresource>
<qresource prefix="icons/breeze/preferences/32">
<file alias="preferences-desktop-emoticons.svg">3rdparty/breeze-icons/icons/preferences/32/preferences-desktop-emoticons.svg</file>
</qresource>
</RCC>
......@@ -18,6 +18,7 @@ set(KAIDAN_SOURCES
${CURDIR}/LogHandler.cpp
${CURDIR}/StatusBar.cpp
${CURDIR}/UploadManager.cpp
${CURDIR}/EmojiModel.cpp
# needed to trigger moc generation
${CURDIR}/Enums.h
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef EMOJIMODEL_H
#define EMOJIMODEL_H
#include <QObject>
#include <QVariant>
#include <QVector>
struct Emoji {
Emoji(const QString& u, const QString& s) : unicode(u), shortname(s) {}
Emoji() {}
QString unicode;
QString shortname;
Q_GADGET
Q_PROPERTY(QString unicode MEMBER unicode)
Q_PROPERTY(QString shortname MEMBER shortname)
};
Q_DECLARE_METATYPE(Emoji)
class EmojiModel : public QObject {
Q_OBJECT
Q_PROPERTY(QVariantMap model READ getModel CONSTANT)
public:
Q_INVOKABLE QVariantMap getModel();
Q_INVOKABLE QVariantList filterModel(const QString& filter);
private:
static const QVariantList people;
static const QVariantList nature;
static const QVariantList food;
static const QVariantList activity;
static const QVariantList travel;
static const QVariantList objects;
static const QVariantList symbols;
static const QVariantList flags;
};
#endif // EMOJIMODEL_H
......@@ -52,6 +52,7 @@
#include "Globals.h"
#include "Enums.h"
#include "StatusBar.h"
#include "EmojiModel.h"
#ifdef STATIC_BUILD
#include "static_plugins.h"
......@@ -164,6 +165,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qRegisterMetaType<QXmppClient::State>("QXmppClient::State");
qRegisterMetaType<MessageType>("MessageType");
qRegisterMetaType<DisconnectionReason>("DisconnectionReason");
qRegisterMetaType<EmojiModel*>("EmojiModel");
// Qt-Translator
QTranslator qtTranslator;
......@@ -256,6 +258,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
KirigamiPlugin::getInstance().registerTypes();
#endif
qmlRegisterType<StatusBar>("StatusBar", 0, 1, "StatusBar");
qmlRegisterType<EmojiModel>("EmojiModel", 0, 1, "EmojiModel");
qmlRegisterUncreatableMetaObject(Enums::staticMetaObject, APPLICATION_ID,
1, 0, "Enums", "Can't create object; only enums defined!");
......
......@@ -34,6 +34,7 @@ import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
import QtGraphicalEffects 1.0
import im.kaidan.kaidan 1.0
import EmojiModel 0.1
import "elements"
Kirigami.ScrollablePage {
......@@ -217,6 +218,39 @@ Kirigami.ScrollablePage {
}
}
EmojiPicker {
x: -width + parent.width
y: -height - 16
width: Kirigami.Units.gridUnit * 20
height: Kirigami.Units.gridUnit * 15
id: emojiPicker
emojiModel: EmojiModel {
id: emojiModel
}
textArea: messageField
}
Controls.ToolButton {
id: emojiPickerButton
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
padding: 0
Kirigami.Icon {
source: "preferences-desktop-emoticons"
enabled: sendButton.enabled
isMask: true
smooth: true
anchors.centerIn: parent
width: Kirigami.Units.gridUnit * 2
height: width
}
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.open()
}
Controls.ToolButton {
id: sendButton
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
Popup {
property var emojiModel
property var textArea
property string emojiCategory: "people"
ColumnLayout {
anchors.fill: parent
GridView {
Layout.fillWidth: true
Layout.fillHeight: true
cellWidth: Kirigami.Units.gridUnit * 2.5
cellHeight: Kirigami.Units.gridUnit * 2.5
boundsBehavior: Flickable.DragOverBounds
clip: true
model: emojiModel.model[emojiCategory]
delegate: ItemDelegate {
width: Kirigami.Units.gridUnit * 2
height: Kirigami.Units.gridUnit * 2
contentItem: Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 20
font.family: "NotoColorEmoji"
text: modelData.unicode
}
hoverEnabled: true
ToolTip.text: modelData.shortname
ToolTip.visible: hovered
onClicked: textArea.insert(textArea.cursorPosition, modelData.unicode)
}
ScrollBar.vertical: ScrollBar {}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 2
color: Kirigami.Theme.highlightColor
}
Row {
Repeater {
model: ListModel {
ListElement { label: "😏"; category: "people" }
ListElement { label: "🌲"; category: "nature" }
ListElement { label: "🍛"; category: "food"}
ListElement { label: "🚁"; category: "activity" }
ListElement { label: "🚅"; category: "travel" }
ListElement { label: "💡"; category: "objects" }
ListElement { label: "🔣"; category: "symbols" }
ListElement { label: "🏁"; category: "flags" }
}
delegate: ItemDelegate {
width: Kirigami.Units.gridUnit * 2
height: Kirigami.Units.gridUnit * 2
contentItem: Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 20
font.family: "NotoColorEmoji"
text: label
}
hoverEnabled: true
ToolTip.text: category
ToolTip.visible: hovered
onClicked: emojiCategory = category
}
}
}
}
}
......@@ -274,6 +274,13 @@ def main():
"Itay Grudev <itay+github.com@grudev.com>": CopyrightAuthor(years = "2015-2018")
}
),
CopyrightTarget(
files = ["src/EmojiModel.cpp", "src/EmojiModel.h", "qml/elements/EmojiPicker.qml"],
licenseName = "GPL-3+",
authorList = {
"Konstantinos Sideris <siderisk@auth.gr>": CopyrightAuthor(years = "2017"),
},
),
CopyrightTarget(
files = ["data/images/message_checkmark.svg", "data/images/diaspora.svg"],
licenseName = "GPL-3+",
......
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