diff options
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/FileManager/DirectoryView.cpp | 50 | ||||
-rw-r--r-- | Applications/FileManager/DirectoryView.h | 2 | ||||
-rw-r--r-- | Applications/IRCClient/IRCAppWindow.cpp | 4 | ||||
-rw-r--r-- | Applications/IRCClient/IRCChannelMemberListModel.cpp | 7 | ||||
-rw-r--r-- | Applications/IRCClient/IRCChannelMemberListModel.h | 3 | ||||
-rw-r--r-- | Applications/IRCClient/IRCLogBufferModel.cpp | 4 | ||||
-rw-r--r-- | Applications/IRCClient/IRCLogBufferModel.h | 1 | ||||
-rw-r--r-- | Applications/IRCClient/IRCWindow.cpp | 1 | ||||
-rw-r--r-- | Applications/IRCClient/IRCWindowListModel.cpp | 7 | ||||
-rw-r--r-- | Applications/IRCClient/IRCWindowListModel.h | 1 |
10 files changed, 56 insertions, 24 deletions
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index a6177b1462..5265943129 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -1,5 +1,47 @@ #include "DirectoryView.h" #include <LibGUI/GSortingProxyModel.h> +#include <AK/FileSystemPath.h> +#include <unistd.h> +#include <stdio.h> + +void DirectoryView::handle_activation(const GModelIndex& index) +{ + if (!index.is_valid()) + return; + dbgprintf("on activation: %d,%d, this=%p, m_model=%p\n", index.row(), index.column(), this, m_model.ptr()); + auto& entry = model().entry(index.row()); + FileSystemPath path(String::format("%s/%s", model().path().characters(), entry.name.characters())); + if (entry.is_directory()) { + open(path.string()); + return; + } + if (entry.is_executable()) { + if (fork() == 0) { + int rc = execl(path.string().characters(), path.string().characters(), nullptr); + if (rc < 0) + perror("exec"); + ASSERT_NOT_REACHED(); + } + return; + } + + if (path.string().to_lowercase().ends_with(".png")) { + if (fork() == 0) { + int rc = execl("/bin/qs", "/bin/qs", path.string().characters(), nullptr); + if (rc < 0) + perror("exec"); + ASSERT_NOT_REACHED(); + } + return; + } + + if (fork() == 0) { + int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.string().characters(), nullptr); + if (rc < 0) + perror("exec"); + ASSERT_NOT_REACHED(); + } +}; DirectoryView::DirectoryView(GWidget* parent) : GStackWidget(parent) @@ -34,6 +76,14 @@ DirectoryView::DirectoryView(GWidget* parent) on_thumbnail_progress(done, total); }; + m_item_view->on_activation = [&] (const GModelIndex& index) { + handle_activation(index); + }; + m_table_view->on_activation = [&] (auto& index) { + auto& filter_model = (GSortingProxyModel&)*m_table_view->model(); + handle_activation(filter_model.map_to_target(index)); + }; + set_view_mode(ViewMode::Icon); } diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h index f657999a7b..dec41cf1d1 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -29,6 +29,8 @@ private: GDirectoryModel& model() { return *m_model; } const GDirectoryModel& model() const { return *m_model; } + void handle_activation(const GModelIndex&); + void set_status_message(const String&); ViewMode m_view_mode { Invalid }; diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index c37a5527c5..20ee953f5a 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -151,9 +151,11 @@ void IRCAppWindow::setup_widgets() m_window_list->set_headers_visible(false); m_window_list->set_alternating_row_colors(false); m_window_list->set_model(m_client.client_window_list_model()); + m_window_list->set_activates_on_selection(true); m_window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); m_window_list->set_preferred_size({ 100, 0 }); - m_client.client_window_list_model()->on_activation = [this] (IRCWindow& window) { + m_window_list->on_activation = [this] (auto& index) { + auto& window = m_client.window_at(index.row()); m_container->set_active_widget(&window); window.clear_unread_count(); }; diff --git a/Applications/IRCClient/IRCChannelMemberListModel.cpp b/Applications/IRCClient/IRCChannelMemberListModel.cpp index 057838a046..25fed4cbf3 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.cpp +++ b/Applications/IRCClient/IRCChannelMemberListModel.cpp @@ -6,7 +6,6 @@ IRCChannelMemberListModel::IRCChannelMemberListModel(IRCChannel& channel) : m_channel(channel) { - set_activates_on_selection(true); } IRCChannelMemberListModel::~IRCChannelMemberListModel() @@ -53,9 +52,3 @@ void IRCChannelMemberListModel::update() { did_update(); } - -void IRCChannelMemberListModel::activate(const GModelIndex& index) -{ - if (on_activation) - on_activation(m_channel.member_at(index.row())); -} diff --git a/Applications/IRCClient/IRCChannelMemberListModel.h b/Applications/IRCClient/IRCChannelMemberListModel.h index 8b6c479763..2f67cf15ca 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Applications/IRCClient/IRCChannelMemberListModel.h @@ -17,9 +17,6 @@ public: virtual ColumnMetadata column_metadata(int column) const override; virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; virtual void update() override; - virtual void activate(const GModelIndex&) override; - - Function<void(const String&)> on_activation; private: explicit IRCChannelMemberListModel(IRCChannel&); diff --git a/Applications/IRCClient/IRCLogBufferModel.cpp b/Applications/IRCClient/IRCLogBufferModel.cpp index 1e451770f2..518ad63f3c 100644 --- a/Applications/IRCClient/IRCLogBufferModel.cpp +++ b/Applications/IRCClient/IRCLogBufferModel.cpp @@ -72,7 +72,3 @@ void IRCLogBufferModel::update() { did_update(); } - -void IRCLogBufferModel::activate(const GModelIndex&) -{ -} diff --git a/Applications/IRCClient/IRCLogBufferModel.h b/Applications/IRCClient/IRCLogBufferModel.h index d4f29740b1..5be8237d07 100644 --- a/Applications/IRCClient/IRCLogBufferModel.h +++ b/Applications/IRCClient/IRCLogBufferModel.h @@ -22,7 +22,6 @@ public: virtual ColumnMetadata column_metadata(int column) const override; virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; virtual void update() override; - virtual void activate(const GModelIndex&) override; private: explicit IRCLogBufferModel(Retained<IRCLogBuffer>&&); diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index ea00c7801d..7364707e82 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -37,6 +37,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na member_view->set_preferred_size({ 100, 0 }); member_view->set_alternating_row_colors(false); member_view->set_model(channel().member_model()); + member_view->set_activates_on_selection(true); } m_text_editor = new GTextEditor(GTextEditor::SingleLine, this); diff --git a/Applications/IRCClient/IRCWindowListModel.cpp b/Applications/IRCClient/IRCWindowListModel.cpp index 2adb2ef360..bc089c2e0c 100644 --- a/Applications/IRCClient/IRCWindowListModel.cpp +++ b/Applications/IRCClient/IRCWindowListModel.cpp @@ -8,7 +8,6 @@ IRCWindowListModel::IRCWindowListModel(IRCClient& client) : m_client(client) { - set_activates_on_selection(true); } IRCWindowListModel::~IRCWindowListModel() @@ -72,9 +71,3 @@ void IRCWindowListModel::update() { did_update(); } - -void IRCWindowListModel::activate(const GModelIndex& index) -{ - if (on_activation) - on_activation(m_client.window_at(index.row())); -} diff --git a/Applications/IRCClient/IRCWindowListModel.h b/Applications/IRCClient/IRCWindowListModel.h index 607658cd66..d565eb78e3 100644 --- a/Applications/IRCClient/IRCWindowListModel.h +++ b/Applications/IRCClient/IRCWindowListModel.h @@ -21,7 +21,6 @@ public: virtual ColumnMetadata column_metadata(int column) const override; virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; virtual void update() override; - virtual void activate(const GModelIndex&) override; Function<void(IRCWindow&)> on_activation; |