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 ecabbc379b27eaf35c658afe068f68d5a061f48c..ba476bb2ac5361ffb12318656abb0951aa82d4a5 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 @@ -852,6 +852,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 89fd697607422ff6344f4c84ac9cf5cb0fd5bbd8..1ecd8fc637d4f0b76cd5ef0494d8b6fe1717f963 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 @@ -198,6 +198,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 9d25869ba81e8a9815e56514a060a0a7d5d0dc2b..6067060b6558ad4145355718ab4a81c6d0eb8717 100644 --- a/src/filterbar/filterbar.cpp +++ b/src/filterbar/filterbar.cpp @@ -113,9 +113,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 a7c81d70635f44e41d2b5f62689a0f95411ea826..28b6b9eff9397cb6fb6c8e2dd95c31312765e0b1 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); @@ -930,16 +931,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 6ecc486cb90f6a1b6a700b498e6e2ba1f4c29257..7bc1bf13a509eec8a7b36374b04c059c8145c1d7 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; @@ -989,6 +1003,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