Skip to content

Commit b95f234

Browse files
committed
Add move functionality.
1 parent aa521b2 commit b95f234

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

‎src/remote_widget.cpp‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
2626
ui.refresh->setIcon(style->standardIcon(QStyle::SP_BrowserReload));
2727
ui.mkdir->setIcon(style->standardIcon(QStyle::SP_FileDialogNewFolder));
2828
ui.rename->setIcon(style->standardIcon(QStyle::SP_FileIcon));
29+
ui.move->setIcon(style->standardIcon(QStyle::SP_DirOpenIcon));
2930
ui.purge->setIcon(style->standardIcon(QStyle::SP_TrashIcon));
3031
ui.mount->setIcon(style->standardIcon(QStyle::SP_DirLinkIcon));
3132
ui.stream->setIcon(style->standardIcon(QStyle::SP_MediaPlay));
@@ -38,6 +39,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
3839
ui.buttonRefresh->setDefaultAction(ui.refresh);
3940
ui.buttonMkdir->setDefaultAction(ui.mkdir);
4041
ui.buttonRename->setDefaultAction(ui.rename);
42+
ui.buttonMove->setDefaultAction(ui.move);
4143
ui.buttonPurge->setDefaultAction(ui.purge);
4244
ui.buttonMount->setDefaultAction(ui.mount);
4345
ui.buttonStream->setDefaultAction(ui.stream);
@@ -82,6 +84,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
8284
if (model->isLoading(index))
8385
{
8486
ui.refresh->setDisabled(true);
87+
ui.move->setDisabled(true);
8588
ui.rename->setDisabled(true);
8689
ui.purge->setDisabled(true);
8790
ui.mount->setDisabled(true);
@@ -92,6 +95,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
9295
{
9396
ui.refresh->setDisabled(false);
9497
ui.rename->setDisabled(topLevel);
98+
ui.move->setDisabled(topLevel);
9599
ui.purge->setDisabled(topLevel);
96100
ui.mount->setDisabled(!isFolder);
97101
ui.stream->setDisabled(isFolder);
@@ -168,6 +172,35 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
168172
}
169173
});
170174

175+
QObject::connect(ui.move, &QAction::triggered, this, [=]()
176+
{
177+
QModelIndex index = ui.tree->selectionModel()->selectedRows().front();
178+
179+
QString path = model->path(index).path();
180+
QString pathMsg = isLocal ? QDir::toNativeSeparators(path) : path;
181+
182+
QString name = model->path(index.parent()).path() + "/";
183+
name = QInputDialog::getText(this, "Move", QString("New location for %1").arg(pathMsg), QLineEdit::Normal, name);
184+
if (!name.isEmpty())
185+
{
186+
QProcess process;
187+
UseRclonePassword(&process);
188+
process.setProgram(GetRclone());
189+
process.setArguments(QStringList()
190+
<< "move"
191+
<< GetRcloneConf()
192+
<< remote + ":" + path
193+
<< remote + ":" + name);
194+
process.setReadChannelMode(QProcess::MergedChannels);
195+
196+
ProgressDialog progress("Move", "Moving...", pathMsg, &process, this);
197+
if (progress.exec() == QDialog::Accepted)
198+
{
199+
model->refresh(index);
200+
}
201+
}
202+
});
203+
171204
QObject::connect(ui.purge, &QAction::triggered, this, [=]()
172205
{
173206
QModelIndex index = ui.tree->selectionModel()->selectedRows().front();
@@ -376,6 +409,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
376409
menu.addSeparator();
377410
menu.addAction(ui.mkdir);
378411
menu.addAction(ui.rename);
412+
menu.addAction(ui.move);
379413
menu.addAction(ui.purge);
380414
menu.addSeparator();
381415
menu.addAction(ui.mount);

‎src/remote_widget.ui‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
</property>
8282
</widget>
8383
</item>
84+
<item>
85+
<widget class="QToolButton" name="buttonMove">
86+
<property name="text">
87+
<string>M&amp;ove</string>
88+
</property>
89+
<property name="toolButtonStyle">
90+
<enum>Qt::ToolButtonTextBesideIcon</enum>
91+
</property>
92+
</widget>
93+
</item>
8494
<item>
8595
<widget class="QToolButton" name="buttonPurge">
8696
<property name="text">
@@ -275,6 +285,11 @@
275285
<string>E&amp;xport</string>
276286
</property>
277287
</action>
288+
<action name="move">
289+
<property name="text">
290+
<string>M&amp;ove</string>
291+
</property>
292+
</action>
278293
</widget>
279294
<tabstops>
280295
<tabstop>buttonRefresh</tabstop>

0 commit comments

Comments
 (0)