diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index bc62c753..6c22948d 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -177,6 +177,7 @@ QMenuBar *ActionManager::buildMenuBar(QWidget *parent) addCloneOfAction(fileMenu, "open"); addCloneOfAction(fileMenu, "openurl"); fileMenu->addMenu(buildRecentsMenu(true, fileMenu)); + addCloneOfAction(fileMenu, "reloadfile"); fileMenu->addSeparator(); #ifdef Q_OS_MACOS fileMenu->addSeparator(); @@ -585,6 +586,8 @@ void ActionManager::actionTriggered(QAction *triggeredAction, MainWindow *releva relevantWindow->openWith(openWithItem); } else if (key == "openurl") { relevantWindow->pickUrl(); + } else if (key == "reloadfile") { + relevantWindow->reloadFile(); } else if (key == "opencontainingfolder") { relevantWindow->openContainingFolder(); } else if (key == "showfileinfo") { @@ -660,6 +663,10 @@ void ActionManager::initializeActionLibrary() auto *openUrlAction = new QAction(QIcon::fromTheme("document-open-remote", QIcon::fromTheme("folder-remote")), tr("Open &URL...")); actionLibrary.insert("openurl", openUrlAction); + auto *reloadFileAction = new QAction(QIcon::fromTheme("view-refresh"), tr("Re&load File")); + reloadFileAction->setData({"disable"}); + actionLibrary.insert("reloadfile", reloadFileAction); + auto *closeWindowAction = new QAction(QIcon::fromTheme("window-close"), tr("Close Window")); actionLibrary.insert("closewindow", closeWindowAction); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e431516f..17fcad0a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -667,6 +667,11 @@ void MainWindow::pickUrl() inputDialog->open(); } +void MainWindow::reloadFile() +{ + graphicsView->reloadFile(); +} + void MainWindow::openWith(const OpenWith::OpenWithItem &openWithItem) { OpenWith::openWith(getCurrentFileDetails().fileInfo.absoluteFilePath(), openWithItem); diff --git a/src/mainwindow.h b/src/mainwindow.h index 9bae41c5..19c82bca 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -51,6 +51,8 @@ class MainWindow : public QMainWindow void pickUrl(); + void reloadFile(); + void openContainingFolder(); void openWith(const OpenWith::OpenWithItem &exec); diff --git a/src/qvgraphicsview.cpp b/src/qvgraphicsview.cpp index 3e25ca0f..b5c604f9 100644 --- a/src/qvgraphicsview.cpp +++ b/src/qvgraphicsview.cpp @@ -244,6 +244,14 @@ void QVGraphicsView::loadFile(const QString &fileName) imageCore.loadFile(fileName); } +void QVGraphicsView::reloadFile() +{ + if (!getCurrentFileDetails().isPixmapLoaded) + return; + + imageCore.loadFile(getCurrentFileDetails().fileInfo.absoluteFilePath(), true); +} + void QVGraphicsView::postLoad() { updateLoadedPixmapItem(); diff --git a/src/qvgraphicsview.h b/src/qvgraphicsview.h index 8299dbf1..d2fb8624 100644 --- a/src/qvgraphicsview.h +++ b/src/qvgraphicsview.h @@ -38,6 +38,8 @@ class QVGraphicsView : public QGraphicsView void loadMimeData(const QMimeData *mimeData); void loadFile(const QString &fileName); + void reloadFile(); + void zoomIn(const QPoint &pos = QPoint(-1, -1)); void zoomOut(const QPoint &pos = QPoint(-1, -1)); diff --git a/src/qvimagecore.cpp b/src/qvimagecore.cpp index 0a933997..8a940abb 100644 --- a/src/qvimagecore.cpp +++ b/src/qvimagecore.cpp @@ -68,7 +68,7 @@ QVImageCore::QVImageCore(QObject *parent) : QObject(parent) settingsUpdated(); } -void QVImageCore::loadFile(const QString &fileName) +void QVImageCore::loadFile(const QString &fileName, bool isReloading) { if (waitingOnLoad) { @@ -105,7 +105,7 @@ void QVImageCore::loadFile(const QString &fileName) QString cacheKey = getPixmapCacheKey(sanitaryFileName, fileInfo.size(), targetColorSpace); //check if cached already before loading the long way - auto *cachedData = QVImageCore::pixmapCache.take(cacheKey); + auto *cachedData = isReloading ? nullptr : QVImageCore::pixmapCache.take(cacheKey); if (cachedData != nullptr) { ReadData readData = *cachedData; diff --git a/src/qvimagecore.h b/src/qvimagecore.h index 2cf443e4..92796af7 100644 --- a/src/qvimagecore.h +++ b/src/qvimagecore.h @@ -60,7 +60,7 @@ class QVImageCore : public QObject explicit QVImageCore(QObject *parent = nullptr); - void loadFile(const QString &fileName); + void loadFile(const QString &fileName, bool isReloaing = false); ReadData readFile(const QString &fileName, const QColorSpace &targetColorSpace, bool forCache); void loadPixmap(const ReadData &readData); void closeImage(); diff --git a/src/shortcutmanager.cpp b/src/shortcutmanager.cpp index 3bd7c155..f1d88535 100644 --- a/src/shortcutmanager.cpp +++ b/src/shortcutmanager.cpp @@ -44,6 +44,7 @@ void ShortcutManager::initializeShortcutsList() { shortcutsList.append({tr("Open"), "open", keyBindingsToStringList(QKeySequence::Open), {}}); shortcutsList.append({tr("Open URL"), "openurl", QStringList(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_O).toString()), {}}); + shortcutsList.append({tr("Reload File"), "reloadfile", keyBindingsToStringList(QKeySequence::Refresh), {}}); shortcutsList.append({tr("Open Containing Folder"), "opencontainingfolder", {}, {}}); //Sets open containing folder action name to platform-appropriate alternative #ifdef Q_OS_WIN