2015-04-22 13:29:39 +00:00
|
|
|
/*
|
2020-08-25 17:07:38 +00:00
|
|
|
* SPDX-FileCopyrightText: 2015 Ashish Bansal <bansal.ashish096@gmail.com>
|
2015-04-22 13:29:39 +00:00
|
|
|
*
|
2020-08-25 17:07:38 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2015-04-22 13:29:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "global.h"
|
2018-03-04 13:38:16 +00:00
|
|
|
|
2015-10-10 13:09:48 +00:00
|
|
|
#include "dolphin_generalsettings.h"
|
2018-03-04 13:38:16 +00:00
|
|
|
#include "dolphindebug.h"
|
2019-12-23 10:06:54 +00:00
|
|
|
#include "dolphinmainwindowinterface.h"
|
2021-06-04 12:04:14 +00:00
|
|
|
#include "views/viewproperties.h"
|
2015-10-10 13:09:48 +00:00
|
|
|
|
2021-01-02 17:48:52 +00:00
|
|
|
#include <KConfigWatcher>
|
2020-04-13 20:49:10 +00:00
|
|
|
#include <KDialogJobUiDelegate>
|
|
|
|
#include <KIO/ApplicationLauncherJob>
|
|
|
|
#include <KService>
|
2022-10-11 19:21:09 +00:00
|
|
|
#include <KWindowSystem>
|
2018-02-04 10:38:50 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
2015-04-22 13:29:39 +00:00
|
|
|
QList<QUrl> Dolphin::validateUris(const QStringList &uriList)
|
|
|
|
{
|
2016-10-02 23:05:42 +00:00
|
|
|
const QString currentDir = QDir::currentPath();
|
2015-04-22 13:29:39 +00:00
|
|
|
QList<QUrl> urls;
|
2020-10-23 17:48:22 +00:00
|
|
|
for (const QString &str : uriList) {
|
2016-10-02 23:05:42 +00:00
|
|
|
const QUrl url = QUrl::fromUserInput(str, currentDir, QUrl::AssumeLocalFile);
|
2015-04-22 13:29:39 +00:00
|
|
|
if (url.isValid()) {
|
|
|
|
urls.append(url);
|
|
|
|
} else {
|
|
|
|
qCWarning(DolphinDebug) << "Invalid URL: " << str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return urls;
|
|
|
|
}
|
2015-10-10 13:09:48 +00:00
|
|
|
|
|
|
|
QUrl Dolphin::homeUrl()
|
|
|
|
{
|
|
|
|
return QUrl::fromUserInput(GeneralSettings::homeUrl(), QString(), QUrl::AssumeLocalFile);
|
|
|
|
}
|
2017-03-08 15:52:15 +00:00
|
|
|
|
|
|
|
void Dolphin::openNewWindow(const QList<QUrl> &urls, QWidget *window, const OpenNewWindowFlags &flags)
|
|
|
|
{
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
QString command = QStringLiteral("dolphin --new-window");
|
2017-03-08 15:52:15 +00:00
|
|
|
|
|
|
|
if (flags.testFlag(OpenNewWindowFlag::Select)) {
|
|
|
|
command.append(QLatin1String(" --select"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!urls.isEmpty()) {
|
|
|
|
command.append(QLatin1String(" %U"));
|
|
|
|
}
|
2020-04-13 20:49:10 +00:00
|
|
|
KService::Ptr service(new KService(QApplication::applicationDisplayName(), command, QApplication::windowIcon().name()));
|
|
|
|
auto *job = new KIO::ApplicationLauncherJob(service, window);
|
|
|
|
job->setUrls(urls);
|
|
|
|
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, window));
|
|
|
|
job->start();
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2022-10-11 19:21:09 +00:00
|
|
|
bool Dolphin::attachToExistingInstance(const QList<QUrl> &inputUrls,
|
|
|
|
bool openFiles,
|
|
|
|
bool splitView,
|
|
|
|
const QString &preferredService,
|
|
|
|
const QString &activationToken)
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
{
|
2019-12-23 10:06:54 +00:00
|
|
|
bool attached = false;
|
|
|
|
|
2022-10-12 20:04:07 +00:00
|
|
|
if (inputUrls.isEmpty()) {
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Add an option to show tabs from last time when Dolphin starts
Summary:
All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today
restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default.
The settings window is accordingly adjusted to be clear about what applies when:
{F7681752}
FEATURE: 413564
FIXED-IN: 20.08.0
Depends on D25106
Depends on D25219
Test Plan:
With the new setting turned off:
- No behavioral changes at all
With the new setting turned on:
- When launched from the GUI or CLI without any URLs, dolphin restores session
- When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here)
- When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session
- When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here)
- "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running
Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis
Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis
Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D11382
2019-07-19 17:52:12 +00:00
|
|
|
auto dolphinInterfaces = dolphinGuiInstances(preferredService);
|
2019-12-23 19:08:41 +00:00
|
|
|
if (dolphinInterfaces.isEmpty()) {
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-24 13:24:24 +00:00
|
|
|
int activeWindowIndex = -1;
|
|
|
|
for (const auto &interface : qAsConst(dolphinInterfaces)) {
|
|
|
|
++activeWindowIndex;
|
|
|
|
|
|
|
|
auto isActiveWindowReply = interface.first->isActiveWindow();
|
|
|
|
isActiveWindowReply.waitForFinished();
|
|
|
|
if (!isActiveWindowReply.isError() && isActiveWindowReply.value()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
|
2022-05-24 13:24:24 +00:00
|
|
|
// check to see if any instances already have any of the given URLs or their parents open
|
2022-10-12 20:04:07 +00:00
|
|
|
QList<QUrl> newWindowURLs;
|
|
|
|
for (const QUrl &url : inputUrls) {
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
bool urlFound = false;
|
2022-10-12 20:04:07 +00:00
|
|
|
const QString urlString = url.toString();
|
2022-05-24 13:24:24 +00:00
|
|
|
|
|
|
|
// looping through the windows starting from the active one
|
|
|
|
int i = activeWindowIndex;
|
|
|
|
do {
|
|
|
|
auto &interface = dolphinInterfaces[i];
|
|
|
|
|
2022-10-12 20:04:07 +00:00
|
|
|
auto isUrlOpenReply = openFiles ? interface.first->isItemVisibleInAnyView(urlString) : interface.first->isUrlOpen(urlString);
|
2019-12-23 10:06:54 +00:00
|
|
|
isUrlOpenReply.waitForFinished();
|
|
|
|
if (!isUrlOpenReply.isError() && isUrlOpenReply.value()) {
|
2022-10-12 20:04:07 +00:00
|
|
|
interface.second.append(urlString);
|
2019-08-11 10:35:08 +00:00
|
|
|
urlFound = true;
|
|
|
|
break;
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
}
|
2022-05-24 13:24:24 +00:00
|
|
|
|
|
|
|
i = (i + 1) % dolphinInterfaces.size();
|
|
|
|
} while (i != activeWindowIndex);
|
|
|
|
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
if (!urlFound) {
|
2022-10-12 20:04:07 +00:00
|
|
|
if (GeneralSettings::openExternallyCalledFolderInNewTab()) {
|
|
|
|
dolphinInterfaces[activeWindowIndex].second.append(urlString);
|
|
|
|
} else {
|
|
|
|
newWindowURLs.append(url);
|
|
|
|
}
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-08 15:52:15 +00:00
|
|
|
|
2020-05-28 20:02:03 +00:00
|
|
|
for (const auto &interface : qAsConst(dolphinInterfaces)) {
|
2022-05-24 13:24:24 +00:00
|
|
|
if (interface.second.isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto reply = openFiles ? interface.first->openFiles(interface.second, splitView) : interface.first->openDirectories(interface.second, splitView);
|
2021-08-14 11:07:24 +00:00
|
|
|
reply.waitForFinished();
|
|
|
|
if (!reply.isError()) {
|
2022-10-11 19:21:09 +00:00
|
|
|
interface.first->activateWindow(activationToken);
|
2021-08-14 11:07:24 +00:00
|
|
|
attached = true;
|
Open externally called files/directories in new tabs
Summary:
FEATURE: 183429
FIXED-IN: 19.08.0
GUI: new cli argument --new-window
Externally called files/directories are opened in a a new tab of an instance of Dolphin that already exists. If any of the given URIs are already open in a tab, then those tabs are activated instead of a new tab being opened. If there is no instance then the files/directories are opened in a new window. The newly opened file/directory has its tab activated, and consequently, the window is also activated.
When the user clicks "Open In New Window" or "Detach Tab", the files/directories are opened in a new window.
Test Plan:
[Manual]
Before testing, set the default file manager in system settings as the newly built Dolphin executable.
One must also include the new dolphin executable in the $PATH, otherwise some functions will attempt to open the system dolphin instead of the new one.
Furthermore, running two different versions of Dolphin (in particular, where one does not have this patch included) can result in bugs appearing, in particular, new tabs not opening as old instances will not recognise the DBus commands sent to it. However, I see no reason why a user will have two different versions of Dolphin (apart from people like us :D).
Open directories with the help of auxillary programs (i.e. a browser). The files/directories should appear in a new window if an instance does not exist. If an existence already exists, then a new tab should be opened and activated in that instance and the window activated.
Use QDBusViewer to open folders/items by calling the ShowFolders/ShowItems methods in org.freedesktop.FileManager1 of the Dolphin instance.
When a user chooses to "Open In New Window"/"Detach Tab" then the files/directories should be opened in a new window.
Reviewers: #dolphin, elvisangelaccio
Subscribers: zzag, dfaure, fvogt, fikrim, magar, fbg13, davidedmundson, kwin, ngraham, elvisangelaccio, anthonyfieroni, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D16648
2019-05-30 20:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-12 20:04:07 +00:00
|
|
|
if (attached && !newWindowURLs.isEmpty()) {
|
|
|
|
if (openFiles) {
|
|
|
|
openNewWindow(newWindowURLs, nullptr, Dolphin::OpenNewWindowFlag::Select);
|
|
|
|
} else {
|
|
|
|
openNewWindow(newWindowURLs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-23 10:06:54 +00:00
|
|
|
return attached;
|
2017-03-08 15:52:15 +00:00
|
|
|
}
|
Add an option to show tabs from last time when Dolphin starts
Summary:
All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today
restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default.
The settings window is accordingly adjusted to be clear about what applies when:
{F7681752}
FEATURE: 413564
FIXED-IN: 20.08.0
Depends on D25106
Depends on D25219
Test Plan:
With the new setting turned off:
- No behavioral changes at all
With the new setting turned on:
- When launched from the GUI or CLI without any URLs, dolphin restores session
- When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here)
- When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session
- When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here)
- "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running
Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis
Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis
Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D11382
2019-07-19 17:52:12 +00:00
|
|
|
|
|
|
|
QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Dolphin::dolphinGuiInstances(const QString &preferredService)
|
|
|
|
{
|
|
|
|
QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
|
2023-04-20 08:50:40 +00:00
|
|
|
if (!preferredService.isEmpty()) {
|
2023-05-24 08:52:59 +00:00
|
|
|
QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
|
|
|
|
new OrgKdeDolphinMainWindowInterface(preferredService, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
|
|
|
|
if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
|
|
|
|
dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
|
|
|
|
}
|
Add an option to show tabs from last time when Dolphin starts
Summary:
All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today
restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default.
The settings window is accordingly adjusted to be clear about what applies when:
{F7681752}
FEATURE: 413564
FIXED-IN: 20.08.0
Depends on D25106
Depends on D25219
Test Plan:
With the new setting turned off:
- No behavioral changes at all
With the new setting turned on:
- When launched from the GUI or CLI without any URLs, dolphin restores session
- When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here)
- When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session
- When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here)
- "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running
Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis
Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis
Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D11382
2019-07-19 17:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Look for dolphin instances among all available dbus services.
|
2021-07-09 08:30:58 +00:00
|
|
|
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
|
|
|
const QStringList dbusServices = sessionInterface ? sessionInterface->registeredServiceNames().value() : QStringList();
|
Add an option to show tabs from last time when Dolphin starts
Summary:
All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today
restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default.
The settings window is accordingly adjusted to be clear about what applies when:
{F7681752}
FEATURE: 413564
FIXED-IN: 20.08.0
Depends on D25106
Depends on D25219
Test Plan:
With the new setting turned off:
- No behavioral changes at all
With the new setting turned on:
- When launched from the GUI or CLI without any URLs, dolphin restores session
- When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here)
- When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session
- When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here)
- "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running
Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis
Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis
Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D11382
2019-07-19 17:52:12 +00:00
|
|
|
// Don't match the service without trailing "-" (unique instance)
|
|
|
|
const QString pattern = QStringLiteral("org.kde.dolphin-");
|
|
|
|
// Don't match the pid without leading "-"
|
|
|
|
const QString myPid = QLatin1Char('-') + QString::number(QCoreApplication::applicationPid());
|
|
|
|
for (const QString &service : dbusServices) {
|
|
|
|
if (service.startsWith(pattern) && !service.endsWith(myPid)) {
|
2023-05-24 08:52:59 +00:00
|
|
|
// Check if instance can handle our URLs
|
|
|
|
QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
|
|
|
|
new OrgKdeDolphinMainWindowInterface(service, QStringLiteral("/dolphin/Dolphin_1"), QDBusConnection::sessionBus()));
|
|
|
|
if (interface->isValid() && !interface->lastError().isValid()) {
|
|
|
|
dolphinInterfaces.append(qMakePair(interface, QStringList()));
|
|
|
|
}
|
Add an option to show tabs from last time when Dolphin starts
Summary:
All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today
restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default.
The settings window is accordingly adjusted to be clear about what applies when:
{F7681752}
FEATURE: 413564
FIXED-IN: 20.08.0
Depends on D25106
Depends on D25219
Test Plan:
With the new setting turned off:
- No behavioral changes at all
With the new setting turned on:
- When launched from the GUI or CLI without any URLs, dolphin restores session
- When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here)
- When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session
- When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here)
- "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running
Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis
Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis
Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D11382
2019-07-19 17:52:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dolphinInterfaces;
|
|
|
|
}
|
2021-01-02 17:48:52 +00:00
|
|
|
|
2021-06-04 12:04:14 +00:00
|
|
|
QPair<QString, Qt::SortOrder> Dolphin::sortOrderForUrl(QUrl &url)
|
|
|
|
{
|
|
|
|
ViewProperties globalProps(url);
|
|
|
|
return QPair<QString, Qt::SortOrder>(globalProps.sortRole(), globalProps.sortOrder());
|
|
|
|
}
|
|
|
|
|
2021-01-02 17:48:52 +00:00
|
|
|
double GlobalConfig::animationDurationFactor()
|
|
|
|
{
|
|
|
|
if (s_animationDurationFactor >= 0.0) {
|
|
|
|
return s_animationDurationFactor;
|
|
|
|
}
|
|
|
|
// This is the first time this method is called.
|
|
|
|
auto kdeGlobalsConfig = KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("KDE"));
|
|
|
|
updateAnimationDurationFactor(kdeGlobalsConfig, {"AnimationDurationFactor"});
|
|
|
|
|
|
|
|
KConfigWatcher::Ptr configWatcher = KConfigWatcher::create(KSharedConfig::openConfig());
|
|
|
|
connect(configWatcher.data(), &KConfigWatcher::configChanged, &GlobalConfig::updateAnimationDurationFactor);
|
|
|
|
return s_animationDurationFactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GlobalConfig::updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names)
|
|
|
|
{
|
|
|
|
if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) {
|
|
|
|
s_animationDurationFactor = std::max(0.0, group.readEntry("AnimationDurationFactor", 1.0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double GlobalConfig::s_animationDurationFactor = -1.0;
|
2023-07-04 20:07:48 +00:00
|
|
|
|
|
|
|
#include "moc_global.cpp"
|