Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving screenshot is the wrong format (the one above in the list) #2270

Closed
mellon85 opened this issue Jan 17, 2022 · 14 comments
Closed

Saving screenshot is the wrong format (the one above in the list) #2270

mellon85 opened this issue Jan 17, 2022 · 14 comments
Labels
Bug It's a bug MacOS MacOS related
Milestone

Comments

@mellon85
Copy link

Flameshot Version

Flameshot v11.0.0 (ad1bf28)
Compiled with Qt 5.15.2
darwin: 20.6.0
osx: 11.6

Installation Type

Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)

Operating System type and version

Big Sur 11.6.2

Description

When saving a screenshot and I have to select the format it's always off-by-one. Starts with tiff selected and if saved it would save it as PNG, if I select jpeg it will be jp2 instead, etc etc

if I select the topmost (bitmap), it keeps using bitmap.

Steps to reproduce

  1. take any kind of screenshot
  2. press on save
  3. select a format, it will use the one above the selected

Screenshots or screen recordings

No response

System Information

MacOS Big Sur 11.6.2

@mellon85 mellon85 added the Unconfirmed Bug The bug is not confirmed by anyone else. label Jan 17, 2022
@borgmanJeremy borgmanJeremy added Bug It's a bug MacOS MacOS related and removed Unconfirmed Bug The bug is not confirmed by anyone else. labels Jan 17, 2022
@borgmanJeremy
Copy link
Contributor

Thanks, I can confirm this.

@AndreaMarangoni
Copy link
Contributor

I can take this

@borgmanJeremy
Copy link
Contributor

Great thanks for the help

@borgmanJeremy borgmanJeremy added this to the v11.1 milestone Jan 19, 2022
@AndreaMarangoni
Copy link
Contributor

This looks like a bug on Qt. Even the smallest of the sample has that issue.
The only fix I found is to don't use the native dialogs setting the option QFileDialog::Option::DontUseNativeDialog.
Thoughts?

@borgmanJeremy
Copy link
Contributor

If you have a very minimal example can you try building against a newer Qt version? Perhaps even Qt6? I dont really want to use the DontUseNativeDialog option, it makes the Dialog box look terrible on most platforms.

@AndreaMarangoni
Copy link
Contributor

AndreaMarangoni commented Jan 23, 2022

I have tried against QT 6.2.2 and it has the same behaviour unfortunately.
The non-native dialog might be ugly but it fixes the annoying behaviour. I guess a decent compromise :)
BTW i have already pushed a PR #2307 that fixes it. (Still in draft which I can convert when we make a decision)

EDIT: actually I think there is an alternative to keep the native dialog and get it working, which is to go through QFileDialog::getSaveFilename. This of course involves other costs, which are implementation time and chances to introduce other bugs. (I wouldn't recommend)

@borgmanJeremy
Copy link
Contributor

I wonder if it's a bug related to auto generating the file formats. In 10.2 we specifically enumerated a few types, but it 11 we auto generate all possible types. #2307 uses the non-native dialogs which we used once before to fix a small bug and got a significant amount of negative feedback.

This is the commit that changed the file format behavior: 3cad808

@AndreaMarangoni
Copy link
Contributor

Don't think so. I have created a new project which replicates what we are trying to do in production and tested with different versions of Qt.

This is the sample used.

#include <QFileDialog>
#include <QImageWriter>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    const QString extension{"png"};
    QString mimeFilter("image/png");
    auto toStringList = []() -> QStringList {
        QStringList mimeList;
        foreach(const auto & mime, QImageWriter::supportedMimeTypes())
        {
            mimeList.push_back(mime);
        }
        return mimeList;
    };
    const QStringList mimeFilters = toStringList();
    const QString file("/Users/andrea/workspace/randomName.png");
    QFileDialog dialog(nullptr, "Choose your image", file);
    dialog.setMimeTypeFilters(mimeFilters);
    dialog.setOptions(QFileDialog::Option::DontUseNativeDialog);
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.selectMimeTypeFilter(mimeFilter);
    if(QDialog::Accepted == dialog.exec())
    {
    }
    int ret = a.exec();
    return  ret;
}

@borgmanJeremy
Copy link
Contributor

Was this also a problem in 10.2 then?

@AndreaMarangoni
Copy link
Contributor

Completely different dialog..

Screenshot 2022-01-23 at 15 38 45

@borgmanJeremy
Copy link
Contributor

Did you try posting this on the Qt forums? Usually if you post a minimal example to demonstrate the issue they quickly help.

@AndreaSenseon
Copy link

I am not sure how they can help. I bet they will tell me to use non-native dialog option. It is clear that the behaviour is in Qt 5.x and Qt 6.x.
The alternatives are:

  • use NonNative dialogs (only for Mac) until Qt fixes the issue
  • use QFileDialog::getSaveFileName generating filters manually from QImageWriter
  • maybe using a custom QAbstractProxyModel ?

@AndreaMarangoni
Copy link
Contributor

I am not sure how they can help. I bet they will tell me to use non-native dialog option. It is clear that the behaviour is in Qt 5.x and Qt 6.x. The alternatives are:

  • use NonNative dialogs (only for Mac) until Qt fixes the issue
  • use QFileDialog::getSaveFileName generating filters manually from QImageWriter
  • maybe using a custom QAbstractProxyModel ?

sorry this was me with the wrong account if it wasn't obvious 😬

@borgmanJeremy
Copy link
Contributor

Solved with #2379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It's a bug MacOS MacOS related
Projects
None yet
Development

No branches or pull requests

4 participants