flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
25.04k stars 1.6k forks source link

Flatpak Flameshot does not append the File Name while saving a screenshot #2455

Open brennoflavio opened 2 years ago

brennoflavio commented 2 years ago

Flameshot Version

Flameshot v11.0.0 () Compiled with Qt 5.15.3

Installation Type

Flatpak from Flathub

Operating System type and version

Ubuntu 20.04

Description

Flameshot Flatpak application does not append the file name configured while saving the screenshot. For example, that's the file dialog from Flameshot installed with apt:

image

Same action with the app from Flathub:

image

Both with default settings:

image

I tested Appimage it appends the file name while saving. I tested Snap too, and it seems to have the same problem.

While writing this report, I also noticed that when saving the prompt to save the file does not came to focus automatically, it opens in the background and I have to bring it to the front.

I'm no Flatpak expert but maybe some wrong configuration in that package?

Steps to reproduce

  1. Install Flameshot from Flathub
  2. Take a screenshot
  3. Save it
  4. Notice that the file name is empty

Screenshots or screen recordings

Screenshots attached at the Description

System Information

  1. Ubuntu 20.04 LTS, latest stable update

  2. image

  3. Gnome on Xorg

mmahmoudian commented 2 years ago

Thank you for filling the bug report form throughly, highly appreciated.

I'll try to reproduce it and will report back.

mmahmoudian commented 2 years ago

Seems it is related to:

brennoflavio commented 2 years ago

Yep, seems duplicate of that. Don't know if I should close this but I posted my locale as asked in the other issue.

mmahmoudian commented 2 years ago

@brennoflavio I don't think it is a locale issue, plus #1563 is already closed. Let's keep yours open and investigate this.

mmahmoudian commented 2 years ago

I can confirm this issue. I additionally found out that the flameshot.ini is not saved in ~/.config/flameshot/flameshot.ini but rather ~/.var/app/org.flameshot.Flameshot/config/flameshot/flameshot.ini, and also it does not respect the config if it is put into ~/.config/flameshot/flameshot.ini

image

brennoflavio commented 2 years ago

I was testing Fedora in a VM for other reasons and I can confirm that this bug happens there too. So it seems to no be Ubuntu specific

2022-02-25_16-52

allen-munsch commented 2 years ago
12:56:07 jm@pop-os pycharm_projects → uname -a
Linux pop-os 5.15.15-76051515-generic #202201160435~1642693824~21.10~97db1bb SMP Thu Jan 20 17:35:05 U x86_64 x86_64 x86_64 GNU/Linux
12:56:16 jm@pop-os pycharm_projects → lsb_release -a
No LSB modules are available.
Distributor ID: Pop
Description:    Pop!_OS 21.10
Release:    21.10
Codename:   impish
12:56:30 jm@pop-os pycharm_projects → flatpak permission-show org.flameshot.Flameshot
Table      Object     App                     Permissions Data
background background org.flameshot.Flameshot yes         0x00
12:56:36 jm@pop-os pycharm_projects → flatpak info org.flameshot.Flameshot

Flameshot - Powerful and simple to use screenshot software

          ID: org.flameshot.Flameshot
         Ref: app/org.flameshot.Flameshot/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 11.0.0
     License: GPL-3.0-or-later
      Origin: flathub
  Collection: org.flathub.Stable
Installation: user
   Installed: 2.8 MB
     Runtime: org.kde.Platform/x86_64/5.15-21.08
         Sdk: org.kde.Sdk/x86_64/5.15-21.08

      Commit: 250d82d5a6a8fcbe75de5a44de5b355320d9e2c214f2bfc8541a8b9f3268424f
      Parent: e0f4b7633f0096b75c6eb5e130bba7efb7e273157f77bca19242f23a228968a1
     Subject: Remove desktop file Exec entry workaround (8392c3d0)
        Date: 2022-04-04 15:18:32 +0000
12:56:48 jm@pop-os pycharm_projects → locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
12:57:20 jm@pop-os propertymeld ±|AA-1566-jm-1|→ flatpak run org.flameshot.Flameshot
Gtk-Message: 12:57:26.608: Failed to load module "appmenu-gtk-module"
Gtk-Message: 12:57:26.648: Failed to load module "canberra-gtk-module"
Gtk-Message: 12:57:26.648: Failed to load module "canberra-gtk-module"
Qt: Session management error: None of the authentication protocols specified are supported
12:59:57 jm@pop-os pycharm_projects → cat ~/.var/app/org.flameshot.Flameshot/config/flameshot/flameshot.ini 
[General]
contrastOpacity=188
copyPathAfterSave=false
saveAfterCopy=true

