UI blocking with actions that shouldn't affect display....

Gary Greene <[email protected]> Thu, 6 Oct 2005 11:15:07 -0400
Newsgroups gmane.comp.kde.devel.perl
Organization Shore Line Technologies
Message-ID <[email protected]>
While developing the installer for PhoeNUX OS, I've run into a little issue 
that I'm fairly sure is my fault in the code and not the perl-qt module. The 
issue being that when I call an external dialog with the $dialog->show(), and 
then do some tasks in the code after that in the method that calls the 
dialog, it does not show the dialog until the tasks are completed. Attached 
is the code, and the affected subroutine is doInstall() in the MainWidget.pm 
package. Please, if anyone has any ideas on how to get this to not stop the 
the UI from showing, pass me a few pointers. Thanks.


-- 
Gary L. Greene, Jr.
Sent from uriel.tolharadys.net
 11:06:14 up 5 days, 17:40,  4 users,  load average: 0.28, 0.62, 0.63
 
============================================================
Developer and Project Lead for PhoeNUX OS.
 check out http://www.phoenuxos.com/ for more info.
EMAIL : [email protected]
============================================================

_______________________________________________
Kde-perl mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-perl
MainWidget.pm (application/x-perl-module, 32.8 KB)
#!/usr/bin/perl

##############################################################################
#                                                                            #
# AUTHOR: Gary Greene <[email protected]>                                #
# Copyright (C) 2005 Shore Line Technologies, Ltd.                           #
##############################################################################


#==============================================================================
# Start package MainWidget

package MainWidget;
# use strict;
use warnings;
use lib qw( "/home/greeneg/Documents/src/phinos/" );
use Switch;
use Qt;
use Qt::isa "Qt::VBox";
use Qt::attributes qw{
    allDoneGrp
    allDoneMsg
    backBttn
    closingString
    dataLossWarningLbl
    detectedPrevOsString
    driveActionsGrp
    driveText
    driveView
    eulaAgreeChBx
    helpBttn
    installMeRBttn
    installMethod
    line2
    mainWidgetStack
    nextBttn
    ntpChkBx
    partToolBttn
    partToolRBttn
    prevOsIs
    Qt::WhatsThis
    rebootBttn
    stackPageImage6
    step4String
    step5String
    step6String
    takeOverDriveRBttn
    targetSetupGrp
    timezoneListBox
    updatableOsGrp
    upgradeMeRBttn
};
use Qt::slots
    advancedPartAction      => [],
    driveSelected           => ['QIconViewItem*'],
    enableNext              => [],
    installMe               => [],
    nextPage                => [],
    prevPage                => [],
    setNtpServer            => [],
    setWhatsThisMode        => [],
    rebootComputer          => [],
    startDiskDrake          => [],
    takeOverDriveRBAction   => [],
    theyAgreedToTheEULA     => [],
    upgradeMe               => [];
use Qt::signals;
use Cwd;
use Detect;
use Convenience_Lib;
use installProgressDlg;
use Fs;

no strict "subs";

sub NEW {
    shift->SUPER::NEW( @_ );
    my $classname = @_;
    my $self = {};

    this->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    this->setPaletteForegroundColor( &Color( 0, 0, 0 ) );
    this->setPaletteBackgroundPixmap( &Pixmap( "/usr/share/pixmaps/installer/backg.png" ) );

    my $f = Qt::Font();
    $f->setFamily( "Bitstream Vera Sans" );
    $f->setPointSize( 10 );
    this->setFont( $f );

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

    return bless $self, $classname;
}

sub topFrame {
    my $tFrame = Qt::Frame( this, 0 );
    $tFrame->setGeometry( &Rect( 0, -2, 1024, 100 ) );
    $tFrame->setPaletteBackgroundColor( &Color( 0, 64, 127 ) );
    $tFrame->setPaletteBackgroundPixmap( &Pixmap( "/usr/share/pixmaps/installer/tbackg.png" ) );
    $tFrame->setFrameShape( Qt::Frame::StyledPanel() );
    $tFrame->setFrameStyle( Qt::Frame::Raised() );
    $tFrame->setBackgroundOrigin( &WindowOrigin );

    my $topLogo = Qt::Label( $tFrame, "topLogo" );
    $topLogo->setGeometry( &Rect( 10, 10, 300, 70 ) );
    $topLogo->setBackgroundOrigin( &WindowOrigin );
    $topLogo->setPixmap( &Pixmap("/usr/share/pixmaps/installer/phoenux.png" ) );
}

