]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'release/20.08' into master
authorNate Graham <nate@kde.org>
Mon, 5 Oct 2020 21:19:04 +0000 (15:19 -0600)
committerNate Graham <nate@kde.org>
Mon, 5 Oct 2020 21:19:04 +0000 (15:19 -0600)
1  2 
src/dolphinmainwindow.cpp

index 92d673a956b067c7aa881d468bfb0279d9a2c7e4,ab5dc43418b793793b8015766d76f377256470a8..0fb953312f75b0c11d506a71dcee296c2e6c3401
@@@ -1,10 -1,23 +1,10 @@@
 -/***************************************************************************
 - *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
 - *   Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com>               *
 - *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
 - *                                                                         *
 - *   This program is free software; you can redistribute it and/or modify  *
 - *   it under the terms of the GNU General Public License as published by  *
 - *   the Free Software Foundation; either version 2 of the License, or     *
 - *   (at your option) any later version.                                   *
 - *                                                                         *
 - *   This program is distributed in the hope that it will be useful,       *
 - *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 - *   GNU General Public License for more details.                          *
 - *                                                                         *
 - *   You should have received a copy of the GNU General Public License     *
 - *   along with this program; if not, write to the                         *
 - *   Free Software Foundation, Inc.,                                       *
 - *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
 - ***************************************************************************/
 +/*
 + * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
 + * SPDX-FileCopyrightText: 2006 Stefan Monov <logixoul@gmail.com>
 + * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
 + *
 + * SPDX-License-Identifier: GPL-2.0-or-later
 + */
  
  #include "dolphinmainwindow.h"
  
  #include <KIO/CommandLauncherJob>
  #include <KIO/JobUiDelegate>
  #include <KIO/OpenFileManagerWindowJob>
 +#include <KIO/OpenUrlJob>
  #include <KJobWidgets>
  #include <KLocalizedString>
  #include <KMessageBox>
  #include <KNS3/KMoreToolsMenuFactory>
  #include <KProtocolInfo>
  #include <KProtocolManager>
 -#include <KRun>
  #include <KShell>
  #include <KStandardAction>
  #include <KStartupInfo>
@@@ -101,7 -114,7 +101,7 @@@ DolphinMainWindow::DolphinMainWindow() 
      m_bookmarkHandler(nullptr),
      m_controlButton(nullptr),
      m_updateToolBarTimer(nullptr),
 -    m_lastHandleUrlStatJob(nullptr),
 +    m_lastHandleUrlOpenJob(nullptr),
      m_terminalPanel(nullptr),
      m_placesPanel(nullptr),
      m_tearDownFromPlacesRequested(false),
@@@ -475,7 -488,10 +475,10 @@@ void DolphinMainWindow::closeEvent(QClo
          closedByUser = false;
      }
  
-     if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
+     if (m_tabWidget->count() > 1
+         && GeneralSettings::confirmClosingMultipleTabs()
+         && !GeneralSettings::rememberOpenedTabs()
+         && closedByUser) {
          // Ask the user if he really wants to quit and close all tabs.
          // Open a confirmation dialog with 3 buttons:
          // QDialogButtonBox::Yes    -> Quit
@@@ -943,6 -959,18 +946,6 @@@ void DolphinMainWindow::toggleShowMenuB
      }
  }
  
 -QString DolphinMainWindow::activeContainerLocalPath()
 -{
 -    KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
 -    KJobWidgets::setWindow(statJob, this);
 -    statJob->exec();
 -    QUrl url = statJob->mostLocalUrl();
 -    if (url.isLocalFile()) {
 -        return url.toLocalFile();
 -    }
 -    return QDir::homePath();
 -}
 -
  QPointer<QAction> DolphinMainWindow::preferredSearchTool()
  {
      m_searchTools.clear();
@@@ -989,31 -1017,7 +992,31 @@@ void DolphinMainWindow::openPreferredSe
  
  void DolphinMainWindow::openTerminal()
  {
 -    KToolInvocation::invokeTerminal(QString(), activeContainerLocalPath());
 +    const QUrl url = m_activeViewContainer->url();
 +
 +    if (url.isLocalFile()) {
 +        KToolInvocation::invokeTerminal(QString(), url.toLocalFile());
 +        return;
 +    }
 +
 +     // Not a local file, with protocol Class ":local", try stat'ing
 +    if (KProtocolInfo::protocolClass(url.scheme()) == QLatin1String(":local")) {
 +        KIO::StatJob *job = KIO::mostLocalUrl(url);
 +        KJobWidgets::setWindow(job, this);
 +        connect(job, &KJob::result, this, [job]() {
 +            QUrl statUrl;
 +            if (!job->error()) {
 +                statUrl = job->mostLocalUrl();
 +            }
 +
 +            KToolInvocation::invokeTerminal(QString(), statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
 +        });
 +
 +        return;
 +    }
 +
 +    // Nothing worked, just use $HOME
 +    KToolInvocation::invokeTerminal(QString(), QDir::homePath());
  }
  
  void DolphinMainWindow::editSettings()
  
  void DolphinMainWindow::handleUrl(const QUrl& url)
  {
 -    delete m_lastHandleUrlStatJob;
 -    m_lastHandleUrlStatJob = nullptr;
 +    delete m_lastHandleUrlOpenJob;
 +    m_lastHandleUrlOpenJob = nullptr;
  
      if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
          activeViewContainer()->setUrl(url);
 -    } else if (KProtocolManager::supportsListing(url)) {
 -        // stat the URL to see if it is a dir or not
 -        m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
 -        if (m_lastHandleUrlStatJob->uiDelegate()) {
 -            KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
 -        }
 -        connect(m_lastHandleUrlStatJob, &KIO::Job::result,
 -                this, &DolphinMainWindow::slotHandleUrlStatFinished);
 -
      } else {
 -        new KRun(url, this); // Automatically deletes itself after being finished
 -    }
 -}
 +        m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
 +        m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
 +        m_lastHandleUrlOpenJob->setRunExecutables(true);
  
 -void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
 -{
 -    m_lastHandleUrlStatJob = nullptr;
 -    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
 -    const QUrl url = static_cast<KIO::StatJob*>(job)->url();
 -    if (entry.isDir()) {
 -        activeViewContainer()->setUrl(url);
 -    } else {
 -        new KRun(url, this);  // Automatically deletes itself after being finished
 +        connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this,
 +                [this, url](const QString &mimetype) {
 +                    if (mimetype == QLatin1String("inode/directory")) {
 +                        // If it's a dir, we'll take it from here
 +                        m_lastHandleUrlOpenJob->kill();
 +                        m_lastHandleUrlOpenJob = nullptr;
 +                        activeViewContainer()->setUrl(url);
 +                    }
 +        });
 +
 +        connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::result, this, [this]() {
 +            m_lastHandleUrlOpenJob = nullptr;
 +        });
 +
 +        m_lastHandleUrlOpenJob->start();
      }
  }
  
