From 67199a033de4e855dd4b1fd0842dcbd9ef5e295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Fri, 17 Jun 2022 12:01:36 +0200 Subject: [PATCH] Better status bar --- CMakeLists.txt | 1 + imagescrollareagl.cpp | 4 ++-- imagescrollareagl.h | 2 +- mainwindow.cpp | 5 ++++- statusbar.cpp | 23 +++++++++++++++++++++++ statusbar.h | 19 +++++++++++++++++++ 6 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 statusbar.cpp create mode 100644 statusbar.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 50d4240..b25794c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(TENMON_SRC markedfiles.cpp rawimage.cpp starfit.cpp + statusbar.cpp stfslider.cpp stretchtoolbar.cpp ) diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index 8250735..fe9989c 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -471,9 +471,9 @@ void ImageWidget::mouseMoveEvent(QMouseEvent *event) if(m_rawImage->pixel(pix.x(), pix.y(), rgb)) { if(m_bwImg) - emit status(tr("L:%1 %2 X:%3 Y:%4").arg(rgb.x()).arg(sky.toString()).arg((int)pix.x()).arg((int)pix.y())); + emit status(tr("L:%1").arg(rgb.x()), tr("X:%3 Y:%4").arg((int)pix.x()).arg((int)pix.y()), sky.toString()); else - emit status(tr("R:%1 G:%2 B:%3 %4 X:%5 Y:%6").arg(rgb.x()).arg(rgb.y()).arg(rgb.z()).arg(sky.toString()).arg((int)pix.x()).arg((int)pix.y())); + emit status(tr("R:%1 G:%2 B:%3").arg(rgb.x()).arg(rgb.y()).arg(rgb.z()), tr("X:%3 Y:%4").arg((int)pix.x()).arg((int)pix.y()), sky.toString()); } } } diff --git a/imagescrollareagl.h b/imagescrollareagl.h index a42f6f9..4b7bae7 100644 --- a/imagescrollareagl.h +++ b/imagescrollareagl.h @@ -88,7 +88,7 @@ protected: void thumbSelect(QMouseEvent *event); signals: void fileDropped(const QString &path); - void status(const QString &status); + void status(const QString &value, const QString &pixelCoords, const QString &celestialCoords); }; class ImageScrollAreaGL : public QWidget diff --git a/mainwindow.cpp b/mainwindow.cpp index 2b5d0c8..fdd9504 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -19,6 +19,7 @@ #include "loadrunable.h" #include "markedfiles.h" #include "about.h" +#include "statusbar.h" #ifdef __linux__ #include @@ -48,7 +49,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) m_imageGL = new ImageScrollAreaGL(m_database, this); setCentralWidget(m_imageGL); - connect(m_imageGL->imageWidget(), &ImageWidget::status, [this](const QString &status){ statusBar()->showMessage(status); }); + StatusBar *statusBar = new StatusBar(this); + setStatusBar(statusBar); + connect(m_imageGL->imageWidget(), &ImageWidget::status, statusBar, &StatusBar::newStatus); m_stretchPanel = new StretchToolbar(this); connect(m_stretchPanel, SIGNAL(paramChanged(float,float,float)), m_imageGL->imageWidget(), SLOT(setMTFParams(float,float,float))); diff --git a/statusbar.cpp b/statusbar.cpp new file mode 100644 index 0000000..33d23d7 --- /dev/null +++ b/statusbar.cpp @@ -0,0 +1,23 @@ +#include "statusbar.h" +#include + +StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) +{ + m_value = new QLabel(this); + m_pixelCoords = new QLabel(this); + m_celestianCoords = new QLabel(this); + + m_value->setMinimumWidth(m_value->fontMetrics().horizontalAdvance("R:65536 G:65536 B:65536 ")); + m_pixelCoords->setMinimumWidth(m_pixelCoords->fontMetrics().horizontalAdvance("X:65536 Y:65536 ")); + m_celestianCoords->setMinimumWidth(m_celestianCoords->fontMetrics().horizontalAdvance("RA: 00h00m00s DEC: 00° 00' 00\" ")); + addPermanentWidget(m_value); + addPermanentWidget(m_pixelCoords); + addPermanentWidget(m_celestianCoords); +} + +void StatusBar::newStatus(const QString &value, const QString &pixelCoords, const QString &celestialCoords) +{ + m_value->setText(value); + m_pixelCoords->setText(pixelCoords); + m_celestianCoords->setText(celestialCoords); +} diff --git a/statusbar.h b/statusbar.h new file mode 100644 index 0000000..17cadc7 --- /dev/null +++ b/statusbar.h @@ -0,0 +1,19 @@ +#ifndef STATUSBAR_H +#define STATUSBAR_H + +#include +#include + +class StatusBar : public QStatusBar +{ + Q_OBJECT + QLabel *m_value; + QLabel *m_pixelCoords; + QLabel *m_celestianCoords; +public: + explicit StatusBar(QWidget *parent = nullptr); +public slots: + void newStatus(const QString &value, const QString &pixelCoords, const QString &celestialCoords); +}; + +#endif // STATUSBAR_H