From: Peter Penz Date: Sun, 23 Nov 2008 12:28:10 +0000 (+0000) Subject: Opening a tab with the middle mouse button should always be done with one click,... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/dcbf1a11783d47e7e4fa30d488ac93a8bc547e71 Opening a tab with the middle mouse button should always be done with one click, even if double click has been activated. BUG: 162986 svn path=/trunk/KDE/kdebase/apps/; revision=888007 --- diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index ab0c3783c..31f5c6193 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -464,9 +464,8 @@ void DolphinColumnWidget::activate() { setFocus(Qt::OtherFocusReason); - // 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'. + connect(this, SIGNAL(clicked(const QModelIndex&)), + m_view->m_controller, SLOT(requestTab(const QModelIndex&))); if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), m_view->m_controller, SLOT(triggerItem(const QModelIndex&))); diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index f6ee66634..fe8c426f3 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -170,26 +170,33 @@ KFileItem DolphinController::itemForIndex(const QModelIndex& index) const void DolphinController::triggerItem(const QModelIndex& index) { - if (m_mouseButtons & Qt::RightButton) { - // a context menu is opened - assure that no triggering is done - return; + if (m_mouseButtons & Qt::LeftButton) { + const KFileItem item = itemForIndex(index); + if (index.isValid() && (index.column() == KDirModel::Name)) { + emit itemTriggered(item); + } else { + m_itemView->clearSelection(); + emit itemEntered(KFileItem()); + } + m_mouseButtons = Qt::NoButton; + } else if (m_mouseButtons & Qt::RightButton) { + m_mouseButtons = Qt::NoButton; } - - const bool openTab = m_mouseButtons & Qt::MidButton; - m_mouseButtons = Qt::NoButton; +} - const KFileItem item = itemForIndex(index); - if (index.isValid() && (index.column() == KDirModel::Name)) { - if (openTab && (item.isDir() || m_dolphinView->isTabsForFilesEnabled())) { +void DolphinController::requestTab(const QModelIndex& index) +{ + if (m_mouseButtons & Qt::MidButton) { + const KFileItem item = itemForIndex(index); + const bool validRequest = index.isValid() && + (index.column() == KDirModel::Name) && + (item.isDir() || m_dolphinView->isTabsForFilesEnabled()); + if (validRequest) { emit tabRequested(item.url()); - } else { - emit itemTriggered(item); - } - } else { - m_itemView->clearSelection(); - if (!openTab) { - emit itemEntered(KFileItem()); } + m_mouseButtons = Qt::NoButton; + } else if (m_mouseButtons & Qt::RightButton) { + m_mouseButtons = Qt::NoButton; } } diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h index 13a840a38..77e965afe 100644 --- a/src/dolphincontroller.h +++ b/src/dolphincontroller.h @@ -60,6 +60,7 @@ class QWidget; * - indicateSortingChange() * - indicateSortOrderChanged() * - triggerItem() + * - openTab() * - handleKeyPressEvent() * - emitItemEntered() * - emitViewportEntered() @@ -217,10 +218,19 @@ public: public slots: /** * Emits the signal itemTriggered() if the file item for the index \a index - * is not null. The method should be invoked by the - * controller parent whenever the user has triggered an item. + * is not null and the left mouse button has been pressed. If the item is + * null, the signal itemEntered() is emitted. + * The method should be invoked by the controller parent whenever the + * user has triggered an item. */ void triggerItem(const QModelIndex& index); + + /** + * Emits the signal tabRequested(), if the file item for the index \a index + * represents a directory and when the middle mouse button has been pressed. + * The method should be invoked by the controller parent. + */ + void requestTab(const QModelIndex& index); /** * Emits the signal itemEntered() if the file item for the index \a index diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 86a2865b8..c4f54cec4 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -96,10 +96,8 @@ 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(). + connect(this, SIGNAL(clicked(const QModelIndex&)), + controller, SLOT(requestTab(const QModelIndex&))); if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&))); diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 0dd7dd719..52be40b02 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -62,10 +62,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle setMouseTracking(true); - // 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(). + connect(this, SIGNAL(clicked(const QModelIndex&)), + controller, SLOT(requestTab(const QModelIndex&))); if (KGlobalSettings::singleClick()) { connect(this, SIGNAL(clicked(const QModelIndex&)), controller, SLOT(triggerItem(const QModelIndex&)));