Bug 396679 - Open Album in Terminal
Summary: Open Album in Terminal
Status: RESOLVED INTENTIONAL
Alias: None
Product: digikam
Classification: Applications
Component: Albums-MainView (show other bugs)
Version: 5.9.0
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-19 22:01 UTC by Kusi
Modified: 2022-01-02 13:02 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.5.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kusi 2018-07-19 22:01:12 UTC
A right-click on an album should offer the option to open the album in a terminal, the same way as it offers to open the album in a file manager.

Some old discussions in https://bugs.kde.org/show_bug.cgi?id=158507
According to https://bugs.kde.org/show_bug.cgi?id=322117, this was once available? Was this functionality removed?
Comment 1 caulier.gilles 2018-07-21 06:45:13 UTC
This feature have been removed because the quick way to provide the functionality through KF5 is not portable and rely to KIO which is not portable.
Comment 2 Kusi 2018-07-21 10:15:05 UTC
Is is a pity that the functionality of digikam has to suffer due to portability. 

would you accept a patch with conditional compiler directives such that KIO code is only compiled if the target is KDE?
Comment 3 caulier.gilles 2018-07-21 11:58:47 UTC
To be honest, we need a better solution, more portable.

KIO will work only with Plasma desktop. What's about Gnome and other plenty desktop under Linux ? KIO is not only a simple shared libs, there are many run-time dependencies which make an unsolvable puzzle. I know, i tried to embed KIO in digiKam Appimage, and after one week, i left the idea. It's impossible...

So typically, a solution to start a simple terminal opening the current selected album is the right way. Remember : MacOS which has a BSD terminal, and Windows with the older CMD MSDOS like terminal...

Gilles Caulier
Comment 4 Kusi 2018-07-22 14:09:51 UTC
I investigated a bit the problem of launching a terminal cross platform

The following code snippet allows to handle the case of KDE, but it should be easy to extend it for various desktop environments. I just guessed the values for GNOME, I didn't test for GNOME

    QByteArray env = qgetenv("XDG_CURRENT_DESKTOP");
    QString desktopEnvironment = QString::fromLocal8Bit(env.data());
    QMap<QString, QString> terminals;
    terminals["KDE"] = "konsole";
    terminals["GNOME"] = "gnome-shell";
    terminals["WINDOWS"] = "cmd.exe";

    if (terminals.contains(desktopEnvironment))
    {
        QProcess *process = new QProcess(this);
        QString terminal = terminals[desktopEnvironment];
        QString folder = "/share/pictures";
        process->setWorkingDirectory(folder);
        process->start(terminal);
    }

While getting the current platform (linux/win/osx) seems straight forward with either QSysInfo or https://wiki.qt.io/Get_OS_name, it is tricky to get the desktop environment, but it is still feasible w/o too much hassle:

https://stackoverflow.com/questions/47022134/how-can-i-find-out-at-runtime-which-desktop-environment-that-a-qt-application

Remember, if the terminal is not available, the option is just disabled. It doesn't have to exist for every exotic desktop environment

what do you think?
Comment 5 caulier.gilles 2018-07-22 14:54:48 UTC
This first approach sound acceptable.

Look also the Qtbase approach, even if it use a wrong way with KDE and KIO, and it's a little bit complicated.

At least all most important cases are processed, and it must work with MacOS:

https://github.com/qt/qtbase/blob/5.11/src/platformsupport/services/genericunix/qgenericunixservices.cpp#L78

You can certainly take few ideas from this code.

Gilles Caulier