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

FileManager: Add "Open with" menu if alternative applications are available

This commit is contained in:
Tom 2020-07-13 18:58:21 -06:00 committed by Andreas Kling
parent 535113bac4
commit 50903fd88c
4 changed files with 129 additions and 21 deletions

View file

@ -26,7 +26,10 @@
#pragma once
#include <AK/URL.h>
#include <AK/Vector.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/Action.h>
#include <LibGUI/ColumnsView.h>
#include <LibGUI/FileSystemModel.h>
#include <LibGUI/IconView.h>
@ -34,6 +37,20 @@
#include <LibGUI/TableView.h>
#include <sys/stat.h>
class LauncherHandler: public RefCounted<LauncherHandler> {
public:
LauncherHandler(const NonnullRefPtr<Desktop::Launcher::Details>& details)
: m_details(details)
{
}
NonnullRefPtr<GUI::Action> create_launch_action(Function<void(const LauncherHandler&)>);
const Desktop::Launcher::Details& details() const { return *m_details; }
private:
NonnullRefPtr<Desktop::Launcher::Details> m_details;
};
class DirectoryView final : public GUI::StackWidget
, private GUI::ModelClient {
C_OBJECT(DirectoryView)
@ -47,6 +64,9 @@ public:
void open_next_directory();
int path_history_size() const { return m_path_history.size(); }
int path_history_position() const { return m_path_history_position; }
static RefPtr<LauncherHandler> get_default_launch_handler(const NonnullRefPtrVector<LauncherHandler>& handlers);
NonnullRefPtrVector<LauncherHandler> get_launch_handlers(const URL& url);
NonnullRefPtrVector<LauncherHandler> get_launch_handlers(const String& path);
void refresh();