Commit 94745b55 authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Cancelling save/loadLayoutFile dialog should not show an error dialog

Also, add .json to save filename if missing.
parent ecddbd11
Pipeline #213687 passed with stage
in 3 minutes and 4 seconds
......@@ -1006,8 +1006,18 @@ QJsonObject saveSessionsRecurse(QSplitter *splitter)
void ViewManager::saveLayoutFile()
{
QFile file(QFileDialog::getSaveFileName(this->widget(), i18nc("@title:window", "Save File"), QStringLiteral("~/"), i18nc("@item:inlistbox", "Konsole View Layout (*.json)")));
QString fileName(QFileDialog::getSaveFileName(this->widget(), i18nc("@title:window", "Save File"), QStringLiteral("~/"), i18nc("@item:inlistbox", "Konsole View Layout (*.json)")));
// User pressed cancel in dialog
if (fileName.isEmpty()) {
return;
}
if (!fileName.endsWith(QStringLiteral(".json"))) {
fileName.append(QStringLiteral(".json"));
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
KMessageBox::error(this->widget(), i18nc("@label:textbox", "A problem occurred when saving the Layout.\n%1", file.fileName()));
}
......@@ -1062,6 +1072,11 @@ ViewSplitter *restoreSessionsSplitterRecurse(const QJsonObject &jsonSplitter, Vi
} // namespace
void ViewManager::loadLayout(QString file)
{
// User pressed cancel in dialog
if (file.isEmpty()) {
return;
}
QFile jsonFile(file);
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
......
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