1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #3186

initramfs (4):
      feat(status): add ability to copy status messages
      feat(status): make status in about dialog copyable
      refactor(status): enable text selection in about friend dialog
      fix(status): explictly refer to this within lambda
This commit is contained in:
sudden6 2016-04-28 12:05:50 +02:00
commit c1826125cb
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 38 additions and 1 deletions

View File

@ -31,12 +31,15 @@
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignBottom">
<widget class="QLabel" name="statusMessage">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -53,6 +56,12 @@
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>

View File

@ -29,9 +29,11 @@
#include <QBitmap>
#include <QScreen>
#include <QTemporaryFile>
#include <QApplication>
#include <QGuiApplication>
#include <QStyle>
#include <QSplitter>
#include <QClipboard>
#include <cassert>
#include "chatform.h"
#include "src/audio/audio.h"
@ -79,6 +81,7 @@ ChatForm::ChatForm(Friend* chatFriend)
statusMessageLabel->setFont(Style::getFont(Style::Medium));
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
statusMessageLabel->setTextFormat(Qt::PlainText);
statusMessageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
callConfirm = nullptr;
offlineEngine = new OfflineMsgEngine(f);
@ -100,6 +103,7 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);
loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));
copyStatusAction = statusMessageMenu.addAction(QString(), this, SLOT(onCopyStatusMessage()));
connect(core, &Core::fileSendStarted, this, &ChatForm::startFileSend);
connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered);
@ -111,6 +115,15 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
connect(core, &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
{
if(!statusMessageLabel->text().isEmpty())
{
QWidget* sender = static_cast<QWidget*>(this->sender());
statusMessageMenu.exec(sender->mapToGlobal(pos));
}
} );
connect(&typingTimer, &QTimer::timeout, this, [=]{
Core::getInstance()->sendTyping(f->getFriendID(), false);
isTyping = false;
@ -826,6 +839,17 @@ void ChatForm::onMessageInserted()
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()
{
if (!callDurationTimer)
@ -975,6 +999,7 @@ void ChatForm::retranslateUi()
QString volObjectName = volButton->objectName();
QString micObjectName = micButton->objectName();
loadHistoryAction->setText(tr("Load chat history..."));
copyStatusAction->setText(tr("Copy"));
if (volObjectName == QStringLiteral("green"))
volButton->setToolTip(tr("Mute call"));

View File

@ -84,6 +84,7 @@ private slots:
void onScreenshotTaken(const QPixmap &pixmap);
void doScreenshot();
void onMessageInserted();
void onCopyStatusMessage();
private:
void retranslateUi();
@ -101,6 +102,7 @@ private:
CoreAV* coreav;
Friend* f;
CroppingLabel *statusMessageLabel;
QMenu statusMessageMenu;
QLabel *callDuration;
QTimer *callDurationTimer;
QTimer typingTimer;
@ -108,6 +110,7 @@ private:
QElapsedTimer timeElapsed;
OfflineMsgEngine *offlineEngine;
QAction* loadHistoryAction;
QAction* copyStatusAction;
QHash<uint, FileTransferInstance*> ftransWidgets;
void startCounter();