| 
									
										
										
										
											2019-05-26 13:09:31 +01:00
										 |  |  | #include <AK/FileSystemPath.h>
 | 
					
						
							| 
									
										
										
										
											2019-07-13 19:58:04 -05:00
										 |  |  | #include <AK/Optional.h>
 | 
					
						
							| 
									
										
										
										
											2019-07-28 13:04:57 -05:00
										 |  |  | #include <LibCore/CUserInfo.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:10:00 +02:00
										 |  |  | #include <LibGUI/GDialog.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:24:37 +02:00
										 |  |  | #include <LibGUI/GTableView.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GDirectoryModel; | 
					
						
							| 
									
										
										
										
											2019-05-26 22:33:54 +02:00
										 |  |  | class GLabel; | 
					
						
							| 
									
										
										
										
											2019-07-29 15:50:06 -05:00
										 |  |  | class GTextBox; | 
					
						
							| 
									
										
										
										
											2019-03-09 21:38:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 22:10:00 +02:00
										 |  |  | class GFilePicker final : public GDialog { | 
					
						
							| 
									
										
										
										
											2019-07-25 19:49:28 +02:00
										 |  |  |     C_OBJECT(GFilePicker) | 
					
						
							| 
									
										
										
										
											2019-03-09 21:38:13 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-07-13 19:58:04 -05:00
										 |  |  |     enum class Mode { | 
					
						
							|  |  |  |         Open, | 
					
						
							|  |  |  |         Save | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static Optional<String> get_open_filepath(); | 
					
						
							| 
									
										
										
										
											2019-07-28 23:45:50 -05:00
										 |  |  |     static Optional<String> get_save_filepath(const String& title, const String& extension); | 
					
						
							| 
									
										
										
										
											2019-07-13 19:58:04 -05:00
										 |  |  |     static bool file_exists(const StringView& path); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-28 23:45:50 -05:00
										 |  |  |     GFilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), CObject* parent = nullptr); | 
					
						
							| 
									
										
										
										
											2019-03-09 21:38:13 +01:00
										 |  |  |     virtual ~GFilePicker() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-26 13:09:31 +01:00
										 |  |  |     FileSystemPath selected_file() const { return m_selected_file; } | 
					
						
							| 
									
										
										
										
											2019-05-09 04:56:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-16 12:57:04 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-05-26 22:33:54 +02:00
										 |  |  |     void set_preview(const FileSystemPath&); | 
					
						
							|  |  |  |     void clear_preview(); | 
					
						
							| 
									
										
										
										
											2019-07-29 15:50:06 -05:00
										 |  |  |     void on_file_return(); | 
					
						
							| 
									
										
										
										
											2019-05-26 22:33:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-13 19:58:04 -05:00
										 |  |  |     static String ok_button_name(Mode mode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch (mode) { | 
					
						
							|  |  |  |         case Mode::Open: | 
					
						
							|  |  |  |             return "Open"; | 
					
						
							|  |  |  |         case Mode::Save: | 
					
						
							|  |  |  |             return "Save"; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             return "OK"; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:24:37 +02:00
										 |  |  |     GTableView* m_view { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-06-21 18:37:47 +02:00
										 |  |  |     NonnullRefPtr<GDirectoryModel> m_model; | 
					
						
							| 
									
										
										
										
											2019-05-26 13:09:31 +01:00
										 |  |  |     FileSystemPath m_selected_file; | 
					
						
							| 
									
										
										
										
											2019-05-26 22:33:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-29 15:50:06 -05:00
										 |  |  |     GTextBox* m_filename_textbox { nullptr }; | 
					
						
							| 
									
										
										
										
											2019-09-21 14:19:05 +02:00
										 |  |  |     ObjectPtr<GLabel> m_preview_image_label; | 
					
						
							|  |  |  |     ObjectPtr<GLabel> m_preview_name_label; | 
					
						
							|  |  |  |     ObjectPtr<GLabel> m_preview_geometry_label; | 
					
						
							| 
									
										
										
										
											2019-07-13 19:58:04 -05:00
										 |  |  |     Mode m_mode { Mode::Open }; | 
					
						
							| 
									
										
										
										
											2019-07-25 19:49:28 +02:00
										 |  |  | }; |