@@ -164,7 +164,7 @@ class MouseCursorChanger : public QObject
164
164
const auto index = folderList->indexAt (pos);
165
165
if (model->classify (index) == FolderStatusModel::RootFolder &&
166
166
(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))) {
168
168
shape = Qt::PointingHandCursor;
169
169
}
170
170
folderList->setCursor (shape);
@@ -581,51 +581,43 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
581
581
{
582
582
Q_UNUSED (pos);
583
583
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" ));
586
588
connect (ac, &QAction::triggered, this , &AccountSettings::slotOpenCurrentLocalSubFolder);
587
589
588
590
const auto fileName = _model->data (index, FolderStatusDelegate::FolderPathRole).toString ();
589
591
if (!QFile::exists (fileName)) {
590
592
ac->setEnabled (false );
591
593
}
594
+
592
595
const auto info = _model->infoForIndex (index);
593
596
const auto acc = _accountState->account ();
594
597
595
598
if (acc->capabilities ().clientSideEncryptionAvailable ()) {
596
- // Verify if the folder is empty before attempting to encrypt.
597
-
598
599
const auto isEncrypted = info->isEncrypted ();
599
600
const auto isParentEncrypted = _model->isAnyAncestorEncrypted (index);
600
601
const auto isTopFolder = index.parent ().isValid () && !index.parent ().parent ().isValid ();
601
602
const auto isExternal = info->_isExternal ;
602
603
603
604
if (!isEncrypted && !isParentEncrypted && !isExternal && isTopFolder) {
604
- ac = menu. addAction (tr (" Encrypt" ));
605
+ ac = menu-> addAction (tr (" Encrypt" ));
605
606
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); });
609
607
}
610
608
}
611
609
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" ));
616
611
connect (ac, &QAction::triggered, this , &AccountSettings::slotOpenMakeFolderDialog);
617
612
ac->setEnabled (QFile::exists (fileName));
618
613
619
614
const auto folder = info->_folder ;
620
615
if (folder && folder->virtualFilesEnabled ()) {
621
- auto availabilityMenu = menu. addMenu (tr (" Availability" ));
616
+ auto availabilityMenu = menu-> addMenu (tr (" Availability" ));
622
617
623
- // Has '/' suffix convention for paths here but VFS and
624
- // sync engine expects no such suffix
625
618
Q_ASSERT (info->_path .endsWith (' /' ));
626
619
const auto remotePath = info->_path .chopped (1 );
627
620
628
- // It might be an E2EE mangled path, so let's try to demangle it
629
621
const auto journal = folder->journalDb ();
630
622
SyncJournalFileRecord rec;
631
623
if (!journal->getFileRecordByE2eMangledName (remotePath, &rec)) {
@@ -635,13 +627,33 @@ void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index
635
627
const auto path = rec.isValid () ? rec._path : remotePath;
636
628
637
629
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
+ });
639
633
640
634
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
+ });
642
638
}
643
639
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 ());
645
657
}
646
658
647
659
void AccountSettings::slotCustomContextMenuRequested (const QPoint &pos)
@@ -662,6 +674,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
662
674
}
663
675
664
676
treeView->setCurrentIndex (index);
677
+
665
678
const auto alias = _model->data (index, FolderStatusDelegate::FolderAliasRole).toString ();
666
679
const auto folderPaused = _model->data (index, FolderStatusDelegate::FolderSyncPaused).toBool ();
667
680
const auto folderConnected = _model->data (index, FolderStatusDelegate::FolderAccountConnected).toBool ();
@@ -672,16 +685,12 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
672
685
return ;
673
686
}
674
687
675
- const auto menu = new QMenu (treeView);
676
-
688
+ auto menu = new QMenu (treeView);
677
689
menu->setAttribute (Qt::WA_DeleteOnClose);
678
690
679
691
auto ac = menu->addAction (tr (" Open folder" ));
680
692
connect (ac, &QAction::triggered, this , &AccountSettings::slotOpenCurrentFolder);
681
693
682
- ac = menu->addAction (tr (" Edit Ignored Files" ));
683
- connect (ac, &QAction::triggered, this , &AccountSettings::slotEditCurrentIgnoredFiles);
684
-
685
694
ac = menu->addAction (tr (" Create new folder" ));
686
695
connect (ac, &QAction::triggered, this , &AccountSettings::slotOpenMakeFolderDialog);
687
696
ac->setEnabled (QFile::exists (folder->path ()));
@@ -711,63 +720,50 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
711
720
auto availabilityMenu = menu->addMenu (tr (" Availability" ));
712
721
713
722
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
+ });
715
726
ac->setDisabled (Theme::instance ()->enforceVirtualFilesSyncFolder ());
716
727
717
728
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
+ });
719
732
720
733
ac = menu->addAction (tr (" Disable virtual file support …" ));
721
734
connect (ac, &QAction::triggered, this , &AccountSettings::slotDisableVfsCurrentFolder);
722
735
ac->setDisabled (Theme::instance ()->enforceVirtualFilesSyncFolder ());
723
736
}
724
737
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;
734
745
}
735
- }
736
746
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)));
737
756
738
- menu->popup (treeView->mapToGlobal (pos));
757
+ menu->popup (treeView->viewport ()-> mapToGlobal (pos));
739
758
}
740
759
741
760
void AccountSettings::slotFolderListClicked (const QModelIndex &indx)
742
761
{
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
- }
766
762
if (_model->classify (indx) == FolderStatusModel::RootFolder) {
767
763
// tries to find if we clicked on the '...' button.
768
764
const auto treeView = _ui->_folderList ;
769
765
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)) {
771
767
slotCustomContextMenuRequested (pos);
772
768
return ;
773
769
}
0 commit comments