pub unsafe fn new(
        app_ui: &Rc<AppUI>,
        pack_file_contents_ui: &Rc<PackFileContentsUI>,
        global_search_ui: &Rc<GlobalSearchUI>,
        diagnostics_ui: &Rc<DiagnosticsUI>,
        dependencies_ui: &Rc<DependenciesUI>,
    ) -> Result<()> {

        // Initialize a Tool. This also performs some common checks to ensure we can actually use the tool.
        // TODO: Move this to a tool var.
        let paths = match &*GAME_SELECTED.read().unwrap().get_game_key_name() {
            KEY_WARHAMMER_3 => vec![
                PathType::Folder(vec!["db".to_owned(), "factions_tables".to_owned()]),
            ],
            _ => vec![
                PathType::Folder(vec!["db".to_owned(), "factions_tables".to_owned()]),
                PathType::Folder(vec!["db".to_owned(), "faction_banners_tables".to_owned()]),
                PathType::Folder(vec!["db".to_owned(), "faction_uniform_colours_tables".to_owned()]),
            ]
        };

        let view = if cfg!(debug_assertions) { VIEW_DEBUG } else { VIEW_RELEASE };
        let tool = Tool::new(&app_ui.main_window, &paths, &TOOL_SUPPORTED_GAMES, view)?;
        tool.set_title(&tr("faction_painter_title"));
        tool.backup_used_paths(app_ui, pack_file_contents_ui)?;

        // ListView.
        let faction_list_view: QPtr<QListView> = tool.find_widget("faction_list_view")?;
        let faction_list_filter_line_edit: QPtr<QLineEdit> = tool.find_widget("faction_list_filter_line_edit")?;

        // Details view.
        let faction_icon_label: QPtr<QLabel> = tool.find_widget("faction_icon_label")?;
        let faction_name_label: QPtr<QLabel> = tool.find_widget("faction_name_label")?;

        // Banner GroupBox.
        let banner_groupbox: QPtr<QGroupBox> = tool.find_widget("banner_groupbox")?;
        let banner_colour_primary_label: QPtr<QLabel> = tool.find_widget("banner_colour_primary_label")?;
        let banner_colour_secondary_label: QPtr<QLabel> = tool.find_widget("banner_colour_secondary_label")?;
        let banner_colour_tertiary_label: QPtr<QLabel> = tool.find_widget("banner_colour_tertiary_label")?;
        let banner_colour_primary: QPtr<QComboBox> = tool.find_widget("banner_colour_primary")?;
        let banner_colour_secondary: QPtr<QComboBox> = tool.find_widget("banner_colour_secondary")?;
        let banner_colour_tertiary: QPtr<QComboBox> = tool.find_widget("banner_colour_tertiary")?;
        let banner_restore_initial_values_button: QPtr<QPushButton> = tool.find_widget("banner_restore_initial_values_button")?;
        let banner_restore_vanilla_values_button: QPtr<QPushButton> = tool.find_widget("banner_restore_vanilla_values_button")?;

        // Uniform GroupBox.
        let uniform_groupbox: QPtr<QGroupBox> = tool.find_widget("uniform_groupbox")?;
        let uniform_colour_primary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_primary_label")?;
        let uniform_colour_secondary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_secondary_label")?;
        let uniform_colour_tertiary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_tertiary_label")?;
        let uniform_colour_primary: QPtr<QComboBox> = tool.find_widget("uniform_colour_primary")?;
        let uniform_colour_secondary: QPtr<QComboBox> = tool.find_widget("uniform_colour_secondary")?;
        let uniform_colour_tertiary: QPtr<QComboBox> = tool.find_widget("uniform_colour_tertiary")?;
        let uniform_restore_initial_values_button: QPtr<QPushButton> = tool.find_widget("uniform_restore_initial_values_button")?;
        let uniform_restore_vanilla_values_button: QPtr<QPushButton> = tool.find_widget("uniform_restore_vanilla_values_button")?;

        let packed_file_name_label: QPtr<QLabel> = tool.find_widget("packed_file_name_label")?;
        let packed_file_name_line_edit: QPtr<QLineEdit> = tool.find_widget("packed_file_name_line_edit")?;
        packed_file_name_line_edit.set_text(&QString::from_std_str(DEFAULT_FILENAME));

        // Extra stuff.
        let faction_list_filter = QSortFilterProxyModel::new_1a(&faction_list_view);
        let faction_list_model = QStandardItemModel::new_1a(&faction_list_filter);
        faction_list_view.set_model(&faction_list_filter);
        faction_list_filter.set_source_model(&faction_list_model);

        // Filter timer.
        let timer_delayed_updates = QTimer::new_1a(tool.get_ref_main_widget());
        timer_delayed_updates.set_single_shot(true);

        // Build the view itself.
        let view = Rc::new(Self{
            tool,
            timer_delayed_updates,
            faction_list_view,
            faction_list_filter,
            faction_list_model,
            faction_list_filter_line_edit,
            faction_icon_label,
            faction_name_label,
            banner_groupbox,
            banner_colour_primary_label,
            banner_colour_secondary_label,
            banner_colour_tertiary_label,
            banner_colour_primary,
            banner_colour_secondary,
            banner_colour_tertiary,
            banner_restore_initial_values_button,
            banner_restore_vanilla_values_button,
            uniform_groupbox,
            uniform_colour_primary_label,
            uniform_colour_secondary_label,
            uniform_colour_tertiary_label,
            uniform_colour_primary,
            uniform_colour_secondary,
            uniform_colour_tertiary,
            uniform_restore_initial_values_button,
            uniform_restore_vanilla_values_button,
            packed_file_name_label,
            packed_file_name_line_edit,
        });

        // Build the slots and connect them to the view.
        let slots = ToolFactionPainterSlots::new(&view);
        connections::set_connections(&view, &slots);

        // Setup text translations.
        view.setup_translations();

        // Load all the data to the view.
        view.load_data()?;

        // If we hit ok, save the data back to the PackFile.
        if view.tool.get_ref_dialog().exec() == 1 {
            view.save_data(app_ui, pack_file_contents_ui, global_search_ui, diagnostics_ui, dependencies_ui)?;
        }

        // If nothing failed, it means we have successfully saved the data back to disk, or canceled.
        Ok(())
    }
