AlbumShaper  1.0a3
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
DynamicSlider Class Reference

A more dynamic slider that provides moving tooltips that show the slider value. More...

#include <dynamicSlider.h>

Inheritance diagram for DynamicSlider:
Inheritance graph
[legend]
Collaboration diagram for DynamicSlider:
Collaboration graph
[legend]

Signals

void mouseHasMoved ()
 

Public Member Functions

 DynamicSlider (Qt::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 More...
 
void setPrefix (QString val)
 set the prefix that is displayed before the current slider value More...
 
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. More...
 
void setSuffix (QString val)
 set the suffix that is displayed after the current slider value More...
 
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. More...
 
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 More...
 

Private Slots

void updateTooltipLabel ()
 

Private Attributes

QString zeroString
 
QString prefix1
 
QString prefix2
 
QString suffix1
 
QString suffix2
 
SliderToolTiptooltip
 
QPoint cachedMousePos
 

Detailed Description

A more dynamic slider that provides moving tooltips that show the slider value.

Definition at line 23 of file dynamicSlider.h.

Constructor & Destructor Documentation

§ DynamicSlider()

DynamicSlider::DynamicSlider ( Qt::Orientation  orientation,
QWidget parent,
const char *  name = 0 
)

Definition at line 23 of file dynamicSlider.cpp.

References tooltip, and updateTooltipLabel().

24  : QSlider(orientation, parent, name)
25 {
26  //determine the parent screen the tooltip will be displayed in and create tooltip
27  int scr = QApplication::desktop()->screenNumber( this );
28  tooltip = new SliderToolTip( QApplication::desktop()->screen( scr ), this);
30 
31  //make sure tooltip label is updated when the slider value changes
32  connect( this, SIGNAL( valueChanged(int) ),
33  this, SLOT( updateTooltipLabel() ) );
34 }
private class used by the DynamicSlider to show tooltips. do not use!
Definition: dynamicSlider.h:73
SliderToolTip * tooltip
Definition: dynamicSlider.h:62
void updateTooltipLabel()

§ ~DynamicSlider()

DynamicSlider::~DynamicSlider ( )

Definition at line 36 of file dynamicSlider.cpp.

References tooltip.

37 {
38  delete tooltip;
39  tooltip = NULL;
40 }
SliderToolTip * tooltip
Definition: dynamicSlider.h:62

Member Function Documentation

§ getMousePos()

QPoint DynamicSlider::getMousePos ( )

Definition at line 125 of file dynamicSlider.cpp.

References cachedMousePos.

Referenced by SliderToolTip::update().

125 { return cachedMousePos; }
QPoint cachedMousePos
Definition: dynamicSlider.h:63

§ mapValToString()

QString DynamicSlider::mapValToString ( )
protectedvirtual

subclass DynamicSlider and reimplement this method to change the behavior used to display slider values

Reimplemented in BlurSharpenSlider.

Definition at line 76 of file dynamicSlider.cpp.

Referenced by updateTooltipLabel().

77 {
78  //the default behavior is to simply use the slider value directly
79  if( orientation() == Qt::Vertical )
80  return QString("%1").arg( -value() );
81  else
82  return QString("%1").arg(value());
83 }

§ mouseHasMoved

void DynamicSlider::mouseHasMoved ( )
signal

Referenced by mouseMoveEvent().

§ mouseMoveEvent()

void DynamicSlider::mouseMoveEvent ( QMouseEvent *  e)
protected

Definition at line 117 of file dynamicSlider.cpp.

References cachedMousePos, and mouseHasMoved().

118 {
119  //cache the mouse position since the tooltip will need this information when updating itself
120  cachedMousePos = e->pos();
121  QSlider::mouseMoveEvent(e);
122  emit mouseHasMoved();
123 }
void mouseHasMoved()
QPoint cachedMousePos
Definition: dynamicSlider.h:63

§ setPrefix()

void DynamicSlider::setPrefix ( QString  val)

set the prefix that is displayed before the current slider value

Definition at line 48 of file dynamicSlider.cpp.

References prefix1, prefix2, and updateTooltipLabel().

49 {
50  prefix1 = val;
51  prefix2 = QString::null;
53 }
QString prefix2
Definition: dynamicSlider.h:59
QString prefix1
Definition: dynamicSlider.h:59
void updateTooltipLabel()

§ setPrefixes()

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 55 of file dynamicSlider.cpp.

References prefix1, prefix2, and updateTooltipLabel().

Referenced by BlurSharpenSlider::BlurSharpenSlider(), and HistogramEditor::HistogramEditor().

56 {
57  prefix1 = v1;
58  prefix2 = v2;
60 }
QString prefix2
Definition: dynamicSlider.h:59
QString prefix1
Definition: dynamicSlider.h:59
void updateTooltipLabel()

§ setSuffix()

void DynamicSlider::setSuffix ( QString  val)

set the suffix that is displayed after the current slider value

Definition at line 62 of file dynamicSlider.cpp.

References suffix1, suffix2, and updateTooltipLabel().

Referenced by BlurSharpenSlider::BlurSharpenSlider().

63 {
64  suffix1 = val;
65  suffix2 = QString::null;
67 }
QString suffix1
Definition: dynamicSlider.h:60
QString suffix2
Definition: dynamicSlider.h:60
void updateTooltipLabel()

§ setSuffixes()

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 69 of file dynamicSlider.cpp.

References suffix1, suffix2, and updateTooltipLabel().

70 {
71  suffix1 = v1;
72  suffix2 = v2;
74 }
QString suffix1
Definition: dynamicSlider.h:60
QString suffix2
Definition: dynamicSlider.h:60
void updateTooltipLabel()

§ setZeroString()

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 42 of file dynamicSlider.cpp.

References updateTooltipLabel(), and zeroString.

Referenced by BlurSharpenSlider::BlurSharpenSlider(), and HistogramEditor::HistogramEditor().

43 {
44  zeroString = val;
46 }
QString zeroString
Definition: dynamicSlider.h:57
void updateTooltipLabel()

§ updateTooltipLabel

void DynamicSlider::updateTooltipLabel ( )
privateslot

Definition at line 85 of file dynamicSlider.cpp.

References mapValToString(), prefix1, prefix2, suffix1, suffix2, tooltip, and zeroString.

Referenced by DynamicSlider(), setPrefix(), setPrefixes(), setSuffix(), setSuffixes(), and setZeroString().

86 {
87  //determine string that will be used for tooltip
88  QString tipString;
89 
90  //if the value is zero and a zero string has been provided used that
91  if( value() == 0 && !zeroString.isNull() )
92  {
93  tipString = zeroString;
94  }
95  //otherwise construct a tip string using provided prefixes, suffixes, and the current slider value
96  else
97  {
98  //determine prefix and suffix that will be used to construct tooltip string
99  QString p, s;
100  if( value() > 0 || prefix2.isNull() ) p = prefix1;
101  else p = prefix2;
102 
103  if( value() > 0 || suffix2.isNull() ) s = suffix1;
104  else s = suffix2;
105 
106  //construct tipstring
107  tipString = QString("%1%2%3").arg(p).arg(mapValToString()).arg(s);
108 
109  }
110 
111  //update tooltip
112  tooltip->setText( tipString );
113  tooltip->adjustSize();
114  if( tooltip->isShown() ) qApp->processEvents();
115 }
QString suffix1
Definition: dynamicSlider.h:60
QString prefix2
Definition: dynamicSlider.h:59
QString zeroString
Definition: dynamicSlider.h:57
QString suffix2
Definition: dynamicSlider.h:60
QString prefix1
Definition: dynamicSlider.h:59
virtual QString mapValToString()
subclass DynamicSlider and reimplement this method to change the behavior used to display slider valu...
SliderToolTip * tooltip
Definition: dynamicSlider.h:62

Member Data Documentation

§ cachedMousePos

QPoint DynamicSlider::cachedMousePos
private

Definition at line 63 of file dynamicSlider.h.

Referenced by getMousePos(), and mouseMoveEvent().

§ prefix1

QString DynamicSlider::prefix1
private

Definition at line 59 of file dynamicSlider.h.

Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().

§ prefix2

QString DynamicSlider::prefix2
private

Definition at line 59 of file dynamicSlider.h.

Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().

§ suffix1

QString DynamicSlider::suffix1
private

Definition at line 60 of file dynamicSlider.h.

Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().

§ suffix2

QString DynamicSlider::suffix2
private

Definition at line 60 of file dynamicSlider.h.

Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().

§ tooltip

SliderToolTip* DynamicSlider::tooltip
private

Definition at line 62 of file dynamicSlider.h.

Referenced by DynamicSlider(), updateTooltipLabel(), and ~DynamicSlider().

§ zeroString

QString DynamicSlider::zeroString
private

Definition at line 57 of file dynamicSlider.h.

Referenced by setZeroString(), and updateTooltipLabel().


The documentation for this class was generated from the following files: