]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Add new settings for permissions column format
[dolphin.git] / src / views / dolphinview.cpp
index 35d69e610e69ad4c247660f6b918149c07ae88ae..18d2137e36600498f003281a839806d2e27b8142 100644 (file)
@@ -87,6 +87,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     , m_view(nullptr)
     , m_container(nullptr)
     , m_toolTipManager(nullptr)
+    , m_selectNextItem(false)
     , m_selectionChangedTimer(nullptr)
     , m_currentItemUrl()
     , m_scrollToCurrentItem(false)
@@ -749,6 +750,7 @@ void DolphinView::trashSelectedItems()
     using Iface = KIO::AskUserActionInterface;
     auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this);
     connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
+    m_selectNextItem = true;
     trashJob->start();
 #else
     KIO::JobUiDelegate uiDelegate;
@@ -770,6 +772,7 @@ void DolphinView::deleteSelectedItems()
     using Iface = KIO::AskUserActionInterface;
     auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this);
     connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished);
+    m_selectNextItem = true;
     trashJob->start();
 #else
     KIO::JobUiDelegate uiDelegate;
@@ -928,6 +931,11 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
             }
         }
         break;
+    case QEvent::KeyRelease:
+        if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Control) {
+            m_controlWheelAccumulatedDelta = 0;
+        }
+        break;
     case QEvent::FocusIn:
         if (watched == m_container) {
             setActive(true);
@@ -966,10 +974,16 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
 void DolphinView::wheelEvent(QWheelEvent *event)
 {
     if (event->modifiers().testFlag(Qt::ControlModifier)) {
-        const QPoint numDegrees = event->angleDelta() / 8;
-        const QPoint numSteps = numDegrees / 15;
+        m_controlWheelAccumulatedDelta += event->angleDelta().y();
+
+        if (m_controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep) {
+            slotDecreaseZoom();
+            m_controlWheelAccumulatedDelta += QWheelEvent::DefaultDeltasPerStep;
+        } else if (m_controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep) {
+            slotIncreaseZoom();
+            m_controlWheelAccumulatedDelta -= QWheelEvent::DefaultDeltasPerStep;
+        }
 
-        setZoomLevel(zoomLevel() + numSteps.y());
         event->accept();
     } else {
         event->ignore();
@@ -1153,6 +1167,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF &pos)
         action->setCheckable(true);
         action->setChecked(visibleRolesSet.contains(info.role));
         action->setData(info.role);
+        action->setToolTip(info.tooltip);
 
         const bool enable = (!info.requiresBaloo && !info.requiresIndexer) || (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled);
         action->setEnabled(enable);
@@ -1389,6 +1404,7 @@ void DolphinView::slotJobResult(KJob *job)
 
 void DolphinView::slotSelectionChanged(const KItemSet &current, const KItemSet &previous)
 {
+    m_selectNextItem = false;
     const int currentCount = current.count();
     const int previousCount = previous.count();
     const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) || (currentCount > 0 && previousCount == 0);
@@ -1741,6 +1757,7 @@ void DolphinView::slotTwoClicksRenamingTimerTimeout()
 void DolphinView::slotTrashFileFinished(KJob *job)
 {
     if (job->error() == 0) {
+        selectNextItem(); // Fixes BUG: 419914 via selecting next item
         Q_EMIT operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
     } else if (job->error() != KIO::ERR_USER_CANCELED) {
         Q_EMIT errorMessage(job->errorString());
@@ -1750,12 +1767,37 @@ void DolphinView::slotTrashFileFinished(KJob *job)
 void DolphinView::slotDeleteFileFinished(KJob *job)
 {
     if (job->error() == 0) {
+        selectNextItem(); // Fixes BUG: 419914 via selecting next item
         Q_EMIT operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
     } else if (job->error() != KIO::ERR_USER_CANCELED) {
         Q_EMIT errorMessage(job->errorString());
     }
 }
 
+void DolphinView::selectNextItem()
+{
+    if (m_active && m_selectNextItem) {
+        KItemListSelectionManager *selectionManager = m_container->controller()->selectionManager();
+        if (selectedItems().isEmpty()) {
+            Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
+            return;
+        }
+        const auto lastSelectedIndex = m_model->index(selectedItems().last());
+        if (lastSelectedIndex < 0) {
+            Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
+            return;
+        }
+        auto nextItem = lastSelectedIndex + 1;
+        if (nextItem >= itemsCount()) {
+            nextItem = lastSelectedIndex - selectedItemsCount();
+        }
+        if (nextItem >= 0) {
+            selectionManager->setSelected(nextItem, 1);
+        }
+        m_selectNextItem = false;
+    }
+}
+
 void DolphinView::slotRenamingResult(KJob *job)
 {
     if (job->error()) {
@@ -1880,7 +1922,7 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray &role, con
             newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
 
 #ifndef Q_OS_WIN
-            //Confirm hiding file/directory by renaming inline
+            // Confirm hiding file/directory by renaming inline
             if (!hiddenFilesShown() && newName.startsWith(QLatin1Char('.')) && !oldItem.name().startsWith(QLatin1Char('.'))) {
                 KGuiItem yesGuiItem(i18nc("@action:button", "Rename and Hide"), QStringLiteral("view-hidden"));