]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / dolphinviewcontainer.cpp
index 9ed7654fafaf9388e9a4e4cd368aa15044dbe0da..3eaada941fe320e9453a506b39ecacc720301750 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Peter Penz <peter.penz19@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: 2007 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphinviewcontainer.h"
 
@@ -29,6 +16,8 @@
 #include "trash/dolphintrash.h"
 #include "views/viewmodecontroller.h"
 #include "views/viewproperties.h"
+#include "dolphin_detailsmodesettings.h"
+#include "views/dolphinview.h"
 
 #ifdef HAVE_KACTIVITIES
 #include <KActivities/ResourceInstance>
 #include <KFileItemActions>
 #include <KFilePlacesModel>
 #include <KIO/PreviewJob>
+#include <KIO/OpenUrlJob>
+#include <KIO/JobUiDelegate>
 #include <KLocalizedString>
 #include <KMessageWidget>
 #include <KProtocolManager>
-#include <KRun>
 #include <KShell>
 #include <KUrlComboBox>
 #include <KUrlNavigator>
@@ -50,6 +40,7 @@
 #include <QTimer>
 #include <QUrl>
 #include <QVBoxLayout>
+#include <QDesktopServices>
 
 DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     QWidget(parent),
@@ -118,7 +109,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
     connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
     connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
-    connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
+    connect(m_searchBox, &DolphinSearchBox::focusViewRequest, this, &DolphinViewContainer::requestFocus);
     m_searchBox->setWhatsThis(xi18nc("@info:whatsthis findbar",
         "<para>This helps you find files and folders. Enter a <emphasis>"
         "search term</emphasis> and specify search settings with the "
@@ -248,6 +239,12 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
 
     setSearchModeEnabled(isSearchUrl(url));
 
+    connect(DetailsModeSettings::self(), &KCoreConfigSkeleton::configChanged, this, [=]() {
+        if (view()->mode() == DolphinView::Mode::DetailsView) {
+            view()->reload();
+        }
+    });
+
     // Initialize kactivities resource instance
 
 #ifdef HAVE_KACTIVITIES
@@ -448,22 +445,20 @@ void DolphinViewContainer::reload()
     m_messageWidget->hide();
 }
 
-QString DolphinViewContainer::caption() const
+QString DolphinViewContainer::captionWindowTitle() const
 {
-    if (GeneralSettings::showFullPathInTitlebar()) {
+    if (GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
         if (!url().isLocalFile()) {
             return url().adjusted(QUrl::StripTrailingSlash).toString();
         }
         return url().adjusted(QUrl::StripTrailingSlash).path();
+    } else {
+        return DolphinViewContainer::caption();
     }
+}
 
-    KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
-    const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp);
-
-    if (!matchedPlaces.isEmpty()) {
-        return placesModel->text(matchedPlaces.first());
-    }
-
+QString DolphinViewContainer::caption() const
+{
     if (isSearchModeEnabled()) {
         if (currentSearchText().isEmpty()){
             return i18n("Search");
@@ -472,6 +467,14 @@ QString DolphinViewContainer::caption() const
         }
     }
 
+    KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+    const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp);
+
+    if (!matchedPlaces.isEmpty()) {
+        return placesModel->text(matchedPlaces.first());
+    }
+
+
     if (!url().isLocalFile()) {
         QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
         QString caption;
@@ -630,8 +633,10 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
         return;
     }
 
-    KRun *run = new KRun(item.targetUrl(), this);
-    run->setShowScriptExecutionPrompt(true);
+    KIO::OpenUrlJob *job = new KIO::OpenUrlJob(item.targetUrl());
+    job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+    job->setShowOpenOrExecuteDialog(true);
+    job->start();
 }
 
 void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
@@ -691,30 +696,18 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
             QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus);
         }
     } else if (KProtocolManager::isSourceProtocol(url)) {
-        QString app = QStringLiteral("konqueror");
         if (url.scheme().startsWith(QLatin1String("http"))) {
             showMessage(i18nc("@info:status", // krazy:exclude=qmethods
                               "Dolphin does not support web pages, the web browser has been launched"),
                         Information);
-
-            const KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
-            const QString browser = config.readEntry("BrowserApplication");
-            if (!browser.isEmpty()) {
-                app = browser;
-                if (app.startsWith('!')) {
-                    // a literal command has been configured, remove the '!' prefix
-                    app.remove(0, 1);
-                }
-            }
         } else {
             showMessage(i18nc("@info:status",
-                              "Protocol not supported by Dolphin, Konqueror has been launched"),
+                              "Protocol not supported by Dolphin, default application has been launched"),
                         Information);
         }
 
-        const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
-        const QString command = app + ' ' + secureUrl;
-        KRun::runCommand(command, app, app, this);
+        QDesktopServices::openUrl(url);
+        redirect(QUrl(), m_urlNavigator->locationUrl(1));
     } else {
         showMessage(i18nc("@info:status", "Invalid protocol"), Error);
     }