Browse Source

first implementation of emojis

pull/170/head
DenioD 4 years ago
parent
commit
27d743646a
  1. 13
      application.qrc
  2. BIN
      res/emoji/emoji1.png
  3. BIN
      res/emoji/fire.png
  4. BIN
      res/emoji/heart_eyes.png
  5. BIN
      res/emoji/innocent.png
  6. BIN
      res/emoji/joy.png
  7. BIN
      res/emoji/laughing.png
  8. BIN
      res/emoji/money-mouth.png
  9. BIN
      res/emoji/partying_face.png
  10. BIN
      res/emoji/sweet_smile.png
  11. 2
      silentdragon-lite.pro
  12. 20
      src/Chat/Helper/ChatDelegator.h
  13. 8
      src/connection.cpp
  14. 3
      src/connection.h
  15. 196
      src/emoji.ui
  16. 68
      src/mainwindow.cpp
  17. 6
      src/mainwindow.h
  18. 55
      src/mainwindow.ui

13
application.qrc

@ -51,6 +51,7 @@
<file>res/money-mouth.png</file>
<file>res/money-outgoing.png</file>
<file>res/hush-money-white.png</file>
</qresource>
<qresource prefix="/img">
<file>res/hushdlogo.gif</file>
@ -60,6 +61,18 @@
<file>res/silentdragonlite-animated-startup-dark.gif</file>
<file>res/loaderblack.gif</file>
<file>res/loaderwhite.gif</file>
</qresource>
<qresource prefix="/emoji">
<file>res/emoji/emoji1.png</file>
<file>res/emoji/laughing.png</file>
<file>res/emoji/money-mouth.png</file>
<file>res/emoji/sweet_smile.png</file>
<file>res/emoji/joy.png</file>
<file>res/emoji/innocent.png</file>
<file>res/emoji/partying_face.png</file>
<file>res/emoji/heart_eyes.png</file>
<file>res/emoji/fire.png</file>
</qresource>
<qresource prefix="/translations">
<file>res/silentdragonlite_de.qm</file>

BIN
res/emoji/emoji1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
res/emoji/fire.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
res/emoji/heart_eyes.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
res/emoji/innocent.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
res/emoji/joy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
res/emoji/laughing.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
res/emoji/money-mouth.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
res/emoji/partying_face.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
res/emoji/sweet_smile.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

2
silentdragon-lite.pro

@ -14,6 +14,7 @@ QT += widgets
QT += websockets
TARGET = SilentDragonLite
TEMPLATE = app
@ -121,6 +122,7 @@ HEADERS += \
FORMS += \
src/contactrequest.ui \
src/deposithush.ui \
src/emoji.ui \
src/encryption.ui \
src/hushrequest.ui \
src/mainwindow.ui \

20
src/Chat/Helper/ChatDelegator.h

