summary refs log tree commit diff
path: root/src/emoji
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
commit0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a (patch)
tree21f655d30630fe77ba48d07e4b357e2b6c6a5730 /src/emoji
parentMerge pull request #372 from bebehei/notification (diff)
downloadnheko-0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a.tar.xz
Move all files under src/
Diffstat (limited to 'src/emoji')
-rw-r--r--src/emoji/Category.cpp (renamed from src/emoji/Category.cc)0
-rw-r--r--src/emoji/Category.h59
-rw-r--r--src/emoji/ItemDelegate.cpp (renamed from src/emoji/ItemDelegate.cc)0
-rw-r--r--src/emoji/ItemDelegate.h43
-rw-r--r--src/emoji/Panel.cpp (renamed from src/emoji/Panel.cc)4
-rw-r--r--src/emoji/Panel.h66
-rw-r--r--src/emoji/PickButton.cpp (renamed from src/emoji/PickButton.cc)0
-rw-r--r--src/emoji/PickButton.h53
-rw-r--r--src/emoji/Provider.cpp (renamed from src/emoji/Provider.cc)0
-rw-r--r--src/emoji/Provider.h45
10 files changed, 268 insertions, 2 deletions
diff --git a/src/emoji/Category.cc b/src/emoji/Category.cpp

index c1b526f2..c1b526f2 100644 --- a/src/emoji/Category.cc +++ b/src/emoji/Category.cpp
diff --git a/src/emoji/Category.h b/src/emoji/Category.h new file mode 100644
index 00000000..a14029c8 --- /dev/null +++ b/src/emoji/Category.h
@@ -0,0 +1,59 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QLabel> +#include <QLayout> +#include <QListView> +#include <QStandardItemModel> + +#include "ItemDelegate.h" + +namespace emoji { + +class Category : public QWidget +{ + Q_OBJECT + +public: + Category(QString category, std::vector<Emoji> emoji, QWidget *parent = nullptr); + +signals: + void emojiSelected(const QString &emoji); + +protected: + void paintEvent(QPaintEvent *event) override; + +private slots: + void clickIndex(const QModelIndex &index) + { + emit emojiSelected(index.data(Qt::UserRole).toString()); + }; + +private: + QVBoxLayout *mainLayout_; + + QStandardItemModel *itemModel_; + QListView *emojiListView_; + + emoji::Emoji *data_; + emoji::ItemDelegate *delegate_; + + QLabel *category_; +}; +} // namespace emoji diff --git a/src/emoji/ItemDelegate.cc b/src/emoji/ItemDelegate.cpp
index 2cc838e3..2cc838e3 100644 --- a/src/emoji/ItemDelegate.cc +++ b/src/emoji/ItemDelegate.cpp
diff --git a/src/emoji/ItemDelegate.h b/src/emoji/ItemDelegate.h new file mode 100644
index 00000000..e0456308 --- /dev/null +++ b/src/emoji/ItemDelegate.h
@@ -0,0 +1,43 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QModelIndex> +#include <QStandardItemModel> +#include <QStyledItemDelegate> + +#include "Provider.h" + +namespace emoji { + +class ItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + explicit ItemDelegate(QObject *parent = nullptr); + ~ItemDelegate(); + + void paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + +private: + Emoji *data_; +}; +} // namespace emoji diff --git a/src/emoji/Panel.cc b/src/emoji/Panel.cpp
index 89c3f823..710b501e 100644 --- a/src/emoji/Panel.cc +++ b/src/emoji/Panel.cpp
@@ -19,8 +19,8 @@ #include <QScrollBar> #include <QVBoxLayout> -#include "DropShadow.h" -#include "FlatButton.h" +#include "ui/DropShadow.h" +#include "ui/FlatButton.h" #include "emoji/Category.h" #include "emoji/Panel.h" diff --git a/src/emoji/Panel.h b/src/emoji/Panel.h new file mode 100644
index 00000000..ad233c27 --- /dev/null +++ b/src/emoji/Panel.h
@@ -0,0 +1,66 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QScrollArea> + +#include "Provider.h" + +namespace emoji { + +class Category; + +class Panel : public QWidget +{ + Q_OBJECT + +public: + Panel(QWidget *parent = nullptr); + +signals: + void mouseLeft(); + void emojiSelected(const QString &emoji); + +protected: + void leaveEvent(QEvent *event) override + { + emit leaving(); + QWidget::leaveEvent(event); + } + + void paintEvent(QPaintEvent *event) override; + +signals: + void leaving(); + +private: + void showCategory(const Category *category); + + Provider emoji_provider_; + + QScrollArea *scrollArea_; + + int shadowMargin_; + + // Panel dimensions. + int width_; + int height_; + + int categoryIconSize_; +}; +} // namespace emoji diff --git a/src/emoji/PickButton.cc b/src/emoji/PickButton.cpp
index d2b4e9fd..d2b4e9fd 100644 --- a/src/emoji/PickButton.cc +++ b/src/emoji/PickButton.cpp
diff --git a/src/emoji/PickButton.h b/src/emoji/PickButton.h new file mode 100644
index 00000000..d14067c6 --- /dev/null +++ b/src/emoji/PickButton.h
@@ -0,0 +1,53 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QEvent> +#include <QTimer> +#include <QWidget> + +#include "ui/FlatButton.h" + +namespace emoji { + +class Panel; + +class PickButton : public FlatButton +{ + Q_OBJECT +public: + explicit PickButton(QWidget *parent = nullptr); + +signals: + void emojiSelected(const QString &emoji); + +protected: + void enterEvent(QEvent *e) override; + void leaveEvent(QEvent *e) override; + +private: + // Vertical distance from panel's bottom. + int vertical_distance_ = 10; + + // Horizontal distance from panel's bottom right corner. + int horizontal_distance_ = 70; + + QSharedPointer<Panel> panel_; + QTimer hideTimer_; +}; +} // namespace emoji diff --git a/src/emoji/Provider.cc b/src/emoji/Provider.cpp
index f7b8dab9..f7b8dab9 100644 --- a/src/emoji/Provider.cc +++ b/src/emoji/Provider.cpp
diff --git a/src/emoji/Provider.h b/src/emoji/Provider.h new file mode 100644
index 00000000..5cc3ced4 --- /dev/null +++ b/src/emoji/Provider.h
@@ -0,0 +1,45 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * 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 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <QString> +#include <vector> + +namespace emoji { + +struct Emoji +{ + // Unicode code. + QString unicode; + // Keyboard shortcut e.g :emoji: + QString shortname; +}; + +class Provider +{ +public: + static const std::vector<Emoji> people; + static const std::vector<Emoji> nature; + static const std::vector<Emoji> food; + static const std::vector<Emoji> activity; + static const std::vector<Emoji> travel; + static const std::vector<Emoji> objects; + static const std::vector<Emoji> symbols; + static const std::vector<Emoji> flags; +}; +} // namespace emoji