+ return m_searchBar && m_searchBar->isVisible() && m_searchBar->isEnabled();
+}
+
+void DolphinViewContainer::setFocusToSearchBar()
+{
+ Q_ASSERT(isSearchBarVisible());
+ m_searchBar->selectAll();
+}
+
+void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection, SelectionMode::BottomBar::Contents bottomBarContents)
+{
+ const bool wasEnabled = m_view->selectionMode();
+ 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);
+ Q_EMIT selectionModeChanged(false);
+
+ if (!QApplication::focusWidget() || m_selectionModeTopBar->isAncestorOf(QApplication::focusWidget())
+ || m_selectionModeBottomBar->isAncestorOf(QApplication::focusWidget())) {
+ m_view->setFocus();
+ }
+ return;
+ }
+
+ if (!m_selectionModeTopBar) {
+ // Changing the location will disable selection mode.
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, [this]() {
+ setSelectionModeEnabled(false);
+ });
+
+ 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 SelectionMode::BottomBar(actionCollection, this);
+ connect(m_view, &DolphinView::selectionChanged, this, [this](const KFileItemList &selection) {
+ m_selectionModeBottomBar->slotSelectionChanged(selection, m_view->url());
+ });
+ connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, &DolphinViewContainer::showErrorMessage);
+ connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::selectionModeLeavingRequested, this, [this]() {
+ setSelectionModeEnabled(false);
+ });
+ m_topLayout->addWidget(m_selectionModeBottomBar, positionFor.selectionModeBottomBar, 0);
+ }
+ m_selectionModeBottomBar->resetContents(bottomBarContents);
+ if (bottomBarContents == SelectionMode::BottomBar::GeneralContents) {
+ m_selectionModeBottomBar->slotSelectionChanged(m_view->selectedItems(), m_view->url());
+ }
+
+ if (!wasEnabled) {
+ m_selectionModeTopBar->setVisible(true, WithAnimation);
+ m_selectionModeBottomBar->setVisible(true, WithAnimation);
+ Q_EMIT selectionModeChanged(true);
+ }
+}
+
+bool DolphinViewContainer::isSelectionModeEnabled() const
+{
+ const bool isEnabled = m_view->selectionMode();
+ 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;
+}
+
+void DolphinViewContainer::slotSplitTabDisabled()
+{
+ if (m_selectionModeBottomBar) {
+ m_selectionModeBottomBar->slotSplitTabDisabled();
+ }
+}
+
+void DolphinViewContainer::showMessage(const QString &message, KMessageWidget::MessageType messageType, std::initializer_list<QAction *> buttonActions)
+{
+ if (message.isEmpty()) {