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 "dbusinterface.h"
|
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
|
|
|
#include "dolphin_generalsettings.h"
|
2023-02-03 17:14:53 +00:00
|
|
|
#include "global.h"
|
2015-04-22 13:29:39 +00:00
|
|
|
|
|
|
|
#include <KPropertiesDialog>
|
2021-08-20 09:31:36 +00:00
|
|
|
#include <KWindowSystem>
|
2018-03-04 13:38:16 +00:00
|
|
|
|
|
|
|
#include <QDBusConnection>
|
2018-09-17 10:02:51 +00:00
|
|
|
#include <QDBusConnectionInterface>
|
2015-04-22 13:29:39 +00:00
|
|
|
|
2023-02-03 17:14:53 +00:00
|
|
|
DBusInterface::DBusInterface()
|
|
|
|
: QObject()
|
2015-04-22 13:29:39 +00:00
|
|
|
{
|
2023-02-03 17:14:53 +00:00
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"),
|
|
|
|
this,
|
|
|
|
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
2021-07-09 08:30:58 +00:00
|
|
|
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
|
|
|
if (sessionInterface) {
|
|
|
|
sessionInterface->registerService(QStringLiteral("org.freedesktop.FileManager1"), QDBusConnectionInterface::QueueService);
|
|
|
|
}
|
2015-04-22 13:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-02-03 17:14:53 +00:00
|
|
|
void DBusInterface::ShowFolders(const QStringList &uriList, const QString &startUpId)
|
2015-04-22 13:29:39 +00:00
|
|
|
{
|
|
|
|
const QList<QUrl> urls = Dolphin::validateUris(uriList);
|
|
|
|
if (urls.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-24 17:28:26 +00:00
|
|
|
const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
|
2023-02-03 17:14:53 +00:00
|
|
|
if (!Dolphin::attachToExistingInstance(urls, false, GeneralSettings::splitView(), serviceName, startUpId)) {
|
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
|
|
|
Dolphin::openNewWindow(urls);
|
|
|
|
}
|
2015-04-22 13:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-02-03 17:14:53 +00:00
|
|
|
void DBusInterface::ShowItems(const QStringList &uriList, const QString &startUpId)
|
2015-04-22 13:29:39 +00:00
|
|
|
{
|
|
|
|
const QList<QUrl> urls = Dolphin::validateUris(uriList);
|
|
|
|
if (urls.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-24 17:28:26 +00:00
|
|
|
const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
|
2023-02-03 17:14:53 +00:00
|
|
|
if (!Dolphin::attachToExistingInstance(urls, true, GeneralSettings::splitView(), serviceName, startUpId)) {
|
2019-06-23 11:22:41 +00:00
|
|
|
Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select);
|
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
|
|
|
};
|
2015-04-22 13:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-02-03 17:14:53 +00:00
|
|
|
void DBusInterface::ShowItemProperties(const QStringList &uriList, const QString &startUpId)
|
2015-04-22 13:29:39 +00:00
|
|
|
{
|
|
|
|
const QList<QUrl> urls = Dolphin::validateUris(uriList);
|
2015-04-27 11:41:57 +00:00
|
|
|
if (!urls.isEmpty()) {
|
2021-08-20 09:31:36 +00:00
|
|
|
KWindowSystem::setCurrentXdgActivationToken(startUpId);
|
2015-04-27 11:41:57 +00:00
|
|
|
KPropertiesDialog::showDialog(urls);
|
2015-04-22 13:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-24 17:28:26 +00:00
|
|
|
|
2021-06-04 12:04:14 +00:00
|
|
|
void DBusInterface::SortOrderForUrl(const QString &url, QString &role, QString &order)
|
|
|
|
{
|
|
|
|
QUrl qurl(url);
|
|
|
|
auto sort = Dolphin::sortOrderForUrl(qurl);
|
|
|
|
role = sort.first;
|
|
|
|
if (sort.second == Qt::AscendingOrder) {
|
|
|
|
order = QStringLiteral("ascending");
|
|
|
|
} else {
|
|
|
|
order = QStringLiteral("descending");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-24 17:28:26 +00:00
|
|
|
void DBusInterface::setAsDaemon()
|
|
|
|
{
|
|
|
|
m_isDaemon = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DBusInterface::isDaemon() const
|
|
|
|
{
|
|
|
|
return m_isDaemon;
|
|
|
|
}
|
2023-07-04 20:07:48 +00:00
|
|
|
|
|
|
|
#include "moc_dbusinterface.cpp"
|