fix(color): Filter Unix/MacOS dot files from file chooser popup (#4428)
This commit is contained in:
+11
-16
@@ -17,13 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "filechoice.h"
|
#include "filechoice.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "libopenui_file.h"
|
#include "libopenui_file.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "message_dialog.h"
|
#include "message_dialog.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#if !defined(STR_SDCARD)
|
#if !defined(STR_SDCARD)
|
||||||
#define STR_SDCARD "SD"
|
#define STR_SDCARD "SD"
|
||||||
#endif
|
#endif
|
||||||
@@ -32,8 +33,8 @@
|
|||||||
#define STR_NO_FILES_ON_SD "No files on SD Card!"
|
#define STR_NO_FILES_ON_SD "No files on SD Card!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FileChoice::FileChoice(Window* parent, const rect_t &rect,
|
FileChoice::FileChoice(Window *parent, const rect_t &rect, std::string folder,
|
||||||
std::string folder, const char *extension, int maxlen,
|
const char *extension, int maxlen,
|
||||||
std::function<std::string()> getValue,
|
std::function<std::string()> getValue,
|
||||||
std::function<void(std::string)> setValue,
|
std::function<void(std::string)> setValue,
|
||||||
bool stripExtension) :
|
bool stripExtension) :
|
||||||
@@ -48,11 +49,7 @@ FileChoice::FileChoice(Window* parent, const rect_t &rect,
|
|||||||
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
|
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FileChoice::getLabelText()
|
std::string FileChoice::getLabelText() { return getValue(); }
|
||||||
{
|
|
||||||
return getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool FileChoice::openMenu()
|
bool FileChoice::openMenu()
|
||||||
{
|
{
|
||||||
@@ -69,9 +66,10 @@ bool FileChoice::openMenu()
|
|||||||
res = sdReadDir(&dir, &fno, firstTime);
|
res = sdReadDir(&dir, &fno, firstTime);
|
||||||
if (res != FR_OK || fno.fname[0] == 0)
|
if (res != FR_OK || fno.fname[0] == 0)
|
||||||
break; // break on error or end of dir
|
break; // break on error or end of dir
|
||||||
if (fno.fattrib & AM_DIR) continue; // skip subfolders
|
if (fno.fattrib & (AM_HID | AM_SYS | AM_DIR))
|
||||||
if (fno.fattrib & AM_HID) continue; // skip hidden files
|
continue; // Ignore subfolders, hidden files and system files
|
||||||
if (fno.fattrib & AM_SYS) continue; // skip system files
|
if (fno.fname[0] == '.' && fno.fname[1] != '.')
|
||||||
|
continue; // Ignore hidden files under UNIX, but not ..
|
||||||
|
|
||||||
fnExt = getFileExtension(fno.fname, 0, 0, &fnLen, &extLen);
|
fnExt = getFileExtension(fno.fname, 0, 0, &fnLen, &extLen);
|
||||||
|
|
||||||
@@ -132,7 +130,4 @@ bool FileChoice::openMenu()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileChoice::onClicked()
|
void FileChoice::onClicked() { openMenu(); }
|
||||||
{
|
|
||||||
openMenu();
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user