mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
FileManager: Make DirectoryView listen for configuration changes
DirectoryView now inherits from Config::Listener and will update its view mode immediately if changed from elsewhere. This is pretty neat. :^)
This commit is contained in:
parent
c8c58626e9
commit
696dbc889f
Notes:
sideshowbarker
2024-07-18 05:15:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/696dbc889f8
@ -340,6 +340,17 @@ void DirectoryView::set_view_mode_from_string(String const& mode)
|
||||
}
|
||||
}
|
||||
|
||||
void DirectoryView::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
|
||||
{
|
||||
if (domain != "FileManager" || group != "DirectoryView")
|
||||
return;
|
||||
|
||||
if (key == "ViewMode") {
|
||||
set_view_mode_from_string(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DirectoryView::set_view_mode(ViewMode mode)
|
||||
{
|
||||
if (m_view_mode == mode)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibConfig/Listener.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ColumnsView.h>
|
||||
@ -38,7 +39,8 @@ private:
|
||||
|
||||
class DirectoryView final
|
||||
: public GUI::StackWidget
|
||||
, private GUI::ModelClient {
|
||||
, private GUI::ModelClient
|
||||
, public Config::Listener {
|
||||
C_OBJECT(DirectoryView);
|
||||
|
||||
public:
|
||||
@ -130,6 +132,9 @@ public:
|
||||
GUI::Action& view_as_table_action() { return *m_view_as_table_action; }
|
||||
GUI::Action& view_as_columns_action() { return *m_view_as_columns_action; }
|
||||
|
||||
// ^Config::Listener
|
||||
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
|
||||
|
||||
private:
|
||||
explicit DirectoryView(Mode);
|
||||
|
||||
|
@ -92,6 +92,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
Config::pledge_domains({ "FileManager", "WindowManager" });
|
||||
Config::monitor_domain("FileManager");
|
||||
|
||||
if (is_desktop_mode)
|
||||
return run_in_desktop_mode();
|
||||
|
Loading…
Reference in New Issue
Block a user