#!/usr/bin/perl -w

package mainWidget;
use strict;
use Qt;
use Qt::isa "Qt::VBox";
use stackPage;

sub NEW {
    shift->SUPER::NEW( @_ );

    this->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    this->setPaletteForegroundColor( &Color( 255, 255, 255 ) );

    topFrame();
    midFrame();
    btmFrame();
}

sub topFrame {
    my $f = Qt::Font( Qt::Font( "Bitstream Vera Sans" ) );

    my $tFrame = Qt::Frame( this, 0, 0 );
    $tFrame->setPaletteBackgroundColor( &Color( 0, 64, 127 ) );
    $tFrame->setPaletteForegroundColor( &Color( 255, 255, 255 ) );
    $tFrame->setFixedHeight( 100 );

    my $myLabel = Qt::Label( "Welcome to Ark Linux", $tFrame );
    $myLabel->setGeometry( Qt::Rect( 300, 0, 600, 90 ) );
    $myLabel->setFont( Qt::Font( "Bitstream Vera Sans", 24, &Qt::Font::Bold ) );
    $myLabel->setAlignment( &AlignCenter );
}

sub midFrame {
    my $mainWidgetStack = Qt::WidgetStack( this, 0 );
    
    my $introPage = Qt::Widget( $mainWidgetStack, 0 );
    my $introPageLayout = Qt::VBoxLayout( $introPage, 11, 6, 0);
    my $welcomeTextLabel = Qt::Label( $introPage, 0 );
    $introPageLayout->addWidget( $welcomeTextLabel );
    my $spacer1 = Qt::SpacerItem( 1500, 20, Qt::SizePolicy::Expanding(), Qt::SizePolicy::Minimum() );
    $introPageLayout->addItem( $spacer1 );
    my $spacer2 = Qt::SpacerItem( 20, 800, Qt::SizePolicy::Minimum(), Qt::SizePolicy::Expanding() );
    $introPageLayout->addItem( $spacer2 );
    my $string = "<font size=2>Now that you have installed Ark Linux, please spend a few moments to
                  configure your computer.<p>
                  If you have any questions about an option, feel free to click the help button below
                  and then click on the item while the cursor looks like a question mark to view it's
                  inline help.</font>";
    $welcomeTextLabel->setText( $string );
    $welcomeTextLabel->setFont( Qt::Font( "Bitstream Vera Sans", 14, &Qt::Font::Normal ) );
    $mainWidgetStack->addWidget( $introPage, 0 );

    my $accountsSetupPage = Qt::Widget( $mainWidgetStack, 0 );
    my $accountsSetupPageLayout = Qt::VBoxLayout( $accountsSetupPage, 11, 6, 0 );
    my $step1String = Qt::Label( $accountsSetupPage, 0 );
    $step1String->setText( "<font size=\+4>Step 1:</font>" );
#    $accountsSetupPage->addWidget( $step1String );
    
    

    
}

sub btmFrame {
    my $backIcon = Qt::Pixmap( "/usr/share/icons/crystalsvg/32x32/actions/back.png" );
    my $helpIcon = Qt::Pixmap( "/usr/share/icons/crystalsvg/32x32/actions/help.png" );
    my $exitIcon = Qt::Pixmap( "/usr/share/icons/crystalsvg/32x32/actions/stop.png" );
    my $nextIcon = Qt::Pixmap( "/usr/share/icons/crystalsvg/32x32/actions/forward.png" );

    my $line1 = Qt::Frame( this, 0 );
    $line1->setGeometry( Qt::Rect( 0, 700, 1024, 20 ) );
    $line1->setFrameShape( Qt::Frame::HLine() );
    $line1->setFrameShadow( Qt::Frame::Sunken() );

    my $privLayWidget = Qt::Widget( this, "bLayMan" );
    $privLayWidget->setGeometry( Qt::Rect( 10, 720, 1000, 42 ) );
    my $bLayMan = Qt::HBoxLayout( $privLayWidget, 11, 6, "layout2");

    my $backBttn = Qt::PushButton( $privLayWidget, 0 );
    $backBttn->setFlat( 1 );
    $backBttn->setPixmap( $backIcon );
    $backBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $bLayMan->addWidget( $backBttn );

    my $b_Spacer = Qt::SpacerItem( 750, 20, &Qt::SizePolicy::Expanding, &Qt::SizePolicy::Minimum );
    $bLayMan->addItem( $b_Spacer );

    my $helpBttn = Qt::PushButton( $privLayWidget, 0 );
    $helpBttn->setFlat( 1 );
    $helpBttn->setPixmap( $helpIcon );
    $helpBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $bLayMan->addWidget( $helpBttn );

    my $line2 = Qt::Frame( $privLayWidget, 0 );
    $line2->setFrameShape( Qt::Frame::VLine() );
    $line2->setFrameShadow( Qt::Frame::Sunken() );
    $bLayMan->addWidget( $line2 );

    my $exitBttn = Qt::PushButton( $privLayWidget, 0 );
    $exitBttn->setFlat( 1 );
    $exitBttn->setPixmap( $exitIcon );
    $exitBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $bLayMan->addWidget( $exitBttn );
    $exitBttn->connect( $exitBttn, SIGNAL 'pressed()', Qt::app(), SLOT  'quit()' );
    
    my $nextBttn = Qt::PushButton( $privLayWidget, 0 );
    $nextBttn->setFlat( 1 );
    $nextBttn->setPixmap( $nextIcon );
    $nextBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $bLayMan->addWidget( $nextBttn );
    $nextBttn->connect( $nextBttn, SIGNAL 'pressed()', $wdgt::midFrame, SLOT 'raiseWidget( aboutToShow() )' );
}

1;

package main;
use Qt;
use strict;

use mainWidget;

my $app = Qt::Application(\@ARGV);
my $wdgt = mainWidget;

Qt::Object::connect( $app, SIGNAL( "lastWindowClosed()" ), $app, SLOT( "quit()" ) );

$app->setName( "AFTWiZard" );

$app->setMainWidget( $wdgt );

$wdgt->showFullScreen();
$wdgt->show();

$app->exec();

exit 0;
