diff options
author | SupSuper | 2018-11-20 02:11:59 +0000 |
---|---|---|
committer | Thierry Crozat | 2018-12-16 10:48:13 +0000 |
commit | fbc9c7d371a4a123f3180ed54f26dfb5799fcc36 (patch) | |
tree | 466f031d69e0a6881ec0f9215cb816f67754215a | |
parent | 5fce1ae46400576c7d65a9ea63ff1c00952cf71c (diff) | |
download | scummvm-rg350-fbc9c7d371a4a123f3180ed54f26dfb5799fcc36.tar.gz scummvm-rg350-fbc9c7d371a4a123f3180ed54f26dfb5799fcc36.tar.bz2 scummvm-rg350-fbc9c7d371a4a123f3180ed54f26dfb5799fcc36.zip |
BACKENDS: Hook GUI browser to DialogManager
-rw-r--r-- | common/dialogs.h | 11 | ||||
-rw-r--r-- | gui/browser.cpp | 19 | ||||
-rw-r--r-- | gui/browser.h | 17 |
3 files changed, 31 insertions, 16 deletions
diff --git a/common/dialogs.h b/common/dialogs.h index 70c4837aa5..76a5174822 100644 --- a/common/dialogs.h +++ b/common/dialogs.h @@ -24,7 +24,7 @@ #define COMMON_DIALOG_MANAGER_H #include "common/scummsys.h" -#include "common/str.h" +#include "common/fs.h" #if defined(USE_SYSDIALOGS) @@ -48,9 +48,14 @@ public: virtual ~DialogManager() {} /** - * Displays a dialog for selecting a file or folder. + * Displays a dialog for selecting a file or folder in the filesystem. + * + * @param title The dialog title + * @param choice The path selected by the user + * @param isDirBrowser Restrict selection to directories + * @return The dialog result */ - virtual DialogResult showFileBrowser() { return kDialogError; } + virtual DialogResult showFileBrowser(const char *title, FSNode &choice, bool isDirBrowser = false) { return kDialogError; } }; } // End of namespace Common diff --git a/gui/browser.cpp b/gui/browser.cpp index 264f3a64f9..f3176803e3 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -28,6 +28,9 @@ #include "common/config-manager.h" #include "common/system.h" #include "common/algorithm.h" +#if defined(USE_SYSDIALOGS) +#include "common/dialogs.h" +#endif #include "common/translation.h" @@ -49,6 +52,7 @@ enum { BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) : Dialog("Browser") { + _title = title; _isDirBrowser = dirBrowser; _fileList = NULL; _currentPath = NULL; @@ -79,6 +83,21 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) new ButtonWidget(this, "Browser.Choose", _("Choose"), 0, kChooseCmd); } +int BrowserDialog::runModal() { +#if defined(USE_SYSDIALOGS) + // Try to use the backend browser + Common::DialogManager *dialogManager = g_system->getDialogManager(); + if (dialogManager) { + Common::DialogManager::DialogResult result = dialogManager->showFileBrowser(_title, _choice, _isDirBrowser); + if (result != Common::DialogManager::kDialogError) { + return result; + } + } +#endif + // If all else fails, use the GUI browser + return Dialog::runModal(); +} + void BrowserDialog::open() { // Call super implementation Dialog::open(); diff --git a/gui/browser.h b/gui/browser.h index 557563e0fa..2ef9a9c56e 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -37,35 +37,26 @@ class BrowserDialog : public Dialog { public: BrowserDialog(const char *title, bool dirBrowser); -#ifdef MACOSX - ~BrowserDialog(); virtual int runModal(); -#else virtual void open(); - virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); -#endif const Common::FSNode &getResult() { return _choice; } protected: -#ifdef MACOSX - const void *_titleRef; - const void *_chooseRef; -#else ListWidget *_fileList; EditTextWidget *_currentPath; Common::FSNode _node; - Common::FSList _nodeContent; + Common::FSList _nodeContent; + bool _showHidden; CheckboxWidget *_showHiddenWidget; -#endif + Common::FSNode _choice; + const char *_title; bool _isDirBrowser; -#ifndef MACOSX void updateListing(); -#endif }; } // End of namespace GUI |