Limo
A simple mod manager
Loading...
Searching...
No Matches
FomodDialog Class Reference

Dialog used to interact with a FomodInstaller. More...

#include <fomoddialog.h>

Inheritance diagram for FomodDialog:
Collaboration diagram for FomodDialog:

Signals

void addModAccepted (int app_id, AddModInfo info)
 Signals dialog completion.
 
void addModAborted ()
 Signals mod installation has been aborted.
 

Public Member Functions

 FomodDialog (QWidget *parent=nullptr)
 Initializes the UI.
 
 ~FomodDialog ()
 Deletes the UI.
 
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.
 
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.
 
bool hasSteps () const
 Checks if the dialog has any steps.
 

Private Slots

void onNextButtonPressed ()
 Advances the dialog by one step.
 
void onPluginSelected (bool checked)
 Called when a button has been pressed, updates the next button.
 
void onBackButtonPressed ()
 Takes a step back.
 
void on_buttonBox_rejected ()
 Emits addModAborted.
 

Private Member Functions

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.
 
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.
 
bool selectionIsValid ()
 Verifies if the current selection satisfies the requirements to advance to the next step.
 
std::vector< std::vector< bool > > getSelection ()
 For every group, for every plugin: True if plugin is currently selected.
 
void updateNextButton ()
 Updates text and enabled status of next_button_, depending on the step.
 
void closeEvent (QCloseEvent *event) override
 Closes the dialog and emits a signal indicating installation has been canceled.
 
void reject () override
 Closes the dialog and emits a signal indicating the dialog has been closed.
 

Private Attributes

Ui::FomodDialog * ui
 Contains auto-generated UI elements.
 
std::unique_ptr< fomod::FomodInstallerinstaller_
 Used to parse the fomod file.
 
fomod::InstallStep cur_step_
 Contains the current step in the installation process.
 
QList< QButtonGroup * > button_groups_
 Buttons used to represent plugin options.
 
QList< fomod::PluginGroup::Typegroup_types_
 Determines selection restrictions for button groups.
 
QPushButton * next_button_
 Button used to advance the dialog.
 
QPushButton * back_button_
 Button used to step back in the dialog.
 
std::set< int > none_groups_
 Some button groups require a dummy button. This holds the ids of those groups.
 
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 selected during the installation.
 
bool has_no_steps_
 If true: This dialog is non interactive.
 
AddModInfo add_mod_info_
 Contains necessary data to install the mod upon dialog completion.
 
int app_id_
 Application for which the new mod is to be installed.
 
bool dialog_completed_ = false
 Indicates whether the dialog has been completed.
 

Detailed Description

Dialog used to interact with a FomodInstaller.

Constructor & Destructor Documentation

◆ FomodDialog()

FomodDialog::FomodDialog ( QWidget * parent = nullptr)

Initializes the UI.

Parameters
parentParent of this widget.

Member Function Documentation

◆ addModAccepted

void FomodDialog::addModAccepted ( int app_id,
AddModInfo info )
signal

Signals dialog completion.

Parameters
app_idApplication for which the new mod is to be installed.
infoContains all data needed to install the mod.

◆ closeEvent()

void FomodDialog::closeEvent ( QCloseEvent * event)
overrideprivate

Closes the dialog and emits a signal indicating installation has been canceled.

Parameters
eventThe close event sent upon closing the dialog.

◆ getResult()

std::vector< std::pair< sfs::path, sfs::path > > FomodDialog::getResult ( ) const

Returns pairs of source and destinations for every selected file during the installation process.

Returns
The files.

◆ getSelection()

std::vector< std::vector< bool > > FomodDialog::getSelection ( )
private

For every group, for every plugin: True if plugin is currently selected.

Returns
The selection.

◆ hasSteps()

bool FomodDialog::hasSteps ( ) const

Checks if the dialog has any steps.

Returns
True if there are steps.

◆ makeButton()

QAbstractButton * FomodDialog::makeButton ( fomod::PluginGroup::Type type,
const QString & text,
const QString & description,
const QString & image_path ) const
private

Creates a new FomodCheckBox or FomodRatioButton for selection of a plugin.

Parameters
typeGenerated button type is determined based on this plugin type.
textText of the new button.
descriptionDescription of the plugin represented by this button.
image_pathPath to an image for the plugin represented by this button.
Returns
Pointer to the new button.

◆ onPluginSelected

void FomodDialog::onPluginSelected ( bool checked)
privateslot

Called when a button has been pressed, updates the next button.

Parameters
checkedButton check state.

◆ selectionIsValid()

bool FomodDialog::selectionIsValid ( )
private

Verifies if the current selection satisfies the requirements to advance to the next step.

Returns
True if valid.

◆ setupDialog()

void FomodDialog::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.

Parameters
config_fileEither a direct path to a fomod configuration file or a path to a directory containing fomod/ModuleConfig.xml.
target_pathPath used by the FomodInstaller to check for dependencies.
app_versionApp version used for fomod conditions. All version checks evaluate to true if this is left empty.
infoContains necessary data to install the mod upon dialog completion.
app_idApplication for which the new mod is to be installed.

◆ updateInstallStep()

void FomodDialog::updateInstallStep ( std::optional< std::pair< std::vector< std::vector< bool > >, fomod::InstallStep > > prev_step = {})
private

Takes one step forwards or backwards in the installation and updates the UI.

Parameters
prev_stepPair of the selection and installer state during the previous step. If this is empty, the installer advances, else the installer takes a step back.

The documentation for this class was generated from the following files: