Commit bb58f9f1 authored by David Faure's avatar David Faure
Browse files

Port to KFileCustomDialog

Summary: Thanks Laurent for writing that class :-)

Test Plan: File dialog looks good again. Tested saving a 8-bit PNG, worked.

Reviewers: tcanabrava, broulik, pino, andreagenor

Reviewed By: broulik

Differential Revision: https://phabricator.kde.org/D26645
parent 39e3b58d
......@@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
project(kolourpaint VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION "5.11.0")
set(KF5_MIN_VERSION "5.58.0")
set(KF5_MIN_VERSION "5.67.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
......@@ -336,6 +336,7 @@ add_executable(kolourpaint ${kolourpaint_SRCS})
target_link_libraries(kolourpaint
KF5::XmlGui
KF5::KIOFileWidgets
KF5::TextWidgets
Qt5::PrintSupport
${KSANE_LIBRARIES}
......
......@@ -55,6 +55,7 @@
#include <kactioncollection.h>
#include <KSharedConfig>
#include <kconfiggroup.h>
#include <KFileCustomDialog>
#include <KPluralHandlingSpinBox>
#include <kmessagebox.h>
#include <krecentfilesaction.h>
......@@ -881,27 +882,21 @@ QUrl kpMainWindow::askForSaveURL (const QString &caption,
docMetaInfo,
this);
QFileDialog fd(this);
fd.setAcceptMode (QFileDialog::AcceptSave);
fd.setOption (QFileDialog::DontUseNativeDialog);
fd.setDirectoryUrl (QUrl (startURL));
KFileCustomDialog fd (QUrl (startURL), this);
fd.setOperationMode (KFileWidget::Saving);
fd.setWindowTitle (caption);
fd.setMimeTypeFilters (mimeTypes);
fd.selectMimeTypeFilter (fdSaveOptions.mimeType ());
fd.setCustomWidget (saveOptionsWidget);
KFileWidget *fw = fd.fileWidget();
fw->setConfirmOverwrite (true);
fw->setMimeFilter (mimeTypes, fdSaveOptions.mimeType ());
if (localOnly) {
fd.setSupportedSchemes ({QStringLiteral("file")});
fw->setMode (KFile::File | KFile::LocalOnly);
}
// insert the checkbox below the filter box
if (QGridLayout* gl = qobject_cast<QGridLayout*>(fd.layout ())) {
gl->addWidget (saveOptionsWidget, gl->rowCount (), 0, 1, gl->columnCount ());
}
saveOptionsWidget->setVisualParent (&fd);
connect (&fd, &QFileDialog::filterSelected,
this, [saveOptionsWidget, &fd]() {
saveOptionsWidget->setMimeType(fd.selectedMimeTypeFilter());
});
connect (fw, &KFileWidget::filterChanged,
saveOptionsWidget, &kpDocumentSaveOptionsWidget::setMimeType);
if ( fd.exec() == QDialog::Accepted )
{
......@@ -922,7 +917,7 @@ QUrl kpMainWindow::askForSaveURL (const QString &caption,
*chosenSaveOptions = newSaveOptions;
}
const QList<QUrl> selectedUrls = fd.selectedUrls ();
const QList<QUrl> selectedUrls = fw->selectedUrls ();
if (selectedUrls.isEmpty()) { // shouldn't happen
return {};
}
......
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