/// This function creates the tool's dialog.
///
/// NOTE: This can fail at runtime if any of the expected widgets is not in the UI's XML.
This function creates the tool's dialog.
NOTE: This can fail at runtime if any of the expected widgets is not in the UI's XML.
This function creates the tool ' s dialog . NOTE : This can fail at runtime if any of the expected widgets is not in the UI ' s XML .
pub unsafe fn new(
        app_ui: &Rc<AppUI>,
        pack_file_contents_ui: &Rc<PackFileContentsUI>,
        global_search_ui: &Rc<GlobalSearchUI>,
        diagnostics_ui: &Rc<DiagnosticsUI>,
        dependencies_ui: &Rc<DependenciesUI>,
    ) -> Result<()> {
        // Initialize a Tool. This also performs some common checks to ensure we can actually use the tool.
        // TODO: Move this to a tool var.
        let paths = match &*GAME_SELECTED.read().unwrap().get_game_key_name() {
            KEY_WARHAMMER_3 => vec![
                PathType::Folder(vec!["db".to_owned(), "factions_tables".to_owned()]),
            ],
            _ => vec![
                PathType::Folder(vec!["db".to_owned(), "factions_tables".to_owned()]),
                PathType::Folder(vec!["db".to_owned(), "faction_banners_tables".to_owned()]),
                PathType::Folder(vec!["db".to_owned(), "faction_uniform_colours_tables".to_owned()]),
            ]
        };
        let view = if cfg!(debug_assertions) { VIEW_DEBUG } else { VIEW_RELEASE };
        let tool = Tool::new(&app_ui.main_window, &paths, &TOOL_SUPPORTED_GAMES, view)?;
        tool.set_title(&tr("faction_painter_title"));
        tool.backup_used_paths(app_ui, pack_file_contents_ui)?;
        // ListView.
        let faction_list_view: QPtr<QListView> = tool.find_widget("faction_list_view")?;
        let faction_list_filter_line_edit: QPtr<QLineEdit> = tool.find_widget("faction_list_filter_line_edit")?;
        // Details view.
        let faction_icon_label: QPtr<QLabel> = tool.find_widget("faction_icon_label")?;
        let faction_name_label: QPtr<QLabel> = tool.find_widget("faction_name_label")?;
        // Banner GroupBox.
        let banner_groupbox: QPtr<QGroupBox> = tool.find_widget("banner_groupbox")?;
        let banner_colour_primary_label: QPtr<QLabel> = tool.find_widget("banner_colour_primary_label")?;
        let banner_colour_secondary_label: QPtr<QLabel> = tool.find_widget("banner_colour_secondary_label")?;
        let banner_colour_tertiary_label: QPtr<QLabel> = tool.find_widget("banner_colour_tertiary_label")?;
        let banner_colour_primary: QPtr<QComboBox> = tool.find_widget("banner_colour_primary")?;
        let banner_colour_secondary: QPtr<QComboBox> = tool.find_widget("banner_colour_secondary")?;
        let banner_colour_tertiary: QPtr<QComboBox> = tool.find_widget("banner_colour_tertiary")?;
        let banner_restore_initial_values_button: QPtr<QPushButton> = tool.find_widget("banner_restore_initial_values_button")?;
        let banner_restore_vanilla_values_button: QPtr<QPushButton> = tool.find_widget("banner_restore_vanilla_values_button")?;
        // Uniform GroupBox.
        let uniform_groupbox: QPtr<QGroupBox> = tool.find_widget("uniform_groupbox")?;
        let uniform_colour_primary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_primary_label")?;
        let uniform_colour_secondary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_secondary_label")?;
        let uniform_colour_tertiary_label: QPtr<QLabel> = tool.find_widget("uniform_colour_tertiary_label")?;
        let uniform_colour_primary: QPtr<QComboBox> = tool.find_widget("uniform_colour_primary")?;
        let uniform_colour_secondary: QPtr<QComboBox> = tool.find_widget("uniform_colour_secondary")?;
        let uniform_colour_tertiary: QPtr<QComboBox> = tool.find_widget("uniform_colour_tertiary")?;
        let uniform_restore_initial_values_button: QPtr<QPushButton> = tool.find_widget("uniform_restore_initial_values_button")?;
        let uniform_restore_vanilla_values_button: QPtr<QPushButton> = tool.find_widget("uniform_restore_vanilla_values_button")?;
        let packed_file_name_label: QPtr<QLabel> = tool.find_widget("packed_file_name_label")?;
        let packed_file_name_line_edit: QPtr<QLineEdit> = tool.find_widget("packed_file_name_line_edit")?;
        packed_file_name_line_edit.set_text(&QString::from_std_str(DEFAULT_FILENAME));
        // Extra stuff.
        let faction_list_filter = QSortFilterProxyModel::new_1a(&faction_list_view);
        let faction_list_model = QStandardItemModel::new_1a(&faction_list_filter);
        faction_list_view.set_model(&faction_list_filter);
        faction_list_filter.set_source_model(&faction_list_model);
        // Filter timer.
        let timer_delayed_updates = QTimer::new_1a(tool.get_ref_main_widget());
        timer_delayed_updates.set_single_shot(true);
        // Build the view itself.
        let view = Rc::new(Self{
            tool,
            timer_delayed_updates,
            faction_list_view,
            faction_list_filter,
            faction_list_model,
            faction_list_filter_line_edit,
            faction_icon_label,
            faction_name_label,
            banner_groupbox,
            banner_colour_primary_label,
            banner_colour_secondary_label,
            banner_colour_tertiary_label,
            banner_colour_primary,
            banner_colour_secondary,
            banner_colour_tertiary,
            banner_restore_initial_values_button,
            banner_restore_vanilla_values_button,
            uniform_groupbox,
            uniform_colour_primary_label,
            uniform_colour_secondary_label,
            uniform_colour_tertiary_label,
            uniform_colour_primary,
            uniform_colour_secondary,
            uniform_colour_tertiary,
            uniform_restore_initial_values_button,
            uniform_restore_vanilla_values_button,
            packed_file_name_label,
            packed_file_name_line_edit,
        });
        // Build the slots and connect them to the view.
        let slots = ToolFactionPainterSlots::new(&view);
        connections::set_connections(&view, &slots);
        // Setup text translations.
        view.setup_translations();
        // Load all the data to the view.
        view.load_data()?;
        // If we hit ok, save the data back to the PackFile.
        if view.tool.get_ref_dialog().exec() == 1 {
            view.save_data(app_ui, pack_file_contents_ui, global_search_ui, diagnostics_ui, dependencies_ui)?;
        }
        // If nothing failed, it means we have successfully saved the data back to disk, or canceled.
        Ok(())
    }
