Skip to content

Commit 4ff1403

Browse files
committed
Added copy paste.
1 parent b027269 commit 4ff1403

5 files changed

Lines changed: 41 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ This project contains a cross platform (Linux & Windows for now) SSH and SFTP cl
120120
- [ ] Show link target in properties window.
121121
- [X] Improve arrow navigation with shift and control.
122122
- [X] Scroll into view of recently selected item when using keyboard controls.
123-
- [ ] Mouse side keys
124-
- [ ] Ctrl + C / Ctrl + V for copy paste.
123+
- [X] Ctrl + C / Ctrl + V for copy paste.
125124

126125
## Open Files & Monitoring
127126
- [ ] Open files with associated application.
128-
- [ ] Monitor changes on open files. Add monitoring tab for that and add auto upload option.
127+
- [ ] Monitor changes on open files. Add monitoring tab for that and add auto upload option.
128+
129+
# Known Problems
130+
131+
- Cannot use mouse side keys for history navigation (yet) because of a bug in webkit show them as "button 0".

frontend/include/frontend/session_components/operation_queue/displayed_transfer_operation.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class DisplayedTransferOperation : public OperationCard<DisplayedTransferOperati
5454
class_ = "opq-transfer-text",
5555
alt = fmt::format("{} -> {}", remotePath_.generic_string(), localPath_.generic_string())
5656
}(
57-
fmt::format("{} -> {}", remotePath_.generic_string(), localPath_.generic_string())
57+
type_ == SharedData::OperationType::Download
58+
? fmt::format("{} -> {}", remotePath_.generic_string(), localPath_.generic_string())
59+
: fmt::format("{} -> {}", localPath_.generic_string(), remotePath_.generic_string())
5860
),
5961
div{
6062
class_ = "opq-bytes-per-second"

nui-file-explorer/include/nui-file-explorer/side/side_implementation.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ using namespace std::string_literals;
1919

2020
namespace NuiFileExplorer
2121
{
22+
class Side;
23+
2224
enum class SortCriterion
2325
{
2426
Name,
@@ -34,6 +36,7 @@ namespace NuiFileExplorer
3436
constexpr static std::string_view tableGridTemplateColumnsHiddenValue = "25px";
3537

3638
SideSettings settings;
39+
Side* otherSide{nullptr};
3740
std::unique_ptr<ISideModel> model;
3841

3942
Nui::Observed<std::vector<ItemWithInternals>> items{};
@@ -54,6 +57,8 @@ namespace NuiFileExplorer
5457
std::map<long long, std::weak_ptr<Nui::Dom::BasicElement>> searchResultElements;
5558
std::weak_ptr<Nui::Dom::BasicElement> pathBoxElement{};
5659

60+
std::vector<Item> copiedFiles{};
61+
5762
DropdownMenu newItemMenu{
5863
{
5964
"File",

nui-file-explorer/source/nui-file-explorer/side.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace NuiFileExplorer
5555
{
5656
iconFlavor_ = std::make_unique<IconFlavor>(*this, otherSide);
5757
tableFlavor_ = std::make_unique<TableFlavor>(*this, otherSide);
58+
impl_->otherSide = &otherSide;
5859
}
5960
Side::~Side() = default;
6061
Side::Side(Side&&) = default;
@@ -102,6 +103,30 @@ namespace NuiFileExplorer
102103
impl_->model->goBack();
103104
return;
104105
}
106+
if (event.key() == "c" && event.ctrlKey())
107+
{
108+
const auto selectedItems = this->selectedItems();
109+
if (!selectedItems.empty())
110+
impl_->copiedFiles = selectedItems;
111+
return;
112+
}
113+
if (event.key() == "v" && event.ctrlKey())
114+
{
115+
if (impl_->otherSide)
116+
{
117+
const auto& copiedFiles = impl_->otherSide->impl_->copiedFiles;
118+
if (!copiedFiles.empty())
119+
{
120+
// If only a single item is selected and its a directory, set that as the target subdir for the
121+
// transfer. Otherwise, transfer to the current directory.
122+
std::optional<std::filesystem::path> targetSubdir = std::nullopt;
123+
auto selectedItems = this->selectedItems();
124+
if (selectedItems.size() == 1 && selectedItems.front().isDirectory())
125+
targetSubdir = selectedItems.front().path.filename();
126+
impl_->otherSide->model().onTransfer(copiedFiles, targetSubdir);
127+
}
128+
}
129+
}
105130

106131
if (!impl_->selectionManager.onKeyboardEvent(event))
107132
actionWasTaken.disarm();
@@ -180,7 +205,7 @@ namespace NuiFileExplorer
180205
{
181206
const auto& items = impl_->model->items();
182207

183-
auto selectedPaths = impl_->selectionManager.selectedPaths();
208+
const auto selectedPaths = impl_->selectionManager.selectedPaths();
184209
impl_->selectionManager.loseTrackToAllSelections();
185210

186211
std::set<std::filesystem::path> pathSet;

static/assets/language.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ en_US:
6363
renameFailed: "Rename Failed"
6464
externalDropWebkitWarningTitle: "External Drop Is Faulty"
6565
externalDropWebkitWarningText: "Due to technical limitations of the WebKitGTK engine, dropping external items onto the remote side only works for single items."
66+
uploadSingleConfirmText: "Are you sure you want to upload this item '{}' to {}?"
6667
uploadConfirmTitle: "Upload Items?"
6768
deleteFilesFailedTitle: "Delete Files Failed"
6869
createFileFailedTitle: "Create File Failed"

0 commit comments

Comments
 (0)