Skip to content

Commit d0ecf08

Browse files
committed
Merge #380 [stable-3.16] nmc/2025/2003-Folderview_Settings_Dialog_New
2 parents 2fdd08d + d795205 commit d0ecf08

8 files changed

+242
-85
lines changed

src/gui/accountsettings.cpp

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class MouseCursorChanger : public QObject
164164
const auto index = folderList->indexAt(pos);
165165
if (model->classify(index) == FolderStatusModel::RootFolder &&
166166
(FolderStatusDelegate::errorsListRect(folderList->visualRect(index)).contains(pos) ||
167-
FolderStatusDelegate::optionsButtonRect(folderList->visualRect(index),folderList->layoutDirection()).contains(pos))) {
167+
FolderStatusDelegate::moreRectPos(folderList->visualRect(index)).contains(pos))) {
168168
shape = Qt::PointingHandCursor;
169169
}
170170
folderList->setCursor(shape);
@@ -581,51 +581,43 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
581581
{
582582
Q_UNUSED(pos);
583583

584-
QMenu menu;
585-
auto ac = menu.addAction(tr("Open folder"));
584+
auto menu = new QMenu(this);
585+
menu->setAttribute(Qt::WA_DeleteOnClose);
586+
587+
auto ac = menu->addAction(tr("Open folder"));
586588
connect(ac, &QAction::triggered, this, &AccountSettings::slotOpenCurrentLocalSubFolder);
587589

588590
const auto fileName = _model->data(index, FolderStatusDelegate::FolderPathRole).toString();
589591
if (!QFile::exists(fileName)) {
590592
ac->setEnabled(false);
591593
}
594+
592595
const auto info = _model->infoForIndex(index);
593596
const auto acc = _accountState->account();
594597

595598
if (acc->capabilities().clientSideEncryptionAvailable()) {
596-
// Verify if the folder is empty before attempting to encrypt.
597-
598599
const auto isEncrypted = info->isEncrypted();
599600
const auto isParentEncrypted = _model->isAnyAncestorEncrypted(index);
600601
const auto isTopFolder = index.parent().isValid() && !index.parent().parent().isValid();
601602
const auto isExternal = info->_isExternal;
602603

603604
if (!isEncrypted && !isParentEncrypted && !isExternal && isTopFolder) {
604-
ac = menu.addAction(tr("Encrypt"));
605+
ac = menu->addAction(tr("Encrypt"));
605606
connect(ac, &QAction::triggered, [this, info] { slotMarkSubfolderEncrypted(info); });
606-
} else {
607-
// Ignore decrypting for now since it only works with an empty folder
608-
// connect(ac, &QAction::triggered, [this, &info] { slotMarkSubfolderDecrypted(info); });
609607
}
610608
}
611609

612-
ac = menu.addAction(tr("Edit Ignored Files"));
613-
connect(ac, &QAction::triggered, this, &AccountSettings::slotEditCurrentLocalIgnoredFiles);
614-
615-
ac = menu.addAction(tr("Create new folder"));
610+
ac = menu->addAction(tr("Create new folder"));
616611
connect(ac, &QAction::triggered, this, &AccountSettings::slotOpenMakeFolderDialog);
617612
ac->setEnabled(QFile::exists(fileName));
618613

619614
const auto folder = info->_folder;
620615
if (folder && folder->virtualFilesEnabled()) {
621-
auto availabilityMenu = menu.addMenu(tr("Availability"));
616+
auto availabilityMenu = menu->addMenu(tr("Availability"));
622617

623-
// Has '/' suffix convention for paths here but VFS and
624-
// sync engine expects no such suffix
625618
Q_ASSERT(info->_path.endsWith('/'));
626619
const auto remotePath = info->_path.chopped(1);
627620

628-
// It might be an E2EE mangled path, so let's try to demangle it
629621
const auto journal = folder->journalDb();
630622
SyncJournalFileRecord rec;
631623
if (!journal->getFileRecordByE2eMangledName(remotePath, &rec)) {
@@ -635,13 +627,33 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
635627
const auto path = rec.isValid() ? rec._path : remotePath;
636628

637629
ac = availabilityMenu->addAction(Utility::vfsPinActionText());
638-
connect(ac, &QAction::triggered, this, [this, folder, path] { slotSetSubFolderAvailability(folder, path, PinState::AlwaysLocal); });
630+
connect(ac, &QAction::triggered, this, [this, folder, path] {
631+
slotSetSubFolderAvailability(folder, path, PinState::AlwaysLocal);
632+
});
639633

640634
ac = availabilityMenu->addAction(Utility::vfsFreeSpaceActionText());
641-
connect(ac, &QAction::triggered, this, [this, folder, path] { slotSetSubFolderAvailability(folder, path, PinState::OnlineOnly); });
635+
connect(ac, &QAction::triggered, this, [this, folder, path] {
636+
slotSetSubFolderAvailability(folder, path, PinState::OnlineOnly);
637+
});
642638
}
643639

644-
menu.exec(QCursor::pos());
640+
const auto highlightColor = palette().highlight().color();
641+
menu->setStyleSheet(QString(R"(
642+
QMenu {
643+
border: 1px solid black;
644+
border-radius: 4px;
645+
padding: 6px;
646+
}
647+
QMenu::item {
648+
padding: 8px;
649+
}
650+
QMenu::item:selected,
651+
QMenu::item:hover {
652+
background-color: %1;
653+
}
654+
)").arg(highlightColor.name(QColor::HexRgb)));
655+
656+
menu->popup(QCursor::pos());
645657
}
646658

647659
void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
@@ -662,6 +674,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
662674
}
663675

664676
treeView->setCurrentIndex(index);
677+
665678
const auto alias = _model->data(index, FolderStatusDelegate::FolderAliasRole).toString();
666679
const auto folderPaused = _model->data(index, FolderStatusDelegate::FolderSyncPaused).toBool();
667680
const auto folderConnected = _model->data(index, FolderStatusDelegate::FolderAccountConnected).toBool();
@@ -672,16 +685,12 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
672685
return;
673686
}
674687

