AccountSettings: limit the clickable region of the 'add folder' button
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 16 Oct 2019 08:29:37 +0000 (10:29 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:03 +0000 (10:59 +0100)
Issue #7326

src/gui/accountsettings.cpp

index 4a4f4d5c0a08f0a16423d5685d2507a2e3be352f..2e412e99197b734552d53c6f2e6fb467e021b81f 100644 (file)
@@ -483,6 +483,16 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
 {
     if (indx.data(FolderStatusDelegate::AddButton).toBool()) {
         // "Add Folder Sync Connection"
+        QTreeView *tv = _ui->_folderList;
+        auto pos = tv->mapFromGlobal(QCursor::pos());
+        QStyleOptionViewItem opt;
+        opt.initFrom(tv);
+        auto btnRect = tv->visualRect(indx);
+        auto btnSize = tv->itemDelegate(indx)->sizeHint(opt, indx);
+        auto actual = QStyle::visualRect(opt.direction, btnRect, QRect(btnRect.topLeft(), btnSize));
+        if (!actual.contains(pos))
+            return;
+
         if (indx.flags() & Qt::ItemIsEnabled) {
             slotAddFolder();
         } else {