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:
parent
57ce030f1d
commit
1935d0c6ec
|
@ -4,6 +4,8 @@
|
||||||
#include "src/persistence/profile.h"
|
#include "src/persistence/profile.h"
|
||||||
#include "src/nexus.h"
|
#include "src/nexus.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -16,10 +18,21 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *parent) :
|
||||||
ui->label_4->hide();
|
ui->label_4->hide();
|
||||||
ui->aliases->hide();
|
ui->aliases->hide();
|
||||||
|
|
||||||
|
statusMessageMenu.addAction(tr("Copy"), this, SLOT(onCopyStatusMessage()));
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
|
||||||
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked);
|
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked);
|
||||||
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
|
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
|
||||||
connect(ui->removeHistory, &QPushButton::clicked, this, &AboutUser::onRemoveHistoryClicked);
|
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;
|
this->toxId = toxId;
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
||||||
|
@ -105,6 +118,17 @@ void AboutUser::onRemoveHistoryClicked()
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutUser::onCopyStatusMessage()
|
||||||
|
{
|
||||||
|
QString text = ui->statusMessage->text();
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
|
if (clipboard)
|
||||||
|
{
|
||||||
|
clipboard->setText(text, QClipboard::Clipboard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AboutUser::~AboutUser()
|
AboutUser::~AboutUser()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define ABOUTUSER_H
|
#define ABOUTUSER_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QMenu>
|
||||||
#include "src/friend.h"
|
#include "src/friend.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AboutUser *ui;
|
Ui::AboutUser *ui;
|
||||||
|
QMenu statusMessageMenu;
|
||||||
ToxId toxId;
|
ToxId toxId;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -27,6 +29,7 @@ private slots:
|
||||||
void onAutoAcceptClicked();
|
void onAutoAcceptClicked();
|
||||||
void onSelectDirClicked();
|
void onSelectDirClicked();
|
||||||
void onRemoveHistoryClicked();
|
void onRemoveHistoryClicked();
|
||||||
|
void onCopyStatusMessage();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ABOUTUSER_H
|
#endif // ABOUTUSER_H
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user