mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 22:35:07 +00:00
TextEditor: Include extension during SaveAs
When we save-as in the text editor we now auto-populate GFilePicker /w the current name & extension.
This commit is contained in:
parent
80cb833594
commit
a175e76948
6 changed files with 34 additions and 20 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue