AlbumShaper  1.0a3
dynamicSlider.h
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 #ifndef GUI_DYNAMICSLIDER_H
12 #define GUI_DYNAMICSLIDER_H
13 
14 #include <qslider.h>
15 #include <qlabel.h>
16 #include <qpoint.h>
17 //Added by qt3to4:
18 #include <QMouseEvent>
19 
20 class SliderToolTip;
21 //==========================================
23 class DynamicSlider : public QSlider
24 {
25 Q_OBJECT
26 public:
27  DynamicSlider( Qt::Orientation orientation, QWidget* parent, const char* name=0 );
29 
31  void setZeroString( QString val );
32 
34  void setPrefix( QString val );
35 
37  void setPrefixes( QString prefix1, QString prefix2 );
38 
40  void setSuffix( QString val );
41 
43  void setSuffixes( QString suffix1, QString suffix2 );
44 
45  //used by the tooltip class to determine the current mouse position
46  QPoint getMousePos();
47 
48 protected:
49  //cache and announce to the tooltip class that the mouse has moved
50  void mouseMoveEvent(QMouseEvent* e);
51 
54  virtual QString mapValToString();
55 
56 private:
57  QString zeroString;
58 
59  QString prefix1, prefix2;
60  QString suffix1, suffix2;
61 
64 
65 signals:
66  void mouseHasMoved();
67 
68 private slots:
69  void updateTooltipLabel();
70 };
71 //==========================================
73 class SliderToolTip : public QLabel
74 {
75 Q_OBJECT
76 
77 public:
78  SliderToolTip( QWidget* parent, DynamicSlider* slider);
79 
80 private:
82 
83 private slots:
84  void showTooltip();
85  void update();
86  void hideTooltip();
87 };
88 //==========================================
89 
90 #endif //GUI_DYNAMICSLIDER_H
DynamicSlider * slider
Definition: dynamicSlider.h:81
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...
QString suffix1
Definition: dynamicSlider.h:60
QString prefix2
Definition: dynamicSlider.h:59
void mouseHasMoved()
private class used by the DynamicSlider to show tooltips. do not use!
Definition: dynamicSlider.h:73
QString zeroString
Definition: dynamicSlider.h:57
QString suffix2
Definition: dynamicSlider.h:60
QString prefix1
Definition: dynamicSlider.h:59
QPoint getMousePos()
virtual QString mapValToString()
subclass DynamicSlider and reimplement this method to change the behavior used to display slider valu...
QPoint cachedMousePos
Definition: dynamicSlider.h:63
SliderToolTip * tooltip
Definition: dynamicSlider.h:62
A more dynamic slider that provides moving tooltips that show the slider value.
Definition: dynamicSlider.h:23
void mouseMoveEvent(QMouseEvent *e)
DynamicSlider(Qt::Orientation orientation, QWidget *parent, const char *name=0)
void setZeroString(QString val)
when set, a zero string is shown instead of the current value/prefix/suffix when the slider value is ...
void setSuffix(QString val)
set the suffix that is displayed after the current slider value
void updateTooltipLabel()
void setPrefix(QString val)
set the prefix that is displayed before 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...