diff --git a/src/dialogs/VersionInfoDialog.cpp b/src/dialogs/VersionInfoDialog.cpp index 9cd5e03c1..8871ae053 100644 --- a/src/dialogs/VersionInfoDialog.cpp +++ b/src/dialogs/VersionInfoDialog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include VersionInfoDialog::VersionInfoDialog(QWidget *parent) : QDialog(parent), ui(new Ui::VersionInfoDialog), core(Core()) @@ -21,6 +22,45 @@ VersionInfoDialog::VersionInfoDialog(QWidget *parent) VersionInfoDialog::~VersionInfoDialog() {} +void VersionInfoDialog::on_buttonBox_rejected() +{ + close(); +} + +void VersionInfoDialog::on_copyVersionInfoButton_clicked() +{ + QString vinfo = "# " + ui->leftLabel->text() + "\n"; + + // Iterate & Copy leftTreeWidget items + QTreeWidgetItemIterator itl(ui->leftTreeWidget); + + int keyColumnIndex = 0, valueColumnIndex = 1; + + while (*itl) { + QString row = (*itl)->text(keyColumnIndex) + " : " + (*itl)->text(valueColumnIndex) + "\n"; + vinfo.append(row); + ++itl; + } + + vinfo.append("\n# " + ui->rightLabel->text() + "\n"); + + // Iterate & Copy rightTreeWidget items + QTreeWidgetItemIterator itr(ui->rightTreeWidget); + + while (*itr) { + QString row = (*itr)->text(keyColumnIndex) + " : " + (*itr)->text(valueColumnIndex) + "\n"; + vinfo.append(row); + ++itr; + } + + // Copy to Clipboard + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(vinfo); + + QMessageBox::information(this, tr("Copy to Clipboard"), + tr("Version information was successfully copied!")); +} + void VersionInfoDialog::fillVersionInfo() { RzCoreLocked core(Core()); diff --git a/src/dialogs/VersionInfoDialog.h b/src/dialogs/VersionInfoDialog.h index 7974e059d..8803705e7 100644 --- a/src/dialogs/VersionInfoDialog.h +++ b/src/dialogs/VersionInfoDialog.h @@ -18,6 +18,16 @@ class VersionInfoDialog : public QDialog explicit VersionInfoDialog(QWidget *parent = nullptr); ~VersionInfoDialog(); +private slots: + void on_buttonBox_rejected(); + + /** + * @fn AboutDialog::on_copyVersionInfoButton_clicked() + * + * @brief Copies the table values to Clipboard. + */ + void on_copyVersionInfoButton_clicked(); + private: std::unique_ptr ui; CutterCore *core; diff --git a/src/dialogs/VersionInfoDialog.ui b/src/dialogs/VersionInfoDialog.ui index 54e197b83..2c4832471 100644 --- a/src/dialogs/VersionInfoDialog.ui +++ b/src/dialogs/VersionInfoDialog.ui @@ -135,6 +135,29 @@ + + + + + + + + :/img/icons/copy.svg:/img/icons/copy.svg + + + Copy + + + + + + + QDialogButtonBox::Close + + + + +