diff --git a/src/filewidgets/kurlnavigator.h b/src/filewidgets/kurlnavigator.h --- a/src/filewidgets/kurlnavigator.h +++ b/src/filewidgets/kurlnavigator.h @@ -481,8 +481,8 @@ Q_PRIVATE_SLOT(d, void slotProtocolChanged(const QString &protocol)) Q_PRIVATE_SLOT(d, void slotToggleEditableButtonPressed()) Q_PRIVATE_SLOT(d, void dropUrls(const QUrl &destination, QDropEvent *)) - Q_PRIVATE_SLOT(d, void slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button)) - Q_PRIVATE_SLOT(d, void openContextMenu()) + Q_PRIVATE_SLOT(d, void slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)) + Q_PRIVATE_SLOT(d, void openContextMenu(QPoint)) Q_PRIVATE_SLOT(d, void openPathSelectorMenu()) Q_PRIVATE_SLOT(d, void updateButtonVisibility()) Q_PRIVATE_SLOT(d, void switchToBreadcrumbMode()) diff --git a/src/filewidgets/kurlnavigator.cpp b/src/filewidgets/kurlnavigator.cpp --- a/src/filewidgets/kurlnavigator.cpp +++ b/src/filewidgets/kurlnavigator.cpp @@ -105,9 +105,9 @@ * of the navigator if the left mouse button has been used. If the middle * mouse button has been used, the signal tabRequested() will be emitted. */ - void slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button); + void slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers); - void openContextMenu(); + void openContextMenu(const QPoint &p); void slotPathBoxChanged(const QString &text); @@ -280,7 +280,7 @@ q->setContextMenuPolicy(Qt::CustomContextMenu); connect(q, SIGNAL(customContextMenuRequested(QPoint)), - q, SLOT(openContextMenu())); + q, SLOT(openContextMenu(QPoint))); } void KUrlNavigator::Private::initialize(const QUrl &url) @@ -448,16 +448,16 @@ } } -void KUrlNavigator::Private::slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button) +void KUrlNavigator::Private::slotNavigatorButtonClicked(const QUrl &url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers) { - if (button & Qt::LeftButton) { - q->setLocationUrl(url); - } else if (button & Qt::MidButton) { + if (button & Qt::MidButton || (button & Qt::LeftButton && modifiers & Qt::ControlModifier)) { emit q->tabRequested(url); + } else if (button & Qt::LeftButton) { + q->setLocationUrl(url); } } -void KUrlNavigator::Private::openContextMenu() +void KUrlNavigator::Private::openContextMenu(const QPoint &p) { q->setActive(true); @@ -475,6 +475,18 @@ popup->addSeparator(); + //We are checking for receivers because it's odd to have a tab entry even if it's not supported, like in the case of the open dialog + if (q->receivers(SIGNAL(tabRequested(QUrl))) > 0) { + for (auto button : qAsConst(m_navButtons)) { + if (button->geometry().contains(p)) { + const auto url = button->url(); + QAction* openInTab = popup->addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18n("Open %1 in tab", button->text())); + q->connect(openInTab, &QAction::triggered, q, [this, url](){ Q_EMIT q->tabRequested(url); }); + break; + } + } + } + // provide radiobuttons for toggling between the edit and the navigation mode QAction *editAction = popup->addAction(i18n("Edit")); editAction->setCheckable(true); @@ -602,8 +614,8 @@ button->setForegroundRole(QPalette::WindowText); connect(button, SIGNAL(urlsDropped(QUrl,QDropEvent*)), q, SLOT(dropUrls(QUrl,QDropEvent*))); - connect(button, SIGNAL(clicked(QUrl,Qt::MouseButton)), - q, SLOT(slotNavigatorButtonClicked(QUrl,Qt::MouseButton))); + connect(button, SIGNAL(clicked(QUrl,Qt::MouseButton,Qt::KeyboardModifiers)), + q, SLOT(slotNavigatorButtonClicked(QUrl,Qt::MouseButton,Qt::KeyboardModifiers))); connect(button, SIGNAL(finishedTextResolving()), q, SLOT(updateButtonVisibility())); appendWidget(button); diff --git a/src/filewidgets/kurlnavigatorbutton.cpp b/src/filewidgets/kurlnavigatorbutton.cpp --- a/src/filewidgets/kurlnavigatorbutton.cpp +++ b/src/filewidgets/kurlnavigatorbutton.cpp @@ -283,7 +283,7 @@ switch (event->key()) { case Qt::Key_Enter: case Qt::Key_Return: - emit clicked(m_url, Qt::LeftButton); + emit clicked(m_url, Qt::LeftButton, event->modifiers()); break; case Qt::Key_Down: case Qt::Key_Space: @@ -366,7 +366,7 @@ if (!isAboveArrow(event->x()) || (event->button() != Qt::LeftButton)) { // the mouse has been released above the text area and not // above the [>] button - emit clicked(m_url, event->button()); + emit clicked(m_url, event->button(), event->modifiers()); cancelSubDirsRequest(); } KUrlNavigatorButtonBase::mouseReleaseEvent(event); @@ -453,7 +453,7 @@ const int result = action->data().toInt(); QUrl url(m_url); url.setPath(concatPaths(url.path(), m_subDirs.at(result).first)); - emit clicked(url, button); + emit clicked(url, button, Qt::NoModifier); } void KUrlNavigatorButton::statFinished(KJob *job) @@ -573,7 +573,7 @@ QUrl url(KIO::upUrl(m_url)); url.setPath(concatPaths(url.path(), m_subDirs[targetIndex].first)); - emit clicked(url, Qt::LeftButton); + emit clicked(url, Qt::LeftButton, Qt::NoModifier); m_subDirs.clear(); } diff --git a/src/filewidgets/kurlnavigatorbutton_p.h b/src/filewidgets/kurlnavigatorbutton_p.h --- a/src/filewidgets/kurlnavigatorbutton_p.h +++ b/src/filewidgets/kurlnavigatorbutton_p.h @@ -90,7 +90,7 @@ */ void urlsDropped(const QUrl &destination, QDropEvent *event); - void clicked(const QUrl &url, Qt::MouseButton button); + void clicked(const QUrl &url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers); /** * Is emitted, if KUrlNavigatorButton::setUrl() cannot resolve diff --git a/src/widgets/kfileitemactions.cpp b/src/widgets/kfileitemactions.cpp --- a/src/widgets/kfileitemactions.cpp +++ b/src/widgets/kfileitemactions.cpp @@ -400,7 +400,7 @@ const bool ok = std::all_of(items.constBegin(), items.constEnd(), - [&types, &excludeTypes, this](const KFileItem &i) + [&types, &excludeTypes](const KFileItem &i) { return mimeTypeListContains(types, i) && !mimeTypeListContains(excludeTypes, i); });