File: Window.pm

package info (click to toggle)
qt4-perl 4.8.4-1.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,636 kB
  • ctags: 8,100
  • sloc: perl: 42,963; cpp: 28,039; makefile: 160; xml: 98; sh: 4
file content (168 lines) | stat: -rw-r--r-- 5,135 bytes parent folder | download | duplicates (3)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package Window;

use strict;
use warnings;

use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Widget );
use SlidersGroup;

# [0]
sub horizontalSliders() {
    return this->{horizontalSliders};
}

sub verticalSliders() {
    return this->{verticalSliders};
}

sub stackedWidget() {
    return this->{stackedWidget};
}

sub controlsGroup() {
    return this->{controlsGroup};
}

sub minimumLabel() {
    return this->{minimumLabel};
}

sub maximumLabel() {
    return this->{maximumLabel};
}

sub valueLabel() {
    return this->{valueLabel};
}

sub invertedAppearance() {
    return this->{invertedAppearance};
}

sub invertedKeyBindings() {
    return this->{invertedKeyBindings};
}

sub minimumSpinBox() {
    return this->{minimumSpinBox};
}

sub maximumSpinBox() {
    return this->{maximumSpinBox};
}

sub valueSpinBox() {
    return this->{valueSpinBox};
}

sub orientationCombo() {
    return this->{orientationCombo};
}
# [0]

# [0]
sub NEW {
    my ( $class, $parent ) = @_;
    $class->SUPER::NEW( $parent );

    this->{horizontalSliders} = SlidersGroup(Qt::Horizontal(), this->tr('Horizontal'));
    this->{verticalSliders} = SlidersGroup(Qt::Vertical(), this->tr('Vertical'));

    this->{stackedWidget} = Qt::StackedWidget();
    this->stackedWidget->addWidget(this->horizontalSliders);
    this->stackedWidget->addWidget(this->verticalSliders);

    this->createControls(this->tr('Controls'));
# [0]

# [1]
    this->connect(this->horizontalSliders, SIGNAL 'valueChanged(int)',
# [1] //! [2]
            this->verticalSliders, SLOT 'setValue(int)');
    this->connect(this->verticalSliders, SIGNAL 'valueChanged(int)',
            this->valueSpinBox, SLOT 'setValue(int)');
    this->connect(this->valueSpinBox, SIGNAL 'valueChanged(int)',
            this->horizontalSliders, SLOT 'setValue(int)');

    my $layout = Qt::HBoxLayout();
    $layout->addWidget(this->controlsGroup);
    $layout->addWidget(this->stackedWidget);
    this->setLayout($layout);

    this->minimumSpinBox->setValue(0);
    this->maximumSpinBox->setValue(20);
    this->valueSpinBox->setValue(5);

    this->setWindowTitle(this->tr('Sliders'));
}
# [2]

# [3]
sub createControls {
# [3] //! [4]
    my ($title) = @_;
    this->{controlsGroup} = Qt::GroupBox($title);

    this->{minimumLabel} = Qt::Label(this->tr('Minimum value:'));
    this->{maximumLabel} = Qt::Label(this->tr('Maximum value:'));
    this->{valueLabel} = Qt::Label(this->tr('Current value:'));

    this->{invertedAppearance} = Qt::CheckBox(this->tr('Inverted appearance'));
    this->{invertedKeyBindings} = Qt::CheckBox(this->tr('Inverted key bindings'));

# [4] //! [5]
    this->{minimumSpinBox} = Qt::SpinBox();
# [5] //! [6]
    this->minimumSpinBox->setRange(-100, 100);
    this->minimumSpinBox->setSingleStep(1);

    this->{maximumSpinBox} = Qt::SpinBox();
    this->maximumSpinBox->setRange(-100, 100);
    this->maximumSpinBox->setSingleStep(1);

    this->{valueSpinBox} = Qt::SpinBox();
    this->valueSpinBox->setRange(-100, 100);
    this->valueSpinBox->setSingleStep(1);

    this->{orientationCombo} = Qt::ComboBox();
    this->orientationCombo->addItem(this->tr('Horizontal slider-like widgets'));
    this->orientationCombo->addItem(this->tr('Vertical slider-like widgets'));

# [6] //! [7]
    this->connect(this->orientationCombo, SIGNAL 'activated(int)',
# [7] //! [8]
            this->stackedWidget, SLOT 'setCurrentIndex(int)');
    this->connect(this->minimumSpinBox, SIGNAL 'valueChanged(int)',
            this->horizontalSliders, SLOT 'setMinimum(int)');
    this->connect(this->minimumSpinBox, SIGNAL 'valueChanged(int)',
            this->verticalSliders, SLOT 'setMinimum(int)');
    this->connect(this->maximumSpinBox, SIGNAL 'valueChanged(int)',
            this->horizontalSliders, SLOT 'setMaximum(int)');
    this->connect(this->maximumSpinBox, SIGNAL 'valueChanged(int)',
            this->verticalSliders, SLOT 'setMaximum(int)');
    this->connect(this->invertedAppearance, SIGNAL 'toggled(bool)',
            this->horizontalSliders, SLOT 'invertAppearance(bool)');
    this->connect(this->invertedAppearance, SIGNAL 'toggled(bool)',
            this->verticalSliders, SLOT 'invertAppearance(bool)');
    this->connect(this->invertedKeyBindings, SIGNAL 'toggled(bool)',
            this->horizontalSliders, SLOT 'invertKeyBindings(bool)');
    this->connect(this->invertedKeyBindings, SIGNAL 'toggled(bool)',
            this->verticalSliders, SLOT 'invertKeyBindings(bool)');

    my $controlsLayout = Qt::GridLayout();
    $controlsLayout->addWidget(this->minimumLabel, 0, 0);
    $controlsLayout->addWidget(this->maximumLabel, 1, 0);
    $controlsLayout->addWidget(this->valueLabel, 2, 0);
    $controlsLayout->addWidget(this->minimumSpinBox, 0, 1);
    $controlsLayout->addWidget(this->maximumSpinBox, 1, 1);
    $controlsLayout->addWidget(this->valueSpinBox, 2, 1);
    $controlsLayout->addWidget(this->invertedAppearance, 0, 2);
    $controlsLayout->addWidget(this->invertedKeyBindings, 1, 2);
    $controlsLayout->addWidget(this->orientationCombo, 3, 0, 1, 3);
    this->controlsGroup->setLayout($controlsLayout);
}
# [8]

1;