1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

FileManager: Small improvements to PropertyDialog's apply button logic

The apply button used to be enabled directly after opening the dialog.
Changes in the permissions now enable/disable the apply button as well.
This commit is contained in:
Till Mayer 2020-06-18 19:11:46 +02:00 committed by Andreas Kling
parent 072e6a6405
commit 5bd0015583
2 changed files with 7 additions and 4 deletions

View file

@ -83,7 +83,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
m_name_box->set_enabled(!disable_rename); m_name_box->set_enabled(!disable_rename);
m_name_box->on_change = [&]() { m_name_box->on_change = [&]() {
m_name_dirty = m_name != m_name_box->text(); m_name_dirty = m_name != m_name_box->text();
m_apply_button->set_enabled(true); m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty);
}; };
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png")); set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"));
@ -111,6 +111,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
} }
m_mode = st.st_mode; m_mode = st.st_mode;
m_old_mode = st.st_mode;
auto properties = Vector<PropertyValuePair>(); auto properties = Vector<PropertyValuePair>();
properties.append({ "Type:", get_description(m_mode) }); properties.append({ "Type:", get_description(m_mode) });
@ -164,7 +165,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
update(); update();
} }
PropertiesDialog::~PropertiesDialog() {} PropertiesDialog::~PropertiesDialog() { }
void PropertiesDialog::update() void PropertiesDialog::update()
{ {
@ -181,8 +182,8 @@ void PropertiesDialog::permission_changed(mode_t mask, bool set)
m_mode &= ~mask; m_mode &= ~mask;
} }
m_permissions_dirty = true; m_permissions_dirty = m_mode != m_old_mode;
m_apply_button->set_enabled(true); m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty);
} }
String PropertiesDialog::make_full_path(String name) String PropertiesDialog::make_full_path(String name)
@ -217,6 +218,7 @@ bool PropertiesDialog::apply_changes()
return false; return false;
} }
m_old_mode = m_mode;
m_permissions_dirty = false; m_permissions_dirty = false;
} }

View file

@ -91,6 +91,7 @@ private:
String m_name; String m_name;
String m_path; String m_path;
mode_t m_mode; mode_t m_mode;
mode_t m_old_mode;
bool m_permissions_dirty { false }; bool m_permissions_dirty { false };
bool m_name_dirty { false }; bool m_name_dirty { false };
}; };