1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
package SlidersGroup;
use strict;
use warnings;
use QtCore4;
use QtGui4;
# [0]
use QtCore4::isa qw( Qt::GroupBox );
use QtCore4::signals
valueChanged => ['int'];
use QtCore4::slots
setValue => ['int'],
setMinimum => ['int'],
setMaximum => ['int'],
invertAppearance => ['bool'],
invertKeyBindings => ['bool'];
sub slider() {
return this->{slider};
}
sub scrollBar() {
return this->{scrollBar};
}
sub dial() {
return this->{dial};
}
# [0]
# [0]
sub NEW {
my ( $class, $orientation, $title, $parent) = @_;
$class->SUPER::NEW( $title, $parent );
my $slider = this->{slider} = Qt::Slider($orientation);
$slider->setFocusPolicy(Qt::StrongFocus());
$slider->setTickPosition(Qt::Slider::TicksBothSides());
$slider->setTickInterval(10);
$slider->setSingleStep(1);
my $scrollBar = this->{scrollBar} = Qt::ScrollBar($orientation);
$scrollBar->setFocusPolicy(Qt::StrongFocus());
my $dial = this->{dial} = Qt::Dial();
$dial->setFocusPolicy(Qt::StrongFocus());
this->connect($slider, SIGNAL 'valueChanged(int)', $scrollBar, SLOT 'setValue(int)');
this->connect($scrollBar, SIGNAL 'valueChanged(int)', $dial, SLOT 'setValue(int)');
this->connect($dial, SIGNAL 'valueChanged(int)', $slider, SLOT 'setValue(int)');
# [0] //! [1]
this->connect($dial, SIGNAL 'valueChanged(int)', this, SIGNAL 'valueChanged(int)');
# [1] //! [2]
# [2] //! [3]
my $direction;
# [3] //! [4]
if ($orientation == Qt::Horizontal()) {
$direction = Qt::BoxLayout::TopToBottom();
}
else {
$direction = Qt::BoxLayout::LeftToRight();
}
my $slidersLayout = Qt::BoxLayout($direction);
$slidersLayout->addWidget($slider);
$slidersLayout->addWidget($scrollBar);
$slidersLayout->addWidget($dial);
this->setLayout($slidersLayout);
}
# [4]
# [5]
sub setValue {
# [5] //! [6]
my ($value) = @_;
this->slider->setValue($value);
}
# [6]
# [7]
sub setMinimum {
# [7] //! [8]
my ($value) = @_;
this->slider->setMinimum($value);
this->scrollBar->setMinimum($value);
this->dial->setMinimum($value);
}
# [8]
# [9]
sub setMaximum {
# [9] //! [10]
my ($value) = @_;
this->slider->setMaximum($value);
this->scrollBar->setMaximum($value);
this->dial->setMaximum($value);
}
# [10]
# [11]
sub invertAppearance {
# [11] //! [12]
my ($invert) = @_;
this->slider->setInvertedAppearance($invert);
this->scrollBar->setInvertedAppearance($invert);
this->dial->setInvertedAppearance($invert);
}
# [12]
# [13]
sub invertKeyBindings {
# [13] //! [14]
my ($invert) = @_;
this->slider->setInvertedControls($invert);
this->scrollBar->setInvertedControls($invert);
this->dial->setInvertedControls($invert);
}
# [14]
1;
|