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 (90 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download | duplicates (4)
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
package Window;

use strict;
use warnings;
use QtCore4;
use QtGui4;
# [0]
use QtCore4::isa qw( Qt::Widget );
use CircleWidget;

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

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

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

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

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

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

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

    this->{aliasedLabel} = this->createLabel(this->tr('Aliased'));
    this->{antialiasedLabel} = this->createLabel(this->tr('Antialiased'));
    this->{intLabel} = this->createLabel(this->tr('Int'));
    this->{floatLabel} = this->createLabel(this->tr('Float'));
    this->{circleWidgets} = [];

    my $layout = Qt::GridLayout();
    $layout->addWidget(this->aliasedLabel, 0, 1);
    $layout->addWidget(this->antialiasedLabel, 0, 2);
    $layout->addWidget(this->intLabel, 1, 0);
    $layout->addWidget(this->floatLabel, 2, 0);
# [0]

# [1]
    my $timer = Qt::Timer(this);

    for (my $i = 0; $i < 2; ++$i) {
        for (my $j = 0; $j < 2; ++$j) {
            this->circleWidgets->[$i]->[$j] = CircleWidget();
            this->circleWidgets->[$i]->[$j]->setAntialiased($j != 0);
            this->circleWidgets->[$i]->[$j]->setFloatBased($i != 0);

            this->connect($timer, SIGNAL 'timeout()',
                    this->circleWidgets->[$i]->[$j], SLOT 'nextAnimationFrame()');

            $layout->addWidget(this->circleWidgets->[$i]->[$j], $i + 1, $j + 1);
        }
    }
# [1] //! [2]
    $timer->start(100);
    this->setLayout($layout);

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

# [3]
sub createLabel
{
    my ($text) = @_;
    my $label = Qt::Label($text);
    $label->setAlignment(Qt::AlignCenter());
    $label->setMargin(2);
    $label->setFrameStyle(Qt::Frame::Box() | Qt::Frame::Sunken());
    return $label;
}
# [3]

1;