diff --git a/viewer/JFJochViewerWindow.cpp b/viewer/JFJochViewerWindow.cpp index 4a97d19a..ed28ca5b 100644 --- a/viewer/JFJochViewerWindow.cpp +++ b/viewer/JFJochViewerWindow.cpp @@ -328,6 +328,9 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString connect(this, &JFJochViewerWindow::adjustForegroundButton, viewer, &JFJochDiffractionImage::adjustForeground); + connect(this, &JFJochViewerWindow::setAutoForegroundOnce, + viewer, &JFJochDiffractionImage::setAutoForegroundOnce); + if (!file.isEmpty()) LoadFile(file, 0, 1, false); } @@ -380,6 +383,11 @@ void JFJochViewerWindow::keyPressEvent(QKeyEvent *event) { event->accept(); return; } + if (event->key() == Qt::Key_A && ! event->isAutoRepeat()) { + emit setAutoForegroundOnce(); + event->accept(); + return; + } QMainWindow::keyPressEvent(event); } diff --git a/viewer/JFJochViewerWindow.h b/viewer/JFJochViewerWindow.h index ae53a2c0..f0de7f32 100644 --- a/viewer/JFJochViewerWindow.h +++ b/viewer/JFJochViewerWindow.h @@ -47,6 +47,7 @@ signals: void LoadFileRequest(const QString &filename, qint64 image_number, qint64 summation, bool retry); void LoadImageRequest(int64_t image_number, int64_t summation); void adjustForegroundButton(bool input); + void setAutoForegroundOnce(); }; diff --git a/viewer/image_viewer/JFJochDiffractionImage.cpp b/viewer/image_viewer/JFJochDiffractionImage.cpp index bdaea9b0..d21e26ed 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.cpp +++ b/viewer/image_viewer/JFJochDiffractionImage.cpp @@ -342,14 +342,19 @@ void JFJochDiffractionImage::loadImage(std::shared_ptr void JFJochDiffractionImage::setAutoForeground(bool input) { auto_fg = input; - if (image && auto_fg) { - // If auto_foreground is not set, then view stays with the current settings till these are explicitly changed + // If auto_foreground is not set, then view stays with the current settings till these are explicitly changed + if (auto_fg) + setAutoForegroundOnce(); + emit autoForegroundChanged(auto_fg); +} + +void JFJochDiffractionImage::setAutoForegroundOnce() { + if (image) { foreground = image->GetAutoContrastValue(); emit foregroundChanged(foreground); GeneratePixmap(); Redraw(); } - emit autoForegroundChanged(auto_fg); } void JFJochDiffractionImage::setResolutionRing(QVector v) { diff --git a/viewer/image_viewer/JFJochDiffractionImage.h b/viewer/image_viewer/JFJochDiffractionImage.h index 3b3f8f98..913dd889 100644 --- a/viewer/image_viewer/JFJochDiffractionImage.h +++ b/viewer/image_viewer/JFJochDiffractionImage.h @@ -56,7 +56,7 @@ private: public slots: void loadImage(std::shared_ptr image); void setAutoForeground(bool input); - + void setAutoForegroundOnce(); void setResolutionRing(QVector v); void setResolutionRingMode(RingMode mode);