X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FInstallWizard.cpp;h=e1beb403c012478ad72e663b09c537a7568f07a6;hb=240603adb1c5f6a48ced8147d88af547fecaa5c8;hp=c99cc8a0762b51af47fd5751362078705a739b34;hpb=e248ae8e6480f161e70bd6d50c2351cf1d64c4e1;p=tools%2Finstall.git diff --git a/src/InstallWizard.cpp b/src/InstallWizard.cpp index c99cc8a..e1beb40 100644 --- a/src/InstallWizard.cpp +++ b/src/InstallWizard.cpp @@ -1,27 +1,72 @@ -// File : InstallWizard.cpp -// Created : Thu Mar 27 12:01:00 2003 -// Author : Vadim SANDLER -// Project : PAL/SALOME -// Module : InstallWizard -// Copyright : 2004 CEA -// $Header$ +/**************************************************************************** +** $Id$ +** +** Definition of the QWizard class. +** +** Created : 990101 +** +** Copyright (C) 1999 by Trolltech AS. All rights reserved. +** +** This file is part of the dialogs module of the Qt GUI Toolkit. +** +** This file may be distributed under the terms of the Q Public License +** as defined by Trolltech AS of Norway and appearing in the file +** LICENSE.QPL included in the packaging of this file. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition +** licenses may use this file in accordance with the Qt Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for +** information about Qt Commercial License Agreements. +** See http://www.trolltech.com/qpl/ for QPL licensing information. +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ #include "InstallWizard.h" -#include "qlayout.h" -#include "qpushbutton.h" -#include "qcursor.h" -#include "qlabel.h" -#include "qwidgetstack.h" -#include "qapplication.h" -#include "qptrlist.h" -#include "qpainter.h" -#include "qaccel.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PROCESS_EVENT QEvent::User+100 + +class ProcessEvent : public QCustomEvent +{ +public: + ProcessEvent( int retValue = 0, void* data = 0 ): QCustomEvent( PROCESS_EVENT ), myReturnValue( retValue ), myData( data ) {} + const int returnValue() const { return myReturnValue; } + void* data() const { return myData; } +private: + int myReturnValue; + void* myData; +}; class InstallWizardPrivate { public: - struct Page { + struct Page { Page( QWidget * widget, const QString & title ): w( widget ), t( title ), backEnabled( TRUE ), nextEnabled( TRUE ), finishEnabled( FALSE ), @@ -42,6 +87,8 @@ public: QWidgetStack * ws; QPtrList pages; QLabel * title; + QHBox * titleBox; + QHBox * logoBox; QPushButton * backButton; QPushButton * nextButton; QPushButton * finishButton; @@ -80,7 +127,11 @@ InstallWizard::InstallWizard( QWidget *parent, const char *name, bool modal, d->current = 0; // not quite true, but... d->ws = new QWidgetStack( this, "qt_widgetstack" ); d->pages.setAutoDelete( TRUE ); - d->title = new QLabel( this, "title label" ); + d->titleBox = new QHBox( this, "title box" ); + d->title = new QLabel( d->titleBox, "title label" ); + d->logoBox = new QHBox( d->titleBox, "logo box" ); + d->logoBox->setSpacing( 2 ); + d->titleBox->setStretchFactor( d->title, 10 ); // create in nice tab order d->nextButton = new QPushButton( this, "next" ); @@ -319,9 +370,21 @@ void InstallWizard::next() while ( i > 0 && (i >= (int)d->pages.count() || !d->pages.at( i ) ) ) i--; if ( d->pages.at( i ) ) { - if ( d->current && !acceptData( d->current->t ) ) - return; - showPage( d->pages.at( i )->w ); + if ( d->current ) { + setNextEnabled( false ); + setBackEnabled( false ); + if ( !acceptData( d->current->t ) ) { + setNextEnabled( true ); + setBackEnabled( true ); + return; + } + } + // VSR : commented 10/02/05 ---> + // Next page will be shown later in processValidateEvent() method + // this allows custom validation, for instance by using external processing threads. + // See SALOME_InstallWizard.cxx for details where it is used. + //showPage( d->pages.at( i )->w ); + // VSR : commented 10/02/05 <--- } } @@ -698,7 +761,7 @@ time \a title changes. void InstallWizard::layOutTitleRow( QHBoxLayout * layout, const QString & title ) { d->title->setText( title ); - layout->addWidget( d->title, 10 ); + layout->addWidget( d->titleBox, 10 ); } /*! @@ -707,6 +770,7 @@ Should return true in success */ bool InstallWizard::acceptData( const QString& ) { + postValidateEvent( this ); return TRUE; } @@ -816,3 +880,75 @@ QWidget* InstallWizard::page( const QString& title ) const } return 0; } + +/*! +Adds logo to be shown at the right of the page title +*/ +void InstallWizard::addLogo( const QPixmap& pm ) +{ + QLabel* logo = new QLabel( d->logoBox, "logo" ); + logo->setPixmap( pm ); + logo->setAlignment( AlignCenter ); + logo->setScaledContents( false ); + logo->show(); +} + +/*! +Remove all logos +*/ +void InstallWizard::removeLogos() +{ + QObjectList* children = d->logoBox->queryList( "QLabel" ); + if ( children ) { + QObjectListIt it( *children ); + QObject *obj; + while ( (obj = it.current()) != 0 ) { + ++it; + delete obj; + } + } + delete children; +} + +/*! +Posts validation event +*/ +void InstallWizard::postValidateEvent( InstallWizard* iw, const int val, void* data ) +{ + QThread::postEvent( iw, new ProcessEvent( val, data ) ); +} + +/*! +Processes validation event: default implementation just to show next page +*/ +void InstallWizard::processValidateEvent( const int /* val */, void* /* data */ ) +{ + int i = 0; + while( i < (int)d->pages.count() && d->pages.at( i ) && + d->current && d->pages.at( i )->w != d->current->w ) + i++; + i++; + while( i <= (int)d->pages.count()-1 && + ( !d->pages.at( i ) || !appropriate( d->pages.at( i )->w ) ) ) + i++; + // if we fell of the end of the world, step back + while ( i > 0 && (i >= (int)d->pages.count() || !d->pages.at( i ) ) ) + i--; + if ( d->pages.at( i ) ) { + showPage( d->pages.at( i )->w ); + } + setNextEnabled( true ); + setBackEnabled( true ); +} + +/*! +Process events received +*/ +bool InstallWizard::event ( QEvent* e ) +{ + if ( e->type() == PROCESS_EVENT ) { + ProcessEvent* pe = (ProcessEvent*)e; + processValidateEvent( pe->returnValue(), pe->data() ); + } + return QDialog::event( e ); +}