Added duplicate action
This commit is contained in:
parent
68a4998993
commit
73325e9fe7
3 changed files with 34 additions and 0 deletions
1
assets/data/icons/RemixIcon/file-copy-line.svg
Normal file
1
assets/data/icons/RemixIcon/file-copy-line.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 464 B |
|
|
@ -234,6 +234,33 @@ void FileSelectScreen::move_selected_files(const std::filesystem::path& fromPath
|
|||
}
|
||||
}
|
||||
|
||||
void FileSelectScreen::duplicate_selected_files(const std::filesystem::path& inPath) {
|
||||
std::vector<std::string> toFolderListNames;
|
||||
|
||||
int globCount;
|
||||
char** filesInPath = SDL_GlobDirectory(inPath.c_str(), "*", 0, &globCount);
|
||||
if(filesInPath) {
|
||||
for(int i = 0; i < globCount; i++) {
|
||||
std::filesystem::path p(filesInPath[i]);
|
||||
toFolderListNames.emplace_back(p.filename().stem());
|
||||
}
|
||||
}
|
||||
else
|
||||
SDL_CreateDirectory(inPath.string().c_str());
|
||||
|
||||
for(const FileInfo& f : fileList) {
|
||||
if(f.selected) {
|
||||
std::string newFileName = ensure_string_unique(toFolderListNames, f.fileName);
|
||||
std::filesystem::path filePath = inPath / (f.fileName + World::DOT_FILE_EXTENSION);
|
||||
std::filesystem::path thumbnailPath = inPath / (f.fileName + ".jpg");
|
||||
std::filesystem::path newFilePath = inPath / (newFileName + "." + World::FILE_EXTENSION);
|
||||
std::filesystem::path newThumbnailPath = inPath / (newFileName + ".jpg");
|
||||
SDL_CopyFile(filePath.string().c_str(), newFilePath.string().c_str());
|
||||
SDL_CopyFile(thumbnailPath.string().c_str(), newThumbnailPath.string().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileSelectScreen::delete_selected_files_in_trash() {
|
||||
for(const FileInfo& f : fileList) {
|
||||
if(f.selected) {
|
||||
|
|
@ -263,6 +290,11 @@ void FileSelectScreen::edit_action_bar() {
|
|||
update_file_list(fileList, savePath, false);
|
||||
editMode = false;
|
||||
});
|
||||
edit_action_bar_button("duplicate", "data/icons/RemixIcon/file-copy-line.svg", "Duplicate", [&] {
|
||||
duplicate_selected_files(savePath);
|
||||
update_file_list(fileList, savePath, false);
|
||||
editMode = false;
|
||||
});
|
||||
}
|
||||
else if(selectedMenu == SelectedMenu::TRASH) {
|
||||
edit_action_bar_button("restore", "data/icons/RemixIcon/refresh-line.svg", "Restore", [&] {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class FileSelectScreen : public Screen {
|
|||
MOVE_OUT_OF_TRASH
|
||||
};
|
||||
void move_selected_files(const std::filesystem::path& fromPath, const std::filesystem::path& toPath, TrashMoveType trashMoveType);
|
||||
void duplicate_selected_files(const std::filesystem::path& inPath);
|
||||
void delete_selected_files_in_trash();
|
||||
|
||||
enum class FileViewType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue