Bug 334963 - Spawning a KDE file picker dialog via Qt Quick Dialogs fails
Summary: Spawning a KDE file picker dialog via Qt Quick Dialogs fails
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Maarten De Meyer
URL:
Keywords:
: 344586 345002 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-05-17 22:13 UTC by Eike Hein
Modified: 2015-07-19 07:19 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Hein 2014-05-17 22:13:53 UTC
I wasn't able to locate Bugzilla product for the frameworksintegration repository, so I'm using KIO as the next best thing - please reassign as appropriate.

Qt Quick contains a Dialogs module that offers QML API wrappers around common system dialogs, such as file pickers: http://doc-snapshot.qt-project.org/qt5-stable/qtquick-dialogs-qmlmodule.html

Here's a minimal example from the documentation that can be saved as a .qml file and launched using qmlscene:

import QtQuick 2.2
import QtQuick.Dialogs 1.0

FileDialog {
    id: fileDialog
    title: "Please choose a file"
    onAccepted: {
        console.log("You chose: " + fileDialog.fileUrls)
        Qt.quit()
    }
    onRejected: {
        console.log("Canceled")
        Qt.quit()
    }
    Component.onCompleted: visible = true
}

It doesn't work. There's KDE-related debug output on the terminal so things do get as far as our platform plugin code somehow, but the dialog won't actually appear (though the visible property does change state).

The FontDialog example from the same Qt Quick module works fine.



Reproducible: Always
Comment 1 Maarten De Meyer 2014-10-02 19:44:29 UTC
Yes, it seems like we still need a bugzilla category for frameworkintegration.
https://git.reviewboard.kde.org/r/120467/
Comment 2 luigide 2014-10-08 20:36:01 UTC
Same here.
also opened there:
https://bugreports.qt-project.org/browse/QTBUG-41333
Comment 3 Shawn Rutledge 2014-10-09 13:19:40 UTC
Here is the problem:

bool KDEPlatformFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
    initializeDialog();
    m_dialog->setWindowFlags(windowFlags);
    m_dialog->setModal(windowModality != Qt::NonModal);
    if (windowModality == Qt::NonModal) {
        m_dialog->show();
...

The QtQuick FileDialog is window modal by default.  That is not a reason to avoid showing it.  Unlike widget-based applications, QtQuick applications cannot call QDialog::exec().  So the modality is just meant to request the window manager to make the window behave as a modal one.

So I tried taking out the "if".  That makes it work OK with QtQuick.  Then I tried qtbase/examples/widgets/dialogs/standarddialogs.  If I call any of the static methods (e.g. getOpenFileName()), the dialog appears but is non-interactive, so I can't actually choose a file.

We don't have this problem with plain QFileDialog or with any other native dialogs on other platforms, so I'm confident that it can be fixed.
Comment 4 Jeremy Whiting 2014-11-10 18:44:53 UTC
Before david ran astyle on that code it used to also call m_dialog->exec() if the dialog was supposed to be modal.

With the change here: https://git.reviewboard.kde.org/r/121098/ the QML case works again, but when I try the stanarddialogs test the static methods are making the dialog appear twice in a row for some reason.
Comment 5 Maarten De Meyer 2014-11-10 21:43:42 UTC
(In reply to Jeremy Whiting from comment #4)
> With the change here: https://git.reviewboard.kde.org/r/121098/ the QML case
> works again, but when I try the stanarddialogs test the static methods are
> making the dialog appear twice in a row for some reason.

That's because m_dialog->exec() is called twice. Once here and once in KDEPlatformFileDialogHelper::exec()

Thank you for looking into this.
Comment 6 Jeremy Whiting 2014-11-10 21:52:49 UTC
Ok, I confirm I get the same result as you if I just remove the if (that does solve the qml usage also, but when using standarddialogs test the ui shows up but isn't interactive...)
Comment 7 Jeremy Whiting 2015-03-17 01:15:45 UTC
*** Bug 344586 has been marked as a duplicate of this bug. ***
Comment 8 Lukáš Tinkl 2015-03-17 14:22:05 UTC
Git commit 9814e4b773b2b34afafa0c5d242594bbb4f9a6ae by Lukáš Tinkl.
Committed on 17/03/2015 at 14:20.
Pushed by lukas into branch 'master'.

fix native modal file dialogs in QML
REVIEW: 120467

M  +4    -5    src/platformtheme/kdeplatformfiledialoghelper.cpp

http://commits.kde.org/frameworkintegration/9814e4b773b2b34afafa0c5d242594bbb4f9a6ae
Comment 9 Lukáš Tinkl 2015-03-26 16:02:01 UTC
*** Bug 345002 has been marked as a duplicate of this bug. ***
Comment 10 Cjacker 2015-07-19 07:19:11 UTC
I encounter a problem about  filedialog popping up in some qt apps, for example, designer, baka-mplayer  with qt-5.5.0, framework-5.12, plasma-5.3.2.

It's very easy to reproduce: open filedialog, press 'ESC', again and again, finally(three or four times) the filedialog popup(since 'ESC' key works) but not visible. the main interface of application locked(since it's a modal dialog).

As i remember, with qt-5.4.2 also had this problem. 

At first, I think it belongs to kwin, after tried openbox, there is no improvement.

I also tried the git codes of frameworkintegration, the problem remains.


Here is the fix.
--- frameworkintegration-5.12.0/src/platformtheme/kdeplatformfiledialoghelper.cpp   2015-07-05 08:51:22.000000000 +0000
+++ frameworkintegration-5.12.0n/src/platformtheme/kdeplatformfiledialoghelper.cpp  2015-07-19 14:57:46.891751979 +0000
@@ -303,6 +303,7 @@
     m_dialog->show();
     KSharedConfig::Ptr conf = KSharedConfig::openConfig();
     KWindowConfig::restoreWindowSize(m_dialog->windowHandle(), conf->group("FileDialogSize"));
+    m_dialog->resize(m_dialog->windowHandle()->size());
     return true;
 }