@@@ -1361,20 -1368,20 +1364,20 @@@ void DolphinMainWindow::setupActions(
          "action they are removed from their old location.") +  cutCopyPastePara);
  
      QAction* copyToOtherViewAction = actionCollection()->addAction(QStringLiteral("copy_to_inactive_split_view"));
 -    copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to inactive split view"));
 +    copyToOtherViewAction->setText(i18nc("@action:inmenu", "Copy to Inactive Split View"));
      copyToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Copy", "This copies the selected items from "
          "the <emphasis>active</emphasis> view to the inactive split view."));
      copyToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
 -    copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to inactive split view"));
 +    copyToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Copy to Inactive Split View"));
      actionCollection()->setDefaultShortcut(copyToOtherViewAction, Qt::SHIFT + Qt::Key_F5 );
      connect(copyToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::copyToInactiveSplitView);
  
      QAction* moveToOtherViewAction = actionCollection()->addAction(QStringLiteral("move_to_inactive_split_view"));
 -    moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to inactive split view"));
 +    moveToOtherViewAction->setText(i18nc("@action:inmenu", "Move to Inactive Split View"));
      moveToOtherViewAction->setWhatsThis(xi18nc("@info:whatsthis Move", "This moves the selected items from "
          "the <emphasis>active</emphasis> view to the inactive split view."));
      moveToOtherViewAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut")));
 -    moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to inactive split view"));
 +    moveToOtherViewAction->setIconText(i18nc("@action:inmenu Edit", "Move to Inactive Split View"));
      actionCollection()->setDefaultShortcut(moveToOtherViewAction, Qt::SHIFT + Qt::Key_F6 );
      connect(moveToOtherViewAction, &QAction::triggered, m_tabWidget, &DolphinTabWidget::moveToInactiveSplitView);
  
      actionCollection()->setDefaultShortcut(openPreferredSearchTool, Qt::CTRL + Qt::SHIFT + Qt::Key_F);
      connect(openPreferredSearchTool, &QAction::triggered, this, &DolphinMainWindow::openPreferredSearchTool);
  
 -#ifdef HAVE_TERMINAL
      if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
          QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
          openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
          actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
          connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
  
 +#ifdef HAVE_TERMINAL
          QAction* focusTerminalPanel = actionCollection()->addAction(QStringLiteral("focus_terminal_panel"));
          focusTerminalPanel->setText(i18nc("@action:inmenu Tools", "Focus Terminal Panel"));
          focusTerminalPanel->setIcon(QIcon::fromTheme(QStringLiteral("swap-panels")));
          actionCollection()->setDefaultShortcut(focusTerminalPanel, Qt::CTRL + Qt::SHIFT + Qt::Key_F4);
          connect(focusTerminalPanel, &QAction::triggered, this, &DolphinMainWindow::focusTerminalPanel);
 -    }
  #endif
 +    }
  
      // setup 'Bookmarks' menu
      KActionMenu *bookmarkMenu = new KActionMenu(i18nc("@title:menu", "&Bookmarks"), this);
@@@ -2107,8 -2114,6 +2110,8 @@@ void DolphinMainWindow::connectViewSign
              this, &DolphinMainWindow::goForward);
      connect(view, &DolphinView::urlActivated,
              this, &DolphinMainWindow::handleUrl);
 +    connect(view, &DolphinView::goUpRequested,
 +            this, &DolphinMainWindow::goUp);
  
      const KUrlNavigator* navigator = container->urlNavigator();
      connect(navigator, &KUrlNavigator::urlChanged,