Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
35053e57
Unverified
Commit
35053e57
authored
Feb 21, 2018
by
Rémi Verschelde
Committed by
GitHub
Feb 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16710 from YeldhamDev/filedialog_nothing_disabled
Fixed "Open" button being enabled when nothing is selected in a FileDialog while in "Open folder" mode
parents
0667f2ac
db80d563
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
file_dialog.cpp
scene/gui/file_dialog.cpp
+7
-11
file_dialog.h
scene/gui/file_dialog.h
+1
-1
No files found.
scene/gui/file_dialog.cpp
View file @
35053e57
...
@@ -210,7 +210,7 @@ void FileDialog::_action_pressed() {
...
@@ -210,7 +210,7 @@ void FileDialog::_action_pressed() {
bool
valid
=
false
;
bool
valid
=
false
;
if
(
filter
->
get_selected
()
==
filter
->
get_item_count
()
-
1
)
{
if
(
filter
->
get_selected
()
==
filter
->
get_item_count
()
-
1
)
{
valid
=
true
;
//match none
valid
=
true
;
//
match none
}
else
if
(
filters
.
size
()
>
1
&&
filter
->
get_selected
()
==
0
)
{
}
else
if
(
filters
.
size
()
>
1
&&
filter
->
get_selected
()
==
0
)
{
// match all filters
// match all filters
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++
)
{
...
@@ -287,7 +287,7 @@ bool FileDialog::_is_open_should_be_disabled() {
...
@@ -287,7 +287,7 @@ bool FileDialog::_is_open_should_be_disabled() {
TreeItem
*
ti
=
tree
->
get_selected
();
TreeItem
*
ti
=
tree
->
get_selected
();
// We have something that we can't select?
// We have something that we can't select?
if
(
!
ti
)
if
(
!
ti
)
return
true
;
return
mode
!=
MODE_OPEN_DIR
;
// In "Open folder" mode, having nothing selected picks the current folder.
Dictionary
d
=
ti
->
get_metadata
(
0
);
Dictionary
d
=
ti
->
get_metadata
(
0
);
...
@@ -320,16 +320,14 @@ void FileDialog::deselect_items() {
...
@@ -320,16 +320,14 @@ void FileDialog::deselect_items() {
case
MODE_OPEN_FILE
:
case
MODE_OPEN_FILE
:
case
MODE_OPEN_FILES
:
case
MODE_OPEN_FILES
:
get_ok
()
->
set_text
(
TTR
(
"Open"
));
get_ok
()
->
set_text
(
TTR
(
"Open"
));
get_ok
()
->
set_disabled
(
false
);
break
;
break
;
case
MODE_OPEN_DIR
:
case
MODE_OPEN_DIR
:
get_ok
()
->
set_text
(
TTR
(
"Select Current Folder"
));
get_ok
()
->
set_text
(
TTR
(
"Select Current Folder"
));
get_ok
()
->
set_disabled
(
false
);
break
;
break
;
}
}
}
}
}
}
void
FileDialog
::
_tree_selected
()
{
void
FileDialog
::
_tree_selected
()
{
TreeItem
*
ti
=
tree
->
get_selected
();
TreeItem
*
ti
=
tree
->
get_selected
();
...
@@ -347,7 +345,7 @@ void FileDialog::_tree_selected() {
...
@@ -347,7 +345,7 @@ void FileDialog::_tree_selected() {
get_ok
()
->
set_disabled
(
_is_open_should_be_disabled
());
get_ok
()
->
set_disabled
(
_is_open_should_be_disabled
());
}
}
void
FileDialog
::
_tree_
dc_selec
ted
()
{
void
FileDialog
::
_tree_
item_activa
ted
()
{
TreeItem
*
ti
=
tree
->
get_selected
();
TreeItem
*
ti
=
tree
->
get_selected
();
if
(
!
ti
)
if
(
!
ti
)
...
@@ -756,7 +754,7 @@ void FileDialog::_bind_methods() {
...
@@ -756,7 +754,7 @@ void FileDialog::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"_unhandled_input"
),
&
FileDialog
::
_unhandled_input
);
ClassDB
::
bind_method
(
D_METHOD
(
"_unhandled_input"
),
&
FileDialog
::
_unhandled_input
);
ClassDB
::
bind_method
(
D_METHOD
(
"_tree_selected"
),
&
FileDialog
::
_tree_selected
);
ClassDB
::
bind_method
(
D_METHOD
(
"_tree_selected"
),
&
FileDialog
::
_tree_selected
);
ClassDB
::
bind_method
(
D_METHOD
(
"_tree_
db_selected"
),
&
FileDialog
::
_tree_dc_selec
ted
);
ClassDB
::
bind_method
(
D_METHOD
(
"_tree_
item_activated"
),
&
FileDialog
::
_tree_item_activa
ted
);
ClassDB
::
bind_method
(
D_METHOD
(
"_dir_entered"
),
&
FileDialog
::
_dir_entered
);
ClassDB
::
bind_method
(
D_METHOD
(
"_dir_entered"
),
&
FileDialog
::
_dir_entered
);
ClassDB
::
bind_method
(
D_METHOD
(
"_file_entered"
),
&
FileDialog
::
_file_entered
);
ClassDB
::
bind_method
(
D_METHOD
(
"_file_entered"
),
&
FileDialog
::
_file_entered
);
ClassDB
::
bind_method
(
D_METHOD
(
"_action_pressed"
),
&
FileDialog
::
_action_pressed
);
ClassDB
::
bind_method
(
D_METHOD
(
"_action_pressed"
),
&
FileDialog
::
_action_pressed
);
...
@@ -881,7 +879,7 @@ FileDialog::FileDialog() {
...
@@ -881,7 +879,7 @@ FileDialog::FileDialog() {
filter
=
memnew
(
OptionButton
);
filter
=
memnew
(
OptionButton
);
filter
->
set_stretch_ratio
(
3
);
filter
->
set_stretch_ratio
(
3
);
filter
->
set_h_size_flags
(
SIZE_EXPAND_FILL
);
filter
->
set_h_size_flags
(
SIZE_EXPAND_FILL
);
filter
->
set_clip_text
(
true
);
//
too many extensions overflow
it
filter
->
set_clip_text
(
true
);
//
too many extensions overflows
it
hbc
->
add_child
(
filter
);
hbc
->
add_child
(
filter
);
vbc
->
add_child
(
hbc
);
vbc
->
add_child
(
hbc
);
...
@@ -890,9 +888,8 @@ FileDialog::FileDialog() {
...
@@ -890,9 +888,8 @@ FileDialog::FileDialog() {
_update_drives
();
_update_drives
();
connect
(
"confirmed"
,
this
,
"_action_pressed"
);
connect
(
"confirmed"
,
this
,
"_action_pressed"
);
//cancel->connect("pressed", this,"_cancel_pressed");
tree
->
connect
(
"cell_selected"
,
this
,
"_tree_selected"
,
varray
(),
CONNECT_DEFERRED
);
tree
->
connect
(
"cell_selected"
,
this
,
"_tree_selected"
,
varray
(),
CONNECT_DEFERRED
);
tree
->
connect
(
"item_activated"
,
this
,
"_tree_
db_selec
ted"
,
varray
());
tree
->
connect
(
"item_activated"
,
this
,
"_tree_
item_activa
ted"
,
varray
());
tree
->
connect
(
"nothing_selected"
,
this
,
"deselect_items"
);
tree
->
connect
(
"nothing_selected"
,
this
,
"deselect_items"
);
dir
->
connect
(
"text_entered"
,
this
,
"_dir_entered"
);
dir
->
connect
(
"text_entered"
,
this
,
"_dir_entered"
);
file
->
connect
(
"text_entered"
,
this
,
"_file_entered"
);
file
->
connect
(
"text_entered"
,
this
,
"_file_entered"
);
...
@@ -922,7 +919,6 @@ FileDialog::FileDialog() {
...
@@ -922,7 +919,6 @@ FileDialog::FileDialog() {
exterr
->
set_text
(
RTR
(
"Must use a valid extension."
));
exterr
->
set_text
(
RTR
(
"Must use a valid extension."
));
add_child
(
exterr
);
add_child
(
exterr
);
//update_file_list();
update_filters
();
update_filters
();
update_dir
();
update_dir
();
...
...
scene/gui/file_dialog.h
View file @
35053e57
...
@@ -107,7 +107,7 @@ private:
...
@@ -107,7 +107,7 @@ private:
void
_tree_selected
();
void
_tree_selected
();
void
_select_drive
(
int
p_idx
);
void
_select_drive
(
int
p_idx
);
void
_tree_
dc_selec
ted
();
void
_tree_
item_activa
ted
();
void
_dir_entered
(
String
p_dir
);
void
_dir_entered
(
String
p_dir
);
void
_file_entered
(
const
String
&
p_file
);
void
_file_entered
(
const
String
&
p_file
);
void
_action_pressed
();
void
_action_pressed
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment