diff --git a/src/app/file_selector.cpp b/src/app/file_selector.cpp index feff734a9..9a8eb718f 100644 --- a/src/app/file_selector.cpp +++ b/src/app/file_selector.cpp @@ -55,8 +55,7 @@ std::string show_file_selector(const std::string& title, } } - FileSelector fileSelector(type == FileSelectorType::Open ? FileSelector::Open: - FileSelector::Save); + FileSelector fileSelector(type); return fileSelector.show(title, initialPath, showExtensions); } diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp index 3880f2db0..12d79e588 100644 --- a/src/app/ui/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -241,7 +241,7 @@ private: FileSelector* m_filesel; }; -FileSelector::FileSelector(Type type) +FileSelector::FileSelector(FileSelectorType type) : Window(WithTitleBar, "") , m_type(type) , m_navigationLocked(false) @@ -385,7 +385,7 @@ std::string FileSelector::show( // Change the file formats/extensions to be shown std::string initialExtension = base::get_file_extension(initialPath); std::string exts = showExtensions; - if (m_type == Open) { + if (m_type == FileSelectorType::Open) { auto it = preferred_open_extensions.find(exts); if (it == preferred_open_extensions.end()) exts = showExtensions; @@ -393,7 +393,7 @@ std::string FileSelector::show( exts = preferred_open_extensions[exts]; } else { - ASSERT(m_type == Save); + ASSERT(m_type == FileSelectorType::Save); if (!initialExtension.empty()) exts = initialExtension; } @@ -562,7 +562,7 @@ again: buf += getSelectedExtension(); } - if (m_type == Save && base::is_file(buf)) { + if (m_type == FileSelectorType::Save && base::is_file(buf)) { int ret = Alert::show("Warning<setExtensions(exts.c_str()); m_navigationLocked = false; - if (m_type == Open) { + if (m_type == FileSelectorType::Open) { std::string origShowExtensions = m_fileType->getItem(0)->getValue(); preferred_open_extensions[origShowExtensions] = m_fileType->getValue(); } } - if (m_type == Save) { + if (m_type == FileSelectorType::Save) { std::string newExtension = getSelectedExtension(); std::string fileName = m_fileName->getValue(); std::string currentExtension = base::get_file_extension(fileName); diff --git a/src/app/ui/file_selector.h b/src/app/ui/file_selector.h index f4e0133a6..034870f28 100644 --- a/src/app/ui/file_selector.h +++ b/src/app/ui/file_selector.h @@ -9,6 +9,7 @@ #define APP_UI_FILE_SELECTOR_H_INCLUDED #pragma once +#include "app/file_selector.h" #include "base/unique_ptr.h" #include "ui/window.h" @@ -27,9 +28,7 @@ namespace app { class FileSelector : public ui::Window { public: - enum Type { Open, Save }; - - FileSelector(Type type); + FileSelector(FileSelectorType type); void goBack(); void goForward(); @@ -56,7 +55,7 @@ namespace app { void onFileListCurrentFolderChanged(); std::string getSelectedExtension() const; - Type m_type; + FileSelectorType m_type; std::string m_defExtension; ui::Button* m_goBack; ui::Button* m_goForward;