sub midFrame {
    $mainWidgetStack = Qt::WidgetStack( this, "mainWidgetStack" );
    $mainWidgetStack->setGeometry( &Rect( 10, 110, 1010, 670 ) );

    #==========================================================================
    # Page 1: Intro
    #==========================================================================
    my $introPage = Qt::Widget( $mainWidgetStack, "introPage" );
    my $introPageLayout = Qt::VBoxLayout( $introPage, 11, 6, "introPageLayout" );
    my $welcomeTextLabel = Qt::Label( $introPage, "welcomeTextLabel" );
    my $string0 = &tr ( "<font size=+2>Welcome to PhoeNUX OS</font>
                  <p>Thank you for choosing PhoeNUX OS. Our installer
                  will now lead you through installing the operating
                  system.<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." );
    $welcomeTextLabel->setText( $string0 );
    $welcomeTextLabel->setGeometry( 10, 20, 700, 500 );
    $welcomeTextLabel->setBackgroundOrigin( &WindowOrigin() );
    $introPageLayout->addWidget( $welcomeTextLabel );
    my $spacer1 = Qt::SpacerItem( 970, 20, Qt::SizePolicy::Expanding(), Qt::SizePolicy::Minimum() );
    $introPageLayout->addItem( $spacer1 );
    my $spacer2 = Qt::SpacerItem( 20, 440, Qt::SizePolicy::Minimum(), Qt::SizePolicy::Expanding() );
    $introPageLayout->addItem( $spacer2 );
    Qt::WhatsThis::add( $introPage,
                        &tr( "<b>Installer</b><br>\n
                        This is the PhoeNUX OS Install Wizard. It is\n
                        designed to help new users install PhoeNUX OS on\n
                        their computer.<br>
                        If you are curious about a setting in the wizard,\n
                        select the help icon and click the option for more\n
                        information." ) );

    my $stackPageImage0 = Qt::Label( $introPage, "stackPageImage0" );
    $stackPageImage0->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage0->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage0->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/intro.png" ) );

    $mainWidgetStack->addWidget( $introPage, 1 );

    #=========================================================================
    # Page 2: EULA
    #=========================================================================
    my $eulaPage = Qt::Widget( $mainWidgetStack, "eulaPage" );
    my $step1String = Qt::Label( $eulaPage, "step1String" );
    $step1String->setText( &tr( "<font size=+2>Step 1 - End User License Agreement.</font>" ) );
    $step1String->setGeometry( &Rect( 10, 10, 500, 35 ) );

    my $eulaGrp = Qt::VGroupBox( $eulaPage, "eulaGrp" );
    $eulaGrp->setGeometry( &Rect( 3, 60, 1013, 525 ) );
    $eulaGrp->setFrameShape( Qt::ButtonGroup::NoFrame() );

    my $cwdPath = getcwd();
    my $eulaPath = "$cwdPath/eula.html";
    my $eulaHtmlDump = qx(/bin/cat $eulaPath);
    my $eulaText = Qt::TextBrowser( $eulaGrp, "eulaText" );
    $eulaText->setText( $eulaHtmlDump );

    $eulaAgreeChBx = Qt::CheckBox( $eulaGrp, "eulaAgreeChBx" );
    $eulaAgreeChBx->setText( &tr( "&I agree to the End User License Agreement." ) );
    $eulaAgreeChBx->connect( $eulaAgreeChBx, SIGNAL "clicked()", this, SLOT "theyAgreedToTheEULA()" );

    $mainWidgetStack->addWidget( $eulaPage, 2 );

    #==========================================================================
    # Page 3: Select your timezone....
    #==========================================================================
    my $timeSetupPage = Qt::Widget( $mainWidgetStack, "timeSetupPage" );

    my $step2String = Qt::Label( $timeSetupPage, "step2String" );
    $step2String->setText( &tr( "<font size=+2>Step 2 - Timezone Setup.</font>" ) );
    $step2String->setGeometry( &Rect( 10, 10, 360, 35 ) );

    my $timezoneSetupGrp = Qt::VGroupBox( $timeSetupPage, "timezoneSetupGrp" );
    $timezoneSetupGrp->setGeometry( &Rect( 3, 60, 1010, 350 ) );
    $timezoneSetupGrp->setFrameShape( Qt::ButtonGroup::NoFrame() );
    $timezoneSetupGrp->setTitle( &tr( "Select your local timezone." ) );

    $timezoneListBox = Qt::ListBox( $timezoneSetupGrp, "timezoneListBox" );
    $timezoneListBox->insertItem( "UTC -12:  International Date Line West", 0 );
    $timezoneListBox->insertItem( "UTC -11:  Midway Island, Samoa", 1 );
    $timezoneListBox->insertItem( "UTC -10:  Hawaii-Aleutian Standard Time", 2 );
    $timezoneListBox->insertItem( "UTC -9:   Alaska Standard Time", 3 );
    $timezoneListBox->insertItem( "UTC -8:   Pacific Standard Time, Tijuana", 4 );
    $timezoneListBox->insertItem( "UTC -7:   Arizona", 5 );
    $timezoneListBox->insertItem( "UTC -7:   Chihuahua, La Paz, Mazatlan", 6 );
    $timezoneListBox->insertItem( "UTC -7:   Mountain Standard Time", 7 );
    $timezoneListBox->insertItem( "UTC -6:   Central America", 8 );
    $timezoneListBox->insertItem( "UTC -6:   Central Standard Time", 9 );
    $timezoneListBox->insertItem( "UTC -6:   Guadalajara, Mexico City, Monterey", 10 );
    $timezoneListBox->insertItem( "UTC -6:   Saskatchewan", 11 );
    $timezoneListBox->insertItem( "UTC -5:   Bogota, Lima, Quito", 12 );
    $timezoneListBox->insertItem( "UTC -5:   Eastern Standard Time", 13 );
    $timezoneListBox->insertItem( "UTC -5:   Indiana", 14 );
    $timezoneListBox->insertItem( "UTC -4:   Atlantic Standard Time", 15 );
    $timezoneListBox->insertItem( "UTC -4:   Caracas, La Paz", 16 );
    $timezoneListBox->insertItem( "UTC -4:   Santiago", 17 );
    $timezoneListBox->insertItem( "UTC -3:30 Newfoundland Standard Time", 18 );
    $timezoneListBox->insertItem( "UTC -3:   Brasilia", 19 );
    $timezoneListBox->insertItem( "UTC -3:   Buenos Aires, Georgetown", 20 );
    $timezoneListBox->insertItem( "UTC -3:   Greenland", 21 );

    my $ntpLabal = Qt::Label( $timeSetupPage, "ntpLabal" );
    $ntpLabal->setText( &tr( "<font size=+0>Would you like your computer's
                              clock to be synced to a time server on the
                              internet?</font>
                             " ) );
    $ntpLabal->setGeometry( &Rect( 12, 400, 1010, 50 ) );

    $ntpChkBx = Qt::CheckBox( $timeSetupPage, "ntpChkBx" );
    $ntpChkBx->setText( &tr( "&Yes, please configure my computer to sync to a time server." ) );
    $ntpChkBx->setGeometry( 12, 450, 800, 20 );
    $ntpChkBx->connect( $ntpChkBx, SIGNAL( "clicked()" ), this, SLOT( "setNtpServer()" ) );

    my $stackPageImage2 = Qt::Label( $timeSetupPage, "stackPageImage2" );
    $stackPageImage2->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage2->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage2->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/clock.png" ) );

    Qt::WhatsThis::add( $timeSetupPage,
                        &tr( " <b>
                               Select your Timezone
                               </b><br>
                               In this step, the installer allows you to set \n
                               the timezone that you live in and whether to \n
                               start the ntp service to keep your computer\'s\n
                               internal clock in sync with time servers on the\n
                               internet.
                             " ) );

    $mainWidgetStack->addWidget( $timeSetupPage, 3 );

    #==========================================================================
    # Page 4: type of install...
    #==========================================================================
    my $installTypePage = Qt::Widget( $mainWidgetStack, "installTypePage" );
    my $step3String = Qt::Label( $installTypePage, "step3String" );
    $step3String->setText( &tr( "<font size=+2>Step 3 - Installation Type.</font>" ) );
    $step3String->setGeometry( &Rect( 10, 10, 500, 35 ) );

    my $installTypeGrp = Qt::ButtonGroup( $installTypePage, "installTypeGrp" );
    $installTypeGrp->setGeometry( &Rect( 3, 60, 990, 400 ) );
    $installTypeGrp->setFrameShape( Qt::ButtonGroup::NoFrame() );
    $installTypeGrp->setTitle( &tr( "What method should be used to install PhoeNUX OS?" ) );

    $installMeRBttn = Qt::RadioButton( $installTypeGrp, "installMeRBttn" );
    $installMeRBttn->setGeometry( &Rect( 20, 30, 850, 20 ) );
    $installMeRBttn->setBackgroundOrigin( &WindowOrigin() );
    $installMeRBttn->setText( &tr( "&Install PhoeNUX OS for the first time." ) );
    $installMeRBttn->connect( $installMeRBttn, SIGNAL "clicked()", this, SLOT "installMe()" );

    my $installMeLabel = Qt::Label( $installTypeGrp, "installMeLabel" );
    $installMeLabel->setGeometry( &Rect( 40, 55, 675, 55 ) );
    $installMeLabel->setBackgroundOrigin( &WindowOrigin() );
    $installMeLabel->setText( &tr( "<font size=+0>This option will perform a
                                    fresh installation of PhoeNUX OS along with
                                    many common and useful applications to a
                                    target hard disk that will be selected in
                                    the next step of the installation.
                                    </font>" ) );

    $upgradeMeRBttn = Qt::RadioButton( $installTypeGrp, "upgradeMeRBttn" );
    $upgradeMeRBttn->setGeometry( &Rect( 20, 145, 850, 20 ) );
    $upgradeMeRBttn->setBackgroundOrigin( &WindowOrigin() );
    $upgradeMeRBttn->setText( &tr( "&Upgrade PhoeNUX OS from one release to another." ) );
    $upgradeMeRBttn->connect( $upgradeMeRBttn, SIGNAL "clicked()", this, SLOT "upgradeMe()" );
    $upgradeMeRBttn->setEnabled( 0 );

    my $upgradeMeLabel = Qt::Label( $installTypeGrp, "upgradeMeLabel" );
    $upgradeMeLabel->setGeometry( &Rect( 40, 170, 675, 75 ) );
    $upgradeMeLabel->setBackgroundOrigin( &WindowOrigin() );
    $upgradeMeLabel->setText( &tr( "<font size=+0>This option allows a system
                                    to be upgraded from one release to the next
                                    fairly painlessly. Note however, that with
                                    any upgrade, third programs that have been
                                    installed may not operate correctly or at
                                    all. Please see the online compatiblity list
                                    to determine if any applications you have
                                    were reported to cause issues after an
                                    upgrade.</font>" ) );
    $upgradeMeLabel->hide();

    my $stackPageImage3 = Qt::Label( $installTypePage, "stackPageImage3" );
    $stackPageImage3->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage3->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage3->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/kpackage.png" ) );

    Qt::WhatsThis::add( $installTypePage,
                        &tr( " <b>
                               Select your Installation Type.
                               </b><br>
                               In this step, you can select whether this\n
                               install will be an Install or an Update from\n
                               one version to another.<p>
                             " ) );

    $mainWidgetStack->addWidget( $installTypePage, 4 );

    #==========================================================================
    # Page 5: Where to install to...
    #==========================================================================
    my $targetSetupPage = Qt::Widget( $mainWidgetStack, "targetSetupPage" );

    #--------------------------------------------------------------------------
    # Installation target page....
    #--------------------------------------------------------------------------
    $step4String = Qt::Label( $targetSetupPage, "step4String" );
    $step4String->setText( &tr( "<font size=+2>Step 4 - Select Installation Target.</font>" ) );
    $step4String->setGeometry( &Rect( 10, 10, 500, 35 ) );
    $step4String->hide();

    $targetSetupGrp = Qt::GroupBox( $targetSetupPage, "targetSetupGrp" );
    $targetSetupGrp->setGeometry( &Rect( 3, 60, 1010, 220 ) );
    $targetSetupGrp->setFrameShape( Qt::GroupBox::NoFrame() );
    $targetSetupGrp->setTitle( &tr( "Which disk should PhoeNUX OS be installed onto?" ) );
    $targetSetupGrp->hide();

    $driveView = Qt::IconView( $targetSetupGrp, "driveView" );
    $driveView->setGeometry( &Rect( 10, 20, 1000, 185 ) );
    $driveView->setFrameShape( &Qt::IconView::StyledPanel() );
    $driveView->setFrameShadow( &Qt::IconView::Plain() );

    &drivePopulate();

    $driveActionsGrp = Qt::ButtonGroup( $targetSetupPage, "driveActionsGrp" );
    $driveActionsGrp->setGeometry( &Rect( 13, 280, 780, 300 ) );
    $driveActionsGrp->setTitle( &tr( "Partitioning actions..." ) );
    $driveActionsGrp->hide();

    $takeOverDriveRBttn = Qt::RadioButton( $driveActionsGrp, "takeOverDriveRBttn" );
    $takeOverDriveRBttn->setGeometry( &Rect( 13, 30, 400, 20 ) );
    $takeOverDriveRBttn->setBackgroundOrigin( &WindowOrigin() );
    $takeOverDriveRBttn->setText( &tr( "&Take over this drive." ) );
    $takeOverDriveRBttn->connect( $takeOverDriveRBttn, SIGNAL "clicked()",
                                  this, SLOT "takeOverDriveRBAction()" );

    my $takeOverDriveLbl = Qt::Label( $driveActionsGrp, "takeOverDriveLbl" );
    $takeOverDriveLbl->setGeometry( &Rect( 35, 55, 700, 30 ) );
    $takeOverDriveLbl->setBackgroundOrigin( &WindowOrigin() );
    $takeOverDriveLbl->setText( &tr( "<font size=+0>Use the entire selected drive to install onto.
                                      <br>" ) );

    $dataLossWarningLbl = Qt::Label( $driveActionsGrp, "dataLossWarningLbl" );
    $dataLossWarningLbl->setGeometry( &Rect( 35, 70, 700, 20 ) );
    $dataLossWarningLbl->setBackgroundOrigin( &WindowOrigin() );
    $dataLossWarningLbl->setText( &tr( "<font color=red>
                                      Note that this will delete all data from the selected disk!
                                      </font></font>" ) );
    $dataLossWarningLbl->hide();

    ##################################################
    #### TODO: REMEMBER TO REENABLE ONCE READY!!! ####
    ##################################################
    $partToolRBttn = Qt::RadioButton( $driveActionsGrp, "partToolRBttn" );
    $partToolRBttn->setGeometry( &Rect( 13, 95, 400, 20 ) );
    $partToolRBttn->setBackgroundOrigin( &WindowOrigin() );
    $partToolRBttn->setText( &tr( "&Manual partitioning." ) );
    $partToolRBttn->connect( $partToolRBttn, SIGNAL "clicked()", this, SLOT "advancedPartAction()" );
    $partToolRBttn->hide();

    my $manualPartitioningDriveLbl = Qt::Label( $driveActionsGrp, "leaveDriveIntactLbl" );
    $manualPartitioningDriveLbl->setGeometry( &Rect( 35, 110, 500, 30 ) );
    $manualPartitioningDriveLbl->setBackgroundOrigin( &WindowOrigin() );
    $manualPartitioningDriveLbl->setText( &tr( "<font size=+0>This option allows you to set up your
                                                disk drives partitions manually.
                                                </font>" ) );
    $manualPartitioningDriveLbl->hide();

    $partToolBttn = Qt::PushButton( $driveActionsGrp, "partToolBttn" );
    $partToolBttn->setGeometry( &Rect( 550, 110, 200, 30 ) );
    $partToolBttn->setText( &tr( "&Partitioning Tool" ) );
    $partToolBttn->setFlat( 1 );
    $partToolBttn->setCursor( Qt::Cursor( 13 ) );
    $partToolBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $partToolBttn->setEnabled( 0 );
    $partToolBttn->connect( $partToolBttn, SIGNAL "clicked()", this, SLOT "startDiskDrake()" );
    $partToolBttn->hide();

    $driveActionsGrp->setEnabled( 0 );

    Qt::WhatsThis::add( $targetSetupPage, &tr( " <b>
                               Select and prepare the installation target.
                               </b><br>
                               In this step, you must select which hard disk\n
                               you'd like to install PhoeNUX OS to. When you\n
                               select the drive, a dialog will appear that\n
                               will ask you whether you would like to either<br>
                                a) take over the harddisk,<br>
                                b) install to an existing partition or,<br>
                                c) manually partition the target drive." ) );

    Qt::WhatsThis::add( $partToolBttn, &tr( " <b>
                               Advanced partitioning with DiskDrake.
                               </b><br>
                               When you click this button, DiskDrake will appear\n
                               and allow you to partition, format and select the\n
                               mount points you want to have the harddisks mounted\n
                               to when PhoeNUX OS is installed onto your computer.\n" ) );

    #--------------------------------------------------------------------------
    # Upgrade target page.....
    #--------------------------------------------------------------------------
    $detectedPrevOsString = Qt::Label( $targetSetupPage, "step4String" );
    $detectedPrevOsString->setText( &tr( "<font size=+2>
                                          Step 4 - Detecting Previous Installed Systems...
                                          </font>" ) );
    $detectedPrevOsString->setGeometry( &Rect( 10, 10, 700, 35 ) );
    $detectedPrevOsString->hide();

    $updatableOsGrp = Qt::GroupBox( $targetSetupPage, "targetSetupGrp" );
    $updatableOsGrp->setGeometry( &Rect( 3, 60, 1010, 220 ) );
    $updatableOsGrp->setFrameShape( Qt::GroupBox::NoFrame() );
    $updatableOsGrp->setTitle( &tr( "The following updatable installations are shown below:" ) );
    $updatableOsGrp->hide();

    $prevOsIs = Qt::Label( $targetSetupPage, "prevOsIs" );
    $prevOsIs->setGeometry( &Rect( 10, 80, 500, 20 ) );
    $prevOsIs->setText( "" );
    $prevOsIs->hide();

    my $stackPageImage4 = Qt::Label( $targetSetupPage, "stackPageImage3" );
    $stackPageImage4->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage4->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage4->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/hdd.png" ) );

    $mainWidgetStack->addWidget( $targetSetupPage, 5 );

    #==========================================================================
    # Page 6: install....
    #==========================================================================
    my $installPage = Qt::Widget( $mainWidgetStack, "installPage" );

    #--------------------------------------------------------------------------
    # Install
    #--------------------------------------------------------------------------
    $step5String = Qt::Label( $installPage, "step5String" );
    $step5String->setText( &tr( "<font size=+2>Installing.....</font>" ) );
    $step5String->setGeometry( &Rect( 10, 10, 500, 35 ) );
    $step5String->hide();

    #--------------------------------------------------------------------------
    # Upgrade
    #--------------------------------------------------------------------------
    $step6String = Qt::Label( $installPage, "step6String" );
    $step6String->setText( &tr( "<font size=+2> Upgrading.....</font>" ) );
    $step6String->setGeometry( &Rect( 10, 10, 500, 35 ) );
    $step6String->hide();

    $stackPageImage5 = Qt::Label( $installPage, "stackPageImage5" );
    $stackPageImage5->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage5->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage5->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/ark.png" ) );

    #--------------------------------------------------------------------------
    # Closing
    #--------------------------------------------------------------------------
    $closingString = Qt::Label( $installPage, "closingString" );
    $closingString->setText( &tr( "<font size=+2>The Install has Completed.</font>" ) );
    $closingString->setGeometry( &Rect( 10, 10, 500, 35 ) );
    $closingString->hide();

    $allDoneGrp = Qt::VBox( $installPage, "allDoneGrp" );
    $allDoneGrp->setGeometry( &Rect( 10, 55, 1000, 25 ) );
    $allDoneGrp->setFrameShape( Qt::GroupBox::NoFrame() );
    $allDoneGrp->hide();

    $allDoneMsg = Qt::Label( $allDoneGrp, "allDoneMsg" );
    $allDoneMsg->setText( &tr( "<font color=\"black\">
                                Click the \"Reboot\" button below to reboot your
                                computer to complete your install.
                                </font>" ) );

    $stackPageImage6 = Qt::Label( $installPage, "stackPageImage3" );
    $stackPageImage6->setGeometry( &Rect( 850, 420, 128, 128 ) );
    $stackPageImage6->setBackgroundOrigin( &WindowOrigin );
    $stackPageImage6->setPixmap( &Pixmap( "/usr/share/pixmaps/installer/intro.png" ) );
    $stackPageImage6->hide();

    $mainWidgetStack->addWidget( $installPage, 6 );
}

sub btmFrame {
    my $backIcon = &Pixmap( "/usr/share/pixmaps/installer/back.png" );
    my $rebootIcon = &Pixmap( "/usr/share/pixmaps/installer/exit.png" );
    my $helpIcon = &Pixmap( "/usr/share/pixmaps/installer/help.png" );
    my $nextIcon = &Pixmap( "/usr/share/pixmaps/installer/forward.png" );

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

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

    $backBttn = Qt::PushButton( $privLayWidget, "backBttn" );
    $backBttn->setFlat( 1 );
    $backBttn->setPixmap( $backIcon );
    $backBttn->setCursor( Qt::Cursor( 13 ) );
    $backBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $backBttn->connect( $backBttn, SIGNAL "pressed()", this, SLOT "prevPage()" );
    $backBttn->hide();
    Qt::ToolTip::add( $backBttn, &tr( "Back to the previous step...." ) );
    $bLayMan->addWidget( $backBttn );

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

    $rebootBttn = Qt::PushButton( $privLayWidget, "rebootBttn" );
    $rebootBttn->setFlat( 1 );
    $rebootBttn->setPixmap( $rebootIcon );
    $rebootBttn->setCursor( Qt::Cursor( 13 ) );
    $rebootBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $rebootBttn->connect( $rebootBttn, SIGNAL "pressed()", this, SLOT "rebootComputer()" );
    $rebootBttn->hide();
    Qt::ToolTip::add( $rebootBttn, &tr( "Reboot now." ) );
    $bLayMan->addWidget( $rebootBttn );

    $helpBttn = Qt::PushButton( $privLayWidget, "helpBttn" );
    $helpBttn->setFlat( 1 );
    $helpBttn->setPixmap( $helpIcon );
    $helpBttn->setCursor( Qt::Cursor( 13 ) );
    $helpBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $helpBttn->connect( $helpBttn, SIGNAL "pressed()", this, SLOT "setWhatsThisMode()" );
    Qt::ToolTip::add( $helpBttn, &tr( "I need help, please." ) );
    $bLayMan->addWidget( $helpBttn );

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

    $nextBttn = Qt::PushButton( $privLayWidget, "nextBttn" );
    $nextBttn->setFlat( 1 );
    $nextBttn->setPixmap( $nextIcon );
    $nextBttn->setCursor( Qt::Cursor( 13 ) );
    $nextBttn->setPaletteBackgroundColor( &Color( 97, 148, 216 ) );
    $nextBttn->connect( $nextBttn, SIGNAL "pressed()", this, SLOT "nextPage()" );
    Qt::ToolTip::add( $nextBttn, &tr( "Next...." ) );
    $bLayMan->addWidget( $nextBttn );
}

sub advancedPartAction {
    &enablePartToolBttn();
    $dataLossWarningLbl->hide();
}

sub disableBack {
    $backBttn->setEnabled( 0 );
}

sub enableDriveActionGrp {
    $driveActionsGrp->setEnabled( 1 );
}

sub detectPrevOs {
}

sub disableHelp {
    $helpBttn->setEnabled( 0 );
}

sub disableNext {
    $nextBttn->setEnabled( 0 );
}

sub disablePartToolBttn {
    $partToolBttn->setEnabled( 0 );
}

sub disableReboot {
    $rebootBttn->setEnabled( 0 );
}

sub doUpgrade {
}

sub doInstall {
    print STDOUT " => Starting installation progress dialog \n";
    my $instPrgDlg = installProgressDlg( this, 0, 0, "install", $installMethod, $driveText );
    $instPrgDlg->show();

    if ( $installMethod eq "take-over" ) {
        $instPrgDlg->trashOldDriveContent( $driveText );
    }

#    $instPrgDlg->installBaseSystem();
#    $instPrgDlg->installDesktop();
#    $instPrgDlg->installApplications();

#    $instPrgDlg->postInstall();
#    $instPrgDlg->close();

#     print STDOUT "* STEP 6: Reboot\n";
#     &hideNext();
#     &showReboot();
#     $step6String->hide();
#     $closingString->show();
#     $stackPageImage5->hide();
#     $stackPageImage6->show();
#     $allDoneGrp->show();
}

sub drivePopulate {
    $driveView->clear();
    my $drvIcon = &Pixmap( "/usr/share/pixmaps/installer/hdd.png" );
    our @ideHarddisks = Detect::detectEide();
    our @scsiHarddisks = Detect::detectScsi();
    our %driveInfo = %{ Detect::detectStrgSize() };
    our @drives = [];
    for ( my $i = 0; $i < @ideHarddisks; $i++ ) {
        my $temp = $ideHarddisks[ $i ];
        chomp( $temp );
        my $driveName = $temp;
        $temp = substr( $temp, 6 );
        my $roundedSize = sprintf( "%.2f", $driveInfo{ $temp } );
        # we can asssume that having drives less than 3 Gig will not install right....
        if ( ! $roundedSize lt 3 ) {
            $drives[ $i ] = Qt::IconViewItem( $driveView,
                                             &tr( "$driveName\n$roundedSize GB" ),
                                             $drvIcon );
            $driveView->connect( $driveView,
                                 SIGNAL "clicked(QIconViewItem*)",
                                 this,
                                 SLOT "driveSelected(QIconViewItem*)" );
        }
    }
}

sub driveSelected {
    &enableDriveActionGrp();
    $driveText = $driveView->currentItem()->text();
    chomp( $driveText );
    $driveText = substr( $driveText, 1, 9 );
}

sub enableBack {
    $backBttn->setEnabled( 1 );
}

sub enableHelp {
    $helpBttn->setEnabled( 1 );
}

sub enableNext {
    $nextBttn->setEnabled( 1 );
}

sub enablePartToolBttn {
    &enableNext();
    $partToolBttn->setEnabled( 1 );
}

sub enableReboot {
    $rebootBttn->setEnabled( 1 );
}

sub hideBack {
    $backBttn->hide();
}

sub hideHelp {
    $helpBttn->hide();
}

sub hideNext {
    $nextBttn->hide();
}

sub hideReboot {
    $rebootBttn->hide();
}

sub installMe {
    &enableNext();
    $step6String->hide();
    $detectedPrevOsString->hide();
    $updatableOsGrp->hide();
    $step4String->show();
    $targetSetupGrp->show();
    $driveActionsGrp->show();
    $step5String->show();
}

sub nextPage {
    my $visible = $mainWidgetStack->id( $mainWidgetStack->visibleWidget() );

    my $startUpPage = 0;
    my $eulaAgreePage = 1;
    my $timeZonePage = 2;
    my $installTypeSelectPage = 3;
    my $installTargetPage = 4;
    my $installNowPage = 5;
    my $rebootComputerPage = 6;

    # change some state aspects to the current pane....
    if ( $visible == $startUpPage ) {
        print STDOUT "Starting Installer...\n";
    } elsif ( $visible == $eulaAgreePage ) {
        print STDOUT "* STEP 1: EULA.\n";
        &hideHelp();
        &disableNext();
        &showBack();
    } elsif ( $visible == $timeZonePage ) {
        print STDOUT "* STEP 2: Choose your Timezone.\n";
        $timezoneListBox->setSelected( 13, 1 );
        &showHelp();
    } elsif ( $visible == $installTypeSelectPage ) {
        print STDOUT "* STEP 3: What type of install?\n";
        &disableNext();
    } elsif ( $visible == $installTargetPage ) {
        print STDOUT "* STEP 4: Where to install to?\n";
        &disableNext();
        if ( $upgradeMeRBttn->isChecked() ) {
            &detectPrevOs();
        }
    } elsif ( $visible == $installNowPage ) {
        $mainWidgetStack->raiseWidget( $visible + 1 );
        print STDOUT "* STEP 5: Installing NOW\n";
        &hideBack();
        &hideHelp();
        &hideNext();
        $line2->hide();
        if ( $upgradeMeRBttn->isChecked() ) {
            print STDOUT " - Upgrade: YES \n";
            print STDOUT " - Install: NO \n";
            &doUpgrade();
        }
        if ( $installMeRBttn->isChecked() ) {
            print STDOUT " - Upgrade: NO \n";
            print STDOUT " - Install: YES \n";
            &doInstall();
        }
    }

    # increment the viewed pane by 1
    $mainWidgetStack->raiseWidget( $visible + 1 );
}

sub prevPage {
    my $visible = $mainWidgetStack->id( $mainWidgetStack->visibleWidget() );

    # decriment the visible ID
    $visible -= 1;

    if ( $visible == 1 ) {
        &enableNext();
        &hideBack();
    } elsif ( $visible == 2 ) {
        &hideHelp();
    } elsif ( $visible == 3 ) {
        &enableNext();
    } elsif ( $visible == 4 ) {
        &disableNext();
    } else {
        &showBack();
    }

    # now change the stackwidget....
    $mainWidgetStack->raiseWidget( $visible );
}

sub rebootComputer {
    system( "/sbin/reboot" );
}

sub setNtpServer {
    print STDOUT " - Use NTPd to sync system clock\n";
}

sub setWhatsThisMode {
    Qt::WhatsThis::enterWhatsThisMode();
    $helpBttn->setDown( 0 );
}

sub showBack {
    $backBttn->show();
}

sub showHelp {
    $helpBttn->show();
}

sub showNext {
    $nextBttn->show();
}

sub showReboot {
    $rebootBttn->show();
}

sub startDiskDrake {
    $installMethod = "custom";
    system( "/usr/sbin/diskdrake --expert --hd" );
}

sub takeOverDriveRBAction {
    &disablePartToolBttn();
    &enableNext();
    $installMethod = "take-over";
    $dataLossWarningLbl->show();
}

sub theyAgreedToTheEULA {
    if ( $eulaAgreeChBx->state() == 0 ) {
        print STDOUT " - EULA: NOT agreed to.\n";
        &disableNext();
    } else {
        print STDOUT " - EULA: agreed to.\n";
        &enableNext();
    }
}

sub upgradeMe {
    &enableNext();
    $step5String->hide();
    $step4String->hide();
    $targetSetupGrp->hide();
    $driveActionsGrp->hide();
    $detectedPrevOsString->show();
    $updatableOsGrp->show();
    $step6String->show();
}

1;

# end of package MainWidget
#==============================================================================
installProgressDlg.pm (application/x-perl-module, 5.6 KB)
use strict;
use utf8;

package installProgressDlg;
use Detect;
use Fs;
use Unpack;
use Qt;
use Qt::isa qw( Qt::Dialog );
use Qt::attributes qw(
    endMsgBox
    progressGroup
    currentPackageLbl
    totalProgressLbl
    cPackagesPBar
    tPackagesRBar
    exitInstallPrematurelyBttn
    instProgrsTxtBox
);
use Qt::slots
    endInstall          => [];

sub NEW {
    shift->SUPER::NEW( @_[ 0..3 ] );
    my $self = {};

    my $method = $_[ 4 ];
    my $drive = $_[ 5 ];

    if ( name() eq "unnamed" ) {
        setName( "installProgressDlg" );
    }

    setSizePolicy( Qt::SizePolicy( 7, 7, 100, 100, this->sizePolicy()->hasHeightForWidth() ) );
    setMinimumSize( Qt::Size( 600, 460 ) );
    setSizeGripEnabled( 0 );

    progressGroup = Qt::GroupBox( this, "progressGroup" );
    progressGroup->setGeometry( Qt::Rect( 10, 0, 580, 460 ) );

    currentPackageLbl = Qt::Label( progressGroup, "currentPackageLbl" );
    currentPackageLbl->setGeometry( Qt::Rect(10, 310, 560, 20 ) );

    totalProgressLbl = Qt::Label( progressGroup, "totalProgressLbl" );
    totalProgressLbl->setGeometry( Qt::Rect( 10, 370, 113, 20 ) );

    cPackagesPBar = Qt::ProgressBar( progressGroup, "cPackagesPBar" );
    cPackagesPBar->setGeometry( Qt::Rect( 10, 330, 560, 26 ) );

    tPackagesRBar = Qt::ProgressBar( progressGroup, "tPackagesRBar" );
    tPackagesRBar->setGeometry( Qt::Rect( 10, 390, 560, 26 ) );

    exitInstallPrematurelyBttn = Qt::PushButton( progressGroup, "exitInstallPrematurelyBttn" );
    exitInstallPrematurelyBttn->setGeometry( Qt::Rect( 450, 425, 120, 27 ) );

    instProgrsTxtBox = Qt::TextBrowser( progressGroup, "isntProgrsTxtBox" );
    instProgrsTxtBox->setGeometry( Qt::Rect( 10, 20, 560, 270 ) );
    instProgrsTxtBox->setCursor( Qt::Cursor( 4 ) );
    instProgrsTxtBox->setFrameShadow( &Qt::TextBrowser::Plain() );
    instProgrsTxtBox->setDragAutoScroll( 1 );
    instProgrsTxtBox->setTextFormat( &Qt::TextBrowser::RichText() );
    instProgrsTxtBox->setWordWrap( &Qt::TextBrowser::NoWrap() );

    languageChange();

    my $resize = Qt::Size(600, 471);
    $resize = $resize->expandedTo( minimumSizeHint() );
    resize( $resize );
    clearWState( &Qt::WState_Polished );

    this->connect( exitInstallPrematurelyBttn, SIGNAL( "clicked()" ),
                   this, SLOT( "endInstall()" ) );

    return bless $self;
}

#  Sets the strings of the subwidgets using the current
#  language.
sub languageChange {
    setCaption( trUtf8( "Installation Progress" ) );
    progressGroup->setTitle( trUtf8( "Installation Progress" ) );
    currentPackageLbl->setText( trUtf8( "Current Package:" ) );
    totalProgressLbl->setText( trUtf8( "Total Progress:" ) );
    exitInstallPrematurelyBttn->setText( trUtf8( "&Cancel Install" ) );
    exitInstallPrematurelyBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+C" ) ) );
}

sub endInstall {
    endMsgBox = Qt::MessageBox::warning( this, "Exit Install",
       "Exiting the install prematurely may cause your system to be unbootable. Do you wish to proceed?",
                                             Qt::MessageBox::Ok(),
                                             Qt::MessageBox::Cancel(),
                                             Qt::MessageBox::NoButton() );
    endMsgBox eq 2 or die " >> Installer going down NOW!!!!!\n";
}

sub trashOldDriveContent {
    my $BLK_CONST = 1024;
    my $swapSize = 0;

    chomp( @_ );
    my $drive = $_[ 0 ];
    print STDOUT " => TARGET DRIVE: $drive \n";
    my $meminfo = Detect::detectMemory();
    chomp( $meminfo );
    $meminfo = substr( $meminfo, 0, -1 );
    $meminfo = $meminfo / $BLK_CONST;
    instProgrsTxtBox->append( "Preparing your disk for installation\n" );
    instProgrsTxtBox->append( "Deleting old hard disk contents..." );
    Fs::clearDriveContent( $drive );
    print STDOUT "  > System RAM: $meminfo";
    print STDOUT "M therefore ";
    if ( $meminfo < 256 ) {
        print STDOUT "creating 512M swap partition.\n";
        instProgrsTxtBox->append( "Creating a 512M swap partition..." );
        $swapSize = 512.0;
        Fs::createSwap( $drive, "primary", 1, 0.0, 512.0 );
    } elsif ( $meminfo >= 256 && $meminfo < 384 ) {
        print STDOUT "creating 256M swap partition.\n";
        instProgrsTxtBox->append( "Creating a 256M swap partition..." );
        $swapSize = 256.0;
        Fs::createSwap( $drive, "primary", 1, 0.0, 256.0 );
    } elsif ( $meminfo >= 384 ) {
        print STDOUT "creating 128M swap partition.\n";
        instProgrsTxtBox->append( "Creating a 128M swap partition..." );
        $swapSize = 128.0;
        Fs::createSwap( $drive, "primary", 1, 0.0, 128.0 );
    }
    instProgrsTxtBox->append( "Creating the root partition that will fill the remaining freed space..." );
    Fs::createRoot( $drive, "primary", 2, $swapSize + 1, -1.0 );
    instProgrsTxtBox->append( "Formatting the swap partition..." );
    Fs::formatSwap( $drive, 1 );
    instProgrsTxtBox->append( "Formatting the / partition..." );
    Fs::formatXfs( $drive, 2 );
    our @swapInfo = ( "$drive"."1", "swap", "swap", "defaults", 0, 0 );
    our @rootInfo = ( "$drive"."2", "/", "xfs", "defaults", 1, 1 );

    instProgrsTxtBox->append( "Activating the swap partition..." );
    Fs::activateSwap( "$drive"."1" );
    instProgrsTxtBox->append( "Mounting the / partition..." );
    Fs::mountDest( "$drive"."2", "xfs" );

    instProgrsTxtBox->append( "Creating the /etc/fstab filesystems table" );
    Fs::createFsTab( \@swapInfo, \@rootInfo );
}

sub installApplications {}

sub installBaseSystem {
    Unpack::initRpmDb();
    Unpack::installBase( "noscripts" );
    Unpack::installBase( "withscripts" );
}

sub installDesktop {}

sub postInstall {}

1;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQBDRT9/+psNrGG9CbMRAvTUAJ9/jb4uCIZvw8wf99sAyKKOMMgGAgCePYqJ
Sxqqc+JCWPtPg9bJUYNa0ZQ=
=npVz
-----END PGP SIGNATURE-----