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

View File

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

View File

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