Skip to content

Commit 33436ad

Browse files
committed
CPluginWindow::configureForQuickView() added; quick viewing images defaults to pixel perfect upscaling
1 parent 42b3054 commit 33436ad

5 files changed

Lines changed: 17 additions & 1 deletion

File tree

doc/plugins.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Plugin destructors must not use their proxy.
2828
Plugin windows use `CFileCommanderViewerPlugin::WindowPtr`, a unique pointer whose deleter is instantiated in the
2929
plugin module. Keep that type across the boundary so allocation and deletion occur in the same dynamic library.
3030
Full viewer windows opt into deletion on close; quick view retains the `WindowPtr` in `CPanelDisplayController`.
31+
A window embedded as quick view is never shown, so its menus and shortcuts are unreachable; `configureForQuickView()`
32+
is the hook for adapting to that.
3133

3234
## Proxy and tab visibility
3335

file-commander-core/src/plugininterface/cpluginwindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ class PLUGIN_EXPORT CPluginWindow : public QMainWindow
1414

1515
[[nodiscard]] bool autoDeleteOnClose() const;
1616
void setAutoDeleteOnClose(bool autoDelete);
17+
18+
// Called before the central widget is embedded into a file panel; the window itself is never shown.
19+
virtual void configureForQuickView() {}
1720
};

plugins/viewer/imageviewer/src/cimageviewerwindow.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ CImageViewerWindow::CImageViewerWindow(CPluginProxy& proxy, QWidget* parent) noe
5050
// Only this action is connected: the group unchecks it whenever the smooth one is picked.
5151
connect(ui->actionPixelPreservingUpscaling, &QAction::toggled, this, [this](bool enabled) {
5252
ui->_imageViewerWidget->setNearestNeighborUpscaling(enabled);
53-
QSettings{}.setValue(SETTINGS_PIXEL_PRESERVING_UPSCALING, enabled);
53+
if (!_quickViewMode) // Quick view forces the mode, so it must not overwrite the stored preference.
54+
QSettings{}.setValue(SETTINGS_PIXEL_PRESERVING_UPSCALING, enabled);
5455
});
5556

5657
// Checking the other action is what switches modes: unchecking the current one would leave the group with no selection.
@@ -114,6 +115,12 @@ bool CImageViewerWindow::displayImage(const QString& imagePath)
114115
return true;
115116
}
116117

118+
void CImageViewerWindow::configureForQuickView()
119+
{
120+
_quickViewMode = true; // Must precede the check: the toggle handler reads it to skip the settings write.
121+
ui->actionPixelPreservingUpscaling->setChecked(true);
122+
}
123+
117124
void CImageViewerWindow::saveImageAs()
118125
{
119126
const QImage& image = ui->_imageViewerWidget->sourceImage();

plugins/viewer/imageviewer/src/cimageviewerwindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ class CImageViewerWindow final : public CPluginWindow
1616

1717
bool displayImage(const QString& imagePath);
1818

19+
void configureForQuickView() override;
20+
1921
private:
2022
void saveImageAs();
2123

2224
private:
2325
QString _currentImagePath;
26+
bool _quickViewMode = false;
2427
Ui::CImageViewerWindow *ui;
2528
};

qt-app/src/panel/cpaneldisplaycontroller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void CPanelDisplayController::startQuickView(CFileCommanderViewerPlugin::WindowP
5353
// Sanity check
5454
assert_and_return_r(_panelStackedWidget && _panelStackedWidget->count() == 1, );
5555
_quickViewWindow->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
56+
_quickViewWindow->configureForQuickView();
5657
_panelStackedWidget->addWidget(_quickViewWindow->centralWidget());
5758
_panelStackedWidget->setCurrentIndex(1);
5859
}

0 commit comments

Comments
 (0)