34#include <NDEVR/QCustomStackedWidget.h>
35#include <NDEVR/File.h>
36#include <NDEVR/FileFormat.h>
37#include <NDEVR/Buffer.h>
38#include <NDEVR/UUID.h>
39#include <NDEVR/INIInterface.h>
45#if NDEVR_SUPPORTS_THREADING
60 class FolderCreatorWidget;
68 QPointer<QCustomTableWidget>
table;
84#if NDEVR_SUPPORTS_THREADING
85 friend class ImageCacheThread;
380 void contextMenu(
const QPoint &pos);
382 void browsingFinished();
384 void updateFilesSlot();
393 QIcon _getIconCallback(
const File& file);
397 void _setCurrentDirectory(
const File& dir);
399 void onUserReadyToFinish(
bool was_browsing);
403 void setFileIcon(
File file, QIcon icon);
411 bool getSelectedFilters(
String & selected_filter,
String & default_suffix);
415 void resolveIcon(
const File& file);
424 File m_current_directory;
425 File m_fallback_directory;
426 String m_current_file_name;
427 String m_current_file_extension;
430 QHBoxLayout* m_top_layout;
431 sint04 m_recent_priority_constant_modifier = 1;
432 fltp08 m_recent_priority_time_modifier = 100.0;
435 bool m_show_recents =
true;
436 bool m_touch_prefer_gallery =
true;
437 bool m_desktop_prefer_gallery =
false;
438 bool m_show_hidden =
false;
439 bool m_show_extensions =
true;
440 bool m_show_favorites;
442 FolderCreatorWidget* m_folder_creation_widget;
448 Button* m_database_button;
451 Button* m_new_folder_button;
452 Button* m_up_level_button;
453 Button* m_favorites_button;
454 QWidget* m_navigation_buttons;
455 QWidget* m_bottom_buttons;
456 QWidget* m_favorites_panel;
464 QIcon m_loading_icon;
465 QWidget* m_popup_dialog;
466 QWidget* m_settings_dialog;
471#if NDEVR_SUPPORTS_THREADING
472 QThread* m_icon_thread =
nullptr;
474 QWidget* m_native_parent =
nullptr;
476 std::function<bool(
const FileFormat&,
const File&)> m_can_read_callback;
The equivelent of std::vector but with a bit more control.
A hash-based key-value store, useful for quick associative lookups.
QWidget * createRequestWidget(File item)
Creates a widget representing a single file request entry.
void postResolveIcons()
Finalizes icon resolution after background icon loading completes.
void clearRecents()
Clears all entries from the recents list.
void autoSelectFavoritesItem()
Automatically selects a favorites item based on the current directory.
bool isFolderBrowser() const
Returns whether this dialog is configured to browse for folders only.
void setCurrentFileName(const StringView &name)
Sets the current file name in the name field.
Buffer< FileRequest > m_selected_files
The currently selected file requests.
const Buffer< UUID > & saveContent() const
Returns the UUIDs of content to be saved.
void hidePopupDialog()
Hides the popup dialog if it is currently shown.
void showRecents()
Switches the display mode to show recent files.
DisplayMode
Enumerates the display modes available in the file chooser dialog.
@ e_favorites
Show favorited files and directories.
@ e_browser
Browse the filesystem directly.
@ e_recents
Show recently accessed files.
void setCurrentFile(const File &file)
Sets the current file, updating both directory and file name.
void setCurrentDirectory(const File ¤t_directory)
Sets the current browsing directory.
bool isSaveDialog() const
Returns whether this dialog is configured for saving files.
const Buffer< FileRequest > & getSelectedRequests() const
Returns the selected file requests, including format information.
void addToRecents(const Buffer< File > &files)
Adds multiple files to the recents list.
QSize sizeHint() const override
Returns the recommended size for this dialog.
void setSaveContent(const Buffer< UUID > &save_content)
Sets the UUIDs of content to be saved.
bool showRecents() const
Returns whether the recents section is shown.
FileFormat currentSelectedFormat() const
Returns the currently selected file format from the format combo box.
TranslatedString actionName() const
Returns the action name displayed on the accept button (e.g., "Open" or "Save").
void retranslate()
Retranslates all user-visible text in the dialog.
bool showFavorites() const
Returns whether the favorites section is shown.
void setActionName(const TranslatedString &action_name)
Sets the action name displayed on the accept button.
FileChooserDialog(const File &ini_location, bool save_dialog=false, QWidget *parent=nullptr)
Constructs a FileChooserDialog with a custom INI settings location.
void autoHideDialog(PopupInfo info=PopupInfo())
Hides the dialog using the most appropriate method for the current platform.
void setIconProvider(const std::function< String(const FileRequest &)> &icon_provider)
Sets a callback to provide custom icons for file requests.
QWidget * settingsDialog()
Creates and returns the settings dialog widget.
void finishReadingINI(INIFactory &factory) override
Called after reading dialog state from INI to finalize initialization.
void setOptions(const Buffer< FileFormat > &extensions, bool save_dialog)
Sets the available file formats and whether this is a save dialog.
void finishBrowse()
Finalizes the browse operation after the user makes a selection.
bool m_needs_to_update
Flag indicating that the file list needs refreshing.
Buffer< File > filterFiles(const Buffer< File > &all_files) const
Filters a list of files according to the current format selection.
void onFileChosenSignal()
Emitted when a file has been chosen by the user.
void setAllowAny(bool allow_any)
Sets whether any file type is allowed regardless of filter.
void setIsFileChooser(bool is_file_chooser)
Sets whether this dialog is choosing files (true) or folders (false).
void setCurrentExtension(const StringView &extension, bool update_format_to_first_match)
Sets the current file extension filter.
void autoShowDialog(PopupInfo info=PopupInfo())
Shows the dialog using the most appropriate method for the current platform.
bool event(QEvent *e) override
Handles events for the dialog.
QWidget * createNavigationButtons()
Creates the navigation button bar (back, up, favorites, etc.).
void updateTableIconSize(QCustomTableWidget *table)
Updates the icon size in the given table to match the current settings.
FileFormat getFileFormat(const StringView &file, const StringView &string) const
Determines the file format from a file path and a filter string.
FileChooserDialog(bool save_dialog=false, QWidget *parent=nullptr)
Constructs a FileChooserDialog.
const Buffer< File > favoriteFiles() const
Returns the list of favorite files and directories.
void setNativeParent(QWidget *native_parent)
Sets the parent widget for native file dialogs.
String extensionsString(const StringView &delimiter=";;") const
Builds a string of all supported extensions joined by the given delimiter.
bool checkFileAgainstFilter(const File &file, const FileFormat &selected_format) const
Checks whether a file matches the given format filter.
void setRecentPriorityModifiers(sint04 constant_modifier, fltp08 recent_priority_time_modifier)
Allows adding weight to a file (changing extension listing order) based on how recently a file has be...
void addItem(ButtonGallery *gallery, QCustomTableWidget *table, uint04 index, const File &item)
Adds a file item to both the gallery and table views.
void setAndSortFormats(const Buffer< FileFormat > &formats)
Assigns and sorts the available file formats by priority.
void setup()
Performs initial setup of all dialog widgets and layout.
void setFallbackDirectory(const File &file)
Sets a fallback directory to use when the current directory is invalid.
static void SaveFileContent(File file)
Saves file content associated with the given file.
void showModifiedTime(bool show_modified_time)
Sets whether the modified time column is visible.
void SetupForFavorites()
Sets up the dialog UI for favorites mode.
void addToRecents(const File &file, bool update_display)
Adds a single file to the recents list.
const Buffer< File > & currentDirectoryFiles() const
Returns the cached list of files in the current directory.
void updateBrowserWidgets()
Refreshes the file browser widgets with current directory content.
QWidget * createBottomPanel()
Creates the bottom panel with accept/cancel buttons and file name input.
void setShowRecents(bool show_recent)
Sets whether the recents section is available.
void onCanceledSignal()
Emitted when the user cancels the dialog.
void onFileChosen(File file)
Called when the user has chosen a file to process the selection.
bool m_allow_any
Whether any file type is accepted regardless of filter.
void selectFileNameField()
Selects and focuses the file name input field.
void showAccessedTime(bool show_accessed_time)
Sets whether the accessed time column is visible.
TranslatedString windowTitle() const
Returns the translated window title for this dialog.
void finishedSignal()
Emitted when the dialog finishes with a selection.
void setAdditionalFavorites(Buffer< File > favorites)
Sets additional directories to appear in the favorites list.
Buffer< File > getSelected() const
Returns the list of files currently selected by the user.
void updateGallery(Button *b)
Updates the gallery display when a button is selected.
void setCanReadCallback(const std::function< bool(const FileFormat &, const File &)> &callback)
Sets a callback to determine if a file can be read with a given format.
FileFormat getFileFormat(const File &file)
Determines the file format for a given file.
void browseFileNative()
Opens a native OS file browse dialog.
virtual void getINI(INIFactory &factory) override
Reads or writes dialog settings from/to an INI factory.
QWidget * createfavoritesPanel()
Creates the favorites side panel.
void showFileSize(bool show_modified_time)
Sets whether the file size column is visible.
void removeFromRecents(File item)
Removes a file from the recents list.
void SetupForBrowser()
Sets up the dialog UI for filesystem browsing mode.
FileFormat getFileFormatFromExtension(const StringView &ext) const
Determines the file format from a file extension string.
const File & currentDirectory() const
Returns the current browsing directory.
void prepareForINI(INIFactory &factory) override
Prepares dialog state for writing to INI.
void browseFile(PopupInfo popup_origin=PopupInfo())
Opens a native file browse dialog.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Contains methods for easily reading and writing to an INI file including efficient casting,...
INIInterface()
Constructs an INIInterface with no default INI file.
A compact way to present a list of options to the user.
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
A message box displays a primary text to alert the user to a situation, an informative text to furthe...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
The default thread class for executing concurrent sequences in the NDEVR API.
A Button that toggles between on and off.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
A FileRequest bundles format data as well as a particular file.