diff options
Diffstat (limited to 'AdminPanel/Shared.pm')
-rw-r--r-- | AdminPanel/Shared.pm | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/AdminPanel/Shared.pm b/AdminPanel/Shared.pm index 6f4f703..77f1d1b 100644 --- a/AdminPanel/Shared.pm +++ b/AdminPanel/Shared.pm @@ -32,6 +32,7 @@ our @EXPORT = qw(warningMsgBox infoMsgBox ask_YesOrNo ask_OkCancel + AboutDialog trim); sub warningMsgBox { @@ -144,6 +145,209 @@ sub ask_YesOrNo { return $retVal; } +sub AboutDialog { + my ($opts) = @_; + + # Credits dialog + sub Credits { + my ($opts) = @_; + + my $factory = yui::YUI::widgetFactory; + my $optional = yui::YUI::optionalWidgetFactory; + + my $licensedlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($licensedlg); + + # header + $factory->createHBox($layout); + my $hbox = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox); + $hbox = $factory->createHBox($align); + $factory->createHeading($hbox, N("Credits")); + + # Credits tab widget + if ($optional->hasDumbTab()) { + $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + my $dumptab = $optional->createDumbTab($align); + my $item = new yui::YItem(N("Written by")); + $item->setSelected(); + $dumptab->addItem( $item ); + $item->DISOWN(); + if (exists $opts->{documenters}) { + $item = new yui::YItem(N("Documented by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + if (exists $opts->{translator_credits}) { + $item = new yui::YItem(N("Translated by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + if (exists $opts->{artists}) { + $item = new yui::YItem(N("Artwork by")); + $dumptab->addItem( $item ); + $item->DISOWN(); + } + my $vbox = $factory->createVBox($dumptab); + $align = $factory->createLeft($vbox); + $factory->createVSpacing($vbox, 1.0); + my $label = $factory->createRichText( $align, "***", 1); + $factory->createVSpacing($vbox, 1.0); + + # start value for first Item + $label->setValue($opts->{authors}) if exists $opts->{authors}; + + # Close button + $align = $factory->createRight($layout); + my $closeButton = $factory->createPushButton($align, N("Close")); + + # manage Credits dialog events + while(1) { + my $event = $licensedlg->waitForEvent(); + my $eventType = $event->eventType(); + + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + + if ($widget == $closeButton) { + last; + } + } + elsif ($event->item() ) { + # $eventType MenuEvent!!! + my $itemLabel = $event->item()->label(); + $itemLabel =~ s/&//; #remove shortcut from label + if ($itemLabel eq N("Written by")) { + $label->setValue($opts->{authors}) if exists $opts->{authors}; + } + elsif ($itemLabel eq N("Documented by")) { + $label->setValue($opts->{documenters}) if exists $opts->{documenters}; + } + elsif ($itemLabel eq N("Translated by")) { + $label->setValue($opts->{translator_credits}) if exists $opts->{translator_credits}; + } + elsif ($itemLabel eq N("Artwork by")) { + $label->setValue($opts->{artists}) if exists $opts->{artists}; + } + } + } + } + else { + print "No tab widgets available!\n"; + } + destroy $licensedlg; + } + + # License dialog + sub License { + my ($license) = @_; + + my $factory = yui::YUI::widgetFactory; + my $licensedlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($licensedlg); + + # header + $factory->createHBox($layout); + my $hbox = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox); + $hbox = $factory->createHBox($align); + $factory->createHeading($hbox, N("License")); + + # license + $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + $factory->createRichText( $align, $license, 1); + + $align = $factory->createRight($layout); + my $closeButton = $factory->createPushButton($align, N("Close")); + + $licensedlg->waitForEvent(); + + destroy $licensedlg; + } + + my $website = "http://www.mageia.org"; + my $website_label = "Mageia"; + my $factory = yui::YUI::widgetFactory; + my $aboutdlg = $factory->createPopupDialog(); + my $layout = $factory->createVBox($aboutdlg); + + # header + $factory->createHBox($layout); + my $hbox_iconbar = $factory->createHBox($layout); + my $align = $factory->createHVCenter($hbox_iconbar); + $hbox_iconbar = $factory->createHBox($align); + $factory->createImage($hbox_iconbar, $opts->{logo}) if exists $opts->{logo}; + my $header = $opts->{name} . " " . $opts->{version}; + $factory->createHeading($hbox_iconbar, $header); + + # comments + my $hbox = $factory->createHBox($layout); + $align = $factory->createAlignment($hbox, 3, 0); + $factory->createLabel( $align, $opts->{comments}, 0, 0) if exists $opts->{comments}; + + # copyright + $hbox = $factory->createHBox($layout); + $align = $factory->createHVCenter($hbox); + $factory->createLabel( $align, $opts->{copyright}, 0, 0) if exists $opts->{copyright}; + + # website / website_label + $hbox = $factory->createHBox($layout); + $align = $factory->createHVCenter($hbox); + $website = $opts->{website} if exists $opts->{website}; + $website_label = $opts->{website_label} if exists $opts->{website_label}; + my $webref = "<a href=\"". $website ."\">". $website_label ."</a>"; + $factory->createRichText( $align, $webref); + + # Credits, License and Close buttons + $hbox = $factory->createHBox($layout); + $align = $factory->createLeft($hbox); + my $hbox1 = $factory->createHBox($align); + my $creditsButton = $factory->createPushButton($hbox1, N("Credits")); + my $licenseButton = $factory->createPushButton($hbox1, N("License")); + $factory->createHSpacing($hbox, 2.0); + $align = $factory->createRight($hbox); + my $closeButton = $factory->createPushButton($align, N("Close")); + + # AboutDialog Events + while(1) { + my $event = $aboutdlg->waitForEvent(); + my $eventType = $event->eventType(); + + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + + if($widget == $licenseButton) { + License($opts->{license}) if exists $opts->{license}; + } + elsif ($widget == $creditsButton) { + Credits($opts); + } + elsif ($widget == $closeButton) { + last; + } + } + elsif ($eventType == $yui::YEvent::MenuEvent) { + my $menuEvent = yui::YMGAWidgetFactory::getYMenuEvent($event); + #TODO check why is not working + run_program::raw({ detach => 1 }, 'www-browser', $menuEvent->id()); + } + } + + destroy $aboutdlg; +} + sub trim { my ($st) = shift; $st =~s /^\s+//g; @@ -172,6 +376,10 @@ sub trim { shows a message box for informations +=head2 AboutDialog + + shows an About Dialog box + =head2 ask_YesOrNo shows a dialog with two buttons (Yes/No) |