Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:epopov:branches:openSUSE:Factory
dolphin
2002-filterbar.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2002-filterbar.patch of Package dolphin
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index bb27e0a5e4650047dd61240f2fee5beca25904b2..ec93cb538f2ec438888dfd633662bffb0bf98294 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -60,7 +60,7 @@ DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMe // make sure that other apps using this part find Dolphin's view-file-columns icons KIconLoader::global()->addAppDir(QStringLiteral("dolphin")); - m_view = new DolphinView(QUrl(), parentWidget); + m_view = new DolphinView(QUrl(), {}, parentWidget); m_view->setTabsForFilesEnabled(true); setWidget(m_view); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index cf7778c824ff160304f217be765a4f3838c6f986..186e2f8a5a5c5b26288b6fa747b573f74efd4e9b 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -119,7 +119,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent) connect(m_filterBar, &FilterBar::focusViewRequest, this, &DolphinViewContainer::requestFocus); // Initialize the main view - m_view = new DolphinView(url, this); + m_view = new DolphinView(url, {this}, this); connect(m_view, &DolphinView::urlChanged, m_filterBar, &FilterBar::clearIfUnlocked); connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide); // m_urlNavigator stays in sync with m_view's location changes and @@ -853,6 +853,17 @@ void DolphinViewContainer::enableUrlNavigatorSelectionRequests() connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested); } +bool DolphinViewContainer::handleKeyPress(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape && isFilterBarVisible()) { + closeFilterBar(); + + return true; + } + + return false; +} + void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl) { Q_UNUSED(oldUrl) diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 60c9b90d161848eeffd3d5810ca8fe815cc515d2..fe92b5cd758d49746967304bc981e01e5fbb00fb 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -44,7 +44,7 @@ class TopBar; * @see KUrlNavigator * @see DolphinStatusBar */ -class DolphinViewContainer : public QWidget +class DolphinViewContainer : public QWidget, public KeyPressHandler { Q_OBJECT @@ -199,6 +199,13 @@ public: void enableUrlNavigatorSelectionRequests(); void clearFilterBar(); + /** + * Handles keypress events. + * + * @see KeyPressHandler + */ + bool handleKeyPress(QKeyEvent *event) override; + public Q_SLOTS: /** * Sets the current active URL, where all actions are applied. The diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp index e4aea4b61fafa5286591d0bd3e58a1324cefccb3..0217e076ace1cfc221156375c50713098cd796d9 100644 --- a/src/filterbar/filterbar.cpp +++ b/src/filterbar/filterbar.cpp @@ -115,9 +115,6 @@ void FilterBar::keyPressEvent(QKeyEvent *event) case Qt::Key_Enter: case Qt::Key_Return: - Q_EMIT focusViewRequest(); - return; - case Qt::Key_Down: case Qt::Key_PageDown: case Qt::Key_Up: diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index da593ebae0d4d3aaa3d80f1a53114376ee5a6974..b7eb8ca1c00c6bf61940cbfe971cbadcaa1c0d2e 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -66,7 +66,7 @@ #include <QToolTip> #include <QVBoxLayout> -DolphinView::DolphinView(const QUrl &url, QWidget *parent) +DolphinView::DolphinView(const QUrl &url, const QList<KeyPressHandler *> keyPressHandlers, QWidget *parent) : QWidget(parent) , m_active(true) , m_tabsForFiles(false) @@ -97,6 +97,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent) , m_twoClicksRenamingTimer(nullptr) , m_placeholderLabel(nullptr) , m_showLoadingPlaceholderTimer(nullptr) + , m_keyPressHandlers(keyPressHandlers) { m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); @@ -945,16 +946,26 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event) updatePalette(); break; - case QEvent::KeyPress: + case QEvent::KeyPress: { hideToolTip(ToolTipManager::HideBehavior::Instantly); - if (GeneralSettings::useTabForSwitchingSplitView()) { - QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); - if (keyEvent->key() == Qt::Key_Tab && keyEvent->modifiers() == Qt::NoModifier) { + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + for (KeyPressHandler *handler : m_keyPressHandlers) { + if (handler->handleKeyPress(keyEvent)) { + return true; + } + } + switch (keyEvent->key()) { + case Qt::Key_Tab: + if (keyEvent->modifiers() == Qt::NoModifier && GeneralSettings::useTabForSwitchingSplitView()) { Q_EMIT toggleActiveViewRequested(); return true; } + break; + default: + break; } break; + } case QEvent::KeyRelease: if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Control) { m_controlWheelAccumulatedDelta = 0; diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 167534458b645fdde516a730d161f47d4690c407..35f20f0db1fac001f038f01d8b43736317fcd4b5 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -41,6 +41,19 @@ class QHelpEvent; class QProxyStyle; class QRegularExpression; +class DOLPHIN_EXPORT KeyPressHandler +{ +public: + virtual ~KeyPressHandler() = default; + + /** + * @return true to stop further handling of the \p event, otherwise return false. + * + * Handles keypress events. + */ + virtual bool handleKeyPress(QKeyEvent *event) = 0; +}; + /** * @short Represents a view for the directory content. * @@ -83,9 +96,10 @@ public: /** * @param url Specifies the content which should be shown. + * @param keyPressHandler Specifies the key press handler. * @param parent Parent widget of the view. */ - DolphinView(const QUrl &url, QWidget *parent); + DolphinView(const QUrl &url, const QList<KeyPressHandler *> keyPressHandlers, QWidget *parent); ~DolphinView() override; @@ -986,6 +1000,8 @@ private: /// Used for selection mode. @see setSelectionMode() std::unique_ptr<QProxyStyle> m_proxyStyle; + const QList<KeyPressHandler *> m_keyPressHandlers; + // For unit tests friend class TestBase; friend class DolphinDetailsViewTest;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor