AlbumShaper
1.0a3
|
A more dynamic slider that provides moving tooltips that show the slider value. More...
#include <dynamicSlider.h>
Signals | |
void | mouseHasMoved () |
Public Member Functions | |
DynamicSlider (Orientation orientation, QWidget *parent, const char *name=0) | |
~DynamicSlider () | |
void | setZeroString (QString val) |
when set, a zero string is shown instead of the current value/prefix/suffix when the slider value is 0 | |
void | setPrefix (QString val) |
set the prefix that is displayed before the current slider value | |
void | setPrefixes (QString prefix1, QString prefix2) |
set two prefix values, one for when the value is positive and one for when the value is negative. | |
void | setSuffix (QString val) |
set the suffix that is displayed after the current slider value | |
void | setSuffixes (QString suffix1, QString suffix2) |
set two suffix values, one for when the value is positive and one for when the value is negative. | |
QPoint | getMousePos () |
Protected Member Functions | |
void | mouseMoveEvent (QMouseEvent *e) |
virtual QString | mapValToString () |
subclass DynamicSlider and reimplement this method to change the behavior used to display slider values | |
Private Slots | |
void | updateTooltipLabel () |
Private Attributes | |
QString | zeroString |
QString | prefix1 |
QString | prefix2 |
QString | suffix1 |
QString | suffix2 |
SliderToolTip * | tooltip |
QPoint | cachedMousePos |
A more dynamic slider that provides moving tooltips that show the slider value.
Definition at line 21 of file dynamicSlider.h.
DynamicSlider::DynamicSlider | ( | Orientation | orientation, |
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
Definition at line 17 of file dynamicSlider.cpp.
References tooltip, and updateTooltipLabel().
: QSlider(orientation, parent, name) { //determine the parent screen the tooltip will be displayed in and create tooltip int scr = QApplication::desktop()->screenNumber( this ); tooltip = new SliderToolTip( QApplication::desktop()->screen( scr ), this); updateTooltipLabel(); //make sure tooltip label is updated when the slider value changes connect( this, SIGNAL( valueChanged(int) ), this, SLOT( updateTooltipLabel() ) ); }
DynamicSlider::~DynamicSlider | ( | ) |
Definition at line 30 of file dynamicSlider.cpp.
References tooltip.
QPoint DynamicSlider::getMousePos | ( | ) |
Definition at line 119 of file dynamicSlider.cpp.
References cachedMousePos.
Referenced by SliderToolTip::update().
{ return cachedMousePos; }
QString DynamicSlider::mapValToString | ( | ) | [protected, virtual] |
subclass DynamicSlider and reimplement this method to change the behavior used to display slider values
Reimplemented in BlurSharpenSlider.
Definition at line 70 of file dynamicSlider.cpp.
Referenced by updateTooltipLabel().
{ //the default behavior is to simply use the slider value directly if( orientation() == Qt::Vertical ) return QString("%1").arg( -value() ); else return QString("%1").arg(value()); }
void DynamicSlider::mouseHasMoved | ( | ) | [signal] |
Referenced by mouseMoveEvent().
void DynamicSlider::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected] |
Definition at line 111 of file dynamicSlider.cpp.
References cachedMousePos, and mouseHasMoved().
{ //cache the mouse position since the tooltip will need this information when updating itself cachedMousePos = e->pos(); QSlider::mouseMoveEvent(e); emit mouseHasMoved(); }
void DynamicSlider::setPrefix | ( | QString | val | ) |
set the prefix that is displayed before the current slider value
Definition at line 42 of file dynamicSlider.cpp.
References prefix1, prefix2, and updateTooltipLabel().
{ prefix1 = val; prefix2 = QString( NULL ); updateTooltipLabel(); }
void DynamicSlider::setPrefixes | ( | QString | prefix1, |
QString | prefix2 | ||
) |
set two prefix values, one for when the value is positive and one for when the value is negative.
Definition at line 49 of file dynamicSlider.cpp.
References prefix1, prefix2, and updateTooltipLabel().
Referenced by BlurSharpenSlider::BlurSharpenSlider(), and HistogramEditor::HistogramEditor().
{ prefix1 = v1; prefix2 = v2; updateTooltipLabel(); }
void DynamicSlider::setSuffix | ( | QString | val | ) |
set the suffix that is displayed after the current slider value
Definition at line 56 of file dynamicSlider.cpp.
References suffix1, suffix2, and updateTooltipLabel().
Referenced by BlurSharpenSlider::BlurSharpenSlider().
{ suffix1 = val; suffix2 = QString( NULL ); updateTooltipLabel(); }
void DynamicSlider::setSuffixes | ( | QString | suffix1, |
QString | suffix2 | ||
) |
set two suffix values, one for when the value is positive and one for when the value is negative.
Definition at line 63 of file dynamicSlider.cpp.
References suffix1, suffix2, and updateTooltipLabel().
{ suffix1 = v1; suffix2 = v2; updateTooltipLabel(); }
void DynamicSlider::setZeroString | ( | QString | val | ) |
when set, a zero string is shown instead of the current value/prefix/suffix when the slider value is 0
Definition at line 36 of file dynamicSlider.cpp.
References updateTooltipLabel(), and zeroString.
Referenced by BlurSharpenSlider::BlurSharpenSlider(), and HistogramEditor::HistogramEditor().
{ zeroString = val; updateTooltipLabel(); }
void DynamicSlider::updateTooltipLabel | ( | ) | [private, slot] |
Definition at line 79 of file dynamicSlider.cpp.
References mapValToString(), prefix1, prefix2, suffix1, suffix2, tooltip, and zeroString.
Referenced by DynamicSlider(), setPrefix(), setPrefixes(), setSuffix(), setSuffixes(), and setZeroString().
{ //determine string that will be used for tooltip QString tipString; //if the value is zero and a zero string has been provided used that if( value() == 0 && !zeroString.isNull() ) { tipString = zeroString; } //otherwise construct a tip string using provided prefixes, suffixes, and the current slider value else { //determine prefix and suffix that will be used to construct tooltip string QString p, s; if( value() > 0 || prefix2.isNull() ) p = prefix1; else p = prefix2; if( value() > 0 || suffix2.isNull() ) s = suffix1; else s = suffix2; //construct tipstring tipString = QString("%1%2%3").arg(p).arg(mapValToString()).arg(s); } //update tooltip tooltip->setText( tipString ); tooltip->adjustSize(); if( tooltip->isShown() ) qApp->processEvents(); }
QPoint DynamicSlider::cachedMousePos [private] |
Definition at line 61 of file dynamicSlider.h.
Referenced by getMousePos(), and mouseMoveEvent().
QString DynamicSlider::prefix1 [private] |
Definition at line 57 of file dynamicSlider.h.
Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().
QString DynamicSlider::prefix2 [private] |
Definition at line 57 of file dynamicSlider.h.
Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().
QString DynamicSlider::suffix1 [private] |
Definition at line 58 of file dynamicSlider.h.
Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().
QString DynamicSlider::suffix2 [private] |
Definition at line 58 of file dynamicSlider.h.
Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().
SliderToolTip* DynamicSlider::tooltip [private] |
Definition at line 60 of file dynamicSlider.h.
Referenced by DynamicSlider(), updateTooltipLabel(), and ~DynamicSlider().
QString DynamicSlider::zeroString [private] |
Definition at line 55 of file dynamicSlider.h.
Referenced by setZeroString(), and updateTooltipLabel().