Hacky tweaks

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2022-11-01 18:12:27 +00:00
parent d03ae34b61
commit 6c7d040439
3 changed files with 20 additions and 7 deletions

View File

@ -132,6 +132,8 @@ QList<BasePage*> ModDownloadDialog::getPages()
if (APPLICATION->capabilities() & Application::SupportsFlame)
pages.append(FlameModPage::create(this, m_instance));
m_selected_page = dynamic_cast<ModPage*>(pages[0]);
return pages;
}
@ -179,17 +181,22 @@ void ModDownloadDialog::selectedPageChanged(BasePage* previous, BasePage* select
return;
}
auto* selected_page = dynamic_cast<ModPage*>(selected);
if (!selected_page) {
m_selected_page = dynamic_cast<ModPage*>(selected);
if (!m_selected_page) {
qCritical() << "Page '" << selected->displayName() << "' in ModDownloadDialog is not a ModPage!";
return;
}
// Same effect as having a global search bar
selected_page->setSearchTerm(prev_page->getSearchTerm());
m_selected_page->setSearchTerm(prev_page->getSearchTerm());
}
bool ModDownloadDialog::selectPage(QString pageId)
{
return m_container->selectPage(pageId);
}
ModPage* ModDownloadDialog::getSelectedPage()
{
return m_selected_page;
}

View File

@ -25,6 +25,7 @@
#include "ModDownloadTask.h"
#include "minecraft/mod/ModFolderModel.h"
#include "ui/pages/BasePageProvider.h"
#include "ui/pages/modplatform/ModPage.h"
namespace Ui
{
@ -56,6 +57,8 @@ public:
bool selectPage(QString pageId);
ModPage* getSelectedPage();
public slots:
void confirm();
void accept() override;
@ -69,6 +72,7 @@ private:
PageContainer * m_container = nullptr;
QDialogButtonBox * m_buttons = nullptr;
QVBoxLayout *m_verticalLayout = nullptr;
ModPage *m_selected_page = nullptr;
QHash<QString, ModDownloadTask*> modTask;
BaseInstance *m_instance;

View File

@ -282,11 +282,13 @@ void ModPage::openUrl(const QUrl& url)
// intended to view in their web browser
if (!slug.isEmpty() && !slug.contains('/') && slug != current.slug) {
dialog->selectPage(page);
ui->searchEdit->setText(slug);
triggerSearch();
connect(listModel->activeJob(), &Task::finished, [this] {
ui->packView->setCurrentIndex(listModel->index(0));
ModPage* newPage = dialog->getSelectedPage();
newPage->ui->searchEdit->setText(slug);
newPage->triggerSearch();
connect(newPage->listModel->activeJob(), &Task::finished, [newPage] {
newPage->ui->packView->setCurrentIndex(newPage->listModel->index(0));
});
return;