mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-28 07:54:49 +03:00
AccountSettings: Easier access to selected folder alias
This commit is contained in:
parent
2841714817
commit
1f245b3791
2 changed files with 50 additions and 56 deletions
|
@ -163,6 +163,14 @@ void AccountSettings::createAccountToolbox()
|
||||||
slotAccountAdded(_accountState);
|
slotAccountAdded(_accountState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AccountSettings::selectedFolderAlias() const
|
||||||
|
{
|
||||||
|
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||||
|
if( !selected.isValid() )
|
||||||
|
return "";
|
||||||
|
return _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
||||||
|
}
|
||||||
|
|
||||||
void AccountSettings::slotOpenAccountWizard()
|
void AccountSettings::slotOpenAccountWizard()
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
|
@ -350,47 +358,43 @@ void AccountSettings::slotFolderWizardRejected()
|
||||||
|
|
||||||
void AccountSettings::slotRemoveCurrentFolder()
|
void AccountSettings::slotRemoveCurrentFolder()
|
||||||
{
|
{
|
||||||
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
auto folder = folderMan->folder(selectedFolderAlias());
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||||
if( selected.isValid() ) {
|
if( selected.isValid() && folder ) {
|
||||||
int row = selected.row();
|
int row = selected.row();
|
||||||
|
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
qDebug() << "Remove Folder alias " << folder->alias();
|
||||||
qDebug() << "Remove Folder alias " << alias;
|
QString shortGuiLocalPath = folder->shortGuiLocalPath();
|
||||||
if( !alias.isEmpty() ) {
|
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
|
||||||
QString shortGuiLocalPath = folderMan->folder(alias)->shortGuiLocalPath();
|
|
||||||
|
|
||||||
QMessageBox messageBox(QMessageBox::Question,
|
QMessageBox messageBox(QMessageBox::Question,
|
||||||
tr("Confirm Folder Sync Connection Removal"),
|
tr("Confirm Folder Sync Connection Removal"),
|
||||||
tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
|
tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
|
||||||
"<p><b>Note:</b> This will <b>not</b> delete any files.</p>").arg(shortGuiLocalPath),
|
"<p><b>Note:</b> This will <b>not</b> delete any files.</p>").arg(shortGuiLocalPath),
|
||||||
QMessageBox::NoButton,
|
QMessageBox::NoButton,
|
||||||
this);
|
this);
|
||||||
QPushButton* yesButton =
|
QPushButton* yesButton =
|
||||||
messageBox.addButton(tr("Remove Folder Sync Connection"), QMessageBox::YesRole);
|
messageBox.addButton(tr("Remove Folder Sync Connection"), QMessageBox::YesRole);
|
||||||
messageBox.addButton(tr("Cancel"), QMessageBox::NoRole);
|
messageBox.addButton(tr("Cancel"), QMessageBox::NoRole);
|
||||||
|
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
if (messageBox.clickedButton() != yesButton) {
|
if (messageBox.clickedButton() != yesButton) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
folderMan->removeFolder( folderMan->folder(alias) );
|
|
||||||
_model->removeRow(row);
|
|
||||||
|
|
||||||
// single folder fix to show add-button and hide remove-button
|
|
||||||
|
|
||||||
emit folderChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
folderMan->removeFolder( folder );
|
||||||
|
_model->removeRow(row);
|
||||||
|
|
||||||
|
// single folder fix to show add-button and hide remove-button
|
||||||
|
|
||||||
|
emit folderChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotOpenCurrentFolder()
|
void AccountSettings::slotOpenCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
auto alias = selectedFolderAlias();
|
||||||
|
if( !alias.isEmpty() ) {
|
||||||
if( selected.isValid() ) {
|
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
|
||||||
emit openFolderAlias(alias);
|
emit openFolderAlias(alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,16 +421,9 @@ void AccountSettings::showConnectionLabel( const QString& message, QStringList e
|
||||||
|
|
||||||
void AccountSettings::slotEnableCurrentFolder()
|
void AccountSettings::slotEnableCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
auto alias = selectedFolderAlias();
|
||||||
|
|
||||||
if( selected.isValid() ) {
|
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
|
||||||
|
|
||||||
if( alias.isEmpty() ) {
|
|
||||||
qDebug() << "Empty alias to enable.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if( !alias.isEmpty() ) {
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
|
||||||
qDebug() << "Application: enable folder with alias " << alias;
|
qDebug() << "Application: enable folder with alias " << alias;
|
||||||
|
@ -477,31 +474,25 @@ void AccountSettings::slotEnableCurrentFolder()
|
||||||
|
|
||||||
void AccountSettings::slotScheduleCurrentFolder()
|
void AccountSettings::slotScheduleCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
|
||||||
if( !selected.isValid() )
|
|
||||||
return;
|
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
if (auto folder = folderMan->folder(selectedFolderAlias())) {
|
||||||
folderMan->scheduleFolder(folderMan->folder(alias));
|
folderMan->scheduleFolder(folder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotForceSyncCurrentFolder()
|
void AccountSettings::slotForceSyncCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
|
||||||
if( !selected.isValid() )
|
|
||||||
return;
|
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
if (auto selectedFolder = folderMan->folder(selectedFolderAlias())) {
|
||||||
|
// Terminate and reschedule any running sync
|
||||||
|
if (Folder* current = folderMan->currentSyncFolder()) {
|
||||||
|
folderMan->terminateSyncProcess();
|
||||||
|
folderMan->scheduleFolder(current);
|
||||||
|
}
|
||||||
|
|
||||||
// Terminate and reschedule any running sync
|
// Insert the selected folder at the front of the queue
|
||||||
if (Folder* current = folderMan->currentSyncFolder()) {
|
folderMan->scheduleFolderNext(selectedFolder);
|
||||||
folderMan->terminateSyncProcess();
|
|
||||||
folderMan->scheduleFolder(current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the selected folder at the front of the queue
|
|
||||||
folderMan->scheduleFolderNext(folderMan->folder(alias));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotOpenOC()
|
void AccountSettings::slotOpenOC()
|
||||||
|
|
|
@ -93,6 +93,9 @@ private:
|
||||||
bool event(QEvent*) Q_DECL_OVERRIDE;
|
bool event(QEvent*) Q_DECL_OVERRIDE;
|
||||||
void createAccountToolbox();
|
void createAccountToolbox();
|
||||||
|
|
||||||
|
/// Returns the alias of the selected folder, empty string if none
|
||||||
|
QString selectedFolderAlias() const;
|
||||||
|
|
||||||
Ui::AccountSettings *ui;
|
Ui::AccountSettings *ui;
|
||||||
|
|
||||||
FolderStatusModel *_model;
|
FolderStatusModel *_model;
|
||||||
|
|
Loading…
Reference in a new issue