File: SplashItem.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 (76 lines) | stat: -rw-r--r-- 1,770 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
package SplashItem;

use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::GraphicsWidget );
use QtCore4::slots
    setValue => ['qreal'];

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

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

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

sub NEW
{
    my ($class, $parent) = @_;
    $class->SUPER::NEW( $parent );
    this->{opacity} = 1.0;

    
    this->{timeLine} = Qt::TimeLine(350);
    timeLine->setCurveShape(Qt::TimeLine::EaseInCurve());
    this->connect(timeLine, SIGNAL 'valueChanged(qreal)', this, SLOT 'setValue(qreal)');

    this->{text} = this->tr('Welcome to the Pad Navigator Example. You can use the' .
              ' keyboard arrows to navigate the icons, and press enter' .
              ' to activate an item. Please press any key to continue.');
    resize(400, 175);
}

sub paint
{
    my ($painter) = @_;
    $painter->setOpacity(opacity);
    $painter->setPen(Qt::Pen(Qt::Brush(Qt::Color(Qt::black())), 2));
    $painter->setBrush(Qt::Brush(Qt::Color(245, 245, 255, 220)));
    $painter->setClipRect(rect());
    $painter->drawRoundRect(3, -100 + 3, 400 - 6, 250 - 6);

    my $textRect = rect()->adjusted(10, 10, -10, -10);
    my $flags = Qt::AlignTop() | Qt::AlignLeft() | Qt::TextWordWrap();

    my $font = Qt::Font();
    $font->setPixelSize(18);
    $painter->setPen(Qt::black());
    $painter->setFont($font);
    $painter->drawText($textRect, $flags, text);
}

sub keyPressEvent
{
    if (timeLine->state() == Qt::TimeLine::NotRunning()) {
        timeLine->start();
    }
}

sub setValue
{
    my ($value) = @_;
    this->{opacity} = 1 - $value;
    setPos(x(), scene()->sceneRect()->top() - rect()->height() * $value);
    if ($value == 1) {
        hide();
    }
}

1;