Commit b2967c9f authored by David Narváez's avatar David Narváez
Browse files

Add Extension to Filename to Save to Kig Format

Summary:
If the user chose to save in Kig format, then just add the extension
as there is no other way to save it.

CCBUG: 404366

Test Plan:
1) Save without extension (might need to disable the "Add .kig extension" box).
2) In the error dialog, select "Save Kig Format".
3) Filename should now have the .kig extension.
4) Repeat, but this time trying to save with a different extension than .kig.

Reviewers: #kde_edu, yurchor

Reviewed By: yurchor

Subscribers: yurchor, kde-edu

Tags: #kde_edu

Differential Revision: https://phabricator.kde.org/D26165
parent 63e4bc0f
......@@ -477,8 +477,26 @@ bool KigPart::saveFile()
"its own. Save to Kig's format instead?" ),
i18n( "Format Not Supported" ), KGuiItem( i18n( "Save Kig Format" ) ), KStandardGuiItem::cancel() ) == KMessageBox::No )
return false;
else
{
QFileInfo save( url().toLocalFile() );
QString extension = save.completeSuffix();
if ( extension.isEmpty() )
{
setUrl( QUrl::fromLocalFile( QString( "%1.kig" ).arg( save.absoluteFilePath() ) ) );
}
else
{
QString newFileName = save.absoluteFilePath();
newFileName.replace( newFileName.lastIndexOf( extension ), extension.length(), QLatin1String( "kig" ) );
setUrl( QUrl::fromLocalFile( newFileName ) );
}
}
internalSaveAs();
};
}
if ( KigFilters::instance()->save( document(), localFilePath() ) )
{
......
Supports Markdown
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