675-
const auto menu = new QMenu(treeView);
676-
688+
auto menu = new QMenu(treeView);
677689
menu->setAttribute(Qt::WA_DeleteOnClose);
678690

679691
auto ac = menu->addAction(tr("Open folder"));
680692
connect(ac, &QAction::triggered, this, &AccountSettings::slotOpenCurrentFolder);
681693

682-
ac = menu->addAction(tr("Edit Ignored Files"));
683-
connect(ac, &QAction::triggered, this, &AccountSettings::slotEditCurrentIgnoredFiles);
684-
685694
ac = menu->addAction(tr("Create new folder"));
686695
connect(ac, &QAction::triggered, this, &AccountSettings::slotOpenMakeFolderDialog);
687696
ac->setEnabled(QFile::exists(folder->path()));
@@ -711,63 +720,50 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
711720
auto availabilityMenu = menu->addMenu(tr("Availability"));
712721

713722
ac = availabilityMenu->addAction(Utility::vfsPinActionText());
714-
connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::AlwaysLocal); });
723+
connect(ac, &QAction::triggered, this, [this]() {
724+
slotSetCurrentFolderAvailability(PinState::AlwaysLocal);
725+
});
715726
ac->setDisabled(Theme::instance()->enforceVirtualFilesSyncFolder());
716727

717728
ac = availabilityMenu->addAction(Utility::vfsFreeSpaceActionText());
718-
connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::OnlineOnly); });
729+
connect(ac, &QAction::triggered, this, [this]() {
730+
slotSetCurrentFolderAvailability(PinState::OnlineOnly);
731+
});
719732

720733
ac = menu->addAction(tr("Disable virtual file support …"));
721734
connect(ac, &QAction::triggered, this, &AccountSettings::slotDisableVfsCurrentFolder);
722735
ac->setDisabled(Theme::instance()->enforceVirtualFilesSyncFolder());
723736
}
724737

725-
if (const auto mode = bestAvailableVfsMode();
726-
!Theme::instance()->disableVirtualFilesSyncFolder() &&
727-
Theme::instance()->showVirtualFilesOption() && !folder->virtualFilesEnabled() && Vfs::checkAvailability(folder->path(), mode)) {
728-
if (mode == Vfs::WindowsCfApi || ConfigFile().showExperimentalOptions()) {
729-
ac = menu->addAction(tr("Enable virtual file support %1 …").arg(mode == Vfs::WindowsCfApi ? QString() : tr("(experimental)")));
730-
// TODO: remove when UX decision is made
731-
ac->setEnabled(!Utility::isPathWindowsDrivePartitionRoot(folder->path()));
732-
//
733-
connect(ac, &QAction::triggered, this, &AccountSettings::slotEnableVfsCurrentFolder);
738+
const auto highlightColor = palette().highlight().color();
739+
740+
menu->setStyleSheet(QString(R"(
741+
QMenu {
742+
border: 1px solid black;
743+
border-radius: 4px;
744+
padding: 6px;
734745
}
735-
}
736746
747+
QMenu::item {
748+
padding: 8px;
749+
}
750+
751+
QMenu::item:selected,
752+
QMenu::item:hover {
753+
background-color: %1;
754+
}
755+
)").arg(highlightColor.name(QColor::HexRgb)));
737756

738-
menu->popup(treeView->mapToGlobal(pos));
757+
menu->popup(treeView->viewport()->mapToGlobal(pos));
739758
}
740759

741760
void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
742761
{
743-
if (indx.data(FolderStatusDelegate::AddButton).toBool()) {
744-
// "Add Folder Sync Connection"
745-
const auto treeView = _ui->_folderList;
746-
const auto pos = treeView->mapFromGlobal(QCursor::pos());
747-
QStyleOptionViewItem opt;
748-
opt.initFrom(treeView);
749-
const auto btnRect = treeView->visualRect(indx);
750-
const auto btnSize = treeView->itemDelegateForIndex(indx)->sizeHint(opt, indx);
751-
const auto actual = QStyle::visualRect(opt.direction, btnRect, QRect(btnRect.topLeft(), btnSize));
752-
if (!actual.contains(pos)) {
753-
return;
754-
}
755-
756-
if (indx.flags() & Qt::ItemIsEnabled) {
757-
slotAddFolder();
758-
} else {
759-
QToolTip::showText(
760-
QCursor::pos(),
761-
_model->data(indx, Qt::ToolTipRole).toString(),
762-
this);
763-
}
764-
return;
765-
}
766762
if (_model->classify(indx) == FolderStatusModel::RootFolder) {
767763
// tries to find if we clicked on the '...' button.
768764
const auto treeView = _ui->_folderList;
769765
const auto pos = treeView->mapFromGlobal(QCursor::pos());
770-
if (FolderStatusDelegate::optionsButtonRect(treeView->visualRect(indx), layoutDirection()).contains(pos)) {
766+
if (FolderStatusDelegate::moreRectPos(treeView->visualRect(indx)).contains(pos)) {
771767
slotCustomContextMenuRequested(pos);
772768
return;
773769
}

src/gui/accountsetupcommandlinemanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ void AccountSetupCommandLineManager::setupAccountFromCommandLine()
114114
_serverUrl.clear();
115115
_remoteDirPath.clear();
116116
_localDirPath.clear();
117-
_isVfsEnabled = true;
117+
_isVfsEnabled = false;
118118
}
119119
}

0 commit comments

Comments
 (0)