From a69d7a39557527794fa871fba3f2909b662c3935 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 9 Sep 2007 18:38:04 +0000 Subject: [PATCH] Reactivate keyboard navigation again. Previously the Return key did not work, as the 'activated()' signal cannot be used (it ignores KDEs single vs. doubleclick setting). svn path=/trunk/KDE/kdebase/apps/; revision=710356 --- src/dolphindetailsview.cpp | 12 ++++++++++++ src/dolphindetailsview.h | 1 + src/dolphiniconsview.cpp | 12 ++++++++++++ src/dolphiniconsview.h | 1 + src/dolphinview.cpp | 2 ++ 5 files changed, 28 insertions(+) diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 1aec30cca..dfd7018bb 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -69,6 +69,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)), this, SLOT(setSortIndicatorOrder(Qt::SortOrder))); + // TODO: Connecting to the signal 'activated()' is not possible, as kstyle + // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is + // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the + // RETURN-key in keyPressEvent(). if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(slotItemActivated(const QModelIndex&))); @@ -271,6 +275,14 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) } } +void DolphinDetailsView::keyPressEvent(QKeyEvent* event) +{ + QTreeView::keyPressEvent(event); + if (event->key() == Qt::Key_Return) { + m_controller->triggerItem(selectionModel()->currentIndex()); + } +} + void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting) { QHeaderView* headerView = header(); diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index fdd93b03c..dc79c31cc 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -56,6 +56,7 @@ protected: virtual void dragMoveEvent(QDragMoveEvent* event); virtual void dropEvent(QDropEvent* event); virtual void paintEvent(QPaintEvent* event); + virtual void keyPressEvent(QKeyEvent* event); private slots: /** diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 37f0bf172..ed2332c05 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -46,6 +46,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle setMouseTracking(true); viewport()->setAttribute(Qt::WA_Hover); + // TODO: Connecting to the signal 'activated()' is not possible, as kstyle + // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is + // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the + // RETURN-key in keyPressEvent(). if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); @@ -202,6 +206,14 @@ void DolphinIconsView::paintEvent(QPaintEvent* event) } } +void DolphinIconsView::keyPressEvent(QKeyEvent* event) +{ + KCategorizedView::keyPressEvent(event); + if (event->key() == Qt::Key_Return) { + m_controller->triggerItem(selectionModel()->currentIndex()); + } +} + void DolphinIconsView::slotShowPreviewChanged(bool showPreview) { updateGridSize(showPreview, m_controller->showAdditionalInfo()); diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h index 7e5544ec0..6cd5b2201 100644 --- a/src/dolphiniconsview.h +++ b/src/dolphiniconsview.h @@ -56,6 +56,7 @@ protected: virtual void dragMoveEvent(QDragMoveEvent* event); virtual void dropEvent(QDropEvent* event); virtual void paintEvent(QPaintEvent* event); + virtual void keyPressEvent(QKeyEvent* event); private slots: void slotShowPreviewChanged(bool show); diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index d145597ca..3e8070cb3 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -432,6 +432,7 @@ void DolphinView::setUrl(const KUrl& url) applyViewProperties(url); startDirLister(url); + itemView()->setFocus(); } void DolphinView::mouseReleaseEvent(QMouseEvent* event) @@ -835,6 +836,7 @@ void DolphinView::createView() this, SLOT(emitContentsMoved())); connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(emitContentsMoved())); + view->setFocus(); } QAbstractItemView* DolphinView::itemView() const -- 2.47.3