Even more fixes
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
a1ed8154f7
commit
a29d88c313
@ -254,19 +254,20 @@ void ModPage::openUrl(const QUrl& url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// detect mod URLs and search instead
|
// detect mod URLs and search instead
|
||||||
int prefixLength;
|
int prefixLength = 0;
|
||||||
const char* page;
|
const char* page;
|
||||||
|
|
||||||
if ((url.host() == "modrinth.com" || url.host() == "www.modrinth.com") && url.path().startsWith("/mod/")) {
|
if ((url.host() == "modrinth.com" || url.host() == "www.modrinth.com") && url.path().startsWith("/mod/")) {
|
||||||
prefixLength = 5;
|
prefixLength = 5;
|
||||||
page = "modrinth";
|
page = "modrinth";
|
||||||
} else if (APPLICATION->capabilities() & Application::SupportsFlame &&
|
} else if (APPLICATION->capabilities() & Application::SupportsFlame &&
|
||||||
(url.host() == "curseforge.com" || url.host() == "www.curseforge.com") &&
|
(url.host() == "curseforge.com" || url.host().endsWith(".curseforge.com"))) {
|
||||||
url.path().toLower().startsWith("/minecraft/mc-mods/")) {
|
if (url.path().toLower().startsWith("/minecraft/mc-mods/"))
|
||||||
prefixLength = 19;
|
prefixLength = 19;
|
||||||
|
else if (url.path().toLower().startsWith("/projects/"))
|
||||||
|
prefixLength = 10;
|
||||||
page = "curseforge";
|
page = "curseforge";
|
||||||
} else
|
}
|
||||||
prefixLength = 0;
|
|
||||||
|
|
||||||
if (prefixLength != 0) {
|
if (prefixLength != 0) {
|
||||||
QString slug = url.path().mid(prefixLength);
|
QString slug = url.path().mid(prefixLength);
|
||||||
@ -282,19 +283,16 @@ void ModPage::openUrl(const QUrl& url)
|
|||||||
dialog->selectPage(page);
|
dialog->selectPage(page);
|
||||||
|
|
||||||
ModPage* newPage = dialog->getSelectedPage();
|
ModPage* newPage = dialog->getSelectedPage();
|
||||||
|
|
||||||
QLineEdit* searchEdit = newPage->ui->searchEdit;
|
QLineEdit* searchEdit = newPage->ui->searchEdit;
|
||||||
|
|
||||||
if (searchEdit->text() != slug) {
|
|
||||||
searchEdit->setText(slug);
|
|
||||||
newPage->triggerSearch();
|
|
||||||
|
|
||||||
ModPlatform::ListModel* model = newPage->listModel;
|
ModPlatform::ListModel* model = newPage->listModel;
|
||||||
QListView* view = newPage->ui->packView;
|
QListView* view = newPage->ui->packView;
|
||||||
|
|
||||||
connect(model->activeJob(), &Task::finished, [url, slug, model, view] {
|
auto jump = [url, slug, model, view] {
|
||||||
for (int row = 0; row < model->rowCount({}); row++) {
|
for (int row = 0; row < model->rowCount({}); row++) {
|
||||||
QModelIndex index = model->index(row);
|
QModelIndex index = model->index(row);
|
||||||
auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>();
|
auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>();
|
||||||
|
|
||||||
if (pack.slug == slug) {
|
if (pack.slug == slug) {
|
||||||
view->setCurrentIndex(index);
|
view->setCurrentIndex(index);
|
||||||
return;
|
return;
|
||||||
@ -303,12 +301,20 @@ void ModPage::openUrl(const QUrl& url)
|
|||||||
|
|
||||||
// The final fallback.
|
// The final fallback.
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
searchEdit->setText(slug);
|
||||||
|
newPage->triggerSearch();
|
||||||
|
|
||||||
|
if (!model->activeJob())
|
||||||
|
jump();
|
||||||
|
else {
|
||||||
|
connect(model->activeJob(), &Task::finished, jump);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// open in the user's web browser
|
// open in the user's web browser
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
|
Loading…
Reference in New Issue
Block a user