Move shortcut connection to constructor

Add copy functionality for changelog on ResourceUpdateDialog

Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
Dylan Schooner
2025-11-07 13:40:54 -05:00
parent 6f4460b604
commit a16026828e
2 changed files with 21 additions and 40 deletions

View File

@@ -23,6 +23,26 @@ ReviewMessageBox::ReviewMessageBox(QWidget* parent, [[maybe_unused]] QString con
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
// Overwrite Ctrl+C functionality to exclude the label when copying text from tree
auto shortcut = new QShortcut(QKeySequence::Copy, ui->modTreeWidget);
connect(shortcut, &QShortcut::activated, [this]() {
auto currentItem = this->ui->modTreeWidget->currentItem();
if (!currentItem)
return;
auto currentColumn = this->ui->modTreeWidget->currentColumn();
auto data = currentItem->data(currentColumn, Qt::UserRole);
QString txt;
if (data.isValid()) {
txt = data.toString();
} else {
txt = currentItem->text(currentColumn);
}
QApplication::clipboard()->setText(txt);
});
}
ReviewMessageBox::~ReviewMessageBox()
@@ -95,26 +115,6 @@ void ReviewMessageBox::appendResource(ResourceInformation&& info)
itemTop->insertChildren(childIndx++, { versionTypeItem });
ui->modTreeWidget->addTopLevelItem(itemTop);
// Overwrite Ctrl+C functionality to exclude the label when copying text from tree
auto shortcut = new QShortcut(QKeySequence::Copy, ui->modTreeWidget);
connect(shortcut, &QShortcut::activated, [this]() {
auto currentItem = this->ui->modTreeWidget->currentItem();
if (!currentItem)
return;
auto currentColumn = this->ui->modTreeWidget->currentColumn();
auto data = currentItem->data(currentColumn, Qt::UserRole);
QString txt;
if (data.isValid()) {
txt = data.toString();
} else {
txt = currentItem->text(currentColumn);
}
QApplication::clipboard()->setText(txt);
});
}
auto ReviewMessageBox::deselectedResources() -> QStringList