Add show hidden folders flag to wxDirDialog

Add wxDD_SHOW_HIDDEN similar to the existing wxFD_SHOW_HIDDEN.
This commit is contained in:
Ian McInerney
2020-01-16 21:00:34 +00:00
committed by Vadim Zeitlin
parent b43f9b0ea4
commit 79d73d4eb3
4 changed files with 12 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[];
#define wxDD_CHANGE_DIR 0x0100 #define wxDD_CHANGE_DIR 0x0100
#define wxDD_DIR_MUST_EXIST 0x0200 #define wxDD_DIR_MUST_EXIST 0x0200
#define wxDD_MULTIPLE 0x0400 #define wxDD_MULTIPLE 0x0400
#define wxDD_SHOW_HIDDEN 0x0001
// deprecated, on by default now, use wxDD_DIR_MUST_EXIST to disable it // deprecated, on by default now, use wxDD_DIR_MUST_EXIST to disable it
#define wxDD_NEW_DIR_BUTTON 0 #define wxDD_NEW_DIR_BUTTON 0

View File

@@ -5,9 +5,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#define wxDD_CHANGE_DIR 0x0100 #define wxDD_CHANGE_DIR 0x0100
#define wxDD_DIR_MUST_EXIST 0x0200 #define wxDD_DIR_MUST_EXIST 0x0200
#define wxDD_MULTIPLE 0x0400 #define wxDD_MULTIPLE 0x0400
#define wxDD_SHOW_HIDDEN 0x0001
#define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now, #define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now,
@@ -45,11 +47,13 @@ const char wxDirDialogNameStr[] = "wxDirCtrl";
@style{wxDD_CHANGE_DIR} @style{wxDD_CHANGE_DIR}
Change the current working directory to the directory chosen by the Change the current working directory to the directory chosen by the
user. user.
@note This flag cannot be used with the @c wxDD_MULTIPLE style. @note This flag cannot be used with the @c wxDD_MULTIPLE style.
@style{wxDD_MULTIPLE} @style{wxDD_MULTIPLE}
Allow the user to select multiple directories. Allow the user to select multiple directories.
This flag is only available since wxWidgets 3.1.4 This flag is only available since wxWidgets 3.1.4
@style{wxDD_SHOW_HIDDEN}
Show hidden and system folders.
This flag is only available since wxWidgets 3.1.4
@endStyleTable @endStyleTable
Notice that @c wxRESIZE_BORDER has special side effect under Windows Notice that @c wxRESIZE_BORDER has special side effect under Windows

View File

@@ -489,7 +489,7 @@ bool MyApp::OnInit()
dir_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D"); dir_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, "Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"); dir_menu->Append(DIALOGS_DIRNEW_CHOOSE, "Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D");
dir_menu->Append(DIALOGS_DIRMULTIPLE_CHOOSE, "Choose multiple directories\tAlt-Ctrl-D"); dir_menu->Append(DIALOGS_DIRMULTIPLE_CHOOSE, "Choose multiple and hidden directories\tAlt-Ctrl-D");
menuDlg->Append(wxID_ANY,"&Directory operations",dir_menu); menuDlg->Append(wxID_ANY,"&Directory operations",dir_menu);
#if USE_DIRDLG_GENERIC #if USE_DIRDLG_GENERIC
@@ -1809,7 +1809,7 @@ void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
void MyFrame::DirChooseMultiple(wxCommandEvent& WXUNUSED(event)) void MyFrame::DirChooseMultiple(wxCommandEvent& WXUNUSED(event))
{ {
// pass some initial dir and the style to wxDirDialog // pass some initial dir and the style to wxDirDialog
int style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE; int style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE | wxDD_SHOW_HIDDEN;
wxString dirHome; wxString dirHome;
wxGetHomeDir(&dirHome); wxGetHomeDir(&dirHome);

View File

@@ -121,6 +121,9 @@ bool wxDirDialog::Create(wxWindow* parent,
gtk_file_chooser_set_select_multiple( gtk_file_chooser_set_select_multiple(
GTK_FILE_CHOOSER(m_widget), HasFlag(wxDD_MULTIPLE) ); GTK_FILE_CHOOSER(m_widget), HasFlag(wxDD_MULTIPLE) );
// Enable show hidden folders if desired
gtk_file_chooser_set_show_hidden(
GTK_FILE_CHOOSER(m_widget), HasFlag(wxDD_SHOW_HIDDEN) );
// local-only property could be set to false to allow non-local files to be loaded. // local-only property could be set to false to allow non-local files to be loaded.
// In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere