1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:17:45 +00:00

Applications: Open folder with pre-selected file where appropriate :^)

This commit is contained in:
speles 2021-03-01 23:27:37 +02:00 committed by Andreas Kling
parent 50de653cc9
commit 6e16a5cdfa
4 changed files with 10 additions and 7 deletions

View file

@ -166,7 +166,7 @@ void DownloadWidget::did_finish(bool success)
m_close_button->set_enabled(true); m_close_button->set_enabled(true);
m_cancel_button->set_text("Open in Folder"); m_cancel_button->set_text("Open in Folder");
m_cancel_button->on_click = [this](auto) { m_cancel_button->on_click = [this](auto) {
Desktop::Launcher::open(URL::create_with_file_protocol(Core::StandardPaths::downloads_directory())); Desktop::Launcher::open(URL::create_with_file_protocol(Core::StandardPaths::downloads_directory(), m_url.basename()));
window()->close(); window()->close();
}; };
m_cancel_button->update(); m_cancel_button->update();

View file

@ -206,13 +206,15 @@ int main(int argc, char** argv)
auto& executable_link_label = *widget.find_descendant_of_type_named<GUI::LinkLabel>("executable_link"); auto& executable_link_label = *widget.find_descendant_of_type_named<GUI::LinkLabel>("executable_link");
executable_link_label.set_text(LexicalPath::canonicalized_path(executable_path)); executable_link_label.set_text(LexicalPath::canonicalized_path(executable_path));
executable_link_label.on_click = [&] { executable_link_label.on_click = [&] {
Desktop::Launcher::open(URL::create_with_file_protocol(LexicalPath(executable_path).dirname())); LexicalPath path { executable_path };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
}; };
auto& coredump_link_label = *widget.find_descendant_of_type_named<GUI::LinkLabel>("coredump_link"); auto& coredump_link_label = *widget.find_descendant_of_type_named<GUI::LinkLabel>("coredump_link");
coredump_link_label.set_text(LexicalPath::canonicalized_path(coredump_path)); coredump_link_label.set_text(LexicalPath::canonicalized_path(coredump_path));
coredump_link_label.on_click = [&] { coredump_link_label.on_click = [&] {
Desktop::Launcher::open(URL::create_with_file_protocol(LexicalPath(coredump_path).dirname())); LexicalPath path { coredump_path };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
}; };
auto& arguments_label = *widget.find_descendant_of_type_named<GUI::Label>("arguments_label"); auto& arguments_label = *widget.find_descendant_of_type_named<GUI::Label>("arguments_label");

View file

@ -113,8 +113,7 @@ PropertiesWindow::PropertiesWindow(const String& path, bool disable_rename, Wind
auto properties = Vector<PropertyValuePair>(); auto properties = Vector<PropertyValuePair>();
properties.append({ "Type:", get_description(m_mode) }); properties.append({ "Type:", get_description(m_mode) });
auto parent_link = URL::create_with_file_protocol(m_parent_path); auto parent_link = URL::create_with_file_protocol(m_parent_path, m_name);
parent_link.set_fragment(m_name);
properties.append(PropertyValuePair { "Location:", path, Optional(parent_link) }); properties.append(PropertyValuePair { "Location:", path, Optional(parent_link) });
if (S_ISLNK(m_mode)) { if (S_ISLNK(m_mode)) {
@ -124,7 +123,7 @@ PropertiesWindow::PropertiesWindow(const String& path, bool disable_rename, Wind
} else { } else {
auto link_directory = LexicalPath(link_destination); auto link_directory = LexicalPath(link_destination);
VERIFY(link_directory.is_valid()); VERIFY(link_directory.is_valid());
auto link_parent = URL::create_with_file_protocol(link_directory.dirname()); auto link_parent = URL::create_with_file_protocol(link_directory.dirname(), link_directory.basename());
properties.append({ "Link target:", link_destination, Optional(link_parent) }); properties.append({ "Link target:", link_destination, Optional(link_parent) });
} }
} }

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "TreeMapWidget.h" #include "TreeMapWidget.h"
#include <AK/LexicalPath.h>
#include <AK/Queue.h> #include <AK/Queue.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
@ -305,7 +306,8 @@ int main(int argc, char* argv[])
Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget))); Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget)));
}); });
auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget, false))); LexicalPath path { get_absolute_path_to_selected_node(treemapwidget) };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
}); });
auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](auto&) { auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](auto&) {
GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget)); GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget));