Limo
A simple mod manager
Loading...
Searching...
No Matches
fomoddialog.h
1
5
6#pragma once
7
10#include <QButtonGroup>
11#include <QDialog>
12#include <filesystem>
13#include <set>
14
15
16namespace Ui
17{
18class FomodDialog;
19}
20
24class FomodDialog : public QDialog
25{
26 Q_OBJECT
27
28public:
33 FomodDialog(QWidget* parent = nullptr);
36
47 void setupDialog(const std::filesystem::path& config_file,
48 const std::filesystem::path& target_path,
49 const QString& app_version,
50 const AddModInfo& info,
51 int app_id);
57 std::vector<std::pair<std::filesystem::path, std::filesystem::path>> getResult() const;
62 bool hasSteps() const;
63
64private:
66 Ui::FomodDialog* ui;
68 std::unique_ptr<fomod::FomodInstaller> installer_;
72 QList<QButtonGroup*> button_groups_;
74 QList<fomod::PluginGroup::Type> group_types_;
76 QPushButton* next_button_;
78 QPushButton* back_button_;
80 std::set<int> none_groups_;
83 std::vector<std::pair<std::filesystem::path, std::filesystem::path>> result_;
91 bool dialog_completed_ = false;
92
101 QAbstractButton* makeButton(fomod::PluginGroup::Type type,
102 const QString& text,
103 const QString& description,
104 const QString& image_path) const;
111 std::optional<std::pair<std::vector<std::vector<bool>>, fomod::InstallStep>> prev_step = {});
117 bool selectionIsValid();
122 std::vector<std::vector<bool>> getSelection();
124 void updateNextButton();
129 void closeEvent(QCloseEvent* event) override;
131 void reject() override;
132
133private slots:
135 void onNextButtonPressed();
140 void onPluginSelected(bool checked);
142 void onBackButtonPressed();
145
146signals:
152 void addModAccepted(int app_id, AddModInfo info);
155};
Contains the AddModInfo struct.
void closeEvent(QCloseEvent *event) override
Closes the dialog and emits a signal indicating installation has been canceled.
Definition fomoddialog.cpp:243
bool has_no_steps_
If true: This dialog is non interactive.
Definition fomoddialog.h:85
int app_id_
Application for which the new mod is to be installed.
Definition fomoddialog.h:89
void reject() override
Closes the dialog and emits a signal indicating the dialog has been closed.
Definition fomoddialog.cpp:252
QList< QButtonGroup * > button_groups_
Buttons used to represent plugin options.
Definition fomoddialog.h:72
bool dialog_completed_
Indicates whether the dialog has been completed.
Definition fomoddialog.h:91
QPushButton * next_button_
Button used to advance the dialog.
Definition fomoddialog.h:76
QAbstractButton * makeButton(fomod::PluginGroup::Type type, const QString &text, const QString &description, const QString &image_path) const
Creates a new FomodCheckBox or FomodRatioButton for selection of a plugin.
Definition fomoddialog.cpp:60
std::unique_ptr< fomod::FomodInstaller > installer_
Used to parse the fomod file.
Definition fomoddialog.h:68
std::vector< std::pair< std::filesystem::path, std::filesystem::path > > getResult() const
Returns pairs of source and destinations for every selected file during the installation process.
Definition fomoddialog.cpp:50
void onPluginSelected(bool checked)
Called when a button has been pressed, updates the next button.
Definition fomoddialog.cpp:294
void onBackButtonPressed()
Takes a step back.
Definition fomoddialog.cpp:299
FomodDialog(QWidget *parent=nullptr)
Initializes the UI.
Definition fomoddialog.cpp:16
void addModAccepted(int app_id, AddModInfo info)
Signals dialog completion.
fomod::InstallStep cur_step_
Contains the current step in the installation process.
Definition fomoddialog.h:70
Ui::FomodDialog * ui
Contains auto-generated UI elements.
Definition fomoddialog.h:66
~FomodDialog()
Deletes the UI.
Definition fomoddialog.cpp:29
bool hasSteps() const
Checks if the dialog has any steps.
Definition fomoddialog.cpp:55
void setupDialog(const std::filesystem::path &config_file, const std::filesystem::path &target_path, const QString &app_version, const AddModInfo &info, int app_id)
Initializes the dialog.
Definition fomoddialog.cpp:34
std::vector< std::vector< bool > > getSelection()
For every group, for every plugin: True if plugin is currently selected.
Definition fomoddialog.cpp:214
bool selectionIsValid()
Verifies if the current selection satisfies the requirements to advance to the next step.
Definition fomoddialog.cpp:192
std::vector< std::pair< std::filesystem::path, std::filesystem::path > > result_
Once the installation has been completed, this contains source and destination paths for every file s...
Definition fomoddialog.h:83
void updateInstallStep(std::optional< std::pair< std::vector< std::vector< bool > >, fomod::InstallStep > > prev_step={})
Takes one step forwards or backwards in the installation and updates the UI.
Definition fomoddialog.cpp:71
QList< fomod::PluginGroup::Type > group_types_
Determines selection restrictions for button groups.
Definition fomoddialog.h:74
void updateNextButton()
Updates text and enabled status of next_button_, depending on the step.
Definition fomoddialog.cpp:233
std::set< int > none_groups_
Some button groups require a dummy button. This holds the ids of those groups.
Definition fomoddialog.h:80
QPushButton * back_button_
Button used to step back in the dialog.
Definition fomoddialog.h:78
AddModInfo add_mod_info_
Contains necessary data to install the mod upon dialog completion.
Definition fomoddialog.h:87
void onNextButtonPressed()
Advances the dialog by one step.
Definition fomoddialog.cpp:261
void addModAborted()
Signals mod installation has been aborted.
void on_buttonBox_rejected()
Emits addModAborted.
Definition fomoddialog.cpp:306
Header for the FomodInstaller class.
Stores data needed to install a new mod.
Definition addmodinfo.h:17
A step during installation.
Definition installstep.h:21
Type
Describes restriction on how plugins in a group can be selected.
Definition plugingroup.h:24