File: MainWindow.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 (108 lines) | stat: -rw-r--r-- 2,772 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
package MainWindow;

use strict;
use warnings;

use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::MainWindow );

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

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

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

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

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

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

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

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

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

my $listEntries = [
    ['MainWindow', 'First'],
    ['MainWindow', 'Second'],
    ['MainWindow', 'Third'],
    0
];

sub NEW {
    my ( $class ) = @_;
    $class->SUPER::NEW();
    my $centralWidget = Qt::Widget();
    this->{centralWidget} = $centralWidget;
    this->setCentralWidget($centralWidget);

    this->createGroupBox();

    my $listWidget = Qt::ListWidget();
    this->{listWidget} = $listWidget;
    for (my $i = 0; $listEntries->[$i]; ++$i) {
        $listWidget->addItem(qApp->translate($listEntries->[$i]->[0], $listEntries->[$i]->[1]));
    }

    my $mainLayout = Qt::VBoxLayout();
    $mainLayout->addWidget(this->groupBox);
    $mainLayout->addWidget($listWidget);
    $centralWidget->setLayout($mainLayout);

    my $exitAction = Qt::Action(this->tr('E&xit'), this);
    this->{exitAction} = $exitAction;
    this->connect($exitAction, SIGNAL 'triggered()', qApp, SLOT 'quit()');

    my $fileMenu = this->menuBar()->addMenu(this->tr('&File'));
    this->{fileMenu} = $fileMenu;
    $fileMenu->setPalette(Qt::Palette(Qt::red()));
    $fileMenu->addAction($exitAction);

    this->setWindowTitle(this->tr('Language:').this->tr('English'));
    this->statusBar()->showMessage(this->tr('Internationalization Example'));

    if (this->tr('LTR') eq 'RTL') {
        this->setLayoutDirection(Qt::RightToLeft());
    }
}

sub createGroupBox {
    my $groupBox = Qt::GroupBox(this->tr('View'));
    this->{groupBox} = $groupBox;
    my $perspectiveRadioButton = Qt::RadioButton(this->tr('Perspective'));
    this->{perspectiveRadioButton} = $perspectiveRadioButton;
    my $isometricRadioButton = Qt::RadioButton(this->tr('Isometric'));
    this->{isometricRadioButton} = $isometricRadioButton;
    my $obliqueRadioButton = Qt::RadioButton(this->tr('Oblique'));
    this->{obliqueRadioButton} = $obliqueRadioButton;
    $perspectiveRadioButton->setChecked(1);

    my $groupBoxLayout = Qt::VBoxLayout();
    $groupBoxLayout->addWidget($perspectiveRadioButton);
    $groupBoxLayout->addWidget($isometricRadioButton);
    $groupBoxLayout->addWidget($obliqueRadioButton);
    $groupBox->setLayout($groupBoxLayout);
}

1;