Commit c87209c4 authored by Laurent Montel's avatar Laurent Montel 😁 Committed by David Faure

Fix typo + use direct

"KDirSelectDialog* dialog = new KDirSelectDialog(options()->initialDirectory());"
as David told me
parent 08001333
......@@ -40,7 +40,6 @@
#include <QPushButton>
#include <QWindow>
#include <QTextStream>
namespace
{
......@@ -279,9 +278,18 @@ void KDEPlatformFileDialogHelper::initializeDialog()
m_dialogInitialized = true;
if (options()->testOption(QFileDialogOptions::ShowDirsOnly)) {
m_dialog->deleteLater();
m_dialog = new KDirSelectDialog(options()->initialDirectory());
connect(m_dialog, &QDialog::accepted, this, &QPlatformDialogHelper::accept);
connect(m_dialog, &QDialog::rejected, this, &QPlatformDialogHelper::reject);
KDirSelectDialog *dialog = new KDirSelectDialog(options()->initialDirectory());
m_dialog = dialog;
connect(dialog, &QDialog::accepted, this, &QPlatformDialogHelper::accept);
connect(dialog, &QDialog::rejected, this, &QPlatformDialogHelper::reject);
if (options()->isLabelExplicitlySet(QFileDialogOptions::Accept)) { // OK button
dialog->setOkButtonText(options()->labelText(QFileDialogOptions::Accept));
} else if (options()->isLabelExplicitlySet(QFileDialogOptions::Reject)) { // Cancel button
dialog->setCancelButtonText(options()->labelText(QFileDialogOptions::Reject));
} else if (options()->isLabelExplicitlySet(QFileDialogOptions::LookIn)) { // Location label
//Not implemented yet.
}
if (!options()->windowTitle().isEmpty())
m_dialog->setWindowTitle(options()->windowTitle());
} else {
......
......@@ -564,6 +564,16 @@ QList<QUrl> KDirSelectDialog::selectedFiles()
return QList<QUrl>() << url();
}
void KDirSelectDialog::setOkButtonText(const QString &text)
{
m_buttons->button(QDialogButtonBox::Ok)->setText(text);
}
void KDirSelectDialog::setCancelButtonText(const QString &text)
{
m_buttons->button(QDialogButtonBox::Cancel)->setText(text);
}
void KDirSelectDialog::setDirectory(const QUrl &directory)
{
setCurrentUrl(directory);
......
......@@ -106,6 +106,8 @@ public:
QString currentFilterText() override;
QList<QUrl> selectedFiles() override;
void setOkButtonText(const QString &text);
void setCancelButtonText(const QString &text);
public Q_SLOTS:
/**
* Sets the current @p url in the dialog.
......
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