pub unsafe fn new ( app_ui : & Rc < AppUI > , pack_file_contents_ui : & Rc < PackFileContentsUI > , global_search_ui : & Rc < GlobalSearchUI > , diagnostics_ui : & Rc < DiagnosticsUI > , dependencies_ui : & Rc < DependenciesUI > , ) -> Result < ( ) > { // Initialize a Tool. This also performs some common checks to ensure we can actually use the tool. // TODO: Move this to a tool var. let paths = match & * GAME_SELECTED . read ( ) . unwrap ( ) . get_game_key_name ( ) { KEY_WARHAMMER_3 => vec ! [ PathType Folder ( vec [ " " to_owned ( ) " " to_owned ( ) ] ) ] , _ => vec ! [ PathType Folder ( vec [ " " to_owned ( ) " " to_owned ( ) ] ) PathType Folder ( vec [ " " to_owned ( ) " " to_owned ( ) ] ) PathType Folder ( vec [ " " to_owned ( ) " " to_owned ( ) ] ) ] } ; let view = if cfg ! ( debug_assertions ) { VIEW_DEBUG } else { VIEW_RELEASE } ; let tool = Tool :: new ( & app_ui . main_window , & paths , & TOOL_SUPPORTED_GAMES , view ) ? ; tool . set_title ( & tr ( " " ) ) ; tool . backup_used_paths ( app_ui , pack_file_contents_ui ) ? ; // ListView. let faction_list_view : QPtr < QListView > = tool . find_widget ( " " ) ? ; let faction_list_filter_line_edit : QPtr < QLineEdit > = tool . find_widget ( " " ) ? ; // Details view. let faction_icon_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let faction_name_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; // Banner GroupBox. let banner_groupbox : QPtr < QGroupBox > = tool . find_widget ( " " ) ? ; let banner_colour_primary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let banner_colour_secondary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let banner_colour_tertiary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let banner_colour_primary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let banner_colour_secondary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let banner_colour_tertiary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let banner_restore_initial_values_button : QPtr < QPushButton > = tool . find_widget ( " " ) ? ; let banner_restore_vanilla_values_button : QPtr < QPushButton > = tool . find_widget ( " " ) ? ; // Uniform GroupBox. let uniform_groupbox : QPtr < QGroupBox > = tool . find_widget ( " " ) ? ; let uniform_colour_primary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let uniform_colour_secondary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let uniform_colour_tertiary_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let uniform_colour_primary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let uniform_colour_secondary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let uniform_colour_tertiary : QPtr < QComboBox > = tool . find_widget ( " " ) ? ; let uniform_restore_initial_values_button : QPtr < QPushButton > = tool . find_widget ( " " ) ? ; let uniform_restore_vanilla_values_button : QPtr < QPushButton > = tool . find_widget ( " " ) ? ; let packed_file_name_label : QPtr < QLabel > = tool . find_widget ( " " ) ? ; let packed_file_name_line_edit : QPtr < QLineEdit > = tool . find_widget ( " " ) ? ; packed_file_name_line_edit . set_text ( & QString :: from_std_str ( DEFAULT_FILENAME ) ) ; // Extra stuff. let faction_list_filter = QSortFilterProxyModel :: new_1a ( & faction_list_view ) ; let faction_list_model = QStandardItemModel :: new_1a ( & faction_list_filter ) ; faction_list_view . set_model ( & faction_list_filter ) ; faction_list_filter . set_source_model ( & faction_list_model ) ; // Filter timer. let timer_delayed_updates = QTimer :: new_1a ( tool . get_ref_main_widget ( ) ) ; timer_delayed_updates . set_single_shot ( true ) ; // Build the view itself. let view = Rc :: new ( Self { tool , timer_delayed_updates , faction_list_view , faction_list_filter , faction_list_model , faction_list_filter_line_edit , faction_icon_label , faction_name_label , banner_groupbox , banner_colour_primary_label , banner_colour_secondary_label , banner_colour_tertiary_label , banner_colour_primary , banner_colour_secondary , banner_colour_tertiary , banner_restore_initial_values_button , banner_restore_vanilla_values_button , uniform_groupbox , uniform_colour_primary_label , uniform_colour_secondary_label , uniform_colour_tertiary_label , uniform_colour_primary , uniform_colour_secondary , uniform_colour_tertiary , uniform_restore_initial_values_button , uniform_restore_vanilla_values_button , packed_file_name_label , packed_file_name_line_edit , } ) ; // Build the slots and connect them to the view. let slots = ToolFactionPainterSlots :: new ( & view ) ; connections :: set_connections ( & view , & slots ) ; // Setup text translations. view . setup_translations ( ) ; // Load all the data to the view. view . load_data ( ) ? ; // If we hit ok, save the data back to the PackFile. if view . tool . get_ref_dialog ( ) . exec ( ) == 1 { view . save_data ( app_ui , pack_file_contents_ui , global_search_ui , diagnostics_ui , dependencies_ui ) ? ; } // If nothing failed, it means we have successfully saved the data back to disk, or canceled. Ok ( ( ) ) }
This function creates the tool's dialog.
This function creates the tool ' s dialog .
app_ui
&Rc<AppUI>
pack_file_contents_ui
&Rc<PackFileContentsUI>
global_search_ui
&Rc<GlobalSearchUI>
diagnostics_ui
&Rc<DiagnosticsUI>
dependencies_ui
&Rc<DependenciesUI>
app_ui
&Rc<AppUI>
pack_file_contents_ui
&Rc<PackFileContentsUI>
global_search_ui
&Rc<GlobalSearchUI>
diagnostics_ui
&Rc<DiagnosticsUI>
dependencies_ui
&Rc<DependenciesUI>