01:35:51 jm@pop-os pycharm_projects → flatpak install flathub runtime/org.kde.Sdk/x86_64/5.15-21.08
Looking for matches…
Skipping: org.kde.Sdk/x86_64/5.15-21.08 is already installed

01:36:11 jm@pop-os pycharm_projects → flatpak run --command=sh --devel org.flameshot.Flameshot
[📦 org.flameshot.Flameshot pycharm_projects]$ 

[📦 org.flameshot.Flameshot pycharm_projects]$ strace -f -e trace=openat  /app/bin/flameshot 
###############
# see attached strace.output.txt for full output
##########
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/data/glib-2.0/schemas/gschemas.compiled", O_RDONLY) = -1 ENOENT (No such file or directory)
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/glib-2.0/settings/keyfile", O_RDONLY) = -1 ENOENT (No such file or directory)

pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//4b0f8a2f69fe591da6cf9ff3308b18f7-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//3eeb9704d03ee6bfbb929403ad74d343-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//b22b90fdf4563fea331de48403585522-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//875d4a635e6464d43159092165235734-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//837925ea37305e78fcd318895b10beb4-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//c77457bdf8575c9b4f7db532f5fb2731-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//5575733b988c81ea4aee12dd1e9922ae-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//fac6e0fd3dca2b0f3a8f92e82df7a0b0-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//65246acf7b047ace76882834c8dd2b2b-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//9fc7b40e74ed2496586b37ae9afd9040-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//7fa031c915e9679fa65815a70ba98f05-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//74d0a551fa0bc862b18d63efa79db368-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//98da798065853957722c26aa2d89b85c-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//1525dd66e04c88134bdbbbee070a2a0a-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//bb92a29f07323623b9f39340e339d8ae-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//9acafef3b16749a65aed566e0ba9af6a-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//02c3d2a553cc0a59ef9c1e729da08704-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//fd8c5faa9ac016c40f4ec2f6f02b470c-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//568a4c66ae3fc5937d7dd9ed7c8549b8-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//5444c839c9c3852ba53e582b11cd38ce-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//f99dcca06ebfb397cca895ef342a96f8-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//7f3b0cb35adb2148104801a88c4bce88-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//d14b16cd56ebc708ae7eb1646b8304f1-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//6a7a596cbb94802f9a1ba62a5a1f82f6-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//bf0a3891f0439c1a81d8ffa3883642d3-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//692215c8d58ef8cefcd4d24244ff920b-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/fontconfig//0ddbdbd750e3249d438f72b69cb90ce5-le64.cache-7", O_RDONLY|O_CLOEXEC) = 16

pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/flameshot/flameshot.ini", O_RDONLY|O_CLOEXEC) = 16

pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/cache/mesa_shader_cache/index", O_RDWR|O_CREAT|O_CLOEXEC, 0644) = 31
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/user-dirs.dirs", O_RDONLY|O_CLOEXEC) = 31
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/QtProject.conf", O_RDONLY|O_CLOEXEC) = 31
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/QtProject.conf", O_RDWR|O_CREAT|O_CLOEXEC, 0666) = 32
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config/QtProject.conf.lock", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 32
pid 119: openat(AT_FDCWD, "/home/jm/.var/app/org.flameshot.Flameshot/config", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = 33

SEE: strace.output.txt

[📦 org.flameshot.Flameshot pycharm_projects]$ find $XYZ -type f | xargs -I{} sh -c "echo && echo {} && echo && cat {}"

/home/jm/.var/app/org.flameshot.Flameshot/config/user-dirs.dirs

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"

/home/jm/.var/app/org.flameshot.Flameshot/config/QtProject.conf

[FileDialog]
history=@Invalid()
lastVisited=file:///home/jm/Pictures
qtVersion=5.15.3
viewMode=Detail

/home/jm/.var/app/org.flameshot.Flameshot/config/flameshot/flameshot.ini

[General]
contrastOpacity=188
copyPathAfterSave=false
saveAfterCopy=true
allen-munsch commented 2 years ago

I was able to get the filepath to "auto save" to the configured path, by enabling

Which appears to skip the ShowSaveFileDialog:

        savePath = ShowSaveFileDialog(QObject::tr("Save screenshot"), savePath);

enable this

( and IMO, I think this is a better default, than having to look at the file dialogue each time, but that assumes the user know's how to enable/disable and has it's own set of issues, etc, I didn't know it existed until I started debugging )

2022-04-10_14-11

    if (!config.savePathFixed()) {
        savePath = ShowSaveFileDialog(QObject::tr("Save screenshot"), savePath);
    }
    if (savePath == "") {
        return okay;
    }

    QFile file{ savePath };
    file.open(QIODevice::WriteOnly);

    okay = capture.save(&file);

    if (okay) {
        QString pathNoFile =
          savePath.left(savePath.lastIndexOf(QLatin1String("/")));

        ConfigHandler().setSavePath(pathNoFile);

        QString msg = QObject::tr("Capture saved as ") + savePath;
        AbstractLogger().attachNotificationPath(savePath) << msg;

        if (config.copyPathAfterSave()) {
            FlameshotDaemon::copyToClipboard(
              savePath, QObject::tr("Path copied to clipboard as ") + savePath);
        }

    }

I'm wondering if adding : https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName

To ShowSaveFileDialog might work?

I've never developed anything with QT, but hopefully this get's us a bit closer to narrowing down what the issue might be?

borgmanJeremy commented 2 years ago

I dug into this last night and I strongly suspect it is a bug in the version of the GTK native dialog that Qt is using. We can test this whenever the next flatpak kde layer is released.

madhur commented 2 years ago

Seeing the same issue

Flameshot v12.0.0 ()
Compiled with Qt 5.15.5
linux: 5.16.2-1.el8.elrepo.x86_64
org.kde.Platform: 5.15-21.08
mmahmoudian commented 2 years ago

Might be related to #1563 and #2703

allen-munsch commented 2 years ago

Just updated and checked again

Flameshot v12.0.0 ()
Compiled with Qt 5.15.5
linux: 5.17.5-76051705-generic
org.kde.Platform: 5.15-21.08

Still seeing it as well.

The Use fixed path workaround works as expected as flameshot'd previously

Although the KDE flatpak version wasn't bumped ( kde.Sdk/x86_64/5.15-21.08 ) so didn't really address what was mentioned already:

allen-munsch commented 2 years ago

just for posterity I found the Qt bug tracker here: https://bugreports.qt.io/browse/?jql=status%20in%20(Reported%2C%20%22Need%20More%20Info%22%2C%20Open%2C%20%22In%20Progress%22%2C%20Reopened%2C%20Accepted%2C%20%22To%20Do%22%2C%20Blocked%2C%20Backlog)%20AND%20text%20~%20%22native%20dialog%20filename%22

mmahmoudian commented 2 years ago

@borgmanJeremy considering your comment and @allen-munsch comment, should this be considered as upstream issue?

borgmanJeremy commented 2 years ago

Yes I think so

BentHaase commented 1 year ago

Is there any way to get this fixed / worked around? I think we can assume that this upstream bug of 8 years (!) does not look like it's going to be fixed any time soon.

What's interesting is, that this has not been an issue with flameshot up until some older release.

allen-munsch commented 1 year ago

@BentHaase i was able to find a work around here: https://github.com/flameshot-org/flameshot/issues/2455#issuecomment-1094352760 by enabling fixed path for screenshots save

Marlliton commented 1 year ago

I was able to get the filepath to "auto save" to the configured path, by enabling

* `savePathFixed`

Which appears to skip the ShowSaveFileDialog:

        savePath = ShowSaveFileDialog(QObject::tr("Save screenshot"), savePath);

enable this

( and IMO, I think this is a better default, than having to look at the file dialogue each time, but that assumes the user know's how to enable/disable and has it's own set of issues, etc, I didn't know it existed until I started debugging )

2022-04-10_14-11

    if (!config.savePathFixed()) {
        savePath = ShowSaveFileDialog(QObject::tr("Save screenshot"), savePath);
    }
    if (savePath == "") {
        return okay;
    }

    QFile file{ savePath };
    file.open(QIODevice::WriteOnly);

    okay = capture.save(&file);

    if (okay) {
        QString pathNoFile =
          savePath.left(savePath.lastIndexOf(QLatin1String("/")));

        ConfigHandler().setSavePath(pathNoFile);

        QString msg = QObject::tr("Capture saved as ") + savePath;
        AbstractLogger().attachNotificationPath(savePath) << msg;

        if (config.copyPathAfterSave()) {
            FlameshotDaemon::copyToClipboard(
              savePath, QObject::tr("Path copied to clipboard as ") + savePath);
        }

    }

I'm wondering if adding : https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName

To ShowSaveFileDialog might work?

I've never developed anything with QT, but hopefully this get's us a bit closer to narrowing down what the issue might be?

It worked for me perfectly.

allen-munsch commented 1 year ago

@BentHaase also, for some reason the link included the ticket that I was last looking at, I only meant to link the qt bug tracker not that ticket in particular. sorry about that.

hubyhuby commented 10 months ago

Samething with the Ubuntu SNAP installation. You can set the autonaming of files, but if you want it to work you need to select "fixed path". So you cannot modify the name at saving.

If you do not select "fixed path" than you have the option to type a name for the file, but the field is empty and doesn t take the autonaming defined.

image

AndrewSav commented 7 months ago

Happy two years anniversary! Still not working though ;(