Commit 333e1d16 authored by Martin Koller's avatar Martin Koller
Browse files

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
parent 015d25f5
......@@ -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;
......
/*
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();
}
}
......
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