X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c..40cc5f665d420071ba6e212c6191c2151f89a065:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index dd72a6d66..1930226d8 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -12,7 +12,7 @@ #include "filterbar/filterbar.h" #include "global.h" #include "search/dolphinsearchbox.h" -#include "selectionmode/selectionmodetopbar.h" +#include "selectionmode/topbar.h" #include "statusbar/dolphinstatusbar.h" #include "views/viewmodecontroller.h" #include "views/viewproperties.h" @@ -24,25 +24,25 @@ #endif #include #include -#include -#include +#include +#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) +#include +#else #include +#endif +#include #include #include #include #include -#include +#include #include #include #include -#include -#include #include #include -#include - -#include +#include // An overview of the widgets contained by this ViewContainer struct LayoutStructure { @@ -375,20 +375,20 @@ void DolphinViewContainer::disconnectUrlNavigator() m_urlNavigatorConnected = nullptr; } -void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection, SelectionModeBottomBar::Contents bottomBarContents) +void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection, SelectionMode::BottomBar::Contents bottomBarContents) { - std::cout << "DolphinViewContainer::setSelectionModeEnabled(" << enabled << ", " << bottomBarContents << ")\n"; const bool wasEnabled = m_view->selectionMode(); - m_view->setSelectionMode(enabled); + m_view->setSelectionModeEnabled(enabled); if (!enabled) { + if (!wasEnabled) { + return; // nothing to do here + } Q_CHECK_PTR(m_selectionModeTopBar); // there is no point in disabling selectionMode when it wasn't even enabled once. Q_CHECK_PTR(m_selectionModeBottomBar); m_selectionModeTopBar->setVisible(false, WithAnimation); m_selectionModeBottomBar->setVisible(false, WithAnimation); - if (wasEnabled) { - Q_EMIT selectionModeChanged(false); - } + Q_EMIT selectionModeChanged(false); return; } @@ -398,29 +398,28 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti setSelectionModeEnabled(false); }); - m_selectionModeTopBar = new SelectionModeTopBar(this); // will be created hidden - connect(m_selectionModeTopBar, &SelectionModeTopBar::leaveSelectionModeRequested, this, [this]() { + m_selectionModeTopBar = new SelectionMode::TopBar(this); // will be created hidden + connect(m_selectionModeTopBar, &SelectionMode::TopBar::selectionModeLeavingRequested, this, [this]() { setSelectionModeEnabled(false); }); m_topLayout->addWidget(m_selectionModeTopBar, positionFor.selectionModeTopBar, 0); } if (!m_selectionModeBottomBar) { - m_selectionModeBottomBar = new SelectionModeBottomBar(actionCollection, this); + m_selectionModeBottomBar = new SelectionMode::BottomBar(actionCollection, this); connect(m_view, &DolphinView::selectionChanged, this, [this](const KFileItemList &selection) { m_selectionModeBottomBar->slotSelectionChanged(selection, m_view->url()); }); - - connect(m_selectionModeBottomBar, &SelectionModeBottomBar::error, this, [this](const QString &errorMessage) { + connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, [this](const QString &errorMessage) { showErrorMessage(errorMessage); }); - connect(m_selectionModeBottomBar, &SelectionModeBottomBar::leaveSelectionModeRequested, this, [this]() { + connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::selectionModeLeavingRequested, this, [this]() { setSelectionModeEnabled(false); }); m_topLayout->addWidget(m_selectionModeBottomBar, positionFor.selectionModeBottomBar, 0); } m_selectionModeBottomBar->resetContents(bottomBarContents); - if (bottomBarContents == SelectionModeBottomBar::GeneralContents) { + if (bottomBarContents == SelectionMode::BottomBar::GeneralContents) { m_selectionModeBottomBar->slotSelectionChanged(m_view->selectedItems(), m_view->url()); } @@ -434,8 +433,15 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti bool DolphinViewContainer::isSelectionModeEnabled() const { const bool isEnabled = m_view->selectionMode(); - Q_ASSERT( !isEnabled // We cannot assert the invisibility of the bars because of the hide animation. - || ( isEnabled && m_selectionModeTopBar && m_selectionModeTopBar->isVisible() && m_selectionModeBottomBar && m_selectionModeBottomBar->isVisible())); + Q_ASSERT((!isEnabled + // We can't assert that the bars are invisible only because the selection mode is disabled because the hide animation might still be playing. + && (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() || + !m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents)) + || ( isEnabled + && m_selectionModeTopBar && m_selectionModeTopBar->isVisible() + // The bottom bar is either visible or was hidden because it has nothing to show in GeneralContents mode e.g. because no items are selected. + && m_selectionModeBottomBar + && (m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::GeneralContents))); return isEnabled; } @@ -757,7 +763,11 @@ void DolphinViewContainer::slotItemActivated(const KFileItem &item) } KIO::OpenUrlJob *job = new KIO::OpenUrlJob(item.targetUrl(), item.mimetype()); - job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoWarningHandlingEnabled, this)); +#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) + job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); +#else + job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); +#endif job->setShowOpenOrExecuteDialog(true); connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished); job->start();