1
//////////////////////////////////////////////////////////////////////////////
2
// oxygensliderdemowidget.cpp
3
// oxygen sliders demo widget
6
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to
10
// deal in the Software without restriction, including without limitation the
11
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
// sell copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
//////////////////////////////////////////////////////////////////////////////
27
#include "oxygensliderdemowidget.h"
28
#include "oxygensliderdemowidget.moc"
30
#include <QtGui/QMenu>
31
#include <QtGui/QStyleOptionSlider>
36
//_____________________________________________________________
37
ProgressBar::ProgressBar( QObject* parent, QProgressBar* progressBar, QCheckBox* checkBox ):
39
_progressBar( progressBar ),
40
_checkBox( checkBox ),
42
{ connect( _checkBox, SIGNAL( toggled( bool ) ), SLOT( toggleBusy( bool ) ) ); }
44
//_____________________________________________________________
45
void ProgressBar::toggleBusy( bool value )
50
_value = _progressBar->value();
51
_progressBar->setMinimum( 0 );
52
_progressBar->setMaximum( 0 );
56
_progressBar->setMinimum( 0 );
57
_progressBar->setMaximum( 100 );
58
_progressBar->setValue( _value );
62
_progressBar->update();
66
//_____________________________________________________________
67
void ProgressBar::setValue( int value )
69
if( !_checkBox->isChecked() )
70
{ _progressBar->setValue( value ); }
73
//_____________________________________________________________
74
SliderDemoWidget::SliderDemoWidget( QWidget* parent ):
81
_progressBar1 = new ProgressBar( this, ui.progressBar, ui.checkBox );
82
_progressBar2 = new ProgressBar( this, ui.progressBar_2, ui.checkBox_2 );
83
ui.checkBox_2->setChecked( true );
85
connect( ui.horizontalSlider, SIGNAL( valueChanged( int ) ), SLOT( updateSliders( int ) ) );
86
connect( ui.horizontalScrollBar, SIGNAL( valueChanged( int ) ), SLOT( updateSliders( int ) ) );
87
connect( ui.verticalSlider, SIGNAL( valueChanged( int ) ), SLOT( updateSliders( int ) ) );
88
connect( ui.verticalScrollBar, SIGNAL( valueChanged( int ) ), SLOT( updateSliders( int ) ) );
89
connect( ui.dial, SIGNAL( valueChanged( int ) ), SLOT( updateSliders( int ) ) );
93
//_____________________________________________________________
94
void SliderDemoWidget::benchmark( void )
97
if( !isVisible() ) return;
100
simulator().slide( ui.horizontalSlider, QPoint( 50, 0 ) );
101
simulator().slide( ui.horizontalSlider, QPoint( -50, 0 ) );
103
simulator().slide( ui.horizontalScrollBar, QPoint( 50, 0 ) );
104
simulator().slide( ui.horizontalScrollBar, QPoint( -50, 0 ) );
107
simulator().slide( ui.verticalScrollBar, QPoint( 0, 50 ) );
108
simulator().slide( ui.verticalScrollBar, QPoint( 0, -50 ) );
110
simulator().slide( ui.verticalSlider, QPoint( 0, 50 ) );
111
simulator().slide( ui.verticalSlider, QPoint( 0, -50 ) );
119
//_____________________________________________________________
120
void SliderDemoWidget::updateSliders( int value )
122
if( _locked ) return;
125
_progressBar1->setValue( value );
126
_progressBar2->setValue( value );
128
ui.horizontalSlider->setValue( value );
129
ui.verticalSlider->setValue( value );
130
ui.progressBar_3->setValue( value );
131
ui.horizontalScrollBar->setValue( value );
132
ui.verticalScrollBar->setValue( value );
133
ui.dial->setValue( value );