mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 21:05:44 +03:00
Selective Sync: Open sub folder context menu #5596
This commit is contained in:
parent
4697f0274f
commit
fbe812b9bc
4 changed files with 41 additions and 5 deletions
|
@ -98,7 +98,8 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
|||
SLOT(slotAccountAdded(AccountState*)));
|
||||
connect(ui->_folderList, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
this, SLOT(slotCustomContextMenuRequested(QPoint)));
|
||||
|
||||
connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
|
||||
this, SLOT(slotFolderListClicked(const QModelIndex&)));
|
||||
connect(ui->_folderList, SIGNAL(expanded(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
|
||||
connect(ui->_folderList, SIGNAL(collapsed(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
|
||||
connect(ui->selectiveSyncNotification, SIGNAL(linkActivated(QString)),
|
||||
|
@ -119,8 +120,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
|||
connect(syncNowWithRemoteDiscovery, SIGNAL(triggered()), SLOT(slotScheduleCurrentFolderForceRemoteDiscovery()));
|
||||
addAction(syncNowWithRemoteDiscovery);
|
||||
|
||||
connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
|
||||
this, SLOT(slotFolderListClicked(const QModelIndex&)));
|
||||
|
||||
|
||||
connect(ui->selectiveSyncApply, SIGNAL(clicked()), _model, SLOT(slotApplySelectiveSync()));
|
||||
connect(ui->selectiveSyncCancel, SIGNAL(clicked()), _model, SLOT(resetFolders()));
|
||||
|
@ -222,6 +222,24 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
|||
return;
|
||||
}
|
||||
|
||||
if (_model->classify(index) == FolderStatusModel::SubFolder) {
|
||||
QTreeView *tv = ui->_folderList;
|
||||
QMenu *menu = new QMenu(tv);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QAction *ac = menu->addAction(tr("Open folder"));
|
||||
connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotOpenCurrentLocalSubFolder()));
|
||||
|
||||
QString fileName = _model->data( index, FolderStatusDelegate::FolderPathRole ).toString();
|
||||
if (!QFile::exists(fileName)) {
|
||||
ac->setEnabled(false);
|
||||
}
|
||||
|
||||
menu->exec(QCursor::pos());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_model->classify(index) != FolderStatusModel::RootFolder) {
|
||||
return;
|
||||
}
|
||||
|
@ -264,6 +282,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
|||
void AccountSettings::slotFolderListClicked(const QModelIndex& indx)
|
||||
{
|
||||
if (indx.data(FolderStatusDelegate::AddButton).toBool()) {
|
||||
// "Add Folder Sync Connection"
|
||||
if (indx.flags() & Qt::ItemIsEnabled) {
|
||||
slotAddFolder();
|
||||
} else {
|
||||
|
@ -403,6 +422,16 @@ void AccountSettings::slotOpenCurrentFolder()
|
|||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotOpenCurrentLocalSubFolder()
|
||||
{
|
||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||
if( !selected.isValid() || _model->classify(selected) != FolderStatusModel::SubFolder)
|
||||
return;
|
||||
QString fileName = _model->data( selected, FolderStatusDelegate::FolderPathRole ).toString();
|
||||
QUrl url = QUrl::fromLocalFile(fileName);
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void AccountSettings::showConnectionLabel( const QString& message, QStringList errors )
|
||||
{
|
||||
const QString errStyle = QLatin1String("color:#ffffff; background-color:#bb4d4d;padding:5px;"
|
||||
|
|
|
@ -75,7 +75,8 @@ protected slots:
|
|||
void slotScheduleCurrentFolderForceRemoteDiscovery();
|
||||
void slotForceSyncCurrentFolder();
|
||||
void slotRemoveCurrentFolder();
|
||||
void slotOpenCurrentFolder();
|
||||
void slotOpenCurrentFolder(); // sync folder
|
||||
void slotOpenCurrentLocalSubFolder(); // selected subfolder in sync folder
|
||||
void slotFolderWizardAccepted();
|
||||
void slotFolderWizardRejected();
|
||||
void slotDeleteAccount();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
enum datarole { FolderAliasRole = Qt::UserRole + 100,
|
||||
HeaderRole,
|
||||
FolderPathRole,
|
||||
FolderPathRole, // for a SubFolder it's the complete path
|
||||
FolderSecondPathRole,
|
||||
FolderErrorMsg,
|
||||
FolderSyncPaused,
|
||||
|
|
|
@ -178,6 +178,12 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
|
|||
return QColor(Qt::red);
|
||||
}
|
||||
break;
|
||||
case FolderStatusDelegate::FolderPathRole: {
|
||||
auto f = x._folder;
|
||||
if (!f)
|
||||
return QVariant();
|
||||
return QVariant(f->path() + x._path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
|
Loading…
Reference in a new issue