GFilePicker: Return paths as FileSystemPath rather than String

This commit is contained in:
faissaloo 2019-05-26 13:09:31 +01:00 committed by Andreas Kling
parent 9b86eb9fad
commit 6ac8aab941
Notes: sideshowbarker 2024-07-19 13:55:43 +09:00
3 changed files with 5 additions and 4 deletions

View file

@ -63,7 +63,7 @@ int main(int argc, char** argv)
auto open_action = GAction::create("Open document", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [window, text_editor, &path](const GAction&) { auto open_action = GAction::create("Open document", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [window, text_editor, &path](const GAction&) {
GFilePicker picker; GFilePicker picker;
if (picker.exec() == GDialog::ExecOK) { if (picker.exec() == GDialog::ExecOK) {
path = picker.selected_file(); path = picker.selected_file().string();
open_sesame(*window, *text_editor, path); open_sesame(*window, *text_editor, path);
} }
}); });

View file

@ -125,7 +125,7 @@ GFilePicker::GFilePicker(const String& path, CObject* parent)
ok_button->set_text("OK"); ok_button->set_text("OK");
ok_button->on_click = [this, filename_textbox] (auto&) { ok_button->on_click = [this, filename_textbox] (auto&) {
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters())); FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters()));
m_selected_file = path.string(); m_selected_file = path;
done(ExecOK); done(ExecOK);
}; };
} }

View file

@ -1,3 +1,4 @@
#include <AK/FileSystemPath.h>
#include <LibGUI/GDialog.h> #include <LibGUI/GDialog.h>
#include <LibGUI/GTableView.h> #include <LibGUI/GTableView.h>
@ -9,12 +10,12 @@ public:
virtual ~GFilePicker() override; virtual ~GFilePicker() override;
// TODO: Should this return a FileSystemPath instead? // TODO: Should this return a FileSystemPath instead?
String selected_file() const { return m_selected_file; } FileSystemPath selected_file() const { return m_selected_file; }
virtual const char* class_name() const override { return "GFilePicker"; } virtual const char* class_name() const override { return "GFilePicker"; }
private: private:
GTableView* m_view { nullptr }; GTableView* m_view { nullptr };
Retained<GDirectoryModel> m_model; Retained<GDirectoryModel> m_model;
String m_selected_file; FileSystemPath m_selected_file;
}; };