diff --git a/launcher/ui/dialogs/ResourceUpdateDialog.cpp b/launcher/ui/dialogs/ResourceUpdateDialog.cpp index 207049fde..eeaf6b3d0 100644 --- a/launcher/ui/dialogs/ResourceUpdateDialog.cpp +++ b/launcher/ui/dialogs/ResourceUpdateDialog.cpp @@ -482,6 +482,7 @@ void ResourceUpdateDialog::appendResource(CheckUpdateTask::Update const& info, Q auto changelog_area = new QTextBrowser(); QString text = info.changelog; + changelog->setData(0, Qt::UserRole, text); if (info.provider == ModPlatform::ResourceProvider::MODRINTH) { text = markdownToHTML(info.changelog.toUtf8()); } @@ -494,26 +495,6 @@ void ResourceUpdateDialog::appendResource(CheckUpdateTask::Update const& info, Q ui->modTreeWidget->setItemWidget(changelog, 0, changelog_area); ui->modTreeWidget->addTopLevelItem(item_top); - - // 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 ResourceUpdateDialog::getTasks() -> const QList diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp index b26227389..904686664 100644 --- a/launcher/ui/dialogs/ReviewMessageBox.cpp +++ b/launcher/ui/dialogs/ReviewMessageBox.cpp @@ -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