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

feat(status): make status in about dialog copyable

This commit is contained in:
initramfs 2016-04-24 02:05:38 -04:00
parent 57ce030f1d
commit 1935d0c6ec
No known key found for this signature in database
GPG Key ID: 78B8BDF87E9EF0AF
3 changed files with 30 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include "src/persistence/profile.h"
#include "src/nexus.h"
#include <QApplication>
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
@ -16,10 +18,21 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *parent) :
ui->label_4->hide();
ui->aliases->hide();
statusMessageMenu.addAction(tr("Copy"), this, SLOT(onCopyStatusMessage()));
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked);
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
connect(ui->removeHistory, &QPushButton::clicked, this, &AboutUser::onRemoveHistoryClicked);
connect(ui->statusMessage, &QLabel::customContextMenuRequested, this, [&](const QPoint& pos)
{
if(!ui->statusMessage->text().isEmpty())
{
QWidget* sender = static_cast<QWidget*>(QObject::sender());
statusMessageMenu.exec(sender->mapToGlobal(pos));
}
} );
this->toxId = toxId;
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
@ -105,6 +118,17 @@ void AboutUser::onRemoveHistoryClicked()
QMessageBox::Ok);
}
void AboutUser::onCopyStatusMessage()
{
QString text = ui->statusMessage->text();
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
clipboard->setText(text, QClipboard::Clipboard);
}
}
AboutUser::~AboutUser()
{
delete ui;

View File

@ -2,6 +2,7 @@
#define ABOUTUSER_H
#include <QDialog>
#include <QMenu>
#include "src/friend.h"
@ -20,6 +21,7 @@ public:
private:
Ui::AboutUser *ui;
QMenu statusMessageMenu;
ToxId toxId;
private slots:
@ -27,6 +29,7 @@ private slots:
void onAutoAcceptClicked();
void onSelectDirClicked();
void onRemoveHistoryClicked();
void onCopyStatusMessage();
};
#endif // ABOUTUSER_H

View File

@ -41,6 +41,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>