Commit ba201a7c authored by Alexander Volkov's avatar Alexander Volkov Committed by Alexander Volkov
Browse files

Get rid of workaround that prevents file dialog from being blocked

Summary:
Invisible proxy QDialog blocks input when the native dialog is shown,
and the workaround is to show the native file dialog with a delay.
But it's not needed since Qt 5.13 after the
QPlatformDialogHelper::DialogIsQtWindow hint was introduced.
parent 137bf194
......@@ -203,8 +203,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
KDirOperator *op = fw->dirOperator();
QCOMPARE(fileViewToString(op->viewMode()), fileViewToString(KFile::Tree));
fw->setViewMode(KFile::Simple);
......@@ -233,8 +231,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......@@ -248,8 +244,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......@@ -264,8 +258,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......@@ -279,8 +271,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......@@ -373,8 +363,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->setUrl(dir);
fw->slotCancel();
......@@ -386,8 +374,6 @@ private Q_SLOTS:
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
QCOMPARE(dialog.directoryUrl().adjusted(QUrl::StripTrailingSlash), dir);
fw->slotCancel();
......
......@@ -50,8 +50,6 @@ private Q_SLOTS:
fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......@@ -69,8 +67,6 @@ private Q_SLOTS:
fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->slotCancel();
}
......
......@@ -22,20 +22,6 @@
KDEPlatformFileDialogBase::KDEPlatformFileDialogBase()
{
m_timer.setInterval(0);
m_timer.setSingleShot(true);
connect(&m_timer, &QTimer::timeout, this, &KDEPlatformFileDialogBase::show);
}
void KDEPlatformFileDialogBase::delayedShow()
{
m_timer.start();
}
void KDEPlatformFileDialogBase::discardDelayedShow()
{
// this is used when hide() is called before timer triggers.
m_timer.stop();
}
void KDEPlatformFileDialogBase::closeEvent(QCloseEvent *e)
......
......@@ -23,7 +23,6 @@
#include <QDialog>
#include <QUrl>
#include <QTimer>
class QDialogButtonBox;
class KDEPlatformFileDialogBase : public QDialog
......@@ -43,9 +42,6 @@ public:
virtual QString currentFilterText() = 0;
virtual QList<QUrl> selectedFiles() = 0;
void delayedShow();
void discardDelayedShow();
Q_SIGNALS:
void closed();
void fileSelected(const QUrl &file);
......@@ -57,7 +53,6 @@ Q_SIGNALS:
protected:
void closeEvent(QCloseEvent *e) override;
QDialogButtonBox *m_buttons;
QTimer m_timer;
};
#endif
......@@ -347,16 +347,11 @@ void KDEPlatformFileDialogHelper::initializeDialog()
void KDEPlatformFileDialogHelper::exec()
{
restoreSize();
// KDEPlatformFileDialog::show() will always be called during QFileDialog::exec()
// discard the delayed show() it and use exec() and it will call show() for us.
// We can't hide and show it here because of https://bugreports.qt.io/browse/QTBUG-48248
m_dialog->discardDelayedShow();
m_dialog->exec();
}
void KDEPlatformFileDialogHelper::hide()
{
m_dialog->discardDelayedShow();
m_dialog->hide();
}
......@@ -389,14 +384,19 @@ bool KDEPlatformFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowMo
m_dialog->setWindowModality(windowModality);
restoreSize();
m_dialog->windowHandle()->setTransientParent(parent);
// Use a delayed show here to delay show() after the internal Qt invisible QDialog.
// The delayed call shouldn't matter, because for other "real" native QPlatformDialog
// implementation like Mac and Windows, the native dialog is not necessarily
// show up immediately.
m_dialog->delayedShow();
m_dialog->show();
return true;
}
QVariant KDEPlatformFileDialogHelper::styleHint(StyleHint hint) const
{
if (hint == DialogIsQtWindow) {
return true;
}
return QPlatformDialogHelper::styleHint(hint);
}
QList<QUrl> KDEPlatformFileDialogHelper::selectedFiles() const
{
return m_dialog->selectedFiles();
......
......@@ -74,6 +74,8 @@ public:
void hide() override;
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override;
QVariant styleHint(StyleHint hint) const override;
private Q_SLOTS:
void saveSize();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment