mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
TextEditorWidget: Added improved save feature.
Instead of saving to a temp file, the TextEditorWidget now saves to a path returned by the improved GFilePicker.
This commit is contained in:
parent
954a0b8efe
commit
82d9410226
4 changed files with 115 additions and 17 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibGUI/GDialog.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
|
||||
|
@ -7,7 +8,16 @@ class GLabel;
|
|||
|
||||
class GFilePicker final : public GDialog {
|
||||
public:
|
||||
GFilePicker(const StringView& path = "/", CObject* parent = nullptr);
|
||||
enum class Mode {
|
||||
Open,
|
||||
Save
|
||||
};
|
||||
|
||||
static Optional<String> get_open_filepath();
|
||||
static Optional<String> get_save_filepath();
|
||||
static bool file_exists(const StringView& path);
|
||||
|
||||
GFilePicker(Mode type = Mode::Open, const StringView& path = "/", CObject* parent = nullptr);
|
||||
virtual ~GFilePicker() override;
|
||||
|
||||
FileSystemPath selected_file() const { return m_selected_file; }
|
||||
|
@ -18,6 +28,18 @@ private:
|
|||
void set_preview(const FileSystemPath&);
|
||||
void clear_preview();
|
||||
|
||||
static String ok_button_name(Mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case Mode::Open:
|
||||
return "Open";
|
||||
case Mode::Save:
|
||||
return "Save";
|
||||
default:
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
GTableView* m_view { nullptr };
|
||||
NonnullRefPtr<GDirectoryModel> m_model;
|
||||
FileSystemPath m_selected_file;
|
||||
|
@ -25,4 +47,5 @@ private:
|
|||
GLabel* m_preview_image_label { nullptr };
|
||||
GLabel* m_preview_name_label { nullptr };
|
||||
GLabel* m_preview_geometry_label { nullptr };
|
||||
};
|
||||
Mode m_mode { Mode::Open };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue