Skip to content

Commit

Permalink
fix modrinth info widget opening dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniol-lck committed Feb 10, 2022
1 parent 979d122 commit 3199908
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/ui/github/githubreleaseinfowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ GitHubReleaseInfoWidget::~GitHubReleaseInfoWidget()

void GitHubReleaseInfoWidget::setRelease(GitHubRelease *release)
{

auto release_ = release;
release_ = release;
emit releaseChanged();
if(!release_) return;
connect(this, &GitHubReleaseInfoWidget::releaseChanged, disconnecter(
connect(release_, &QObject::destroyed, this, [=]{setRelease(nullptr); })));
if(!release_) return;

ui->name->setText(release_->info().name());
ui->body->setMarkdown(release->info().body());
ui->body->setMarkdown(release_->info().body());
}
2 changes: 1 addition & 1 deletion src/ui/modrinth/modrinthmodbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ QDialog *ModrinthModBrowser::getDialog(const QModelIndex &index)
mod->setParent(dialog);
connect(dialog, &ModrinthModDialog::finished, this, [=]{
if(manager_->mods().contains(mod))
mod->setParent(nullptr);
mod->setParent(manager_);
});
return dialog;
}
Expand Down
23 changes: 11 additions & 12 deletions src/ui/modrinth/modrinthmodinfowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,8 @@ void ModrinthModInfoWidget::mouseDoubleClickEvent(QMouseEvent *event)

void ModrinthModInfoWidget::on_actionOpen_Website_Link_triggered()
{

if(!mod_) return;
if(mod_ && mod_->parent() == browser_->manager()){
auto dialog = new ModrinthModDialog(this, mod_);
//set parent
mod_->setParent(dialog);
connect(dialog, &ModrinthModDialog::finished, this, [=, mod = mod_]{
if(browser_->manager()->mods().contains(mod))
mod_->setParent(nullptr);
});
dialog->show();
}
QDesktopServices::openUrl(mod_->modInfo().websiteUrl());
}

void ModrinthModInfoWidget::on_actionCopy_Website_Link_triggered()
Expand All @@ -157,6 +147,15 @@ void ModrinthModInfoWidget::on_actionCopy_Website_Link_triggered()
void ModrinthModInfoWidget::on_actionOpen_Modrinth_Mod_Dialog_triggered()
{
if(!mod_) return;
QDesktopServices::openUrl(mod_->modInfo().websiteUrl());
if(mod_ && mod_->parent() == browser_->manager()){
auto dialog = new ModrinthModDialog(this, mod_);
//set parent
mod_->setParent(dialog);
connect(dialog, &ModrinthModDialog::finished, this, [=, mod = mod_]{
if(browser_->manager()->mods().contains(mod))
mod_->setParent(browser_->manager());
});
dialog->show();
}
}

0 comments on commit 3199908

Please sign in to comment.