Browse Source

Merge pull request #191 from MyHush/dev

reduce emoji size, add hyperlink action
pull/203/merge
Denio 4 years ago
committed by GitHub
parent
commit
8cded7fbca
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 78
      src/Chat/Helper/ChatDelegator.h
  2. 132
      src/mainwindow.cpp
  3. 2
      src/startupencryption.ui

78
src/Chat/Helper/ChatDelegator.h

@ -51,27 +51,24 @@ 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(":fire:", "<img src=':/emoji/res/emoji/fire.png'>"));
bodydoc.setHtml(bodytext.replace(":rolling_eyes:", "<img src=':/emoji/res/emoji/face-with-rolling-eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":stuck_out_tongue:", "<img src=':/emoji/res/emoji/face-with-tongue.png'>"));
bodydoc.setHtml(bodytext.replace(":face_with_3hearts:", "<img src=':/emoji/res/emoji/face_with_3hearts.png'>"));
bodydoc.setHtml(bodytext.replace(":heart_eyes:", "<img src=':/emoji/res/emoji/heart_shaped_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":nauseated:", "<img src=':/emoji/res/emoji/nauseated-face.png'>"));
bodydoc.setHtml(bodytext.replace(":poop:", "<img src=':/emoji/res/emoji/pile-of-poo.png'>"));
bodydoc.setHtml(bodytext.replace(":symbols_mouth:", "<img src=':/emoji/res/emoji/serious-face-with-symbols-covering-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":sunglass:", "<img src=':/emoji/res/emoji/smiling-face-with-sunglasses.png'>"));
bodydoc.setHtml(bodytext.replace(":stuck_out:", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(";p", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(":hush_white:", "<img src=':/emoji/res/emoji/hush-money-white.png'>"));
bodydoc.setHtml(bodytext.replace(":sd:", "<img src=':/emoji/res/emoji/SD.png'>"));
bodydoc.setHtml(bodytext.replace(":a1", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":a2", "<img src=':/emoji/res/emoji/money-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":a3", "<img src=':/emoji/res/emoji/laughing.png'>"));
bodydoc.setHtml(bodytext.replace(":a4", "<img src=':/emoji/res/emoji/sweet_smile.png'>"));
bodydoc.setHtml(bodytext.replace(":a5", "<img src=':/emoji/res/emoji/joy.png'>"));
bodydoc.setHtml(bodytext.replace(":a6", "<img src=':/emoji/res/emoji/innocent.png'>"));
bodydoc.setHtml(bodytext.replace(":a7", "<img src=':/emoji/res/emoji/partying_face.png'>"));
bodydoc.setHtml(bodytext.replace(":a8", "<img src=':/emoji/res/emoji/face-with-rolling-eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":a9", "<img src=':/emoji/res/emoji/face-with-tongue.png'>"));
bodydoc.setHtml(bodytext.replace(":b1", "<img src=':/emoji/res/emoji/face_with_3hearts.png'>"));
bodydoc.setHtml(bodytext.replace(":b2", "<img src=':/emoji/res/emoji/heart_shaped_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":b3", "<img src=':/emoji/res/emoji/nauseated-face.png'>"));
bodydoc.setHtml(bodytext.replace(":b4", "<img src=':/emoji/res/emoji/pile-of-poo.png'>"));
bodydoc.setHtml(bodytext.replace(":b5", "<img src=':/emoji/res/emoji/serious-face-with-symbols-covering-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":b6", "<img src=':/emoji/res/emoji/smiling-face-with-sunglasses.png'>"));
bodydoc.setHtml(bodytext.replace(":b7", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(":b8", "<img src=':/emoji/res/emoji/hush-money-white.png'>"));
bodydoc.setHtml(bodytext.replace(":b9", "<img src=':/emoji/res/emoji/SD.png'>"));
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
bodydoc.setTextWidth(contentswidth);
qreal bodyheight = bodydoc.size().height();
@ -195,27 +192,24 @@ 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(":fire:", "<img src=':/emoji/res/emoji/fire.png'>"));
bodydoc.setHtml(bodytext.replace(":rolling_eyes:", "<img src=':/emoji/res/emoji/face-with-rolling-eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":stuck_out_tongue:", "<img src=':/emoji/res/emoji/face-with-tongue.png'>"));
bodydoc.setHtml(bodytext.replace(":face_with_3hearts:", "<img src=':/emoji/res/emoji/face_with_3hearts.png'>"));
bodydoc.setHtml(bodytext.replace(":heart_eyes:", "<img src=':/emoji/res/emoji/heart_shaped_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":nauseated:", "<img src=':/emoji/res/emoji/nauseated-face.png'>"));
bodydoc.setHtml(bodytext.replace(":poop:", "<img src=':/emoji/res/emoji/pile-of-poo.png'>"));
bodydoc.setHtml(bodytext.replace(":symbols_mouth:", "<img src=':/emoji/res/emoji/serious-face-with-symbols-covering-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":sunglass:", "<img src=':/emoji/res/emoji/smiling-face-with-sunglasses.png'>"));
bodydoc.setHtml(bodytext.replace(":stuck_out:", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(";p", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(":hush_white:", "<img src=':/emoji/res/emoji/hush-money-white.png'>"));
bodydoc.setHtml(bodytext.replace(":sd:", "<img src=':/emoji/res/emoji/SD.png'>"));
bodydoc.setHtml(bodytext.replace(":a1", "<img src=':/emoji/res/emoji/emoji1.png'>"));
bodydoc.setHtml(bodytext.replace(":a2", "<img src=':/emoji/res/emoji/money-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":a3", "<img src=':/emoji/res/emoji/laughing.png'>"));
bodydoc.setHtml(bodytext.replace(":a4", "<img src=':/emoji/res/emoji/sweet_smile.png'>"));
bodydoc.setHtml(bodytext.replace(":a5", "<img src=':/emoji/res/emoji/joy.png'>"));
bodydoc.setHtml(bodytext.replace(":a6", "<img src=':/emoji/res/emoji/innocent.png'>"));
bodydoc.setHtml(bodytext.replace(":a7", "<img src=':/emoji/res/emoji/partying_face.png'>"));
bodydoc.setHtml(bodytext.replace(":a8", "<img src=':/emoji/res/emoji/face-with-rolling-eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":a9", "<img src=':/emoji/res/emoji/face-with-tongue.png'>"));
bodydoc.setHtml(bodytext.replace(":b1", "<img src=':/emoji/res/emoji/face_with_3hearts.png'>"));
bodydoc.setHtml(bodytext.replace(":b2", "<img src=':/emoji/res/emoji/heart_shaped_eyes.png'>"));
bodydoc.setHtml(bodytext.replace(":b3", "<img src=':/emoji/res/emoji/nauseated-face.png'>"));
bodydoc.setHtml(bodytext.replace(":b4", "<img src=':/emoji/res/emoji/pile-of-poo.png'>"));
bodydoc.setHtml(bodytext.replace(":b5", "<img src=':/emoji/res/emoji/serious-face-with-symbols-covering-mouth.png'>"));
bodydoc.setHtml(bodytext.replace(":b6", "<img src=':/emoji/res/emoji/smiling-face-with-sunglasses.png'>"));
bodydoc.setHtml(bodytext.replace(":b7", "<img src=':/emoji/res/emoji/stuck-out.png'>"));
bodydoc.setHtml(bodytext.replace(":b8", "<img src=':/emoji/res/emoji/hush-money-white.png'>"));
bodydoc.setHtml(bodytext.replace(":b9", "<img src=':/emoji/res/emoji/SD.png'>"));
// the width of the contents are the (a fraction of the window width) minus (margins + padding + width of the bubble's tail)
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;

132
src/mainwindow.cpp

@ -1499,22 +1499,72 @@ void MainWindow::setupchatTab() {
QMenu* contextMenuChat;
QAction* copymessage;
QAction* viewexplorer;
QAction* copytxid;
QAction* copylink;
QAction* openlink;
contextMenuChat = new QMenu(ui->listChat);
ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu);
copymessage = new QAction("Copy message to clipboard",contextMenuChat);
viewexplorer = new QAction("View on block explorer",contextMenuChat);
copytxid = new QAction("Copy txid to clipboard ",contextMenuChat);
copylink = new QAction("Copy Hyperlink from memo ",contextMenuChat);
openlink = new QAction("Open Hyperlink in your browser",contextMenuChat);
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu);
//contextMenuChat->autoFillBackground(false);
ui->listChat->addAction(copymessage);
ui->listChat->addAction(viewexplorer);
ui->listChat->addAction(copytxid);
ui->listChat->addAction(copylink);
ui->listChat->addAction(openlink);
});
QObject::connect(copylink, &QAction::triggered, [=] {
QModelIndex index = ui->listChat->currentIndex();
QString memo_chat = index.data(Qt::DisplayRole).toString();
QClipboard *clipboard = QGuiApplication::clipboard();
QRegExp rx("((?:https?|ftp)://\\S+)");
int pos = rx.indexIn(memo_chat, 0);
if (-1 != pos)
{
QString cap = rx.cap(0);
cap = cap.left(cap.indexOf('\''));
int startPos = cap.indexOf("<p>");
int endPos = cap.indexOf("</p>");
int length = endPos - startPos;
QString hyperlink = cap.mid(startPos, length);
clipboard->setText(hyperlink);
ui->statusBar->showMessage(tr("Copied Hyperlink to clipboard"), 3 * 1000);
}
});
QObject::connect(openlink, &QAction::triggered, [=] {
QModelIndex index = ui->listChat->currentIndex();
QString memo_chat = index.data(Qt::DisplayRole).toString();
QRegExp rx("((?:https?|ftp)://\\S+)");
int pos = rx.indexIn(memo_chat, 0);
if (-1 != pos)
{
QString cap = rx.cap(0);
cap = cap.left(cap.indexOf('\''));
int startPos = cap.indexOf("<p>");
int endPos = cap.indexOf("</p>");
int length = endPos - startPos;
QString hyperlink = cap.mid(startPos, length);
QDesktopServices::openUrl(QUrl(hyperlink));
}
});
QObject::connect(copymessage, &QAction::triggered, [=] {
@ -1611,16 +1661,11 @@ void MainWindow::setupchatTab() {
///////// Add contextmenu
QMenu* contextMenu;
QAction* requestAction;
QAction* editAction;
QAction* HushAction;
QAction* requestHushAction;
QAction* subatomicAction;
contextMenu = new QMenu(ui->listContactWidget);
HushAction = new QAction("Send or Request Hush ",contextMenu);
editAction = new QAction("Delete this contact",contextMenu);
subatomicAction = new QAction("Make a subatomic swap with a friend- coming soon",contextMenu);
///////// Set selected Zaddr for Chat with click
@ -1629,7 +1674,6 @@ void MainWindow::setupchatTab() {
ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->listContactWidget->addAction(HushAction);
ui->listContactWidget->addAction(editAction);
ui->listContactWidget->addAction(subatomicAction);
ui->memoTxtChat->setEnabled(false);
ui->emojiButton->setEnabled(false);
@ -1655,8 +1699,6 @@ void MainWindow::setupchatTab() {
QDialog transactionDialog(this);
transaction.setupUi(&transactionDialog);
Settings::saveRestore(&transactionDialog);
// transaction.requestHush->setEnabled(false);
// transaction.requestHush->setVisible(false);
transaction.amountChat->setValidator(this->getAmountValidator());
QString icon = ":icons/res/hush-money-white.png";
QPixmap hush(icon);
@ -2764,111 +2806,111 @@ void MainWindow::on_emojiButton_clicked()
Settings::saveRestore(&emojiDialog);
QObject::connect(emoji.smiley, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":smiley:");
ui->memoTxtChat->insertHtml(":a1");
emojiDialog.close();
});
QObject::connect(emoji.money, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":money_mouth:");
ui->memoTxtChat->insertHtml(":a2");
emojiDialog.close();
});
QObject::connect(emoji.laughing, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":laughing:");
ui->memoTxtChat->insertHtml(":a3");
emojiDialog.close();
});
QObject::connect(emoji.sweet_smile, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":sweet_smile:");
ui->memoTxtChat->insertHtml(":a4");
emojiDialog.close();
});
QObject::connect(emoji.joy, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":joy:");
ui->memoTxtChat->insertHtml(":a5");
emojiDialog.close();
});
QObject::connect(emoji.innocent, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":innocent:");
ui->memoTxtChat->insertHtml(":a6");
emojiDialog.close();
});
QObject::connect(emoji.partying_face, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":partying_face:");
ui->memoTxtChat->insertHtml(":a7");
emojiDialog.close();
});
QObject::connect(emoji.rolling_eyes, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":rolling_eyes:");
ui->memoTxtChat->insertHtml(":a8");
emojiDialog.close();
});
QObject::connect(emoji.tongue, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":stuck_out_tongue:");
ui->memoTxtChat->insertHtml(":a9");
emojiDialog.close();
});
QObject::connect(emoji.hearts3, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":face_with_3hearts:");
ui->memoTxtChat->insertHtml(":b1");
emojiDialog.close();
});
QObject::connect(emoji.heart_eyes, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":heart_eyes:");
ui->memoTxtChat->insertHtml(":b2");
emojiDialog.close();
});
QObject::connect(emoji.nauseated, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":nauseated:");
ui->memoTxtChat->insertHtml(":b3");
emojiDialog.close();
});
QObject::connect(emoji.poop, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":poop:");
ui->memoTxtChat->insertHtml(":b4");
emojiDialog.close();
});
QObject::connect(emoji.symbols_mouth, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":symbols_mouth:");
ui->memoTxtChat->insertHtml(":b5");
emojiDialog.close();
});
QObject::connect(emoji.sunglass, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":sunglass:");
ui->memoTxtChat->insertHtml(":b6");
emojiDialog.close();
});
QObject::connect(emoji.stuck_out, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":stuck_out:");
ui->memoTxtChat->insertHtml(":b7");
emojiDialog.close();
});
QObject::connect(emoji.hush_white, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":hush_white:");
ui->memoTxtChat->insertHtml(":b8");
emojiDialog.close();
});
QObject::connect(emoji.sd, &QPushButton::clicked, [&] () {
ui->memoTxtChat->insertHtml(":sd:");
ui->memoTxtChat->insertHtml(":b9");
emojiDialog.close();
});

2
src/startupencryption.ui

@ -29,7 +29,7 @@
</size>
</property>
<property name="windowTitle">
<string>SDL Startup Decryption</string>
<string>Welcome Back</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">

Loading…
Cancel
Save