summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Koller <kollix@aon.at>2016-09-02 07:51:38 (GMT)
committerMartin Koller <kollix@aon.at>2016-09-02 07:51:38 (GMT)
commit333e1d16efe138d3618f5ec4ecfd6008c7b6a848 (patch)
tree5bae88e1aae7e68367f078f1b9d0b9c70f658adf
parent015d25f5db41b06e27227372917564b413a46b14 (diff)
Fix handling of commandline filename argument when given relative path
When a relative path was given as argument, an invalid QUrl was used, leading to not opening the file. Fixed that. Also when a non-existing filename was given, we now detect the mime-type by the filename extension so that saving this file will correctly do so. BUG: 368131 FIXED-IN: 16.08.1
-rw-r--r--document/kpDocument_Open.cpp21
-rw-r--r--kolourpaint.cpp5
2 files changed, 18 insertions, 8 deletions
diff --git a/document/kpDocument_Open.cpp b/document/kpDocument_Open.cpp
index 65cc2d4..d900560 100644
--- a/document/kpDocument_Open.cpp
+++ b/document/kpDocument_Open.cpp
@@ -48,6 +48,7 @@
#include <qcolor.h>
#include <qimage.h>
+#include <QMimeDatabase>
#include "kpLogCategories.h"
#include <kimageio.h>
@@ -200,13 +201,21 @@ void kpDocument::openNew (const QUrl &url)
m_image->fill(QColor(Qt::white).rgb());
setURL (url, false/*not from url*/);
- // TODO: Maybe we should guess the mimetype from "url"'s filename
- // extension.
- //
- // That way "kolourpaint doesnotexist.bmp" would automatically
- // select the BMP file format when the save dialog comes up for
- // the first time.
+
*m_saveOptions = kpDocumentSaveOptions ();
+
+ if ( !url.isEmpty() )
+ {
+ // guess the mimetype from url's filename extension.
+ //
+ // That way "kolourpaint doesnotexist.bmp" automatically
+ // selects the BMP file format when the save dialog comes up for
+ // the first time.
+
+ QMimeDatabase mimeDb;
+ m_saveOptions->setMimeType(mimeDb.mimeTypeForUrl(url).name());
+ }
+
*m_metaInfo = kpDocumentMetaInfo ();
m_modified = false;
diff --git a/kolourpaint.cpp b/kolourpaint.cpp
index a7be98d..1541d1c 100644
--- a/kolourpaint.cpp
+++ b/kolourpaint.cpp
@@ -1,6 +1,6 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
- Copyright (c) 2015 Martin Koller <kollix@aon.at>
+ Copyright (c) 2015,2016 Martin Koller <kollix@aon.at>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
#include <QApplication>
#include <QCommandLineParser>
+#include <QDir>
#include <KLocalizedString>
int main(int argc, char *argv [])
@@ -105,7 +106,7 @@ int main(int argc, char *argv [])
{
for (int i = 0; i < args.count(); i++)
{
- mainWindow = new kpMainWindow(QUrl::fromUserInput(args[i]));
+ mainWindow = new kpMainWindow(QUrl::fromUserInput(args[i], QDir::currentPath(), QUrl::AssumeLocalFile));
mainWindow->show();
}
}