AlbumShaper  1.0a3
Public Member Functions | Private Slots | Private Attributes
SliderToolTip Class Reference

private class used by the DynamicSlider to show tooltips. do not use! More...

#include <dynamicSlider.h>

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

List of all members.

Public Member Functions

 SliderToolTip (QWidget *parent, DynamicSlider *slider)

Private Slots

void showTooltip ()
void update ()
void hideTooltip ()

Private Attributes

DynamicSliderslider

Detailed Description

private class used by the DynamicSlider to show tooltips. do not use!

Definition at line 71 of file dynamicSlider.h.


Constructor & Destructor Documentation

SliderToolTip::SliderToolTip ( QWidget parent,
DynamicSlider slider 
)

Definition at line 121 of file dynamicSlider.cpp.

References hideTooltip(), showTooltip(), slider, and update().

: QLabel( parent, "toolTipTip",
          WStyle_StaysOnTop | WStyle_Customize | 
          WStyle_NoBorder | WStyle_Tool | WX11BypassWM )
{
  //store slider handle                             
  this->slider = slider;
  
  //setup lable to use standard black writing on a light yellow background so it
  //looks like a normal tooltip
  setPaletteForegroundColor( QColor("Black") );
  setPaletteBackgroundColor( QColor("LightYellow") );

  //use default system tooltip font
  setFont( QToolTip::font() );
  
  //setup the otherparmslike a frame etc so it looks like a normal tooltip
  setMargin(1);
  setAutoMask( FALSE );
  setFrameStyle( QFrame::Plain | QFrame::Box );
  setLineWidth( 1 );
  setAlignment( AlignAuto | AlignTop );
  setIndent(0);
  polish();
  adjustSize();
  
  //show the tooltip when the user presses the slider
  connect( slider, SIGNAL( sliderPressed() ),  this, SLOT( showTooltip() ) );
  
  //move tooltip to follow the slider handle
  setMouseTracking(true);
  connect( slider, SIGNAL( mouseHasMoved() ),  this, SLOT( update() ) );
  
  //hide tooltip when users releases the slider
  connect( slider, SIGNAL( sliderReleased() ), this, SLOT( hideTooltip() ) );
}

Member Function Documentation

void SliderToolTip::hideTooltip ( ) [private, slot]

Definition at line 165 of file dynamicSlider.cpp.

Referenced by SliderToolTip().

{ hide(); }
void SliderToolTip::showTooltip ( ) [private, slot]

Definition at line 158 of file dynamicSlider.cpp.

References update().

Referenced by SliderToolTip().

{
  //make sure label is up-to-date
  update();
  show();
}
void SliderToolTip::update ( ) [private, slot]

Definition at line 167 of file dynamicSlider.cpp.

References DynamicSlider::getMousePos(), height, slider, and width.

Referenced by showTooltip(), and SliderToolTip().

{
  //margin well provide betweent the slider and the tooltip
  const int TOOLTIP_MARGIN = 4;
  
  //fetch slider handle rect
  QRect sliderRect = slider->sliderRect();
  
  //determine location tooltip will be shown
  QPoint tooltipTopLeft;
  if( slider->orientation() == Qt::Horizontal )
  {
    tooltipTopLeft = QPoint( sliderRect.right() + TOOLTIP_MARGIN,
                             slider->getMousePos().y() >= sliderRect.top() ?
                             sliderRect.top() - TOOLTIP_MARGIN - height() :
                             sliderRect.bottom() + TOOLTIP_MARGIN );
  }
  else
  {
    tooltipTopLeft = QPoint( slider->getMousePos().x() >= sliderRect.right() ?
                             sliderRect.left() - TOOLTIP_MARGIN - width() :
                             sliderRect.right() + TOOLTIP_MARGIN,
                             (sliderRect.top() + sliderRect.bottom())/2 - height()/2 );
  }
  
  //map tooltip position from slider widget to screen coordinates
  tooltipTopLeft = slider->mapToGlobal( tooltipTopLeft );
  
  //position tooltip
  move( tooltipTopLeft );
  if( isShown() ) qApp->processEvents();
}

Member Data Documentation

Definition at line 79 of file dynamicSlider.h.

Referenced by SliderToolTip(), and update().


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