diff --git a/rsc/VivyRessources.qrc b/rsc/VivyRessources.qrc index 9078302c70ef82f2cf1a5eda9c0d82fc0b3ec51a..f86514d871aa19755d64bb9729a9771dad6b6240 100644 --- a/rsc/VivyRessources.qrc +++ b/rsc/VivyRessources.qrc @@ -33,6 +33,7 @@ <file alias="document-open.svg">icons/breeze-dark/document-open.svg</file> <file alias="document-save.svg">icons/breeze-dark/document-save.svg</file> <file alias="document-save-as.svg">icons/breeze-dark/document-save-as.svg</file> + <file alias="document-rename.svg">icons/breeze-dark/edit-rename.svg</file> <file alias="folder.svg">icons/breeze-dark/folder.svg</file> <file alias="text-x-generic.svg">icons/breeze-dark/text-x-generic.svg</file> <file alias="help-about.svg">icons/breeze-dark/help-about.svg</file> @@ -45,6 +46,7 @@ <file alias="document-open.svg">icons/breeze-light/document-open.svg</file> <file alias="document-save.svg">icons/breeze-light/document-save.svg</file> <file alias="document-save-as.svg">icons/breeze-light/document-save-as.svg</file> + <file alias="document-rename.svg">icons/breeze-light/edit-rename.svg</file> <file alias="folder.svg">icons/breeze-light/folder.svg</file> <file alias="text-x-generic.svg">icons/breeze-light/text-x-generic.svg</file> <file alias="help-about.svg">icons/breeze-light/help-about.svg</file> diff --git a/rsc/icons/breeze-dark/edit-rename.svg b/rsc/icons/breeze-dark/edit-rename.svg new file mode 100644 index 0000000000000000000000000000000000000000..6a844965eafca88604c3705f6f364bfc2ad28b52 --- /dev/null +++ b/rsc/icons/breeze-dark/edit-rename.svg @@ -0,0 +1,13 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"> + <defs id="defs3051"> + <style type="text/css" id="current-color-scheme"> + .ColorScheme-Text { + color:#eff0f1; + } + </style> + </defs> + <path style="fill:currentColor;fill-opacity:1;stroke:none" + d="M 10.398438 2 L 5.2871094 7.1113281 L 2 10.398438 L 2 14 L 5.6015625 14 L 14 5.6015625 L 10.398438 2 z M 8.3496094 5.4902344 L 10.509766 7.6503906 L 7.3359375 10.826172 L 7.3359375 10.150391 L 6.3222656 10.171875 L 5.2871094 10.171875 L 5.2871094 9.1367188 L 5.2871094 8.5507812 L 6.7285156 7.1113281 L 8.3496094 5.4902344 z M 4.2734375 9.5644531 L 4.2734375 11.185547 L 5.3085938 11.185547 L 6.3007812 11.185547 L 6.3222656 11.837891 L 5.2421875 12.919922 L 3.8007812 12.919922 L 3.0800781 12.199219 L 3.0800781 10.757812 L 4.2734375 9.5644531 z " + class="ColorScheme-Text" + /> +</svg> diff --git a/rsc/icons/breeze-light/edit-rename.svg b/rsc/icons/breeze-light/edit-rename.svg new file mode 100644 index 0000000000000000000000000000000000000000..18ccc58a83cd18f21997fafe18029787255f6117 --- /dev/null +++ b/rsc/icons/breeze-light/edit-rename.svg @@ -0,0 +1,13 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"> + <defs id="defs3051"> + <style type="text/css" id="current-color-scheme"> + .ColorScheme-Text { + color:#232629; + } + </style> + </defs> + <path style="fill:currentColor;fill-opacity:1;stroke:none" + d="M 10.398438 2 L 5.2871094 7.1113281 L 2 10.398438 L 2 14 L 5.6015625 14 L 14 5.6015625 L 10.398438 2 z M 8.3496094 5.4902344 L 10.509766 7.6503906 L 7.3359375 10.826172 L 7.3359375 10.150391 L 6.3222656 10.171875 L 5.2871094 10.171875 L 5.2871094 9.1367188 L 5.2871094 8.5507812 L 6.7285156 7.1113281 L 8.3496094 5.4902344 z M 4.2734375 9.5644531 L 4.2734375 11.185547 L 5.3085938 11.185547 L 6.3007812 11.185547 L 6.3222656 11.837891 L 5.2421875 12.919922 L 3.8007812 12.919922 L 3.0800781 12.199219 L 3.0800781 10.757812 L 4.2734375 9.5644531 z " + class="ColorScheme-Text" + /> +</svg> diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc index d4a72f7f7365b39fabb42be3412ba0f4847a4e01..40263baa1259dda92736b778972b38c66257895f 100644 --- a/src/UI/MainWindow.cc +++ b/src/UI/MainWindow.cc @@ -62,6 +62,7 @@ MainWindow::MainWindow() noexcept DCL_ACTION(openDocument, "&Open document", "Open a document", file); DCL_ACTION(saveFile, "&Save file", "Save the current document", file); DCL_ACTION(saveFileAs, "&Save file as", "Save the current document as", file); + DCL_ACTION(renameFile, "&Rename the file", "Rename the current document", file); fileMenu->addSeparator(); DCL_ACTION(loadSubDocumentAudio, "&Load audio", "Load an audio file as a sub-document", file); DCL_ACTION(loadSubDocumentVideo, "&Load video", "Load a vide file as a sub-document", file); @@ -73,6 +74,7 @@ MainWindow::MainWindow() noexcept ACTION_ADD_ICON(openDocument, VIVY_ICON_OPEN); ACTION_ADD_ICON(saveFile, VIVY_ICON_SAVE); ACTION_ADD_ICON(saveFileAs, VIVY_ICON_SAVE_AS); + ACTION_ADD_ICON(renameFile, VIVY_ICON_RENAME); ACTION_ADD_ICON(openDialogHelp, VIVY_ICON_ABOUT); ACTION_ADD_SHORTCUT(newDocument, QKeySequence::New); @@ -238,7 +240,6 @@ MainWindow::saveFile() noexcept { try { const auto document = getCurrentDocument(); - qDebug() << "Request to save the document" << document->getName(); document->save(); } @@ -247,19 +248,42 @@ MainWindow::saveFile() noexcept } } +void +MainWindow::renameFile() noexcept +{ + try { + const auto docView = getCurrentDocumentView(); + auto document = docView->getDocument(); + const QString filename = + dialogSaveFileName("Select the target file to rename the current file to", + QDir::homePath(), Utils::getVivyDocumentFileSuffixFilter()); + + if (filename.isEmpty()) + throw std::runtime_error("No filename passed"); + + else { + document->rename(filename); // Kubat: Save is called by rename! + emit docView->documentPropertyChanged(); + } + } + + catch (const std::runtime_error &e) { + qCritical() << "Failed to save current document:" << e.what(); + } +} + void MainWindow::saveFileAs() noexcept { try { const auto docView = getCurrentDocumentView(); auto document = docView->getDocument(); - qDebug() << "Request to save the document" << document->getName(); const QString filename = dialogSaveFileName("Select the target file to save into", QDir::homePath(), Utils::getVivyDocumentFileSuffixFilter()); if (filename.isEmpty()) - qWarning() << "Found an empty filename, don't open a file"; + throw std::runtime_error("No filename passed"); else { document->copy(filename); // Kubat: Save is called by copy! diff --git a/src/UI/MainWindow.hh b/src/UI/MainWindow.hh index 9f4c3d66411c8b1b2e858ac79c7e91e4e490a3aa..251e5afd83e245ca3baeb7250a1e643c90c6925a 100644 --- a/src/UI/MainWindow.hh +++ b/src/UI/MainWindow.hh @@ -92,6 +92,7 @@ private slots: void saveFile() noexcept; void saveFileAs() noexcept; + void renameFile() noexcept; void openDialogHelp() noexcept; diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index 3826063a9838fcb173a0dcc0ff72b6575ce3d5ec..4c98c7b36f39795c86a06b664fe4a646a7d4e7c3 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -16,6 +16,7 @@ #define VIVY_ICON_NEW ":icons/dark/document-new.svg" #define VIVY_ICON_SAVE ":icons/dark/document-save.svg" #define VIVY_ICON_SAVE_AS ":icons/dark/document-save-as.svg" +#define VIVY_ICON_RENAME ":icons/dark/document-rename.svg" #define VIVY_ICON_ABOUT ":icons/dark/help-about.svg" #define VIVY_ICON_FILE ":icons/dark/text-x-generic.svg" #define VIVY_ICON_FOLDER ":icons/dark/folder.svg"