Changeset View
Changeset View
Standalone View
Standalone View
mainWindow/kpMainWindow_File.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | #include <QImageReader> | 50 | #include <QImageReader> | ||
51 | #include <QImageWriter> | 51 | #include <QImageWriter> | ||
52 | #include <QMimeDatabase> | 52 | #include <QMimeDatabase> | ||
53 | #include <QPrintPreviewDialog> | 53 | #include <QPrintPreviewDialog> | ||
54 | 54 | | |||
55 | #include <kactioncollection.h> | 55 | #include <kactioncollection.h> | ||
56 | #include <KSharedConfig> | 56 | #include <KSharedConfig> | ||
57 | #include <kconfiggroup.h> | 57 | #include <kconfiggroup.h> | ||
58 | #include <KFileCustomDialog> | ||||
58 | #include <KPluralHandlingSpinBox> | 59 | #include <KPluralHandlingSpinBox> | ||
59 | #include <kmessagebox.h> | 60 | #include <kmessagebox.h> | ||
60 | #include <krecentfilesaction.h> | 61 | #include <krecentfilesaction.h> | ||
61 | #include <kstandardshortcut.h> | 62 | #include <kstandardshortcut.h> | ||
62 | #include <kstandardaction.h> | 63 | #include <kstandardaction.h> | ||
63 | #include <ktoolinvocation.h> | 64 | #include <ktoolinvocation.h> | ||
64 | #include <KLocalizedString> | 65 | #include <KLocalizedString> | ||
65 | 66 | | |||
▲ Show 20 Lines • Show All 810 Lines • ▼ Show 20 Line(s) | |||||
876 | #endif | 877 | #endif | ||
877 | 878 | | |||
878 | auto *saveOptionsWidget = | 879 | auto *saveOptionsWidget = | ||
879 | new kpDocumentSaveOptionsWidget (imageToBeSaved, | 880 | new kpDocumentSaveOptionsWidget (imageToBeSaved, | ||
880 | fdSaveOptions, | 881 | fdSaveOptions, | ||
881 | docMetaInfo, | 882 | docMetaInfo, | ||
882 | this); | 883 | this); | ||
883 | 884 | | |||
884 | QFileDialog fd(this); | 885 | KFileCustomDialog fd (QUrl (startURL), this); | ||
885 | fd.setAcceptMode (QFileDialog::AcceptSave); | 886 | fd.setOperationMode (KFileWidget::Saving); | ||
886 | fd.setOption (QFileDialog::DontUseNativeDialog); | | |||
887 | fd.setDirectoryUrl (QUrl (startURL)); | | |||
888 | fd.setWindowTitle (caption); | 887 | fd.setWindowTitle (caption); | ||
889 | fd.setMimeTypeFilters (mimeTypes); | 888 | fd.setCustomWidget (saveOptionsWidget); | ||
890 | fd.selectMimeTypeFilter (fdSaveOptions.mimeType ()); | 889 | KFileWidget *fw = fd.fileWidget(); | ||
890 | fw->setConfirmOverwrite (true); | ||||
891 | fw->setMimeFilter (mimeTypes, fdSaveOptions.mimeType ()); | ||||
891 | if (localOnly) { | 892 | if (localOnly) { | ||
892 | fd.setSupportedSchemes ({QStringLiteral("file")}); | 893 | fw->setMode (KFile::File | KFile::LocalOnly); | ||
893 | } | 894 | } | ||
894 | 895 | | |||
895 | // insert the checkbox below the filter box | | |||
896 | if (QGridLayout* gl = qobject_cast<QGridLayout*>(fd.layout ())) { | | |||
897 | gl->addWidget (saveOptionsWidget, gl->rowCount (), 0, 1, gl->columnCount ()); | | |||
898 | } | | |||
899 | saveOptionsWidget->setVisualParent (&fd); | 896 | saveOptionsWidget->setVisualParent (&fd); | ||
900 | 897 | | |||
901 | connect (&fd, &QFileDialog::filterSelected, | 898 | connect (fw, &KFileWidget::filterChanged, | ||
902 | this, [saveOptionsWidget, &fd]() { | 899 | saveOptionsWidget, &kpDocumentSaveOptionsWidget::setMimeType); | ||
903 | saveOptionsWidget->setMimeType(fd.selectedMimeTypeFilter()); | | |||
904 | }); | | |||
905 | 900 | | |||
906 | if ( fd.exec() == QDialog::Accepted ) | 901 | if ( fd.exec() == QDialog::Accepted ) | ||
907 | { | 902 | { | ||
908 | kpDocumentSaveOptions newSaveOptions = saveOptionsWidget->documentSaveOptions (); | 903 | kpDocumentSaveOptions newSaveOptions = saveOptionsWidget->documentSaveOptions (); | ||
909 | #if DEBUG_KP_MAIN_WINDOW | 904 | #if DEBUG_KP_MAIN_WINDOW | ||
910 | newSaveOptions.printDebug ("\tnewSaveOptions"); | 905 | newSaveOptions.printDebug ("\tnewSaveOptions"); | ||
911 | #endif | 906 | #endif | ||
912 | 907 | | |||
913 | KConfigGroup cfg (KSharedConfig::openConfig (), forcedSaveOptionsGroup); | 908 | KConfigGroup cfg (KSharedConfig::openConfig (), forcedSaveOptionsGroup); | ||
914 | 909 | | |||
915 | // Save options user forced - probably want to use them in future | 910 | // Save options user forced - probably want to use them in future | ||
916 | kpDocumentSaveOptions::saveDefaultDifferences (cfg, | 911 | kpDocumentSaveOptions::saveDefaultDifferences (cfg, | ||
917 | fdSaveOptions, newSaveOptions); | 912 | fdSaveOptions, newSaveOptions); | ||
918 | cfg.sync (); | 913 | cfg.sync (); | ||
919 | 914 | | |||
920 | 915 | | |||
921 | if (chosenSaveOptions) { | 916 | if (chosenSaveOptions) { | ||
922 | *chosenSaveOptions = newSaveOptions; | 917 | *chosenSaveOptions = newSaveOptions; | ||
923 | } | 918 | } | ||
924 | 919 | | |||
925 | const QList<QUrl> selectedUrls = fd.selectedUrls (); | 920 | const QList<QUrl> selectedUrls = fw->selectedUrls (); | ||
926 | if (selectedUrls.isEmpty()) { // shouldn't happen | 921 | if (selectedUrls.isEmpty()) { // shouldn't happen | ||
927 | return {}; | 922 | return {}; | ||
928 | } | 923 | } | ||
929 | const QUrl selectedUrl = selectedUrls.at(0); | 924 | const QUrl selectedUrl = selectedUrls.at(0); | ||
930 | 925 | | |||
931 | if (allowLossyPrompt) | 926 | if (allowLossyPrompt) | ||
932 | { | 927 | { | ||
933 | // SYNC: kpDocumentSaveOptions elements - everything except quality | 928 | // SYNC: kpDocumentSaveOptions elements - everything except quality | ||
▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines |