diff --git a/qimgv/core.cpp b/qimgv/core.cpp index 47f8c1f8..114d7253 100644 --- a/qimgv/core.cpp +++ b/qimgv/core.cpp @@ -855,9 +855,11 @@ std::shared_ptr Core::getEditableImage(const QString &filePath) { } template -void Core::edit_template(bool save, const std::function, Args...)>& editFunc, Args&&... as) { +void Core::edit_template(bool save, QString action, const std::function, Args...)>& editFunc, Args&&... as) { if(model->isEmpty()) return; + if(save && !mw->showConfirmation(action, "Perform action \""+ action +"\"? \n\nChanges will be saved immediately.")) + return; for(auto path : currentSelection()) { auto img = getEditableImage(path); if(!img) @@ -874,31 +876,33 @@ void Core::edit_template(bool save, const std::functioncurrentViewMode() == MODE_FOLDERVIEW), { ImageLib::flippedH }); + edit_template((mw->currentViewMode() == MODE_FOLDERVIEW), "Flip horizontal", { ImageLib::flippedH }); } void Core::flipV() { - edit_template((mw->currentViewMode() == MODE_FOLDERVIEW), { ImageLib::flippedV }); + edit_template((mw->currentViewMode() == MODE_FOLDERVIEW), "Flip vertical", { ImageLib::flippedV }); } void Core::rotateByDegrees(int degrees) { - edit_template((mw->currentViewMode() == MODE_FOLDERVIEW), { ImageLib::rotated }, degrees); + edit_template((mw->currentViewMode() == MODE_FOLDERVIEW), "Rotate", { ImageLib::rotated }, degrees); } void Core::resize(QSize size) { - edit_template(false, { ImageLib::scaled }, size, QI_FILTER_BILINEAR); + edit_template(false, "Resize", { ImageLib::scaled }, size, QI_FILTER_BILINEAR); } void Core::crop(QRect rect) { if(mw->currentViewMode() == MODE_FOLDERVIEW) return; - edit_template(false, { ImageLib::cropped }, rect); + edit_template(false, "Crop", { ImageLib::cropped }, rect); } void Core::cropAndSave(QRect rect) { if(mw->currentViewMode() == MODE_FOLDERVIEW) return; - edit_template(true, { ImageLib::cropped }, rect); + edit_template(false, "Crop", { ImageLib::cropped }, rect); + saveFile(selectedPath()); + updateInfoString(); } // ---------------------------------------------------------------- image operations ^ diff --git a/qimgv/core.h b/qimgv/core.h index 77998577..26ed4248 100644 --- a/qimgv/core.h +++ b/qimgv/core.h @@ -86,7 +86,7 @@ public slots: QList currentSelection(); template - void edit_template(bool save, const std::function, Args...)>& func, Args&&... as); + void edit_template(bool save, QString actionName, const std::function, Args...)>& func, Args&&... as); void doInteractiveCopy(QString path, QString destDirectory, DialogResult &overwriteAllFiles); void doInteractiveMove(QString path, QString destDirectory, DialogResult &overwriteAllFiles);