refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
#include "Application.h"
|
2022-11-19 20:12:31 +00:00
|
|
|
#include "settings/Setting.h"
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
#include "minecraft/MinecraftInstance.h"
|
|
|
|
#include "ui/pages/BasePage.h"
|
|
|
|
|
2022-08-10 18:48:34 +01:00
|
|
|
class ResourceFolderModel;
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ExternalResourcesPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This page is used as a base for pages in which the user can manage external resources
|
|
|
|
* related to the game, such as mods, shaders or resource packs. */
|
|
|
|
class ExternalResourcesPage : public QMainWindow, public BasePage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-08-10 18:48:34 +01:00
|
|
|
explicit ExternalResourcesPage(BaseInstance* instance, std::shared_ptr<ResourceFolderModel> model, QWidget* parent = nullptr);
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
virtual ~ExternalResourcesPage();
|
|
|
|
|
|
|
|
virtual QString displayName() const override = 0;
|
|
|
|
virtual QIcon icon() const override = 0;
|
|
|
|
virtual QString id() const override = 0;
|
|
|
|
virtual QString helpPage() const override = 0;
|
|
|
|
|
|
|
|
virtual bool shouldDisplay() const override = 0;
|
2023-06-06 22:16:23 +01:00
|
|
|
QString extraHeaderInfoString();
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
|
|
|
|
void openedImpl() override;
|
|
|
|
void closedImpl() override;
|
|
|
|
|
|
|
|
void retranslate() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject* obj, QEvent* ev) override;
|
|
|
|
bool listFilter(QKeyEvent* ev);
|
|
|
|
QMenu* createPopupMenu() override;
|
|
|
|
|
|
|
|
public slots:
|
2022-08-10 18:48:34 +01:00
|
|
|
bool current(const QModelIndex& current, const QModelIndex& previous);
|
|
|
|
|
|
|
|
virtual bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
|
|
|
|
protected slots:
|
2022-08-13 15:58:39 +01:00
|
|
|
void itemActivated(const QModelIndex& index);
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
void filterTextChanged(const QString& newContents);
|
|
|
|
|
|
|
|
virtual void addItem();
|
2022-12-14 15:02:04 +00:00
|
|
|
void removeItem();
|
|
|
|
virtual void removeItems(const QItemSelection &selection);
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
|
2022-08-13 15:58:39 +01:00
|
|
|
virtual void enableItem();
|
|
|
|
virtual void disableItem();
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
|
|
|
|
virtual void viewFolder();
|
|
|
|
virtual void viewConfigs();
|
|
|
|
|
|
|
|
void ShowContextMenu(const QPoint& pos);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BaseInstance* m_instance = nullptr;
|
|
|
|
|
|
|
|
Ui::ExternalResourcesPage* ui = nullptr;
|
2022-08-10 18:48:34 +01:00
|
|
|
std::shared_ptr<ResourceFolderModel> m_model;
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
QSortFilterProxyModel* m_filterModel = nullptr;
|
|
|
|
|
|
|
|
QString m_fileSelectionFilter;
|
|
|
|
QString m_viewFilter;
|
|
|
|
|
|
|
|
bool m_controlsEnabled = true;
|
2022-11-19 20:12:31 +00:00
|
|
|
|
|
|
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
refactor: Create a more clear hierarchy for some instance pages
Previously, the Shaders, Texture packs and Resource packs tabs had as
parent the ModFolderPage, making it so that making changes only to the
Mods page would require checking the id of the page for the correct one.
This was hackish and error-prone.
Now, those pages all inherit from a single class, ExternalResourcesPage,
that handles the basic behaviour of all of them, while allowing for
individual modification in code.
This is still not a clear separation, since internally, all those
resources are derived from Mods, so for now there's still some awkward
common code :/
2022-03-11 21:03:21 +00:00
|
|
|
};
|