summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/GFilePicker.cpp10
-rw-r--r--Libraries/LibGUI/GFilePicker.h4
2 files changed, 7 insertions, 7 deletions
diff --git a/Libraries/LibGUI/GFilePicker.cpp b/Libraries/LibGUI/GFilePicker.cpp
index 323b357106..1e9a44fea7 100644
--- a/Libraries/LibGUI/GFilePicker.cpp
+++ b/Libraries/LibGUI/GFilePicker.cpp
@@ -1,5 +1,6 @@
#include <AK/FileSystemPath.h>
#include <AK/Function.h>
+#include <LibDraw/PNGLoader.h>
#include <LibGUI/GAction.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GButton.h>
@@ -11,7 +12,6 @@
#include <LibGUI/GSortingProxyModel.h>
#include <LibGUI/GTextBox.h>
#include <LibGUI/GToolBar.h>
-#include <LibDraw/PNGLoader.h>
Optional<String> GFilePicker::get_open_filepath()
{
@@ -28,9 +28,9 @@ Optional<String> GFilePicker::get_open_filepath()
return {};
}
-Optional<String> GFilePicker::get_save_filepath()
+Optional<String> GFilePicker::get_save_filepath(const String& title, const String& extension)
{
- GFilePicker picker(Mode::Save);
+ GFilePicker picker(Mode::Save, String::format("%s.%s", title.characters(), extension.characters()));
if (picker.exec() == GDialog::ExecOK) {
String file_path = picker.selected_file().string();
@@ -43,7 +43,7 @@ Optional<String> GFilePicker::get_save_filepath()
return {};
}
-GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
+GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringView& path, CObject* parent)
: GDialog(parent)
, m_model(GDirectoryModel::create())
, m_mode(mode)
@@ -134,7 +134,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
filename_label->set_preferred_size(60, 0);
auto* filename_textbox = new GTextBox(filename_container);
if (m_mode == Mode::Save) {
- filename_textbox->set_text("Untitled.txt"); //TODO: replace .txt with a preferred extension
+ filename_textbox->set_text(file_name);
filename_textbox->set_focus(true);
filename_textbox->select_all();
}
diff --git a/Libraries/LibGUI/GFilePicker.h b/Libraries/LibGUI/GFilePicker.h
index 55d394c895..1316ccd290 100644
--- a/Libraries/LibGUI/GFilePicker.h
+++ b/Libraries/LibGUI/GFilePicker.h
@@ -16,10 +16,10 @@ public:
};
static Optional<String> get_open_filepath();
- static Optional<String> get_save_filepath();
+ static Optional<String> get_save_filepath(const String& title, const String& extension);
static bool file_exists(const StringView& path);
- GFilePicker(Mode type = Mode::Open, const StringView& path = String(get_current_user_home_path()), CObject* parent = nullptr);
+ GFilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), CObject* parent = nullptr);
virtual ~GFilePicker() override;
FileSystemPath selected_file() const { return m_selected_file; }