Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(gischat): add emoji picker #183

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions qtribu/gui/dck_qchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, Optional

# PyQGIS
#
from PyQt5 import QtWebSockets # noqa QGS103
from qgis.core import Qgis, QgsApplication
from qgis.gui import QgisInterface, QgsDockWidget
Expand All @@ -14,6 +13,7 @@
from qgis.PyQt.QtGui import QBrush, QColor, QCursor, QIcon
from qgis.PyQt.QtWidgets import QAction, QMenu, QMessageBox, QTreeWidgetItem, QWidget

# plugin
from qtribu.__about__ import __title__
from qtribu.constants import (
ADMIN_MESSAGES_AVATAR,
Expand All @@ -27,10 +27,9 @@
INTERNAL_MESSAGE_AUTHOR,
QCHAT_NICKNAME_MINLENGTH,
)
from qtribu.gui.dlg_emoji_picker import EmojiPicker
from qtribu.logic.qchat_client import QChatApiClient
from qtribu.tasks.dizzy import DizzyTask

# plugin
from qtribu.toolbelt import PlgLogger, PlgOptionsManager
from qtribu.toolbelt.commons import open_url_in_webviewer, play_resource_sound
from qtribu.toolbelt.preferences import PlgSettingsStructure
Expand Down Expand Up @@ -58,6 +57,8 @@ def __init__(self, iface: QgisInterface, parent: QWidget = None):
self.task_manager = QgsApplication.taskManager()
self.log = PlgLogger().log
self.plg_settings = PlgOptionsManager()
self.emoji_picker_new = EmojiPicker(self)

uic.loadUi(Path(__file__).parent / f"{Path(__file__).stem}.ui", self)

# rules and status signal listener
Expand Down Expand Up @@ -114,6 +115,8 @@ def __init__(self, iface: QgisInterface, parent: QWidget = None):
self.btn_send.setIcon(
QIcon(QgsApplication.iconPath("mActionDoubleArrowRight.svg"))
)
# connect emojis picker
self.btn_emojis_picker.pressed.connect(self.on_emoji_picker_pressed)

@property
def settings(self) -> PlgSettingsStructure:
Expand Down Expand Up @@ -622,6 +625,18 @@ def check_cheatcode(self, message: dict[str, str]) -> bool:
return True
return False

def on_emoji_picker_pressed(self) -> Optional[str]:
"""Display the emoji picker and insert the selected one at the end of message line edit.

:return: selected emoji
:rtype: str
"""
self.emoji_picker_new.show()
# selected_emoji = self.emoji_picker.select()
# self.lne_message.insert(selected_emoji)

# return selected_emoji

def on_renew_clicked(self) -> None:
msg_box = QMessageBox()
msg_box.setWindowTitle(self.tr("QGIS"))
Expand Down
80 changes: 53 additions & 27 deletions qtribu/gui/dck_qchat.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>441</width>
<height>887</height>
<width>482</width>
<height>672</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -182,7 +182,7 @@
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
<number>4</number>
</property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
Expand All @@ -205,6 +205,11 @@
<string notr="true">3</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">4</string>
</property>
</column>
</widget>
</item>
<item>
Expand Down Expand Up @@ -247,13 +252,26 @@
<string>User</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="lbl_nickname_text">
<property name="text">
<string>Nickname:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="lbl_nickname">
<property name="cursor">
<cursorShape>ForbiddenCursor</cursorShape>
</property>
<property name="toolTip">
<string>Nickname set in QTribu's plugin settings</string>
</property>
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_message">
<property name="text">
Expand All @@ -271,25 +289,38 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lbl_nickname">
<property name="cursor">
<cursorShape>ForbiddenCursor</cursorShape>
</property>
<property name="toolTip">
<string>Nickname set in QTribu's plugin settings</string>
</property>
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QgsFilterLineEdit" name="lne_message">
<property name="qgisRelation" stdset="0">
<string notr="true"/>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lne_message">
<property name="maxLength">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_emojis_picker">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="toolTip">
<string>Pick an emoji. Not sure it'll be properly rendered for every users, still it's a bit of un.</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>😀</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand All @@ -314,11 +345,6 @@
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>grb_instance</tabstop>
Expand Down
Loading
Loading