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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
#!/usr/bin/perl -w
=head1 NAME
Debconf::Element::Kde::ElementWidget - Kde UI Widget
=cut
package Debconf::Element::Kde::ElementWidget;
use Qt;
use Qt::isa @ISA = qw(Qt::Widget);
use Qt::attributes qw(layout mytop toplayout);
=head1 DESCRIPTION
This is a helper module for Debconf::Element::Kde, it represents one KDE
widget that is part of a debconf display Element.
=head1 METHODS
=over 4
=item NEW
Sets up the element.
=cut
sub NEW {
shift->SUPER::NEW (@_[0..2]);
mytop = undef;
}
=item settop
Sets the top of the widget.
=cut
sub settop {
mytop = shift;
}
=item init
Initializes the widget.
=cut
sub init {
setSizePolicy(Qt::SizePolicy(1, &Qt::SizePolicy::Preferred, 0,
0, sizePolicy()->hasHeightForWidth()));
toplayout = layout = Qt::VBoxLayout(this, 0, 10, "TopVBox");
if (mytop) {
toplayout->addWidget (mytop);
layout = Qt::VBoxLayout(mytop, 15, 5, "TopVBox");
}
else {
mytop = this;
}
}
=item destroy
Destroy the widget.
=cut
sub destroy {
toplayout -> remove (mytop);
undef mytop;
}
=item top
Returns the top of the widget.
=cut
sub top {
return mytop;
}
=item addwidget
Adds the passed widget to the latout.
=cut
sub addwidget {
layout->addWidget(@_);
}
=item addlayout
Adds the passed layout.
=cut
sub addlayout {
layout->addLayout (@_);
}
=item additem
Adds the passed item to the layout.
=cut
sub additem {
my $item=shift;
layout->addItem($item);
}
=back
=head1 AUTHOR
Peter Rockai <mornfall@logisys.dyndns.org>
=cut
# XXX The above docs suck, and shouldn't it be in its own file?
=head1 NAME
Debconf::Element::Kde - kde UI element
=cut
package Debconf::Element::Kde;
use strict;
use Qt;
use Debconf::Gettext;
use base qw(Debconf::Element);
use Debconf::Element::Kde::ElementWidget;
use Debconf::Encoding qw(to_Unicode);
=head1 DESCRIPTION
This is a type of Element used by the kde FrontEnd.
=head1 METHODS
=over 4
=item create
Called to create a the necessary Qt widgets for the element..
=cut
sub create {
my $this=shift;
$this->parent(shift);
$this->top(Debconf::Element::Kde::ElementWidget($this->parent, undef,
undef, undef));
$this->top->init;
$this->top->show;
}
=item destroy
Called to destroy the element.
=cut
sub destroy {
my $this=shift;
$this->top->destroy;
$this->top->reparent(undef, 0, Qt::Point(0, 0), 0);
$this->top->DESTROY;
$this->top(undef);
}
=item addhbox
Adds a kbox to the layout, and returns it.
=cut
sub addhbox {
my $this=shift;
my $hbox = Qt::HBoxLayout(undef, 0, 8, "SubHBox");
$this->cur->addlayout($hbox);
return $hbox;
}
=item addwidget
Adds a widget.
=cut
sub addwidget {
my $this=shift;
my $widget=shift;
$this->cur->addwidget($widget);
}
=item description
Sets up a label to display the description of the element's question.
=cut
sub description {
my $this=shift;
my $label=Qt::Label($this->cur->top);
$label->setText(to_Unicode($this->question->description));
$label->setSizePolicy(Qt::SizePolicy(1, 1, 0, 0, $label->sizePolicy()->hasHeightForWidth()));
$label->show;
return $label;
}
=item startsect
Creates a groupbox to hold the set of widgets used for this element,
and points cur at it so new widgets go in there.
=cut
sub startsect {
my $this = shift;
my $ew = Debconf::Element::Kde::ElementWidget($this->top);
my $mytop = Qt::GroupBox($ew);
$ew->settop($mytop);
$ew->init;
$this->cur($ew);
$this->top->addwidget($ew);
$ew->show;
}
=item endsect
End adding widgets for this element.
=cut
sub endsect {
my $this = shift;
$this->cur($this->top);
}
=item adddescription
Creates a label for the description of this Element.
=cut
sub adddescription {
my $this=shift;
my $label=$this->description;
$this->addwidget($label);
}
=item addhelp
Creates a label to display the entended descrition of the Question
associated with this Element,
=cut
sub addhelp {
my $this=shift;
my $help=to_Unicode($this->question->extended_description);
return unless length $help;
my $label=Qt::Label($this->cur->top);
$label->setText($help);
$label->setTextFormat(&Qt::AutoText);
$label->setAlignment(&Qt::WordBreak | &Qt::AlignJustify);
$label->setSizePolicy(Qt::SizePolicy(&Qt::SizePolicy::Minimum,
&Qt::SizePolicy::Fixed,
0, 0, $label->sizePolicy()->hasHeightForWidth()));
$this->addwidget($label); # line1
$label->show;
}
=item value
Return the value the user entered.
Defaults to returning nothing.
=cut
sub value {
my $this=shift;
return '';
}
=back
=head1 AUTHOR
Peter Rockai <mornfall@logisys.dyndns.org>
=cut
1
|