Commit dc36d85f authored by Halla Rempt's avatar Halla Rempt
Browse files

Select the mimetype of split images by default to the mimetype of the current image

BUG:373077
parent b19050f8
......@@ -28,7 +28,7 @@
#include <kis_image.h>
#include <kis_paint_device.h>
DlgImagesplit::DlgImagesplit(KisViewManager* view, QString suffix, QStringList listMimeFilter)
DlgImagesplit::DlgImagesplit(KisViewManager* view, const QString &suffix, QStringList listMimeFilter, int defaultMimeIndex)
: KoDialog(view->mainWindow())
{
......@@ -47,8 +47,8 @@ DlgImagesplit::DlgImagesplit(KisViewManager* view, QString suffix, QStringList l
resize(m_page->sizeHint());
m_page->cmbFileType->clear();
m_page->cmbFileType->addItems(listMimeFilter);
m_page->cmbFileType->setCurrentIndex(0);
cmbIndex = 0;
m_page->cmbFileType->setCurrentIndex(defaultMimeIndex);
cmbIndex = defaultMimeIndex;
connect(m_page->chkAutoSave, SIGNAL(stateChanged(int)), SLOT(lineEditEnable()));
connect(m_page->cmbFileType, SIGNAL(activated(int)), this, SLOT(setMimeType(int)));
......
......@@ -39,7 +39,7 @@ class DlgImagesplit: public KoDialog
public:
DlgImagesplit(KisViewManager* view, QString suffix, QStringList listMimeType);
DlgImagesplit(KisViewManager* view, const QString &suffix, QStringList listMimeType, int defaultMimeIndex);
~DlgImagesplit();
bool autoSave();
int horizontalLines();
......
......@@ -100,19 +100,27 @@ void Imagesplit::slotImagesplit()
// Getting all mime types and converting them into names which are displayed at combo box
QStringList listMimeFilter = KisImportExportManager::mimeFilter(KisImportExportManager::Export);
QString defaultMime = QString::fromLatin1(m_view->document()->mimeType());
int defaultMimeIndex = 0;
listMimeFilter.sort();
QStringList filteredMimeTypes;
QStringList listFileType;
int i = 0;
Q_FOREACH (const QString & mimeType, listMimeFilter) {
listFileType.append(KisMimeDatabase::descriptionForMimeType(mimeType));
filteredMimeTypes.append(mimeType);
if (mimeType == defaultMime) {
defaultMimeIndex = i;
}
i++;
}
listMimeFilter = filteredMimeTypes;
Q_ASSERT(listMimeFilter.size() == listFileType.size());
DlgImagesplit *dlgImagesplit = new DlgImagesplit(m_view, suffix, listFileType);
DlgImagesplit *dlgImagesplit = new DlgImagesplit(m_view, suffix, listFileType, defaultMimeIndex);
dlgImagesplit->setObjectName("Imagesplit");
Q_CHECK_PTR(dlgImagesplit);
......@@ -173,11 +181,7 @@ void Imagesplit::slotImagesplit()
KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::SaveFile, "OpenDocument");
dialog.setCaption(i18n("Save Image on Split"));
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
QStringList mimeFilter = m_view->document()->importExportManager()->mimeFilter(KisImportExportManager::Export);
QString defaultMime = QString::fromLatin1(m_view->document()->mimeType());
dialog.setMimeTypeFilters(mimeFilter, defaultMime);
dialog.setMimeTypeFilters(listMimeFilter, defaultMime);
QUrl url = QUrl::fromUserInput(dialog.filename());
......
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