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

View File

@ -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*>(this->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"));

View File

@ -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();