summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Mayer <till.mayer@web.de>2020-06-18 19:11:46 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-18 23:14:13 +0200
commit5bd0015583017a77ff8d32c537306c3b830457f3 (patch)
tree53f7990563b3f5c9ff73c0121afc66c396f4f28e
parent072e6a6405938cde83d6d0cc7fdcd95ad8d4ee61 (diff)
downloadserenity-5bd0015583017a77ff8d32c537306c3b830457f3.zip
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.
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp10
-rw-r--r--Applications/FileManager/PropertiesDialog.h1
2 files changed, 7 insertions, 4 deletions
diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp
index 27a3a25d36..f9426f91f4 100644
--- a/Applications/FileManager/PropertiesDialog.cpp
+++ b/Applications/FileManager/PropertiesDialog.cpp
@@ -83,7 +83,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
m_name_box->set_enabled(!disable_rename);
m_name_box->on_change = [&]() {
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"));
@@ -111,6 +111,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
}
m_mode = st.st_mode;
+ m_old_mode = st.st_mode;
auto properties = Vector<PropertyValuePair>();
properties.append({ "Type:", get_description(m_mode) });
@@ -164,7 +165,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
update();
}
-PropertiesDialog::~PropertiesDialog() {}
+PropertiesDialog::~PropertiesDialog() { }
void PropertiesDialog::update()
{
@@ -181,8 +182,8 @@ void PropertiesDialog::permission_changed(mode_t mask, bool set)
m_mode &= ~mask;
}
- m_permissions_dirty = true;
- m_apply_button->set_enabled(true);
+ m_permissions_dirty = m_mode != m_old_mode;
+ m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty);
}
String PropertiesDialog::make_full_path(String name)
@@ -217,6 +218,7 @@ bool PropertiesDialog::apply_changes()
return false;
}
+ m_old_mode = m_mode;
m_permissions_dirty = false;
}
diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h
index c38e46aae6..d0dfa9efcc 100644
--- a/Applications/FileManager/PropertiesDialog.h
+++ b/Applications/FileManager/PropertiesDialog.h
@@ -91,6 +91,7 @@ private:
String m_name;
String m_path;
mode_t m_mode;
+ mode_t m_old_mode;
bool m_permissions_dirty { false };
bool m_name_dirty { false };
};