Merge pull request #2874 from Trial97/modpack_equal
This commit is contained in:
commit
c57e26cf57
@ -965,6 +965,9 @@ SET(LAUNCHER_SOURCES
|
||||
ui/pages/modplatform/ShaderPackPage.cpp
|
||||
ui/pages/modplatform/ShaderPackModel.cpp
|
||||
|
||||
|
||||
ui/pages/modplatform/ModpackProviderBasePage.h
|
||||
|
||||
ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
|
||||
ui/pages/modplatform/atlauncher/AtlFilterModel.h
|
||||
ui/pages/modplatform/atlauncher/AtlListModel.cpp
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "NewInstanceDialog.h"
|
||||
#include "Application.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
#include "ui/pages/modplatform/import_ftb/ImportFTBPage.h"
|
||||
#include "ui_NewInstanceDialog.h"
|
||||
|
||||
@ -140,6 +141,8 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,
|
||||
auto geometry = screen->availableSize();
|
||||
resize(width(), qMin(geometry.height() - 50, 710));
|
||||
}
|
||||
|
||||
connect(m_container, &PageContainer::selectedPageChanged, this, &NewInstanceDialog::selectedPageChanged);
|
||||
}
|
||||
|
||||
void NewInstanceDialog::reject()
|
||||
@ -316,3 +319,16 @@ void NewInstanceDialog::importIconNow()
|
||||
}
|
||||
APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
|
||||
}
|
||||
|
||||
void NewInstanceDialog::selectedPageChanged(BasePage* previous, BasePage* selected)
|
||||
{
|
||||
auto prevPage = dynamic_cast<ModpackProviderBasePage*>(previous);
|
||||
if (prevPage) {
|
||||
m_searchTerm = prevPage->getSerachTerm();
|
||||
}
|
||||
|
||||
auto nextPage = dynamic_cast<ModpackProviderBasePage*>(selected);
|
||||
if (nextPage) {
|
||||
nextPage->setSearchTerm(m_searchTerm);
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ class NewInstanceDialog : public QDialog, public BasePageProvider {
|
||||
private slots:
|
||||
void on_iconButton_clicked();
|
||||
void on_instNameTextBox_textChanged(const QString& arg1);
|
||||
void selectedPageChanged(BasePage* previous, BasePage* selected);
|
||||
|
||||
private:
|
||||
Ui::NewInstanceDialog* ui = nullptr;
|
||||
@ -98,5 +99,7 @@ class NewInstanceDialog : public QDialog, public BasePageProvider {
|
||||
|
||||
QString importVersion;
|
||||
|
||||
QString m_searchTerm;
|
||||
|
||||
void importIconNow();
|
||||
};
|
||||
|
29
launcher/ui/pages/modplatform/ModpackProviderBasePage.h
Normal file
29
launcher/ui/pages/modplatform/ModpackProviderBasePage.h
Normal file
@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui/pages/BasePage.h"
|
||||
|
||||
class ModpackProviderBasePage : public BasePage {
|
||||
public:
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) = 0;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const = 0;
|
||||
};
|
@ -164,3 +164,13 @@ void AtlPage::onVersionSelectionChanged(QString version)
|
||||
selectedVersion = version;
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void AtlPage::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
||||
QString AtlPage::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
|
@ -42,8 +42,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "Application.h"
|
||||
#include "tasks/Task.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
|
||||
namespace Ui {
|
||||
class AtlPage;
|
||||
@ -51,7 +50,7 @@ class AtlPage;
|
||||
|
||||
class NewInstanceDialog;
|
||||
|
||||
class AtlPage : public QWidget, public BasePage {
|
||||
class AtlPage : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -66,6 +65,11 @@ class AtlPage : public QWidget, public BasePage {
|
||||
|
||||
void openedImpl() override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private:
|
||||
void suggestCurrent();
|
||||
|
||||
|
@ -299,3 +299,12 @@ void FlamePage::updateUi()
|
||||
ui->packDescription->setHtml(StringUtils::htmlListPatch(text + current.description));
|
||||
ui->packDescription->flush();
|
||||
}
|
||||
QString FlamePage::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
|
||||
void FlamePage::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <Application.h>
|
||||
#include <modplatform/flame/FlamePackIndex.h>
|
||||
#include <QTimer>
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
#include "ui/widgets/ProgressWidget.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -53,7 +53,7 @@ namespace Flame {
|
||||
class ListModel;
|
||||
}
|
||||
|
||||
class FlamePage : public QWidget, public BasePage {
|
||||
class FlamePage : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -72,6 +72,11 @@ class FlamePage : public QWidget, public BasePage {
|
||||
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private:
|
||||
void suggestCurrent();
|
||||
|
||||
|
@ -135,4 +135,13 @@ void ImportFTBPage::triggerSearch()
|
||||
currentModel->setSearchTerm(ui->searchEdit->text());
|
||||
}
|
||||
|
||||
void ImportFTBPage::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
||||
QString ImportFTBPage::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
} // namespace FTBImportAPP
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <Application.h>
|
||||
#include "modplatform/import_ftb/PackHelpers.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
#include "ui/pages/modplatform/import_ftb/ListModel.h"
|
||||
|
||||
class NewInstanceDialog;
|
||||
@ -35,7 +35,7 @@ namespace Ui {
|
||||
class ImportFTBPage;
|
||||
}
|
||||
|
||||
class ImportFTBPage : public QWidget, public BasePage {
|
||||
class ImportFTBPage : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -49,6 +49,11 @@ class ImportFTBPage : public QWidget, public BasePage {
|
||||
void openedImpl() override;
|
||||
void retranslate() override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private:
|
||||
void suggestCurrent();
|
||||
void onPackSelectionChanged(Modpack* pack = nullptr);
|
||||
|
@ -369,4 +369,13 @@ void Page::triggerSearch()
|
||||
currentModel->setSearchTerm(ui->searchEdit->text());
|
||||
}
|
||||
|
||||
void Page::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
||||
QString Page::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
} // namespace LegacyFTB
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "QObjectPtr.h"
|
||||
#include "modplatform/legacy_ftb/PackFetchTask.h"
|
||||
#include "modplatform/legacy_ftb/PackHelpers.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
|
||||
class NewInstanceDialog;
|
||||
|
||||
@ -57,7 +57,7 @@ class ListModel;
|
||||
class FilterModel;
|
||||
class PrivatePackManager;
|
||||
|
||||
class Page : public QWidget, public BasePage {
|
||||
class Page : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -71,6 +71,11 @@ class Page : public QWidget, public BasePage {
|
||||
void openedImpl() override;
|
||||
void retranslate() override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private:
|
||||
void suggestCurrent();
|
||||
void onPackSelectionChanged(Modpack* pack = nullptr);
|
||||
|
@ -351,3 +351,13 @@ void ModrinthPage::onVersionSelectionChanged(int index)
|
||||
selectedVersion = ui->versionSelectionBox->currentData().toString();
|
||||
suggestCurrent();
|
||||
}
|
||||
|
||||
void ModrinthPage::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
||||
QString ModrinthPage::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
|
@ -38,9 +38,9 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "ui/dialogs/NewInstanceDialog.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
|
||||
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
#include "ui/widgets/ProgressWidget.h"
|
||||
|
||||
#include <QTimer>
|
||||
@ -54,7 +54,7 @@ namespace Modrinth {
|
||||
class ModpackListModel;
|
||||
}
|
||||
|
||||
class ModrinthPage : public QWidget, public BasePage {
|
||||
class ModrinthPage : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -78,6 +78,11 @@ class ModrinthPage : public QWidget, public BasePage {
|
||||
void openedImpl() override;
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private slots:
|
||||
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
||||
void onVersionSelectionChanged(int index);
|
||||
|
@ -342,3 +342,13 @@ void TechnicPage::onVersionSelectionChanged(QString version)
|
||||
selectedVersion = version;
|
||||
selectVersion();
|
||||
}
|
||||
|
||||
void TechnicPage::setSearchTerm(QString term)
|
||||
{
|
||||
ui->searchEdit->setText(term);
|
||||
}
|
||||
|
||||
QString TechnicPage::getSerachTerm() const
|
||||
{
|
||||
return ui->searchEdit->text();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <Application.h>
|
||||
#include "TechnicData.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include "ui/pages/modplatform/ModpackProviderBasePage.h"
|
||||
#include "ui/widgets/ProgressWidget.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -54,7 +54,7 @@ namespace Technic {
|
||||
class ListModel;
|
||||
}
|
||||
|
||||
class TechnicPage : public QWidget, public BasePage {
|
||||
class TechnicPage : public QWidget, public ModpackProviderBasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -71,6 +71,11 @@ class TechnicPage : public QWidget, public BasePage {
|
||||
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
/** Programatically set the term in the search bar. */
|
||||
virtual void setSearchTerm(QString) override;
|
||||
/** Get the current term in the search bar. */
|
||||
[[nodiscard]] virtual QString getSerachTerm() const override;
|
||||
|
||||
private:
|
||||
void suggestCurrent();
|
||||
void metadataLoaded();
|
||||
|
Loading…
Reference in New Issue
Block a user