File: PlasmaAppletPerlHelloPlasmoid.pm

package info (click to toggle)
qt4-perl 4.5~~svn1145508-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,144 kB
  • ctags: 5,947
  • sloc: perl: 29,224; cpp: 18,849; xml: 98; makefile: 91; sh: 4
file content (46 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download
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
package PlasmaAppletPerlHelloPlasmoid;

use strict;
use warnings;

use KDEUi4;
use Plasma4;
use Qt4::isa qw( Plasma::Applet );

my $foo;

sub NEW {
    my ( $class, $parent, $args ) = @_;
    $args = [map{ Qt4::Variant( $_ ) } @$args]; 
    $class->SUPER::NEW( $parent, $args );
    $foo->{bar} = this;

    this->{m_svg} = Plasma::Svg(this);
    this->{m_icon} = KDE::Icon('document');

    this->{m_svg}->setImagePath('widgets/background');
    this->setBackgroundHints(Plasma::Applet::DefaultBackground());
    this->resize(200,200);
}

sub paintInterface {
    my ( $p, $option, $contentsRect ) = @_;
    $p->setRenderHint(Qt4::Painter::SmoothPixmapTransform());
    $p->setRenderHint(Qt4::Painter::Antialiasing());
 
    # Now we draw the applet, starting with our svg
    this->{m_svg}->resize($contentsRect->width(), $contentsRect->height());
    this->{m_svg}->paint($p, $contentsRect->left(), $contentsRect->top());
 
    # We place the icon and text
    $p->drawPixmap(7, 0, this->{m_icon}->pixmap($contentsRect->width(),$contentsRect->width()-14));
    $p->save();
    $p->setPen(Qt4::white());
    $p->drawText($contentsRect,
                Qt4::AlignBottom() | Qt4::AlignHCenter(),
                "Hello Plasmoid!");
    $p->restore();

}

1;