From edc3e0840a0fcedd6a34cd7d3e03f64d01952bac Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 23 Aug 2020 19:14:32 +0200 Subject: [PATCH 1/3] reduce size of emoji #183, dont close emoji window #184 --- src/Chat/Helper/ChatDelegator.h | 78 ++++++++++++++---------------- src/mainwindow.cpp | 84 ++++++++++++++++++--------------- src/startupencryption.ui | 2 +- 3 files changed, 84 insertions(+), 80 deletions(-) diff --git a/src/Chat/Helper/ChatDelegator.h b/src/Chat/Helper/ChatDelegator.h index 36a856c..6f2032d 100644 --- a/src/Chat/Helper/ChatDelegator.h +++ b/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", "
")); - bodydoc.setHtml(bodytext.replace(":smiley:", "")); - bodydoc.setHtml(bodytext.replace(":-)", "")); - bodydoc.setHtml(bodytext.replace(":money_mouth:", "")); - bodydoc.setHtml(bodytext.replace(":laughing:", "")); - bodydoc.setHtml(bodytext.replace(":sweet_smile:", "")); - bodydoc.setHtml(bodytext.replace(":joy:", "")); - bodydoc.setHtml(bodytext.replace(":innocent:", "")); - bodydoc.setHtml(bodytext.replace(":partying_face:", "")); - bodydoc.setHtml(bodytext.replace(":fire:", "")); - bodydoc.setHtml(bodytext.replace(":rolling_eyes:", "")); - bodydoc.setHtml(bodytext.replace(":stuck_out_tongue:", "")); - bodydoc.setHtml(bodytext.replace(":face_with_3hearts:", "")); - bodydoc.setHtml(bodytext.replace(":heart_eyes:", "")); - bodydoc.setHtml(bodytext.replace(":nauseated:", "")); - bodydoc.setHtml(bodytext.replace(":poop:", "")); - bodydoc.setHtml(bodytext.replace(":symbols_mouth:", "")); - bodydoc.setHtml(bodytext.replace(":sunglass:", "")); - bodydoc.setHtml(bodytext.replace(":stuck_out:", "")); - bodydoc.setHtml(bodytext.replace(";p", "")); - bodydoc.setHtml(bodytext.replace(":hush_white:", "")); - bodydoc.setHtml(bodytext.replace(":sd:", "")); + bodydoc.setHtml(bodytext.replace(":a1", "")); + bodydoc.setHtml(bodytext.replace(":a2", "")); + bodydoc.setHtml(bodytext.replace(":a3", "")); + bodydoc.setHtml(bodytext.replace(":a4", "")); + bodydoc.setHtml(bodytext.replace(":a5", "")); + bodydoc.setHtml(bodytext.replace(":a6", "")); + bodydoc.setHtml(bodytext.replace(":a7", "")); + bodydoc.setHtml(bodytext.replace(":a8", "")); + bodydoc.setHtml(bodytext.replace(":a9", "")); + bodydoc.setHtml(bodytext.replace(":b1", "")); + bodydoc.setHtml(bodytext.replace(":b2", "")); + bodydoc.setHtml(bodytext.replace(":b3", "")); + bodydoc.setHtml(bodytext.replace(":b4", "")); + bodydoc.setHtml(bodytext.replace(":b5", "")); + bodydoc.setHtml(bodytext.replace(":b6", "")); + bodydoc.setHtml(bodytext.replace(":b7", "")); + bodydoc.setHtml(bodytext.replace(":b8", "")); + bodydoc.setHtml(bodytext.replace(":b9", "")); 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", "
")); - bodydoc.setHtml(bodytext.replace(":smiley:", "")); - bodydoc.setHtml(bodytext.replace(":-)", "")); - bodydoc.setHtml(bodytext.replace(":money_mouth:", "")); - bodydoc.setHtml(bodytext.replace(":laughing:", "")); - bodydoc.setHtml(bodytext.replace(":sweet_smile:", "")); - bodydoc.setHtml(bodytext.replace(":joy:", "")); - bodydoc.setHtml(bodytext.replace(":innocent:", "")); - bodydoc.setHtml(bodytext.replace(":partying_face:", "")); - bodydoc.setHtml(bodytext.replace(":fire:", "")); - bodydoc.setHtml(bodytext.replace(":rolling_eyes:", "")); - bodydoc.setHtml(bodytext.replace(":stuck_out_tongue:", "")); - bodydoc.setHtml(bodytext.replace(":face_with_3hearts:", "")); - bodydoc.setHtml(bodytext.replace(":heart_eyes:", "")); - bodydoc.setHtml(bodytext.replace(":nauseated:", "")); - bodydoc.setHtml(bodytext.replace(":poop:", "")); - bodydoc.setHtml(bodytext.replace(":symbols_mouth:", "")); - bodydoc.setHtml(bodytext.replace(":sunglass:", "")); - bodydoc.setHtml(bodytext.replace(":stuck_out:", "")); - bodydoc.setHtml(bodytext.replace(";p", "")); - bodydoc.setHtml(bodytext.replace(":hush_white:", "")); - bodydoc.setHtml(bodytext.replace(":sd:", "")); + bodydoc.setHtml(bodytext.replace(":a1", "")); + bodydoc.setHtml(bodytext.replace(":a2", "")); + bodydoc.setHtml(bodytext.replace(":a3", "")); + bodydoc.setHtml(bodytext.replace(":a4", "")); + bodydoc.setHtml(bodytext.replace(":a5", "")); + bodydoc.setHtml(bodytext.replace(":a6", "")); + bodydoc.setHtml(bodytext.replace(":a7", "")); + bodydoc.setHtml(bodytext.replace(":a8", "")); + bodydoc.setHtml(bodytext.replace(":a9", "")); + bodydoc.setHtml(bodytext.replace(":b1", "")); + bodydoc.setHtml(bodytext.replace(":b2", "")); + bodydoc.setHtml(bodytext.replace(":b3", "")); + bodydoc.setHtml(bodytext.replace(":b4", "")); + bodydoc.setHtml(bodytext.replace(":b5", "")); + bodydoc.setHtml(bodytext.replace(":b6", "")); + bodydoc.setHtml(bodytext.replace(":b7", "")); + bodydoc.setHtml(bodytext.replace(":b8", "")); + bodydoc.setHtml(bodytext.replace(":b9", "")); // 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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d89fae4..dc9a58f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1499,19 +1499,29 @@ 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); }); @@ -2764,111 +2774,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(); + }); diff --git a/src/startupencryption.ui b/src/startupencryption.ui index a8d0325..6a7b8ac 100644 --- a/src/startupencryption.ui +++ b/src/startupencryption.ui @@ -29,7 +29,7 @@ - SDL Startup Decryption + Welcome Back From f4c02946dda3f510102253779e5c88c8baf082c3 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 23 Aug 2020 19:32:03 +0200 Subject: [PATCH 2/3] copy hyperlink from memo/open in browser --- src/mainwindow.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dc9a58f..6de4514 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1525,6 +1525,47 @@ void MainWindow::setupchatTab() { }); +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("

"); + int endPos = cap.indexOf("

"); + 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(); +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("

"); + int endPos = cap.indexOf("

"); + int length = endPos - startPos; + QString hyperlink = cap.mid(startPos, length); + QDesktopServices::openUrl(QUrl(hyperlink)); + +} +}); + QObject::connect(copymessage, &QAction::triggered, [=] { From fcd2fc634b5313667597efcceaa66a63759ba689 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 23 Aug 2020 19:36:00 +0200 Subject: [PATCH 3/3] delete action --- src/mainwindow.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6de4514..79da896 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1550,7 +1550,6 @@ QObject::connect(openlink, &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) @@ -1662,16 +1661,11 @@ if (-1 != pos) ///////// 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 @@ -1680,7 +1674,6 @@ if (-1 != pos) 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); @@ -1706,8 +1699,6 @@ if (-1 != pos) 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);