Merge pull request #1535 from rollenrolm/hidden_files

New option to show/hide hidden files
This commit is contained in:
Juan Linietsky 2015-03-22 14:46:09 -03:00
commit 47efcff8bb
13 changed files with 63 additions and 10 deletions

View file

@ -362,6 +362,10 @@ bool DirAccessPack::current_is_dir() const{
return cdir;
}
bool DirAccessPack::current_is_hidden() const{
return false;
}
void DirAccessPack::list_dir_end() {
list_dirs.clear();

View file

@ -208,6 +208,7 @@ public:
virtual bool list_dir_begin();
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
virtual void list_dir_end();
virtual int get_drive_count();

View file

@ -78,6 +78,7 @@ public:
virtual String get_next(bool* p_is_dir); // compatibility
virtual String get_next()=0;
virtual bool current_is_dir() const=0;
virtual bool current_is_hidden() const=0;
virtual void list_dir_end()=0; ///<

View file

@ -161,6 +161,7 @@ String DirAccessUnix::get_next() {
}
_cishidden=(fname!="." && fname!=".." && fname.begins_with("."));
@ -173,6 +174,11 @@ bool DirAccessUnix::current_is_dir() const {
return _cisdir;
}
bool DirAccessUnix::current_is_hidden() const {
return _cishidden;
}
void DirAccessUnix::list_dir_end() {

View file

@ -50,12 +50,14 @@ class DirAccessUnix : public DirAccess {
String current_dir;
bool _cisdir;
bool _cishidden;
public:
virtual bool list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
virtual void list_dir_end(); ///<

View file

@ -68,6 +68,7 @@ struct DirAccessWindowsPrivate {
bool DirAccessWindows::list_dir_begin() {
_cisdir=false;
_cishidden=false;
if (unicode) {
list_dir_end();
@ -95,6 +96,8 @@ String DirAccessWindows::get_next() {
if (unicode) {
_cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
_cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN);
String name=p->fu.cFileName;
if (FindNextFileW(p->h, &p->fu) == 0) {
@ -108,6 +111,7 @@ String DirAccessWindows::get_next() {
#ifndef WINRT_ENABLED
_cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
_cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN);
String name=p->f.cFileName;
@ -128,6 +132,11 @@ bool DirAccessWindows::current_is_dir() const {
return _cisdir;
}
bool DirAccessWindows::current_is_hidden() const {
return _cishidden;
}
void DirAccessWindows::list_dir_end() {
if (p->h!=INVALID_HANDLE_VALUE) {

View file

@ -58,6 +58,7 @@ class DirAccessWindows : public DirAccess {
bool unicode;
bool _cisdir;
bool _cishidden;
public:

View file

@ -79,6 +79,9 @@ bool DirAccessAndroid::current_is_dir() const{
return false;
}
bool DirAccessAndroid::current_is_hidden() const{
return current!="." && current!=".." && current.begins_with(".");
}
void DirAccessAndroid::list_dir_end(){
if (aad==NULL)

View file

@ -52,6 +52,7 @@ public:
virtual bool list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
virtual void list_dir_end(); ///<
virtual int get_drive_count();

View file

@ -105,6 +105,9 @@ bool DirAccessJAndroid::current_is_dir() const{
return true;
}
bool DirAccessAndroid::current_is_hidden() const{
return current!="." && current!=".." && current.begins_with(".");
}
void DirAccessJAndroid::list_dir_end(){
if (id==0)

View file

@ -29,6 +29,8 @@
#include "file_dialog.h"
#include "scene/gui/label.h"
#include "print_string.h"
#include "os/keyboard.h"
#include "tools/editor/editor_settings.h"
FileDialog::GetIconFunc FileDialog::get_icon_func=NULL;
@ -278,13 +280,20 @@ void FileDialog::update_file_list() {
List<String> dirs;
bool isdir;
bool ishidden;
bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
String item;
while ((item=dir_access->get_next(&isdir))!="") {
if (!isdir)
files.push_back(item);
else
dirs.push_back(item);
ishidden = dir_access->current_is_hidden();
if (show_hidden || !ishidden) {
if (!isdir)
files.push_back(item);
else
dirs.push_back(item);
}
}
dirs.sort_custom<NoCaseComparator>();

View file

@ -28,6 +28,9 @@
/*************************************************************************/
#include "editor_dir_dialog.h"
#include "os/os.h"
#include "os/keyboard.h"
#include "tools/editor/editor_settings.h"
void EditorDirDialog::_update_dir(TreeItem* p_item) {
@ -39,12 +42,21 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) {
da->change_dir(cdir);
da->list_dir_begin();
String p=da->get_next();
bool ishidden;
bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
while(p!="") {
if (da->current_is_dir() && !p.begins_with(".")) {
TreeItem *ti = tree->create_item(p_item);
ti->set_text(0,p);
ti->set_icon(0,get_icon("Folder","EditorIcons"));
ti->set_collapsed(true);
ishidden = da->current_is_hidden();
if (show_hidden || !ishidden) {
if (da->current_is_dir() && !p.begins_with(".")) {
TreeItem *ti = tree->create_item(p_item);
ti->set_text(0,p);
ti->set_icon(0,get_icon("Folder","EditorIcons"));
ti->set_collapsed(true);
}
}
p=da->get_next();

View file

@ -446,6 +446,7 @@ void EditorSettings::_load_defaults() {
set("text_editor/create_signal_callbacks",true);
set("file_dialog/show_hidden_files", false);
set("animation/autorename_animation_tracks",true);
set("animation/confirm_insert_track",true);