@ -51,6 +51,16 @@ inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem cons
bodydoc.setDefaultFont(QFont("Roboto", 12));
QString bodytext(index.data(Qt::DisplayRole).toString());
bodydoc.setHtml(bodytext.replace("\n", "<br>"));
bodydoc.setHtml(bodytext.replace(":smiley:", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":-)", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":money_mouth:", "<img src=':/emoji/res/emoji/money-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":laughing:", "<img src=':/emoji/res/emoji/laughing.png'>"));
bodydoc.setHtml(bodytext.replace(":sweet_smile:", "<img src=':/emoji/res/emoji/sweet_smile.png'>"));
bodydoc.setHtml(bodytext.replace(":joy:", "<img src=':/emoji/res/emoji/joy.png'>"));
bodydoc.setHtml(bodytext.replace(":innocent:", "<img src=':/emoji/res/emoji/innocent.png'>"));
bodydoc.setHtml(bodytext.replace(":partying_face:", "<img src=':/emoji/res/emoji/partying_face.png'>"));
bodydoc.setHtml(bodytext.replace(":heart_eyes:", "<img src=':/emoji/res/emoji/heart_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":fire:", "<img src=':/emoji/res/emoji/fire.png'>"));
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
bodydoc.setTextWidth(contentswidth);
qreal bodyheight = bodydoc.size().height();
@ -174,6 +184,16 @@ inline QSize ListViewDelegate::sizeHint(QStyleOptionViewItem const &option, QMod
bodydoc.setDefaultFont(QFont("Roboto", 12));
QString bodytext(index.data(Qt::DisplayRole).toString());
bodydoc.setHtml(bodytext.replace("\n", "<br>"));
bodydoc.setHtml(bodytext.replace(":smiley:", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":-)", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":money_mouth:", "<img src=':/emoji/res/emoji/money-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":laughing:", "<img src=':/emoji/res/emoji/laughing.png'>"));
bodydoc.setHtml(bodytext.replace(":sweet_smile:", "<img src=':/emoji/res/emoji/sweet_smile.png'>"));
bodydoc.setHtml(bodytext.replace(":joy:", "<img src=':/emoji/res/emoji/joy.png'>"));
bodydoc.setHtml(bodytext.replace(":innocent:", "<img src=':/emoji/res/emoji/innocent.png'>"));
bodydoc.setHtml(bodytext.replace(":partying_face:", "<img src=':/emoji/res/emoji/partying_face.png'>"));
bodydoc.setHtml(bodytext.replace(":heart_eyes:", "<img src=':/emoji/res/emoji/heart_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":fire:", "<img src=':/emoji/res/emoji/fire.png'>"));
// the width of the contents are the (a fraction of the window width) minus (margins + padding + width of the bubble's tail)

8
src/connection.cpp

@ -67,7 +67,6 @@ void ConnectionLoader::doAutoConnect()
{
qDebug() << "Doing autoconnect";
auto config = std::shared_ptr<ConnectionConfig>(new ConnectionConfig());
config->dangerous = false;
config->server = Settings::getInstance()->getSettings().server;
// Initialize the library
@ -78,7 +77,6 @@ void ConnectionLoader::doAutoConnect()
{
main->logger->write(QObject::tr("Using existing wallet."));
char* resp = litelib_initialize_existing(
config->dangerous,
config->server.toStdString().c_str()
);
QString response = litelib_process_response(resp);
@ -93,7 +91,7 @@ void ConnectionLoader::doAutoConnect()
else
{
main->logger->write(QObject::tr("Create/restore wallet."));
createOrRestore(config->dangerous, config->server);
createOrRestore(config->server);
d->show();
}
@ -154,12 +152,12 @@ void ConnectionLoader::doAutoConnect()
});
}
void ConnectionLoader::createOrRestore(bool dangerous, QString server)
void ConnectionLoader::createOrRestore(QString server)
{
// Close the startup dialog, since we'll be showing the wizard
d->hide();
// Create a wizard
FirstTimeWizard wizard(dangerous, server);
FirstTimeWizard wizard(server);
main->logger->write("Start new Wallet with FirstimeWizard");
wizard.exec();
}

3
src/connection.h

@ -10,7 +10,6 @@ class Controller;
struct ConnectionConfig {
QString server;
bool dangerous;
QString proxy;
};
@ -32,7 +31,7 @@ private:
void doAutoConnect();
void createOrRestore(bool dangerous, QString server);
void createOrRestore(QString server);
void showError(QString explanation);
void showInformation(QString info, QString detail = "");

196
src/emoji.ui

@ -1,72 +1,142 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>emojiDialog</class>
<widget class="QDialog" name="emojiDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>261</width>
<height>46</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
<property name="windowTitle">
<string>Emoji</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="smiley">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/emoji1.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="laughing">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/laughing.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sweet_smile">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/sweet_smile.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="joy">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/joy.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="innocent">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/innocent.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="partying_face">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/partying_face.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="money">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/res/money-mouth.png</normalon>
</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

68
src/mainwindow.cpp

@ -20,6 +20,7 @@
#include "ui_sendHushTransactionChat.h"
#include "ui_contactrequest.h"
#include "ui_deposithush.h"
#include "ui_emoji.h"
#include "ui_requestContactDialog.h"
#include "chatmodel.h"
#include "requestdialog.h"
@ -35,6 +36,9 @@
#include "DataStore/DataStore.h"
#include "firsttimewizard.h"
#include "../lib/silentdragonlitelib.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QKeyEvent>
#ifdef Q_OS_WIN
@ -2612,3 +2616,67 @@ void MainWindow::on_givemeZaddr_clicked()
});
}
void MainWindow::on_pushButton_clicked()
{
QDialog emojiDialog(this);
Ui_emojiDialog emoji;
emoji.setupUi(&emojiDialog);
Settings::saveRestore(&emojiDialog);
QObject::connect(emoji.smiley, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":smiley:");
emojiDialog.close();
});
QObject::connect(emoji.money, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":money_mouth:");
emojiDialog.close();
});
QObject::connect(emoji.laughing, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":laughing:");
emojiDialog.close();
});
QObject::connect(emoji.sweet_smile, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":sweet_smile:");
emojiDialog.close();
});
QObject::connect(emoji.joy, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":joy:");
emojiDialog.close();
});
QObject::connect(emoji.innocent, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":innocent:");
emojiDialog.close();
});
QObject::connect(emoji.partying_face, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":partying_face:");
emojiDialog.close();
});
emojiDialog.exec();
}
void MainWindow::on_comboBox_currentIndexChanged(const QString &arg1)
{
Qt::Key key = Qt::Key_1;
QKeyEvent pressEvent = QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier, QKeySequence(key).toString());
QKeyEvent releaseEvent = QKeyEvent(QEvent::KeyRelease, key, Qt::NoModifier);
QCoreApplication::sendEvent(ui->memoTxtChat, &pressEvent);
QCoreApplication::sendEvent(ui->memoTxtChat, &releaseEvent);
}

6
src/mainwindow.h

@ -111,6 +111,12 @@ private slots:
void on_givemeZaddr_clicked();
// void on_pushButton_clicked();
void on_pushButton_clicked();
void on_comboBox_currentIndexChanged(const QString &arg1);
private:
bool fileExists(QString path);

55
src/mainwindow.ui

@ -1341,8 +1341,8 @@
<attribute name="title">
<string>HushChat</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="1" rowspan="4">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18" stretch="0,0,0,0">
@ -1546,7 +1546,7 @@
</item>
</layout>
</item>
<item row="0" column="5" rowspan="4">
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_11">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
@ -1683,6 +1683,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>850</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
@ -1708,7 +1714,19 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item alignment="Qt::AlignBottom">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="sendChatButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@ -1747,7 +1765,34 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/emoji/res/emoji/emoji1.png</normalon>
</iconset>
</property>
<property name="iconSize">
<size>
<width>17</width>
<height>17</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="memoSizeChat">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">

Loading…
Cancel
Save