mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(status): add ability to copy status messages
Adds the ability to copy status messages via a context menu on the status message label. Closes issue #3155
This commit is contained in:
parent
6dd1cd0320
commit
57ce030f1d
|
@ -29,9 +29,11 @@
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QApplication>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
#include <QClipboard>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "chatform.h"
|
#include "chatform.h"
|
||||||
#include "src/audio/audio.h"
|
#include "src/audio/audio.h"
|
||||||
|
@ -79,6 +81,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
||||||
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||||
statusMessageLabel->setTextFormat(Qt::PlainText);
|
statusMessageLabel->setTextFormat(Qt::PlainText);
|
||||||
|
statusMessageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
callConfirm = nullptr;
|
callConfirm = nullptr;
|
||||||
offlineEngine = new OfflineMsgEngine(f);
|
offlineEngine = new OfflineMsgEngine(f);
|
||||||
|
@ -100,6 +103,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);
|
connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);
|
||||||
|
|
||||||
loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));
|
loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));
|
||||||
|
copyStatusAction = statusMessageMenu.addAction(QString(), this, SLOT(onCopyStatusMessage()));
|
||||||
|
|
||||||
connect(core, &Core::fileSendStarted, this, &ChatForm::startFileSend);
|
connect(core, &Core::fileSendStarted, this, &ChatForm::startFileSend);
|
||||||
connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered);
|
connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered);
|
||||||
|
@ -111,6 +115,15 @@ ChatForm::ChatForm(Friend* chatFriend)
|
||||||
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
|
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
|
||||||
connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
|
||||||
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
|
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
|
||||||
|
connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
|
||||||
|
{
|
||||||
|
if(!statusMessageLabel->text().isEmpty())
|
||||||
|
{
|
||||||
|
QWidget* sender = static_cast<QWidget*>(QObject::sender());
|
||||||
|
|
||||||
|
statusMessageMenu.exec(sender->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
} );
|
||||||
connect(&typingTimer, &QTimer::timeout, this, [=]{
|
connect(&typingTimer, &QTimer::timeout, this, [=]{
|
||||||
Core::getInstance()->sendTyping(f->getFriendID(), false);
|
Core::getInstance()->sendTyping(f->getFriendID(), false);
|
||||||
isTyping = false;
|
isTyping = false;
|
||||||
|
@ -826,6 +839,17 @@ void ChatForm::onMessageInserted()
|
||||||
netcam->setShowMessages(true, true);
|
netcam->setShowMessages(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatForm::onCopyStatusMessage()
|
||||||
|
{
|
||||||
|
QString text = statusMessageLabel->text();
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
|
if (clipboard)
|
||||||
|
{
|
||||||
|
clipboard->setText(text, QClipboard::Clipboard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatForm::startCounter()
|
void ChatForm::startCounter()
|
||||||
{
|
{
|
||||||
if (!callDurationTimer)
|
if (!callDurationTimer)
|
||||||
|
@ -975,6 +999,7 @@ void ChatForm::retranslateUi()
|
||||||
QString volObjectName = volButton->objectName();
|
QString volObjectName = volButton->objectName();
|
||||||
QString micObjectName = micButton->objectName();
|
QString micObjectName = micButton->objectName();
|
||||||
loadHistoryAction->setText(tr("Load chat history..."));
|
loadHistoryAction->setText(tr("Load chat history..."));
|
||||||
|
copyStatusAction->setText(tr("Copy"));
|
||||||
|
|
||||||
if (volObjectName == QStringLiteral("green"))
|
if (volObjectName == QStringLiteral("green"))
|
||||||
volButton->setToolTip(tr("Mute call"));
|
volButton->setToolTip(tr("Mute call"));
|
||||||
|
|
|
@ -84,6 +84,7 @@ private slots:
|
||||||
void onScreenshotTaken(const QPixmap &pixmap);
|
void onScreenshotTaken(const QPixmap &pixmap);
|
||||||
void doScreenshot();
|
void doScreenshot();
|
||||||
void onMessageInserted();
|
void onMessageInserted();
|
||||||
|
void onCopyStatusMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
@ -101,6 +102,7 @@ private:
|
||||||
CoreAV* coreav;
|
CoreAV* coreav;
|
||||||
Friend* f;
|
Friend* f;
|
||||||
CroppingLabel *statusMessageLabel;
|
CroppingLabel *statusMessageLabel;
|
||||||
|
QMenu statusMessageMenu;
|
||||||
QLabel *callDuration;
|
QLabel *callDuration;
|
||||||
QTimer *callDurationTimer;
|
QTimer *callDurationTimer;
|
||||||
QTimer typingTimer;
|
QTimer typingTimer;
|
||||||
|
@ -108,6 +110,7 @@ private:
|
||||||
QElapsedTimer timeElapsed;
|
QElapsedTimer timeElapsed;
|
||||||
OfflineMsgEngine *offlineEngine;
|
OfflineMsgEngine *offlineEngine;
|
||||||
QAction* loadHistoryAction;
|
QAction* loadHistoryAction;
|
||||||
|
QAction* copyStatusAction;
|
||||||
|
|
||||||
QHash<uint, FileTransferInstance*> ftransWidgets;
|
QHash<uint, FileTransferInstance*> ftransWidgets;
|
||||||
void startCounter();
|
void startCounter();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user