Files
qt5-legatus-legacy/Lts/Application/THP/thpwidgets/thp_zoom_slider.h
T
2026-08-13 18:33:10 +02:00

153 lines
3.3 KiB
C++
Executable File

/**
* @RDE_HEADER@
* A special slider for zooming
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QWidget>
class QLabel;
class QSlider;
namespace THP
{
/**
* An specialized QSlider
* This slider has a special, fixed range from 0.1 - 100 which is mapped to
* suitable map scales used in the GUEZ.
* The scale is not linear - instead it has a model behind. in smaller scales -
* slider's going to 0.1 - it's resolution is finer than on larger scales -
* slider's going to 100.
* The slider accpets only values within the range 0.1....100. Other values are ignored.
*/
class ZoomSlider : public QWidget
{
Q_OBJECT
Q_PROPERTY(Qt::Orientation Orientation READ getOrientation WRITE setOrientation)
Q_PROPERTY(bool showDescriptionLabel READ getShowDescriptionLabel WRITE setShowDescriptionLabel)
Q_PROPERTY(bool showValueLabel READ getShowValueLabel WRITE setShowValueLabel)
public:
/**
* constructor
*/
explicit ZoomSlider(QWidget *parent = nullptr);
/**
* get the actual Zoom value.
* @return float with the zoom value
*/
double getZoomValue() const;
/**
* Sets the Orientation.
* @param a_orientation The slider's orientation.
*/
void setOrientation(Qt::Orientation a_orientation);
/**
*
*/
Qt::Orientation getOrientation() const;
bool getShowDescriptionLabel() const;
void setShowDescriptionLabel(bool bVisible);
bool getShowValueLabel() const;
void setShowValueLabel(bool bVisible);
/**
* format the given value as it would be shown in the zoom label
*/
QString formatValue(double value) const;
public Q_SLOTS:
/**
* set the slider's actual zoom value. This is a QT-Slot.
* The slider accpet only values within it's range 0.1...100.
* Other values are ignored.
* @param a_zoomValue the new zoom value.
*/
void setZoomValue(double zoomValue);
Q_SIGNALS:
/**
* A QT-Signal which is emitted whenever the slider's value has changed.
* The newly set zoom value is delivered as argument.
*/
void valueChanged(double a_value);
private Q_SLOTS:
/**
* Update the label text
*/
void updateLabel(double newValue);
private:
/**
* Contains the slider's minimum zoom value
*/
const double m_InternalMin;
/**
* Contains the slider's maximum zoom value
*/
const double m_InternalMax;
/**
* Contains the slider's lower threshold value.
* The lower threshold is at 50% of the sliders range.
*/
const int m_LowerThreshold;
/**
* Contains the slider's upper threshold value.
* The upper threshold is at 75% of the sliders range.
*/
const int m_UpperThreshold;
/**
* Contains the slider's range minimum value
*/
const int m_MinRange;
/**
* Contains the slider's range maximum value
*/
const int m_MaxRange;
/**
* The QSlider
*/
QSlider *m_Slider;
/**
* The label for showing the exact slider value.
*/
QLabel *m_lbl;
/**
* The label for showing the 'zoom' text
*/
QLabel *m_text;
/**
* contains the zoom value
*/
double m_ZoomValue;
/**
* The current value of the slider to avoid loops
*/
int m_curSliderVal;
private slots :
/**
* Calculates the zoom value from the slider's position
*/
void calcZoomFromSlider(int a_value);
};
} // namespace THP