1
0

revert: revert feature about saving image as new file with different format.

This reverts commit 5b2255e903.

The feature about saving image as new file with different format is not the goal of an image viewer.
There is no need to keep feature diversity in this fork.
So I simply remove it.
This commit is contained in:
2026-07-02 15:09:54 +08:00
parent f0bb945c7d
commit cd2eac44f1
4 changed files with 0 additions and 76 deletions

View File

@@ -55,7 +55,6 @@ void ActionManager::setupAction(MainWindow *mainWindow)
CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame); CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame);
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionOpen, document-open); CREATE_NEW_THEMEICON_ACTION(mainWindow, actionOpen, document-open);
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionSaveAs, document-save-as);
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip); CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
CREATE_NEW_ACTION(mainWindow, actionFitInView); CREATE_NEW_ACTION(mainWindow, actionFitInView);
CREATE_NEW_ACTION(mainWindow, actionFitByWidth); CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
@@ -85,7 +84,6 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
Q_UNUSED(mainWindow); Q_UNUSED(mainWindow);
actionOpen->setText(QCoreApplication::translate("MainWindow", "&Open...", nullptr)); actionOpen->setText(QCoreApplication::translate("MainWindow", "&Open...", nullptr));
actionSaveAs->setText(QCoreApplication::translate("MainWindow", "Save &As...", nullptr));
actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr)); actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr));
actionToggleMaximize->setText(QCoreApplication::translate("MainWindow", "Toggle maximize", nullptr)); actionToggleMaximize->setText(QCoreApplication::translate("MainWindow", "Toggle maximize", nullptr));
@@ -131,7 +129,6 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
void ActionManager::setupShortcuts() void ActionManager::setupShortcuts()
{ {
actionOpen->setShortcut(QKeySequence::Open); actionOpen->setShortcut(QKeySequence::Open);
actionSaveAs->setShortcut(QKeySequence::SaveAs);
actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
actionZoomIn->setShortcut(QKeySequence::ZoomIn); actionZoomIn->setShortcut(QKeySequence::ZoomIn);
actionZoomOut->setShortcut(QKeySequence::ZoomOut); actionZoomOut->setShortcut(QKeySequence::ZoomOut);

View File

@@ -23,7 +23,6 @@ public:
public: public:
QAction *actionOpen; QAction *actionOpen;
QAction *actionSaveAs;
QAction *actionActualSize; QAction *actionActualSize;
QAction *actionToggleMaximize; QAction *actionToggleMaximize;

View File

@@ -38,7 +38,6 @@
#include <QProcess> #include <QProcess>
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>
#include <QImageWriter>
#ifdef HAVE_QTDBUS #ifdef HAVE_QTDBUS
#include <QDBusInterface> #include <QDBusInterface>
@@ -506,12 +505,6 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
menu->addAction(paste); menu->addAction(paste);
} }
#if 0
if (currentFileUrl.isValid()) {
menu->addAction(m_am->actionSaveAs);
}
#endif // 0
menu->addSeparator(); menu->addSeparator();
menu->addAction(m_am->actionHorizontalFlip); menu->addAction(m_am->actionHorizontalFlip);
@@ -704,70 +697,6 @@ void MainWindow::on_actionOpen_triggered()
} }
} }
void MainWindow::on_actionSaveAs_triggered()
{
QUrl currentFileUrl = currentImageFileUrl();
if (!currentFileUrl.isValid()) {
QMessageBox::warning(this, tr("Save As"), tr("No image is currently open."));
return;
}
QStringList supportedFormats;
QStringList nameFilters;
const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
for (const QByteArray &format : imageFormats) {
QString formatStr = QString::fromLatin1(format).toLower();
if (!formatStr.isEmpty()) {
supportedFormats << formatStr;
nameFilters << tr("%1 Image (*.%2)").arg(formatStr.toUpper(), formatStr);
}
}
if (imageFormats.isEmpty()) {
QMessageBox::warning(this, tr("Save As"),
tr("No supported image formats are available."));
return;
}
QString selectedFilter;
QString saveFilePath = QFileDialog::getSaveFileName(this,
tr("Save As"),
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
nameFilters.join(";;"),
&selectedFilter);
if (saveFilePath.isEmpty()) {
return; // User cancelled
}
// Ensure the file has the correct extension
QString expectedExtension;
const int filterIndex = nameFilters.indexOf(selectedFilter);
if (filterIndex != -1) {
expectedExtension = supportedFormats.at(filterIndex);
}
if (!expectedExtension.isEmpty() && !saveFilePath.endsWith('.' + expectedExtension, Qt::CaseInsensitive)) {
saveFilePath += '.' + expectedExtension;
}
// Save the image
QImageReader imageReader(currentFileUrl.toLocalFile());
imageReader.setAutoTransform(true);
imageReader.setDecideFormatFromContent(true);
imageReader.setAllocationLimit(0);
QImage img(imageReader.read());
QImageWriter writer(saveFilePath);
writer.setFormat(expectedExtension.toLatin1());
if (!writer.write(img)) {
QMessageBox::warning(this, tr("Save As"),
tr("Failed to save image: %1").arg(writer.errorString()));
return;
}
}
void MainWindow::on_actionActualSize_triggered() void MainWindow::on_actionActualSize_triggered()
{ {
m_graphicsView->resetScale(); m_graphicsView->resetScale();

View File

@@ -75,7 +75,6 @@ protected:
private slots: private slots:
void on_actionOpen_triggered(); void on_actionOpen_triggered();
void on_actionSaveAs_triggered();
void on_actionActualSize_triggered(); void on_actionActualSize_triggered();
void on_actionToggleMaximize_triggered(); void on_actionToggleMaximize_triggered();