2020-08-25 17:07:38 +00:00
/*
* SPDX - FileCopyrightText : 2006 Peter Penz < peter . penz19 @ gmail . com >
* SPDX - FileCopyrightText : 2006 Stefan Monov < logixoul @ gmail . com >
* SPDX - FileCopyrightText : 2015 Mathieu Tarral < mathieu . tarral @ gmail . com >
*
* SPDX - License - Identifier : GPL - 2.0 - or - later
*/
2006-11-21 06:02:05 +00:00
2018-03-04 13:38:16 +00:00
# include "dbusinterface.h"
# include "dolphin_generalsettings.h"
2015-07-29 20:54:54 +00:00
# include "dolphin_version.h"
2018-03-04 13:38:16 +00:00
# include "dolphindebug.h"
2007-09-27 12:36:40 +00:00
# include "dolphinmainwindow.h"
2015-04-22 13:29:39 +00:00
# include "global.h"
2020-08-18 21:47:53 +00:00
# include "config-kuserfeedback.h"
# ifdef HAVE_KUSERFEEDBACK
# include "userfeedback/dolphinfeedbackprovider.h"
# endif
2007-09-27 12:36:40 +00:00
2015-02-04 09:22:03 +00:00
# include <KAboutData>
2015-11-14 21:37:40 +00:00
# include <KCrash>
2018-03-04 13:38:16 +00:00
# include <KDBusService>
2014-10-18 12:42:41 +00:00
# include <KLocalizedString>
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
# include <KConfigGui>
2020-12-19 06:45:52 +00:00
# include <KIO/PreviewJob>
2006-11-21 06:02:05 +00:00
2022-05-05 20:09:31 +00:00
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
# include <Kdelibs4ConfigMigrator>
# endif
2018-03-04 13:38:16 +00:00
# include <QApplication>
# include <QCommandLineParser>
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 <QDBusConnection>
# include <QDBusInterface>
# include <QDBusAbstractInterface>
# include <QDBusConnectionInterface>
2020-10-29 21:00:39 +00:00
# include <QSessionManager>
2018-03-04 13:38:16 +00:00
2017-02-19 01:32:48 +00:00
# ifndef Q_OS_WIN
# include <unistd.h>
# endif
# include <iostream>
2021-03-28 15:11:36 +00:00
int main ( int argc , char * * argv )
2006-11-21 06:02:05 +00:00
{
2017-02-19 01:32:48 +00:00
# ifndef Q_OS_WIN
Re-allow running Dolphin as the root user (but still not using sudo)
Summary:
Prohibiting the use of Dolphin as the actual root user (not using `sudo` or `kdesu`) breaks legitimate use cases for using the root user. An example is Kali, a distro that logs in as the root user by default as a deliberate design choice.
In such an environment, there is no additional security vulnerability beyond what you're already potentially exposing yourself to. So, let's re-enable it.
BUG: 387974
FIXED-IN: 18.08.0
Test Plan:
- Log in as normal user and run `sudo dolphin`: you get an error message.
- Log in as normal user and run `kdesu dolphin`: you get an error message.
- Log in as the root user and run dolphin normally: it works.
Reviewers: markg, elvisangelaccio, #dolphin
Reviewed By: markg
Subscribers: chinmoyr, cfeck, elvisangelaccio, mmustac, Fuchs, markg, graesslin, nicolasfella, zzag, kfm-devel, emmanuelp
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12795
2018-05-09 23:18:08 +00:00
// Prohibit using sudo or kdesu (but allow using the root user directly)
2017-02-19 01:32:48 +00:00
if ( getuid ( ) = = 0 ) {
Re-allow running Dolphin as the root user (but still not using sudo)
Summary:
Prohibiting the use of Dolphin as the actual root user (not using `sudo` or `kdesu`) breaks legitimate use cases for using the root user. An example is Kali, a distro that logs in as the root user by default as a deliberate design choice.
In such an environment, there is no additional security vulnerability beyond what you're already potentially exposing yourself to. So, let's re-enable it.
BUG: 387974
FIXED-IN: 18.08.0
Test Plan:
- Log in as normal user and run `sudo dolphin`: you get an error message.
- Log in as normal user and run `kdesu dolphin`: you get an error message.
- Log in as the root user and run dolphin normally: it works.
Reviewers: markg, elvisangelaccio, #dolphin
Reviewed By: markg
Subscribers: chinmoyr, cfeck, elvisangelaccio, mmustac, Fuchs, markg, graesslin, nicolasfella, zzag, kfm-devel, emmanuelp
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12795
2018-05-09 23:18:08 +00:00
if ( ! qEnvironmentVariableIsEmpty ( " SUDO_USER " ) ) {
2021-12-31 17:36:31 +00:00
std : : cout < < " Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities. "
" Instead use Dolphin normally and you will be prompted for elevated privileges when "
" performing file operations that require them. "
< < std : : endl ;
Re-allow running Dolphin as the root user (but still not using sudo)
Summary:
Prohibiting the use of Dolphin as the actual root user (not using `sudo` or `kdesu`) breaks legitimate use cases for using the root user. An example is Kali, a distro that logs in as the root user by default as a deliberate design choice.
In such an environment, there is no additional security vulnerability beyond what you're already potentially exposing yourself to. So, let's re-enable it.
BUG: 387974
FIXED-IN: 18.08.0
Test Plan:
- Log in as normal user and run `sudo dolphin`: you get an error message.
- Log in as normal user and run `kdesu dolphin`: you get an error message.
- Log in as the root user and run dolphin normally: it works.
Reviewers: markg, elvisangelaccio, #dolphin
Reviewed By: markg
Subscribers: chinmoyr, cfeck, elvisangelaccio, mmustac, Fuchs, markg, graesslin, nicolasfella, zzag, kfm-devel, emmanuelp
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12795
2018-05-09 23:18:08 +00:00
return EXIT_FAILURE ;
} else if ( ! qEnvironmentVariableIsEmpty ( " KDESU_USER " ) ) {
2021-12-31 17:36:31 +00:00
std : : cout < < " Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities. "
" Instead use Dolphin normally and you will be prompted for elevated privileges when "
" performing file operations that require them. "
< < std : : endl ;
Re-allow running Dolphin as the root user (but still not using sudo)
Summary:
Prohibiting the use of Dolphin as the actual root user (not using `sudo` or `kdesu`) breaks legitimate use cases for using the root user. An example is Kali, a distro that logs in as the root user by default as a deliberate design choice.
In such an environment, there is no additional security vulnerability beyond what you're already potentially exposing yourself to. So, let's re-enable it.
BUG: 387974
FIXED-IN: 18.08.0
Test Plan:
- Log in as normal user and run `sudo dolphin`: you get an error message.
- Log in as normal user and run `kdesu dolphin`: you get an error message.
- Log in as the root user and run dolphin normally: it works.
Reviewers: markg, elvisangelaccio, #dolphin
Reviewed By: markg
Subscribers: chinmoyr, cfeck, elvisangelaccio, mmustac, Fuchs, markg, graesslin, nicolasfella, zzag, kfm-devel, emmanuelp
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12795
2018-05-09 23:18:08 +00:00
return EXIT_FAILURE ;
}
2017-02-19 01:32:48 +00:00
}
# endif
2019-10-13 16:33:53 +00:00
/**
* enable high dpi support
*/
QCoreApplication : : setAttribute ( Qt : : AA_UseHighDpiPixmaps , true ) ;
QCoreApplication : : setAttribute ( Qt : : AA_EnableHighDpiScaling , true ) ;
2015-02-04 09:22:03 +00:00
QApplication app ( argc , argv ) ;
2016-11-22 16:55:34 +00:00
app . setWindowIcon ( QIcon : : fromTheme ( QStringLiteral ( " system-file-manager " ) , app . windowIcon ( ) ) ) ;
2015-04-27 11:01:18 +00:00
2020-12-19 06:45:52 +00:00
KIO : : PreviewJob : : setDefaultDevicePixelRatio ( app . devicePixelRatio ( ) ) ;
2015-11-14 21:37:40 +00:00
KCrash : : initialize ( ) ;
2022-05-05 20:09:31 +00:00
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
2015-02-06 08:32:39 +00:00
Kdelibs4ConfigMigrator migrate ( QStringLiteral ( " dolphin " ) ) ;
migrate . setConfigFiles ( QStringList ( ) < < QStringLiteral ( " dolphinrc " ) ) ;
migrate . setUiFiles ( QStringList ( ) < < QStringLiteral ( " dolphinpart.rc " ) < < QStringLiteral ( " dolphinui.rc " ) ) ;
migrate . migrate ( ) ;
2022-05-05 20:09:31 +00:00
# endif
2015-02-06 08:32:39 +00:00
2015-11-29 18:19:33 +00:00
KLocalizedString : : setApplicationDomain ( " dolphin " ) ;
2016-03-16 21:17:37 +00:00
KAboutData aboutData ( QStringLiteral ( " dolphin " ) , i18n ( " Dolphin " ) , QStringLiteral ( DOLPHIN_VERSION_STRING ) ,
2015-02-04 09:22:03 +00:00
i18nc ( " @title " , " File Manager " ) ,
KAboutLicense : : GPL ,
2018-11-11 18:00:24 +00:00
i18nc ( " @info:credit " , " (C) 2006-2018 Peter Penz, Frank Reininghaus, Emmanuel Pescosta and Elvis Angelaccio " ) ) ;
2019-12-06 19:41:33 +00:00
aboutData . setHomepage ( QStringLiteral ( " https://kde.org/applications/system/org.kde.dolphin " ) ) ;
2018-11-04 20:21:19 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Elvis Angelaccio " ) ,
i18nc ( " @info:credit " , " Maintainer (since 2018) and developer " ) ,
QStringLiteral ( " elvis.angelaccio@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Emmanuel Pescosta " ) ,
2018-11-04 20:21:19 +00:00
i18nc ( " @info:credit " , " Maintainer (2014-2018) and developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " emmanuelpescosta099@gmail.com " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Frank Reininghaus " ) ,
i18nc ( " @info:credit " , " Maintainer (2012-2014) and developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " frank78ac@googlemail.com " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Peter Penz " ) ,
i18nc ( " @info:credit " , " Maintainer and developer (2006-2012) " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " peter.penz19@gmail.com " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Sebastian Trüg " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " trueg@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " David Faure " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " faure@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Aaron J. Seigo " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " aseigo@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Rafael Fernández López " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " ereslibre@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Kevin Ottens " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " ervin@kde.org " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Holger Freyther " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " freyther@gmx.net " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Max Blazejak " ) ,
i18nc ( " @info:credit " , " Developer " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " m43ksrocks@gmail.com " ) ) ;
2015-02-04 09:22:03 +00:00
aboutData . addAuthor ( i18nc ( " @info:credit " , " Michael Austin " ) ,
i18nc ( " @info:credit " , " Documentation " ) ,
2016-03-16 21:17:37 +00:00
QStringLiteral ( " tuxedup@users.sourceforge.net " ) ) ;
2015-02-04 09:22:03 +00:00
KAboutData : : setApplicationData ( aboutData ) ;
QCommandLineParser parser ;
aboutData . setupCommandLine ( & parser ) ;
// command line options
2016-05-05 11:43:02 +00:00
parser . addOption ( QCommandLineOption ( QStringList ( ) < < QStringLiteral ( " select " ) , i18nc ( " @info:shell " , " The files and folders passed as arguments "
2015-02-04 09:22:03 +00:00
" will be selected. " ) ) ) ;
2016-03-16 21:17:37 +00:00
parser . addOption ( QCommandLineOption ( QStringList ( ) < < QStringLiteral ( " split " ) , i18nc ( " @info:shell " , " Dolphin will get started with a split view. " ) ) ) ;
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
parser . addOption ( QCommandLineOption ( QStringList ( ) < < QStringLiteral ( " new-window " ) , i18nc ( " @info:shell " , " Dolphin will explicitly open in a new window. " ) ) ) ;
2016-03-16 21:17:37 +00:00
parser . addOption ( QCommandLineOption ( QStringList ( ) < < QStringLiteral ( " daemon " ) , i18nc ( " @info:shell " , " Start Dolphin Daemon (only required for DBus Interface) " ) ) ) ;
parser . addPositionalArgument ( QStringLiteral ( " +[Url] " ) , i18nc ( " @info:shell " , " Document to open " ) ) ;
2015-02-04 09:22:03 +00:00
parser . process ( app ) ;
aboutData . processCommandLine ( & parser ) ;
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
const bool splitView = parser . isSet ( QStringLiteral ( " split " ) ) | | GeneralSettings : : splitView ( ) ;
const bool openFiles = parser . isSet ( QStringLiteral ( " select " ) ) ;
const QStringList args = parser . positionalArguments ( ) ;
QList < QUrl > urls = Dolphin : : validateUris ( args ) ;
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
// We later mutate urls, so we need to store if it was empty originally
const bool startedWithURLs = ! urls . 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
2016-03-16 21:17:37 +00:00
if ( parser . isSet ( QStringLiteral ( " daemon " ) ) ) {
2020-10-29 21:00:39 +00:00
// Disable session management for the daemonized version
// See https://bugs.kde.org/show_bug.cgi?id=417219
auto disableSessionManagement = [ ] ( QSessionManager & sm ) {
sm . setRestartHint ( QSessionManager : : RestartNever ) ;
} ;
QObject : : connect ( & app , & QGuiApplication : : commitDataRequest , disableSessionManagement ) ;
QObject : : connect ( & app , & QGuiApplication : : saveStateRequest , disableSessionManagement ) ;
2022-01-04 21:53:44 +00:00
# ifdef FLATPAK
KDBusService dolphinDBusService ( KDBusService : : NoExitOnFailure ) ;
# else
2019-09-02 21:13:52 +00:00
KDBusService dolphinDBusService ;
2022-01-04 21:53:44 +00:00
# endif
2019-09-02 21:13:52 +00:00
DBusInterface interface ;
2019-12-24 17:28:26 +00:00
interface . setAsDaemon ( ) ;
2015-04-22 13:29:39 +00:00
return app . exec ( ) ;
}
2015-02-04 09:22:03 +00:00
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 ( ! parser . isSet ( QStringLiteral ( " new-window " ) ) ) {
if ( Dolphin : : attachToExistingInstance ( urls , openFiles , splitView ) ) {
// Successfully attached to existing instance of Dolphin
return 0 ;
}
}
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
if ( ! startedWithURLs ) {
2019-06-22 13:44:11 +00:00
// We need at least one URL to open Dolphin
urls . append ( Dolphin : : homeUrl ( ) ) ;
}
2019-10-13 16:33:53 +00:00
2019-08-25 16:26:39 +00:00
if ( splitView & & urls . size ( ) < 2 ) {
// Split view does only make sense if we have at least 2 URLs
urls . append ( urls . last ( ) ) ;
}
2019-10-13 16:33:53 +00:00
2015-04-27 11:01:18 +00:00
DolphinMainWindow * mainWindow = new DolphinMainWindow ( ) ;
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 ( openFiles ) {
2015-04-27 11:01:18 +00:00
mainWindow - > openFiles ( urls , splitView ) ;
2015-04-27 10:55:53 +00:00
} else {
2015-04-27 11:01:18 +00:00
mainWindow - > openDirectories ( urls , splitView ) ;
2015-02-04 09:22:03 +00:00
}
2015-04-27 11:01:18 +00:00
mainWindow - > show ( ) ;
2015-02-04 09:22:03 +00:00
2021-07-09 08:32:04 +00:00
// Allow starting Dolphin on a system that is not running DBus:
KDBusService : : StartupOptions serviceOptions = KDBusService : : Multiple ;
if ( ! QDBusConnection : : sessionBus ( ) . isConnected ( ) ) {
serviceOptions | = KDBusService : : NoExitOnFailure ;
}
KDBusService dolphinDBusService ( serviceOptions ) ;
2020-07-19 14:02:02 +00:00
DBusInterface interface ;
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
if ( ! app . isSessionRestored ( ) ) {
KConfigGui : : setSessionConfig ( QStringLiteral ( " dolphin " ) , QStringLiteral ( " dolphin " ) ) ;
}
// Only restore session if:
2020-10-06 18:16:25 +00:00
// 1. Not explicitly opening a new instance
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
// 2. The "remember state" setting is enabled or session restoration after
// reboot is in use
// 3. There is a session available to restore
2020-10-06 18:16:25 +00:00
if ( ! parser . isSet ( QStringLiteral ( " new-window " ) )
& & ( app . isSessionRestored ( ) | | GeneralSettings : : rememberOpenedTabs ( ) )
) {
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
// Get saved state data for the last-closed Dolphin instance
const QString serviceName = QStringLiteral ( " org.kde.dolphin-%1 " ) . arg ( QCoreApplication : : applicationPid ( ) ) ;
if ( Dolphin : : dolphinGuiInstances ( serviceName ) . size ( ) > 0 ) {
const QString className = KXmlGuiWindow : : classNameOfToplevel ( 1 ) ;
if ( className = = QLatin1String ( " DolphinMainWindow " ) ) {
mainWindow - > restore ( 1 ) ;
2020-10-06 18:16:25 +00:00
// If the user passed any URLs to Dolphin, open those in the
// window after session-restoring it
if ( startedWithURLs ) {
2021-07-31 19:31:49 +00:00
if ( openFiles ) {
mainWindow - > openFiles ( urls , splitView ) ;
} else {
mainWindow - > openDirectories ( urls , splitView ) ;
}
2020-10-06 18:16:25 +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
} else {
qCWarning ( DolphinDebug ) < < " Unknown class " < < className < < " in session saved data! " ;
}
2012-12-05 20:44:06 +00:00
}
2007-04-09 19:12:54 +00:00
}
2007-09-27 12:36:40 +00:00
2020-08-18 21:47:53 +00:00
# ifdef HAVE_KUSERFEEDBACK
auto feedbackProvider = DolphinFeedbackProvider : : instance ( ) ;
Q_UNUSED ( feedbackProvider )
# endif
2015-02-04 09:22:03 +00:00
return app . exec ( ) ; // krazy:exclude=crash;
2007-09-27 12:36:40 +00:00
}