Previous to this commit middle-clicking an archive would always open it
in a new tab. This contradicts the recent change
d27ee07de7558470ef7b497fbe3d3504ce7cad07 which made it so middle-click
would open an item in the second application that is available to open
a file.
With this commit, middle-clicking will treat the archive like a folder
only when GeneralSettings::browseThroughArchives is enabled or when
there is no second application available. Otherwise middle-click will
open the archive in the second available application.
#include "dolphincontextmenu.h"
#include "dolphin_contextmenusettings.h"
+#include "dolphin_generalsettings.h"
#include "dolphinmainwindow.h"
#include "dolphinnewfilemenu.h"
#include "dolphinplacesmodelsingleton.h"
m_fileItemActions->insertOpenWithActionsTo(nullptr, this, QStringList{qApp->desktopFileName()});
// For a single file, hint in "Open with" menu that middle-clicking would open it in the secondary app.
- if (m_selectedItems.count() == 1 && !m_fileInfo.isDir()) {
+ // (Unless middle-clicking would open it as a folder in a new tab (e.g. archives).)
+ const QUrl &url = DolphinView::openItemAsFolderUrl(m_fileInfo, GeneralSettings::browseThroughArchives());
+ if (m_selectedItems.count() == 1 && url.isEmpty()) {
if (QAction *openWithSubMenu = findChild<QAction *>(QStringLiteral("openWith_submenu"))) {
Q_ASSERT(openWithSubMenu->menu());
Q_ASSERT(!openWithSubMenu->menu()->isEmpty());
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
job->start();
+ } else {
+ // If no 2nd service available, try to open archives in new tabs, regardless of the "Open archives as folder" setting.
+ const QUrl &url = DolphinView::openItemAsFolderUrl(item);
+ const auto modifiers = QGuiApplication::keyboardModifiers();
+ if (!url.isEmpty()) {
+ // keep in sync with KUrlNavigator::slotNavigatorButtonClicked
+ if (modifiers & Qt::ShiftModifier) {
+ Q_EMIT activeTabRequested(url);
+ } else {
+ Q_EMIT tabRequested(url);
+ }
+ }
}
}
void DolphinView::slotItemMiddleClicked(int index)
{
const KFileItem &item = m_model->fileItem(index);
- const QUrl &url = openItemAsFolderUrl(item);
+ const QUrl &url = openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
const auto modifiers = QGuiApplication::keyboardModifiers();
if (!url.isEmpty()) {
// keep in sync with KUrlNavigator::slotNavigatorButtonClicked