]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Improve Filelight installation UX
[dolphin.git] / src / views / dolphinview.cpp
index c06c49b63c1af065cba7d3047c767eb642a35d03..d42d9cfcd81d7fe9f909548f16766e38c26259ff 100644 (file)
@@ -119,6 +119,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     KItemListController *controller = new KItemListController(m_model, m_view, this);
     const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
     controller->setAutoActivationDelay(delay);
+    connect(controller, &KItemListController::doubleClickViewBackground, this, &DolphinView::doubleClickViewBackground);
 
     // The EnlargeSmallPreviews setting can only be changed after the model
     // has been set in the view by KItemListController.
@@ -146,11 +147,13 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     // This is made using a heavily-modified QLabel rather than a KTitleWidget
     // because KTitleWidget can't be told to turn off mouse-selectable text
     m_placeholderLabel = new QLabel(this);
+    // Don't consume mouse events
+    m_placeholderLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
+
     QFont placeholderLabelFont;
     // To match the size of a level 2 Heading/KTitleWidget
     placeholderLabelFont.setPointSize(qRound(placeholderLabelFont.pointSize() * 1.3));
     m_placeholderLabel->setFont(placeholderLabelFont);
-    m_placeholderLabel->setTextInteractionFlags(Qt::NoTextInteraction);
     m_placeholderLabel->setWordWrap(true);
     m_placeholderLabel->setAlignment(Qt::AlignCenter);
     // Match opacity of QML placeholder label component
@@ -163,10 +166,6 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     auto *centeringLayout = new QVBoxLayout(m_container);
     centeringLayout->addWidget(m_placeholderLabel);
     centeringLayout->setAlignment(m_placeholderLabel, Qt::AlignCenter);
-    m_placeholderLabel->setContextMenuPolicy(Qt::CustomContextMenu);
-    connect(m_placeholderLabel, &QWidget::customContextMenuRequested, this, [this](const QPoint &pos) {
-        slotViewContextMenuRequested(m_placeholderLabel->mapToGlobal(pos));
-    });
 
     controller->setSelectionBehavior(KItemListController::MultiSelection);
     connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
@@ -1716,6 +1715,7 @@ void DolphinView::updateSelectionState()
     if (!m_selectedUrls.isEmpty()) {
         KItemListSelectionManager *selectionManager = m_container->controller()->selectionManager();
 
+        const bool shouldScrollToCurrentItem = m_clearSelectionBeforeSelectingNewItems;
         // if there is a selection already, leave it that way
         // unless some drop/paste job are in the process of creating items
         if (!selectionManager->hasSelection() || m_selectJobCreatedItems) {
@@ -1740,6 +1740,10 @@ void DolphinView::updateSelectionState()
             if (!selectedItems.isEmpty()) {
                 selectionManager->beginAnchoredSelection(selectionManager->currentItem());
                 selectionManager->setSelectedItems(selectedItems);
+                selectionManager->endAnchoredSelection();
+                if (shouldScrollToCurrentItem) {
+                    m_view->scrollToItem(selectedItems.first());
+                }
             }
         }
     }
@@ -1938,7 +1942,10 @@ void DolphinView::slotSortRoleChangedByHeader(const QByteArray &current, const Q
     Q_UNUSED(previous)
     Q_ASSERT(m_model->sortRole() == current);
 
-    setSortRole(current);
+    ViewProperties props(viewPropertiesUrl());
+    props.setSortRole(current);
+
+    Q_EMIT sortRoleChanged(current);
 }
 
 void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray> &current, const QList<QByteArray> &previous)
@@ -2187,8 +2194,16 @@ void DolphinView::pasteToUrl(const QUrl &url)
     m_clearSelectionBeforeSelectingNewItems = true;
     m_markFirstNewlySelectedItemAsCurrent = true;
     m_selectJobCreatedItems = true;
-    // TODO KF6 use KIO::PasteJob::copyJobStarted to hook to earlier events copying/moving
     connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
+    connect(job, &KIO::PasteJob::copyJobStarted, this, [this](const KIO::CopyJob *copyJob) {
+        connect(copyJob, &KIO::CopyJob::copying, this, &DolphinView::slotItemCreatedFromJob);
+        connect(copyJob, &KIO::CopyJob::moving, this, &DolphinView::slotItemCreatedFromJob);
+        connect(copyJob, &KIO::CopyJob::linking, this, [this](KIO::Job *job, const QString &src, const QUrl &dest) {
+            Q_UNUSED(job)
+            Q_UNUSED(src)
+            slotItemCreated(dest);
+        });
+    });
     connect(job, &KIO::PasteJob::result, this, &DolphinView::slotJobResult);
 }