Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
file_manager.h
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __GUI_BACKEND_FILE_MANAGER_H__
5#define __GUI_BACKEND_FILE_MANAGER_H__
6
7#include <memory>
8#include <string>
9#include <utility>
10#include <vector>
11
12#include "gui/backend/io/file_descriptor.h"
13
14#include <QString>
15
21
26{
27 FILE_MANAGER_NONE,
28 FILE_MANAGER_HOME,
29 FILE_MANAGER_DESKTOP,
30 FILE_MANAGER_DRIVE,
31};
32
44struct FileBrowserLocation
45{
46 FileBrowserLocation (
47 QString label,
48 fs::path path,
49 FileManagerSpecialLocation special_location)
50 : label_ (std::move (label)), path_ (std::move (path)),
51 special_location_ (special_location)
52 {
53 }
54 FileBrowserLocation () = default;
55
56 const char * get_icon_name () const
57 {
58 switch (special_location_)
59 {
60 case FileManagerSpecialLocation::FILE_MANAGER_NONE:
61 return "folder";
62 case FileManagerSpecialLocation::FILE_MANAGER_HOME:
63 return "user-home";
64 case FileManagerSpecialLocation::FILE_MANAGER_DESKTOP:
65 return "desktop";
66 case FileManagerSpecialLocation::FILE_MANAGER_DRIVE:
67 return "drive-harddisk-symbolic";
68 }
69 return "folder";
70 }
71
72 void print () const;
73
74 // GMenuModel * generate_context_menu () const;
75
77 QString label_;
78
80 fs::path path_;
81
84};
85
90{
91 FB_SELECTION_TYPE_COLLECTIONS,
92 FB_SELECTION_TYPE_LOCATIONS,
93};
94
100class FileManager
101{
102public:
103 FileManager ();
104
108 void load_files ();
109
118 void
119 set_selection (FileBrowserLocation &sel, bool load_files, bool save_to_settings);
120
127 void add_location_and_save (const fs::path &abs_path);
128
137 void
138 remove_location_and_save (const fs::path &location, bool skip_if_standard);
139
140private:
144 void save_locations ();
145
151 void load_files_from_location (FileBrowserLocation &location);
152
153 // void add_volume (GVolume * vol);
154
155public:
160 std::vector<FileDescriptor> files;
161
165 std::vector<FileBrowserLocation> locations;
166
170 std::unique_ptr<FileBrowserLocation> selection;
171};
172
176
177#endif
std::unique_ptr< FileBrowserLocation > selection
The current selection in the top window.
void remove_location_and_save(const fs::path &location, bool skip_if_standard)
Removes the given location (bookmark) from the saved locations and saves the settings.
void set_selection(FileBrowserLocation &sel, bool load_files, bool save_to_settings)
Sets the current selection and optionally loads the files and saves the location to the settings.
std::vector< FileDescriptor > files
The file descriptors for the files under the current collection/location.
void load_files()
Loads the files under the current selection.
void add_location_and_save(const fs::path &abs_path)
Adds a new location (bookmark) to the saved locations and saves the settings.
std::vector< FileBrowserLocation > locations
The default and user-defined locations (bookmarks).
FileManagerSpecialLocation
Special location type.
FileBrowserSelectionType
Current selection in the top window.
Locations to be used in the file browser.
fs::path path_
Absolute path.
FileManagerSpecialLocation special_location_
Whether this is a standard (undeletable) location.
QString label_
Human readable label.