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-12 02:33:21 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
#include "Application.h"
|
2022-11-20 01:42:31 +05:30
|
|
|
#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-12 02:33:21 +05:30
|
|
|
#include "minecraft/MinecraftInstance.h"
|
|
|
|
#include "ui/pages/BasePage.h"
|
|
|
|
|
2022-08-10 23:18:34 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
|
|
|
|
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 23:18:34 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
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;
|
|
|
|
|
|
|
|
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 23:18:34 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
|
|
|
|
protected slots:
|
2022-08-13 20:28:39 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
void filterTextChanged(const QString& newContents);
|
|
|
|
|
|
|
|
virtual void addItem();
|
2022-12-14 20:32:04 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
|
2022-08-13 20:28:39 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
|
|
|
|
virtual void viewFolder();
|
|
|
|
virtual void viewConfigs();
|
|
|
|
|
|
|
|
void ShowContextMenu(const QPoint& pos);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BaseInstance* m_instance = nullptr;
|
|
|
|
|
|
|
|
Ui::ExternalResourcesPage* ui = nullptr;
|
2022-08-10 23:18:34 +05:30
|
|
|
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-12 02:33:21 +05:30
|
|
|
QSortFilterProxyModel* m_filterModel = nullptr;
|
|
|
|
|
|
|
|
QString m_fileSelectionFilter;
|
|
|
|
QString m_viewFilter;
|
|
|
|
|
|
|
|
bool m_controlsEnabled = true;
|
2022-11-20 01:42:31 +05:30
|
|
|
|
|
|
|
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-12 02:33:21 +05:30
|
|
|
};
|