diff --git a/src/job_options.cpp b/src/job_options.cpp index a1915df8..ed234751 100644 --- a/src/job_options.cpp +++ b/src/job_options.cpp @@ -17,7 +17,7 @@ JobOptions::JobOptions() dontUpdateModified(false), maxDepth(0), deleteExcluded(false), isFolder(false) {} -const qint32 JobOptions::classVersion = 3; +const qint32 JobOptions::classVersion = 4; JobOptions::~JobOptions() {} @@ -145,8 +145,24 @@ QStringList JobOptions::getOptions() const { } } - if (DriveSharedWithMe) { - list << "--drive-shared-with-me"; + // get Google Drive mode option + if (remoteType == "drive") { + if (remoteMode == "shared") { + list << "--drive-shared-with-me"; + } else { + if (remoteMode == "trash") { + list << "--drive-trashed-only"; + } else { + if (remoteMode == "main") { + } else { + // older tasks dont't have googleDriveMode + // and value from DriveSharedWithMe has to be used + if (DriveSharedWithMe) { + list << "--drive-shared-with-me"; + } + } + } + } } list << "--stats" diff --git a/src/job_options.h b/src/job_options.h index 3ea470b7..453a52e0 100644 --- a/src/job_options.h +++ b/src/job_options.h @@ -59,6 +59,8 @@ class JobOptions { bool isFolder; QUuid uniqueId; bool DriveSharedWithMe; + QString remoteMode; + QString remoteType; void setJobType(bool isDownload) { jobType = (isDownload) ? Download : Upload; diff --git a/src/list_of_job_options.cpp b/src/list_of_job_options.cpp index 6ba638d3..d3cfd4d9 100644 --- a/src/list_of_job_options.cpp +++ b/src/list_of_job_options.cpp @@ -153,7 +153,7 @@ QDataStream &operator<<(QDataStream &stream, JobOptions &jo) { << jo.connectTimeout << jo.idleTimeout << jo.retries << jo.lowLevelRetries << jo.deleteExcluded << jo.excluded << jo.extra << jo.DriveSharedWithMe << jo.source << jo.dest << jo.isFolder - << jo.uniqueId; + << jo.uniqueId << jo.remoteMode << jo.remoteType; return stream; } @@ -184,9 +184,14 @@ QDataStream &operator>>(QDataStream &stream, JobOptions &jo) { // stream value if (actualVersion >= 2) { stream >> jo.isFolder; - if (actualVersion >= 3) { - stream >> jo.uniqueId; - } + } + + if (actualVersion >= 3) { + stream >> jo.uniqueId; + } + if (actualVersion >= 4) { + stream >> jo.remoteMode; + stream >> jo.remoteType; } return stream; diff --git a/src/main.cpp b/src/main.cpp index 20760eb5..c78e3432 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,6 +115,18 @@ int main(int argc, char *argv[]) { settings->setValue("Settings/sortTask", "false"); }; + // during first run the remoteMode key might not exist + if (!(settings->contains("Settings/remoteMode"))) { + // if remoteMode does not exist create new key + settings->setValue("Settings/remoteMode", "main"); + }; + + // during first run the remoteType key might not exist + if (!(settings->contains("Settings/remoteType"))) { + // if remoteType does not exist create new key + settings->setValue("Settings/remoteType", "main"); + }; + // set application font size int fontsize = 0; diff --git a/src/main_window.cpp b/src/main_window.cpp index 07c0eaf0..c03ace5b 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -1427,12 +1427,16 @@ void MainWindow::editSelectedTask() { JobOptions *jo = item->GetData(); bool isDownload = (jo->jobType == JobOptions::Download); + QString remoteType = (jo->remoteType); + QString remoteMode = (jo->remoteMode); + QString remote = isDownload ? jo->source : jo->dest; QString path = isDownload ? jo->dest : jo->source; // qDebug() << "remote:" + remote; // qDebug() << "path:" + path; - TransferDialog td(isDownload, false, remote, path, jo->isFolder, this, jo, - true); + + TransferDialog td(isDownload, false, remote, path, jo->isFolder, remoteType, + remoteMode, this, jo, true); td.exec(); } diff --git a/src/remote_widget.cpp b/src/remote_widget.cpp index 14d3d7ac..60ad4339 100644 --- a/src/remote_widget.cpp +++ b/src/remote_widget.cpp @@ -11,6 +11,7 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, const QString &remoteType, QWidget *parent) : QWidget(parent) { + ui.setupUi(this); bool isLocal = remoteType == "local"; @@ -18,6 +19,10 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QString root = isLocal ? "/" : QString(); + QString remoteMode = "main"; + + // QString remoteMode_ = "main"; + #ifndef Q_OS_WIN isLocal = false; #endif @@ -39,14 +44,14 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QString buttonStyle = settings->value("Settings/buttonStyle").toString(); QString buttonSize = settings->value("Settings/buttonSize").toString(); QString rcloneVersion = settings->value("Settings/rcloneVersion").toString(); - settings->setValue("Settings/driveShared", Qt::Unchecked); + settings->setValue("Settings/remoteMode", Qt::Unchecked); ui.tree->setAlternatingRowColors( settings->value("Settings/rowColors", false).toBool()); - ui.checkBoxShared->setChecked(false); - ui.checkBoxShared->setDisabled(!isGoogle); - // hide checkBoxShared for non Google remotes + + ui.cb_GoogleDriveMode->setDisabled(!isGoogle); + // hide cb_GoogleDriveMode for non Google remotes if (!isGoogle) { - ui.checkBoxShared->hide(); + ui.cb_GoogleDriveMode->hide(); } ui.refresh->setIcon(QIcon(":remotes/images/qbutton_icons/refresh.png")); @@ -212,11 +217,13 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, ui.stream->setDisabled(true); ui.upload->setDisabled(true); ui.download->setDisabled(true); - ui.checkBoxShared->setDisabled(true); + ui.cb_GoogleDriveMode->setDisabled(true); path = model->path(model->parent(index)); } else { ui.refresh->setDisabled(false); - bool driveShared = ui.checkBoxShared->checkState(); + + bool driveShared = (ui.cb_GoogleDriveMode->currentIndex() != 0); + ui.mkdir->setDisabled(driveShared); ui.rename->setDisabled(topLevel || driveShared); ui.move->setDisabled(topLevel || driveShared); @@ -246,7 +253,7 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, #endif ui.stream->setDisabled(isFolder); - ui.checkBoxShared->setDisabled(!isGoogle); + ui.cb_GoogleDriveMode->setDisabled(!isGoogle); path = model->path(index); } @@ -260,9 +267,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.refresh, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); model->refresh(index); @@ -270,10 +285,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.mkdir, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); - + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); if (!model->isFolder(index)) { @@ -307,9 +329,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.rename, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -340,9 +370,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.move, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -372,9 +410,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.purge, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -409,9 +455,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.mount, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -436,9 +490,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.stream, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); QString path = model->path(index).path(); @@ -464,30 +526,19 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, emit addStream(remote + ":" + path, stream); }); - QObject::connect(ui.checkBoxShared, &QCheckBox::toggled, ui.shared, - &QAction::toggled); - - QObject::connect(ui.shared, &QAction::toggled, this, [=](const bool checked) { - auto settings = GetSettings(); - settings->setValue("Settings/driveShared", checked); - ui.checkBoxShared->setChecked(checked); - - QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); - QModelIndex top = index; - while (!model->isTopLevel(top)) { - top = top.parent(); - } - ui.tree->selectionModel()->clear(); - ui.tree->selectionModel()->select(top, QItemSelectionModel::Select | - QItemSelectionModel::Rows); - model->refresh(top); - }); - QObject::connect(ui.link, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -512,9 +563,23 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.upload, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + + QString _remoteMode; + + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + _remoteMode = "main"; + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + _remoteMode = "shared"; + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + _remoteMode = "trash"; + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -523,7 +588,8 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, } QDir path = model->path(index); - TransferDialog t(false, false, remote, path, true, this); + TransferDialog t(false, false, remote, path, true, remoteType, _remoteMode, + this); if (t.exec() == QDialog::Accepted) { QString src = t.getSource(); QString dst = t.getDest(); @@ -542,14 +608,29 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.download, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + + QString _remoteMode; + + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + _remoteMode = "main"; + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + _remoteMode = "shared"; + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + _remoteMode = "trash"; + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); QDir path = model->path(index); - TransferDialog t(true, false, remote, path, model->isFolder(index), this); + TransferDialog t(true, false, remote, path, model->isFolder(index), + remoteType, _remoteMode, this); if (t.exec() == QDialog::Accepted) { QString src = t.getSource(); QString dst = t.getDest(); @@ -570,9 +651,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.getTree, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); QString path = model->path(index).path(); @@ -597,9 +686,18 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.getSize, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } + QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); QString path = model->path(index).path(); @@ -623,9 +721,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.export_, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -696,9 +802,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.actionCheck, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); @@ -740,9 +854,17 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, QObject::connect(ui.getInfo, &QAction::triggered, this, [=]() { auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } QProcess *process = new QProcess; UseRclonePassword(process); @@ -761,65 +883,79 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, progress->show(); }); - QObject::connect( - model, &ItemModel::drop, this, - [=](const QDir &path, const QModelIndex &parent) { - auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared - ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); - - qApp->setActiveWindow(this); - QDir destPath = model->path(parent); - QString dest = QFileInfo(path.path()).isDir() - ? destPath.filePath(path.dirName()) - : destPath.path(); - - TransferDialog t(false, true, remote, dest, true, this); - t.setSource(path.path()); - - if (t.exec() == QDialog::Accepted) { - QString src = t.getSource(); - QString dst = t.getDest(); - - QStringList args = t.getOptions(); - emit addTransfer(QString("%1 from %2").arg(t.getMode()).arg(src), src, + QObject::connect(model, &ItemModel::drop, this, + [=](const QDir &path, const QModelIndex &parent) { + auto settings = GetSettings(); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } + + qApp->setActiveWindow(this); + QDir destPath = model->path(parent); + QString dest = QFileInfo(path.path()).isDir() + ? destPath.filePath(path.dirName()) + : destPath.path(); + + TransferDialog t(false, true, remote, dest, true, + remoteType, remoteMode, this); + t.setSource(path.path()); + + if (t.exec() == QDialog::Accepted) { + QString src = t.getSource(); + QString dst = t.getDest(); + + QStringList args = t.getOptions(); + emit addTransfer( + QString("%1 from %2").arg(t.getMode()).arg(src), src, dst, args); - } - }); - - QObject::connect( - ui.tree, &QWidget::customContextMenuRequested, this, - [=](const QPoint &pos) { - auto settings = GetSettings(); - bool driveShared = ui.checkBoxShared->checkState(); - (driveShared - ? settings->setValue("Settings/driveShared", Qt::Checked) - : settings->setValue("Settings/driveShared", Qt::Unchecked)); - - QMenu menu; - menu.addAction(ui.refresh); - menu.addSeparator(); - menu.addAction(ui.mkdir); - menu.addAction(ui.rename); - menu.addAction(ui.move); - menu.addAction(ui.purge); - menu.addSeparator(); - menu.addAction(ui.mount); - menu.addAction(ui.stream); - menu.addAction(ui.upload); - menu.addAction(ui.download); - menu.addSeparator(); - menu.addAction(ui.getSize); - menu.addAction(ui.getTree); - menu.addAction(ui.link); - menu.addAction(ui.export_); - menu.addAction(ui.actionCheck); - menu.addSeparator(); - menu.addAction(ui.getInfo); - menu.exec(ui.tree->viewport()->mapToGlobal(pos)); - }); + } + }); + + QObject::connect(ui.tree, &QWidget::customContextMenuRequested, this, + [=](const QPoint &pos) { + auto settings = GetSettings(); + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } + + QMenu menu; + menu.addAction(ui.refresh); + menu.addSeparator(); + menu.addAction(ui.mkdir); + menu.addAction(ui.rename); + menu.addAction(ui.move); + menu.addAction(ui.purge); + menu.addSeparator(); + menu.addAction(ui.mount); + menu.addAction(ui.stream); + menu.addAction(ui.upload); + menu.addAction(ui.download); + menu.addSeparator(); + menu.addAction(ui.getSize); + menu.addAction(ui.getTree); + menu.addAction(ui.link); + menu.addAction(ui.export_); + menu.addAction(ui.actionCheck); + menu.addSeparator(); + menu.addAction(ui.getInfo); + menu.exec(ui.tree->viewport()->mapToGlobal(pos)); + }); if (isLocal) { QHash drives; @@ -874,6 +1010,55 @@ RemoteWidget::RemoteWidget(IconCache *iconCache, const QString &remote, auto tabs = qobject_cast(parent); tabs->removeTab(tabs->indexOf(this)); }); + + QObject::connect(ui.shared, &QAction::triggered, [=]() { + +/* + // connected when QComboBox cb_GoogleDriveMode emits signal currentIndexChanged(int) + // in remote_widget.ui configured via in Qt Creator + + + cb_GoogleDriveMode + currentIndexChanged(int) + shared + trigger() + + + 881 + 27 + + + -1 + -1 + + + + +*/ + auto settings = GetSettings(); + + switch (ui.cb_GoogleDriveMode->currentIndex()) { + case 0: + settings->setValue("Settings/remoteMode", "main"); + break; + case 1: + settings->setValue("Settings/remoteMode", "shared"); + break; + case 2: + settings->setValue("Settings/remoteMode", "trash"); + break; + } + + QModelIndex index = ui.tree->selectionModel()->selectedRows().front(); + QModelIndex top = index; + while (!model->isTopLevel(top)) { + top = top.parent(); + } + ui.tree->selectionModel()->clear(); + ui.tree->selectionModel()->select(top, QItemSelectionModel::Select | + QItemSelectionModel::Rows); + model->refresh(top); + }); } RemoteWidget::~RemoteWidget() {} diff --git a/src/remote_widget.ui b/src/remote_widget.ui index 27ea04d2..33def782 100755 --- a/src/remote_widget.ui +++ b/src/remote_widget.ui @@ -6,7 +6,7 @@ 0 0 - 994 + 1064 552 @@ -238,13 +238,31 @@ - - - Show Google Drive "Shared with Me" - - - Shared + + + + 0 + 0 + + + + 0 + + + Main + + + + + Shared with me + + + + + Trash + + @@ -517,5 +535,22 @@ rclone about tree - + + + cb_GoogleDriveMode + currentIndexChanged(int) + shared + trigger() + + + 881 + 27 + + + -1 + -1 + + + + diff --git a/src/transfer_dialog.cpp b/src/transfer_dialog.cpp index 0236c29e..ea933753 100644 --- a/src/transfer_dialog.cpp +++ b/src/transfer_dialog.cpp @@ -4,10 +4,13 @@ TransferDialog::TransferDialog(bool isDownload, bool isDrop, const QString &remote, const QDir &path, - bool isFolder, QWidget *parent, JobOptions *task, - bool editMode) + bool isFolder, const QString &remoteType, + const QString &remoteMode, QWidget *parent, + JobOptions *task, bool editMode) : QDialog(parent), mIsDownload(isDownload), mIsFolder(isFolder), - mIsEditMode(editMode), mJobOptions(task) { + mIsEditMode(editMode), mRemoteMode(remoteMode), mRemoteType(remoteType), + mJobOptions(task) { + ui.setupUi(this); resize(0, 0); @@ -210,13 +213,17 @@ TransferDialog::TransferDialog(bool isDownload, bool isDrop, ui.buttonDest->setVisible(isDownload); ui.buttonDefaultDest->setVisible(isDownload); - // Info only - should not be edited - // would be nice to display it only for Google Drive - todo - ui.checkisDriveSharedWithMe->setDisabled(true); + // remoteType != "" applies tasks saved before remoteType was introduced + if (!(remoteType == "")) { + if (!(remoteType == "drive")) { + + qDebug() << QString("Hiding: "); + ui.googleDriveMode->setVisible(false); + ui.googleDriveModeLabel->setVisible(false); + } + } - ui.checkisDriveSharedWithMe->setChecked( - settings->value("Settings/driveShared", false).toBool()); - // always clear for new jobs + ui.googleDriveMode->setText(remoteMode); ui.textDescription->clear(); if (mIsEditMode && mJobOptions != nullptr) { @@ -430,17 +437,8 @@ JobOptions *TransferDialog::getJobOptions() { mJobOptions->isFolder = mIsFolder; mJobOptions->description = ui.textDescription->text(); - // auto settings = GetSettings(); - // mJobOptions->DriveSharedWithMe = settings->value("Settings/driveShared", - // false).toBool(); - - if (mIsEditMode) - mJobOptions->DriveSharedWithMe = ui.checkisDriveSharedWithMe->isChecked(); - else { - auto settings = GetSettings(); - mJobOptions->DriveSharedWithMe = - settings->value("Settings/driveShared", false).toBool(); - }; + mJobOptions->remoteType = mRemoteType; + mJobOptions->remoteMode = mRemoteMode; return mJobOptions; } @@ -503,8 +501,17 @@ void TransferDialog::putJobOptions() { ui.textSource->setText(mJobOptions->source); ui.textDest->setText(mJobOptions->dest); ui.textDescription->setText(mJobOptions->description); - // DDBB - ui.checkisDriveSharedWithMe->setChecked(mJobOptions->DriveSharedWithMe); + + if (mJobOptions->remoteMode == "") { + // task saved before googleDriveMode was added + if (mJobOptions->DriveSharedWithMe) { + ui.googleDriveMode->setText("shared"); + } else { + ui.googleDriveMode->setText("main"); + } + } else { + ui.googleDriveMode->setText(mJobOptions->remoteMode); + } } void TransferDialog::done(int r) { diff --git a/src/transfer_dialog.h b/src/transfer_dialog.h index 57ebcee4..ef2e5749 100644 --- a/src/transfer_dialog.h +++ b/src/transfer_dialog.h @@ -9,7 +9,7 @@ class TransferDialog : public QDialog { public: TransferDialog(bool isDownload, bool isDrop, const QString &remote, - const QDir &path, bool isFolder, QWidget *parent = nullptr, + const QDir &path, bool isFolder, const QString &remoteType, const QString &remoteMode, QWidget *parent = nullptr, JobOptions *task = nullptr, bool editMode = false); ~TransferDialog(); @@ -29,6 +29,8 @@ class TransferDialog : public QDialog { bool mDryRun = false; bool mIsFolder; bool mIsEditMode; + QString mRemoteMode; + QString mRemoteType; JobOptions *mJobOptions; diff --git a/src/transfer_dialog.ui b/src/transfer_dialog.ui index ee3f3900..5145df27 100644 --- a/src/transfer_dialog.ui +++ b/src/transfer_dialog.ui @@ -7,7 +7,7 @@ 0 0 954 - 633 + 635 @@ -84,12 +84,6 @@ 0 - - - 0 - 24 - - @@ -126,12 +120,6 @@ 0 - - - 0 - 24 - - @@ -190,12 +178,6 @@ - - - 0 - 0 - - rclone move @@ -206,12 +188,6 @@ - - - 0 - 0 - - rclone copy @@ -225,12 +201,6 @@ - - - 0 - 0 - - rclone sync @@ -380,22 +350,6 @@ - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 10 - - - - @@ -417,12 +371,6 @@ 0 - - - 0 - 24 - - <html><head/><body><p>extra options applied to rclone during transfer</p><p>e.g. --filter &quot;- *.bak&quot;</p></body></html> @@ -446,32 +394,37 @@ 0 - - - 0 - 24 - - - - - true - - - --drive-shared-with-me - - - Drive shared with me - - - false - - + + + + + Google Drive mode: + + + + + + + Qt::NoContextMenu + + + * { background-color: rgba(0, 0, 0, 0); } + + + false + + + true + + + + @@ -531,12 +484,6 @@ - - - 0 - 0 - - Transfer parameters @@ -859,7 +806,7 @@ - + 0 0 @@ -958,7 +905,6 @@ checkSkipExisting checkCompare cbCompare - checkisDriveSharedWithMe checkSameFilesystem checkDontUpdateModified textBandwidth diff --git a/src/utils.cpp b/src/utils.cpp index d93b0e75..24602ab0 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -260,11 +260,16 @@ void SetRclonePassword(const QString &rclonePassword) { QStringList GetDriveSharedWithMe() { auto settings = GetSettings(); - bool driveShared = settings->value("Settings/driveShared", false).toBool(); + QString googleDriveMode = settings->value("Settings/remoteMode", "main").toString(); + QStringList driveSharedOption; - if (driveShared) { + + if (googleDriveMode == "shared") { driveSharedOption << "--drive-shared-with-me"; } + if (googleDriveMode == "trash") { + driveSharedOption << "--drive-trashed-only"; + } return driveSharedOption; }