jfjoch_viewer: Set foreground with holding F
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QSplitter>
|
||||
#include <QThread>
|
||||
#include <QDockWidget>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "JFJochImageReadingWorker.h"
|
||||
#include "image_viewer/JFJochDiffractionImage.h"
|
||||
@@ -28,6 +29,8 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
menuBar = new JFJochViewerMenu(this);
|
||||
setMenuBar(menuBar);
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
auto toolBarImage = new JFJochViewerToolbarImage(this);
|
||||
addToolBar(Qt::TopToolBarArea, toolBarImage);
|
||||
addToolBarBreak(Qt::TopToolBarArea);
|
||||
@@ -315,6 +318,9 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
|
||||
connect(menuBar, &JFJochViewerMenu::openDatasetInfo, this, &JFJochViewerWindow::NewDatasetInfo);
|
||||
NewDatasetInfo();
|
||||
|
||||
connect(this, &JFJochViewerWindow::adjustForegroundButton,
|
||||
viewer, &JFJochDiffractionImage::adjustForeground);
|
||||
|
||||
if (!file.isEmpty())
|
||||
LoadFile(file, 0, 1);
|
||||
}
|
||||
@@ -360,3 +366,21 @@ void JFJochViewerWindow::NewDatasetInfo() {
|
||||
connect(info, &JFJochViewerDatasetInfo::writeStatusBar,
|
||||
statusbar, &JFJochViewerStatusBar::display);
|
||||
}
|
||||
|
||||
void JFJochViewerWindow::keyPressEvent(QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_F) {
|
||||
emit adjustForegroundButton(true);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
QMainWindow::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void JFJochViewerWindow::keyReleaseEvent(QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_F) {
|
||||
emit adjustForegroundButton(false);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
QMainWindow::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ private:
|
||||
|
||||
QThread *reading_thread;
|
||||
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyReleaseEvent(QKeyEvent *event) override;
|
||||
public slots:
|
||||
void LoadFile(const QString &filename, qint64 image_number, qint64 summation);
|
||||
void LoadImage(qint64 image_number, qint64 summation);
|
||||
@@ -40,6 +42,7 @@ public slots:
|
||||
signals:
|
||||
void LoadFileRequest(const QString &filename, qint64 image_number, qint64 summation);
|
||||
void LoadImageRequest(int64_t image_number, int64_t summation);
|
||||
void adjustForegroundButton(bool input);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -76,7 +76,10 @@ void JFJochImage::wheelEvent(QWheelEvent *event) {
|
||||
// Get the position of the mouse in scene coordinates
|
||||
QPointF targetScenePos = mapToScene(event->position().toPoint());
|
||||
|
||||
if (event->modifiers() == Qt::ShiftModifier) {
|
||||
const bool adjustForeground =
|
||||
(event->modifiers() == Qt::ShiftModifier) || m_adjustForegroundWithWheel;
|
||||
|
||||
if (adjustForeground) {
|
||||
float new_foreground = foreground + event->angleDelta().y() / 120.0f;
|
||||
if (new_foreground < 1)
|
||||
new_foreground = 1.0;
|
||||
@@ -821,3 +824,7 @@ void JFJochImage::fitToViewShorterSideOnce() {
|
||||
initial_fit_done_ = true;
|
||||
last_fit_viewport_ = vp;
|
||||
}
|
||||
|
||||
void JFJochImage::adjustForeground(bool input) {
|
||||
m_adjustForegroundWithWheel = input;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
class JFJochImage : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
|
||||
bool m_adjustForegroundWithWheel = false;
|
||||
|
||||
void DrawROI();
|
||||
virtual void addCustomOverlay();
|
||||
void updateROI();
|
||||
@@ -101,6 +103,8 @@ public slots:
|
||||
|
||||
void centerOnSpot(QPointF point);
|
||||
void fitToView();
|
||||
|
||||
void adjustForeground(bool input);
|
||||
public:
|
||||
explicit JFJochImage(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user