1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
22 #define y2log_component "qt-wizard"
23 #include <ycp/y2log.h>
25 // For the command parser
28 #include <YShortcut.h>
31 #include <QSvgRenderer>
33 #include <QStackedWidget>
34 #include "ui_QHelpDialog.h"
39 #include <qmenudata.h>
42 #include <qpushbutton.h>
44 #include <qtabwidget.h>
45 #include <qtoolbutton.h>
47 #include "QY2ListView.h"
48 #include <QGridLayout>
54 #include "YQApplication.h"
56 #include "YQAlignment.h"
57 #include "YQReplacePoint.h"
60 #include "YQWizardButton.h"
61 #include "YQIconPool.h"
62 #include "YQWidgetFactory.h"
63 #include "YQSignalBlocker.h"
64 #include "QY2LayoutUtils.h"
70 #define PIXMAP_DIR THEMEDIR "/wizard/"
76 #define TEXTDOMAIN "packages-qt"
78 #define USE_ICON_ON_HELP_BUTTON 0
81 YQWizard::YQWizard( YWidget * parent,
82 const string & backButtonLabel,
83 const string & abortButtonLabel,
84 const string & nextButtonLabel,
85 YWizardMode wizardMode )
86 : QFrame( (QWidget *) parent->widgetRep() )
92 , _backButtonLabel( backButtonLabel )
93 , _abortButtonLabel( abortButtonLabel )
94 , _nextButtonLabel( nextButtonLabel )
96 QHBoxLayout* layout = new QHBoxLayout( this );
97 layout->setSpacing( 0 );
98 layout->setMargin( 0 );
100 setWidgetRep( this );
102 _stepsEnabled = (wizardMode == YWizardMode_Steps);
103 _treeEnabled = (wizardMode == YWizardMode_Tree);
106 _direction = YQWizard::Forward;
113 _releaseNotesButton = 0;
124 _sendButtonEvents = true;
125 _contentsReplacePoint = 0;
127 //FIXME _stepsList.setAutoDelete( true );
128 //FIXME _stepsIDs.setAutoDelete( false ); // Only for one of both!
130 YQUI::setTextdomain( TEXTDOMAIN );
132 //layoutTitleBar( this );
134 layout->addLayout( layoutSideBar( this ) );
135 layout->addWidget( layoutWorkArea( this ) );
140 YQWizard::~YQWizard()
147 void YQWizard::layoutTitleBar( QWidget * parent )
149 QFrame * titleBar = new QFrame( parent );
150 YUI_CHECK_NEW( titleBar );
152 QHBoxLayout *layout = new QHBoxLayout( titleBar );
153 titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
159 QLabel * left = new QLabel( titleBar );
160 layout->addWidget( left );
161 left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
163 QPixmap leftLogo( PIXMAP_DIR "title-bar-left.png" );
165 if ( ! leftLogo.isNull() )
167 left->setPixmap( leftLogo );
168 left->setFixedSize( leftLogo.size() );
173 // Center stretch space
176 layout->addStretch( 10 );
183 QLabel * right = new QLabel( titleBar );
184 YUI_CHECK_NEW( right );
186 layout->addWidget( right );
188 QPixmap rightLogo( PIXMAP_DIR "title-bar-right.png" );
190 if ( ! rightLogo.isNull() )
192 right->setPixmap( rightLogo );
193 right->setFixedSize( rightLogo.size() );
199 QLayout *YQWizard::layoutSideBar( QWidget * parent )
201 _sideBar = new QStackedWidget( parent );
202 YUI_CHECK_NEW( _sideBar );
203 _sideBar->setMinimumWidth( YQUI::ui()->defaultSize( YD_HORIZ ) / 5 );
204 _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); // hor/vert
206 QVBoxLayout *vbox = new QVBoxLayout( );
207 vbox->addWidget( _sideBar );
216 else if ( _stepsEnabled )
225 void YQWizard::layoutStepsPanel()
228 _stepsPanel = new QFrame( _sideBar );
229 _sideBar->addWidget( _stepsPanel );
230 _sideBar->setObjectName( "steps" );
231 _stepsPanel->setProperty( "class", "steps QFrame" );
233 // Steps panel bottom buttons ("Help", "Release Notes")
235 // Layouts for the buttons
237 _releaseNotesButton = new QPushButton( _( "Release Notes..." ), _stepsPanel );
238 _releaseNotesButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ) ); // hor/vert
240 connect( _releaseNotesButton, SIGNAL( clicked() ),
241 this, SLOT ( releaseNotesClicked() ) );
243 _releaseNotesButton->hide(); // hidden until showReleaseNotesButton() is called
245 _stepsDirty = true; // no layout yet
250 void YQWizard::addStep( const string & text, const string & id )
252 QString qId = fromUTF8( id );
254 if ( _stepsIDs[ qId ] )
256 y2error( "Step ID \"%s\" (\"%s\") already used for \"%s\"",
259 qPrintable( _stepsIDs[ qId ]->name() ) );
263 if ( _stepsList.last() && _stepsList.last()->name() == fromUTF8( text ) )
265 // Consecutive steps with the same name will be shown as one single step.
267 // Since steps are always added at the end of the list, it is
268 // sufficient to check the last step of the list. If the texts are the
269 // same, the other with the same text needs to get another (additional)
270 // ID to make sure setCurrentStep() works as it should.
271 _stepsList.last()->addID( qId );
275 _stepsList.append( new YQWizard::Step( fromUTF8( text ), qId ) );
279 _stepsIDs.insert( qId, _stepsList.last() );
284 void YQWizard::addStepHeading( const string & text )
286 _stepsList.append( new YQWizard::StepHeading( fromUTF8( text ) ) );
292 void YQWizard::updateSteps()
297 // Create a grid layout for the steps
298 QVBoxLayout *_stepsVBox = new QVBoxLayout( _stepsPanel );
300 QGridLayout *_stepsGrid = new QGridLayout( );
301 YUI_CHECK_NEW( _stepsGrid );
302 _stepsVBox->addLayout( _stepsGrid );
303 _stepsGrid->setColumnMinimumWidth( 0, 10 );
304 _stepsGrid->setRowStretch( 0, 1 );
305 _stepsGrid->setRowStretch( 1, 1 );
306 _stepsGrid->setRowStretch( 2, 99 );
308 const int statusCol = 1;
309 const int nameCol = 2;
314 // Create widgets for all steps and step headings in the internal list
317 for ( QList<Step*>::iterator i = _stepsList.begin(); i != _stepsList.end(); ++i)
319 YQWizard::Step * step = *i;
320 if ( step->isHeading() )
326 QLabel * label = new QLabel( step->name(), _stepsPanel );
327 YUI_CHECK_NEW( label );
328 label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
329 label->setProperty( "class", "steps_heading" );
331 step->setNameLabel( label );
332 _stepsGrid->addWidget( label,
334 1, nameCol - statusCol );
336 else // No heading - ordinary step
342 QLabel * statusLabel = new QLabel( _stepsPanel );
343 YUI_CHECK_NEW( statusLabel );
345 step->setStatusLabel( statusLabel );
346 statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
347 _stepsGrid->addWidget( statusLabel, row, statusCol );
353 QLabel * nameLabel = new QLabel( step->name(), _stepsPanel );
354 YUI_CHECK_NEW( nameLabel );
355 nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
357 step->setNameLabel( nameLabel );
358 _stepsGrid->addWidget( nameLabel, row, nameCol );
364 _stepsVBox->addStretch( 99 );
365 QVBoxLayout *rbl = new QVBoxLayout();
366 rbl->addWidget( _releaseNotesButton, 0, Qt::AlignCenter );
368 _stepsVBox->addLayout( rbl );
369 _stepsVBox->addStretch( 29 );
375 void YQWizard::updateStepStates()
380 YQWizard::Step * currentStep = findStep( _currentStepID );
381 QList<YQWizard::Step*>::iterator step = _stepsList.begin();
385 // Set status icon and color for the current step
386 currentStep->setStatus( Step::Current );
389 // Set all steps before the current to "done"
392 while ( step != _stepsList.end() && *step != currentStep )
394 ( *step )->setStatus( Step::Done );
398 // Skip the current step - continue with the step after it
400 if ( step != _stepsList.end() )
405 // Set all steps after the current to "to do"
408 while ( step != _stepsList.end() )
410 ( *step )->setStatus( Step::Todo );
415 void YQWizard::setCurrentStep( const string & id )
417 _currentStepID = fromUTF8( id );
422 void YQWizard::deleteSteps()
429 YQWizard::Step * YQWizard::findStep( const QString & id )
434 return _stepsIDs[ id ];
438 void YQWizard::layoutHelpPanel()
443 // Button box with bottom gradient
446 QLabel * buttonBox = new QLabel( _sideBar );
447 YUI_CHECK_NEW( buttonBox );
449 QPushButton * button;
454 // "Tree" button - intentionally without keyboard shortcut
455 button = new QPushButton( _( "Tree" ), buttonBox );
456 YUI_CHECK_NEW( button );
457 _treeButton = button;
459 pixmap = QPixmap( PIXMAP_DIR "tree-button.png" );
464 // "Steps" button - intentionally without keyboard shortcut
465 button = new QPushButton( _( "Steps" ), buttonBox );
466 YUI_CHECK_NEW( button );
467 _stepsButton = button;
468 _stepsButton->hide();
470 pixmap = QPixmap( PIXMAP_DIR "steps-button.png" );
474 // Create a dummy button just to find out how high it would become
475 button = new QPushButton( "Dummy", buttonBox );
476 YUI_CHECK_NEW( button );
480 #if USE_ICON_ON_HELP_BUTTON
481 if ( ! pixmap.isNull() )
482 button->setPixmap( pixmap );
485 layoutSideBarButtonBox( buttonBox, button );
489 connect( button, SIGNAL( clicked() ),
490 this, SLOT ( showTree() ) );
492 else if ( _stepsEnabled )
494 connect( button, SIGNAL( clicked() ),
495 this, SLOT ( showSteps() ) );
499 // Hide the dummy button - the button box height is fixed now.
505 void YQWizard::layoutTreePanel()
507 _treePanel = new QFrame( _sideBar );
508 YUI_CHECK_NEW( _treePanel );
509 QHBoxLayout *layout = new QHBoxLayout( _treePanel );
510 _sideBar->addWidget( _treePanel );
512 QVBoxLayout * vbox = new QVBoxLayout();
513 YUI_CHECK_NEW( vbox );
514 layout->addLayout( vbox );
518 _tree = new QY2ListView( _treePanel );
519 YUI_CHECK_NEW( _tree );
520 vbox->addWidget( _tree );
523 // _tree->addColumn( "" );
524 // _tree->header()->hide();
526 _tree->setRootIsDecorated( true );
527 _tree->setSortByInsertionSequence( true );
529 connect( _tree, SIGNAL( selectionChanged ( void ) ),
530 this, SLOT ( treeSelectionChanged ( void ) ) );
532 connect( _tree, SIGNAL( spacePressed ( QTreeWidgetItem * ) ),
533 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
535 connect( _tree, SIGNAL( doubleClicked ( QTreeWidgetItem * ) ),
536 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
541 void YQWizard::addTreeItem( const string & parentID, const string & text, const string & id )
543 QString qId = fromUTF8( id );
547 y2error( "YQWizard widget not created with `opt(`treeEnabled) !" );
551 YQWizard::TreeItem * item = 0;
552 YQWizard::TreeItem * parent = 0;
554 if ( ! parentID.empty() )
556 parent = findTreeItem( parentID );
561 item = new YQWizard::TreeItem( parent, fromUTF8( text ), qId );
562 YUI_CHECK_NEW( item );
566 item = new YQWizard::TreeItem( _tree, fromUTF8( text ), qId );
567 YUI_CHECK_NEW( item );
570 if ( ! qId.isEmpty() )
571 _treeIDs.insert( qId, item );
576 void YQWizard::deleteTreeItems()
586 YQWizard::TreeItem * YQWizard::findTreeItem( const string & id )
591 return _treeIDs[ fromUTF8( id ) ];
595 void YQWizard::selectTreeItem( const string & id )
599 YQWizard::TreeItem * item = findTreeItem( id );
603 YQSignalBlocker sigBlocker( _tree );
605 _tree->setCurrentItem(item);
606 _tree->scrollToItem(item);
612 void YQWizard::sendTreeEvent( QTreeWidgetItem * listViewItem )
616 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> ( listViewItem );
618 if ( item && ! item->id().isEmpty() )
619 sendEvent( toUTF8( item->id() ) );
624 void YQWizard::treeSelectionChanged()
625 { //FIXME is currentItem correct or selected.first
627 sendTreeEvent( _tree->currentItem() );
631 string YQWizard::currentTreeSelection()
635 QTreeWidgetItem * sel = _tree->currentItem();
639 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> (sel);
641 if ( item && ! item->id().isEmpty() )
642 return toUTF8( item->id() );
651 QWidget *YQWizard::layoutWorkArea( QWidget * parent )
653 QFrame *workArea = new QFrame( parent );
654 workArea->setObjectName( "work_area" );
656 QVBoxLayout *vbox = new QVBoxLayout( workArea );
658 _menuBar = new QMenuBar( workArea );
659 YUI_CHECK_NEW( _menuBar );
661 _menuBar->hide(); // will be made visible when menus are added
662 vbox->addWidget( _menuBar );
665 // Dialog icon and heading
668 QHBoxLayout * headingHBox = new QHBoxLayout();
669 YUI_CHECK_NEW( headingHBox );
670 //headingHBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
671 vbox->addLayout( headingHBox );
673 _dialogIcon = new QLabel( workArea );
674 YUI_CHECK_NEW( _dialogIcon );
675 headingHBox->addWidget( _dialogIcon );
676 _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); // hor/vert
677 _dialogIcon->setObjectName( "DialogIcon" );
679 _dialogHeading = new QLabel( workArea );
680 YUI_CHECK_NEW( _dialogHeading );
681 headingHBox->addWidget( _dialogHeading );
682 _dialogHeading->setAlignment( Qt::AlignLeft );
683 _dialogHeading->setWordWrap( true );
684 _dialogHeading->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
685 _dialogHeading->setObjectName( "DialogHeading" );
688 // Client area (the part that belongs to the YCP application)
691 layoutClientArea( workArea );
692 vbox->addWidget( _clientArea );
698 QLayout *bb = layoutButtonBox( workArea );
699 vbox->addLayout( bb );
706 void YQWizard::layoutClientArea( QWidget * parent )
708 _clientArea = new QFrame( parent );
709 YUI_CHECK_NEW( _clientArea );
710 QVBoxLayout *layout = new QVBoxLayout( _clientArea );
711 // _clientArea->layout()->setMargin( 4 );
714 // HVCenter for wizard contents
717 _contents = new YQAlignment( this, _clientArea, YAlignCenter, YAlignCenter );
718 YUI_CHECK_NEW( _contents );
719 layout->addWidget( _contents );
720 _contents->QObject::setProperty( "class", "Contents" );
722 _contents->setStretchable( YD_HORIZ, true );
723 _contents->setStretchable( YD_VERT, true );
724 _contents->installEventFilter( this );
725 _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
728 // Replace point for wizard contents
731 _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
734 // Initial YEmpty widget contents of replace point
737 YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
738 _contentsReplacePoint->showChild();
744 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
747 // QHBoxLayout for the buttons
750 QHBoxLayout * hbox = new QHBoxLayout(); // parent, spacing
751 YUI_CHECK_NEW( hbox );
753 hbox->setSpacing( 0 );
754 hbox->setMargin( 0 );
756 // Help button - intentionally without keyboard shortcut
757 _helpButton = new QPushButton( _( "Help" ), parent );
758 YUI_CHECK_NEW( _helpButton );
760 connect( _helpButton, SIGNAL( clicked() ),
761 this, SLOT ( showHelp() ) );
763 #if USE_ICON_ON_HELP_BUTTON
764 QPixmap pixmap = QPixmap( PIXMAP_DIR "help-button.png" );
766 if ( ! pixmap.isNull() )
767 _helpButton->setPixmap( pixmap );
769 hbox->addWidget( _helpButton );
771 hbox->addStretch( 10 );
777 _abortButton = new YQWizardButton( this, parent, _abortButtonLabel );
778 YUI_CHECK_NEW( _abortButton );
780 hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
781 connect( _abortButton, SIGNAL( clicked() ),
782 this, SLOT ( slotAbortClicked() ) );
784 hbox->addSpacing( 10 );
790 _backButton = new YQWizardButton( this, parent, _backButtonLabel );
791 YUI_CHECK_NEW( _backButton );
793 hbox->addWidget( (QWidget *) _backButton->widgetRep() );
794 connect( _backButton, SIGNAL( clicked() ),
795 this, SLOT ( slotBackClicked() ) );
797 if ( _backButton->text().isEmpty() )
804 hbox->addSpacing( 5 );
806 _nextButton = new YQWizardButton( this, parent, _nextButtonLabel );
807 YUI_CHECK_NEW( _nextButton );
809 hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
810 connect( _nextButton, SIGNAL( clicked() ),
811 this, SLOT ( slotNextClicked() ) );
816 void YQWizard::destroyButtons()
829 void YQWizard::connectNotify ( const char * signal )
831 if ( QString( signal ).contains( "nextClicked()" ) )
833 y2debug( "nextClicked connected, no longer directly sending button events" );
834 _sendButtonEvents = false;
839 void YQWizard::disconnectNotify ( const char * signal )
841 if ( QString( signal ).contains( "nextClicked()" ) )
843 y2debug( "nextClicked disconnected, directly sending button events again" );
844 _sendButtonEvents = true;
849 void YQWizard::setDialogIcon( const string & iconName )
853 if ( ! iconName.empty() )
855 QPixmap icon( iconName.c_str() );
858 y2warning( "Couldn't load dialog icon \"%s\"", iconName.c_str() );
861 _dialogIcon->setPixmap( icon );
862 topLevelWidget()->setWindowIcon( icon );
867 _dialogIcon->clear();
868 topLevelWidget()->setWindowIcon( QIcon() );
874 void YQWizard::setDialogHeading( const string & headingText )
876 if ( _dialogHeading )
878 if ( ! headingText.empty() )
879 _dialogHeading->setText( fromUTF8( headingText ) );
881 _dialogHeading->clear();
885 string YQWizard::debugLabel()
887 if ( _dialogHeading )
889 QString label = _dialogHeading->text();
890 label = label.simplified(); // Replace any embedded newline with a single blank
892 if ( ! label.isEmpty() )
894 label.prepend( "YQWizard \"" );
895 label.append( "\"" );
897 return toUTF8( label );
901 return "untitled YQWizard";
904 void YQWizard::setHelpText( const string & helpText )
906 _qHelpText = fromUTF8( helpText );
907 _qHelpText.replace( "&product;", YQUI::ui()->productName() );
911 void YQWizard::slotBackClicked()
915 if ( _sendButtonEvents )
916 YQUI::ui()->sendEvent( new YWidgetEvent( _backButton, YEvent::Activated ) );
918 _direction = YQWizard::Backward;
922 void YQWizard::slotAbortClicked()
926 if ( _sendButtonEvents )
927 YQUI::ui()->sendEvent( new YWidgetEvent( _abortButton, YEvent::Activated ) );
931 void YQWizard::slotNextClicked()
935 if ( _sendButtonEvents )
936 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
938 _direction = YQWizard::Forward;
942 void YQWizard::showHelp()
944 QDialog helpDlg( this );
946 ui.setupUi( &helpDlg );
947 ui.textBrowser->setText( _qHelpText );
952 void YQWizard::releaseNotesClicked()
954 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
956 if ( ! _releaseNotesButtonId.empty() )
958 y2milestone( "Release Notes button clicked" );
959 sendEvent( _releaseNotesButtonId );
964 void YQWizard::showSteps()
966 if ( _sideBar && _stepsPanel )
968 _sideBar->setCurrentWidget( _stepsPanel );
973 void YQWizard::showTree()
975 if ( _sideBar && _treePanel )
977 _sideBar->setCurrentWidget( _treePanel );
983 void YQWizard::addMenu( const string & text,
988 QMenu * menu = new QMenu( _menuBar );
989 YUI_CHECK_NEW( menu );
991 _menuIDs.insert( fromUTF8( id ), menu );
992 //FIXME _menuBar->insertItem( fromUTF8( text ), menu );
994 connect( menu, SIGNAL( activated ( int ) ),
995 this, SLOT ( sendMenuEvent( int ) ) );
1002 void YQWizard::addSubMenu( const string & parentMenuID,
1003 const string & text,
1006 QMenu* parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1010 QMenu * menu = new QMenu( _menuBar );
1011 YUI_CHECK_NEW( menu );
1013 _menuIDs.insert( fromUTF8( id ), menu );
1014 //FIXME parentMenu->insertItem( fromUTF8( text ), menu );
1016 connect( menu, SIGNAL( activated ( int ) ),
1017 this, SLOT ( sendMenuEvent( int ) ) );
1021 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1026 void YQWizard::addMenuEntry( const string & parentMenuID,
1027 const string & text,
1028 const string & idString )
1030 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1034 int id = _menuEntryIDs.size();
1035 _menuEntryIDs.push_back( idString );
1036 //FIXME parentMenu->insertItem( fromUTF8( text ), id );
1040 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1045 void YQWizard::addMenuSeparator( const string & parentMenuID )
1047 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1051 parentMenu->addSeparator();
1055 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1060 void YQWizard::deleteMenus()
1067 _menuEntryIDs.clear();
1072 void YQWizard::sendMenuEvent( int numID )
1074 if ( numID >= 0 && numID < (int) _menuEntryIDs.size() )
1076 sendEvent( _menuEntryIDs[ numID ] );
1080 y2error( "Invalid menu ID: %d", numID );
1085 void YQWizard::sendEvent( const string & id )
1087 YQUI::ui()->sendEvent( new YMenuEvent( id ) );
1091 int YQWizard::preferredWidth()
1093 return sizeHint().width();
1097 int YQWizard::preferredHeight()
1099 return sizeHint().height();
1103 void YQWizard::setSize( int newWidth, int newHeight )
1105 resize( newWidth, newHeight );
1111 void YQWizard::resizeClientArea()
1113 y2debug( "resizing client area" );
1114 QRect contentsRect = _clientArea->contentsRect();
1115 _contents->setSize( contentsRect.width(), contentsRect.height() );
1118 bool YQWizard::eventFilter( QObject * obj, QEvent * ev )
1120 if ( ev->type() == QEvent::Resize && obj == _contents )
1123 return true; // Event handled
1126 return QWidget::eventFilter( obj, ev );
1130 void YQWizard::setButtonLabel( YPushButton * button, const string & newLabel )
1132 button->setLabel( newLabel );
1133 YDialog::currentDialog()->checkShortcuts();
1135 YQWizardButton * wizardButton = dynamic_cast<YQWizardButton *> (button);
1138 wizardButton->setVisible( !newLabel.empty() );
1142 void YQWizard::showReleaseNotesButton( const string & label, const string & id )
1144 return; // no longer supported!
1146 if ( ! _releaseNotesButton )
1148 y2error( "NULL Release Notes button" );
1150 if ( ! _stepsPanel )
1151 y2error( "This works only if there is a \"steps\" panel!" );
1156 // no way to check the shortcut, so strip it
1157 _releaseNotesButton->setText( fromUTF8( YShortcut::cleanShortcutString( label ) ) );
1158 _releaseNotesButtonId = id;
1160 _releaseNotesButton->show();
1164 void YQWizard::hideReleaseNotesButton()
1166 if ( _releaseNotesButton && !_releaseNotesButton->isHidden() )
1167 _releaseNotesButton->hide();
1171 void YQWizard::retranslateInternalButtons()
1173 YQUI::setTextdomain( TEXTDOMAIN );
1176 // "Help" button - intentionally without keyboard shortcut
1177 _helpButton->setText( _( "Help" ) );
1180 // "Steps" button - intentionally without keyboard shortcut
1181 _stepsButton->setText( _( "Steps" ) );
1184 // "Tree" button - intentionally without keyboard shortcut
1185 _treeButton->setText( _( "Tree" ) );
1188 void YQWizard::Step::setStatus( Status s )
1190 if ( !_statusLabel || !_nameLabel || _status == s )
1197 _statusLabel->setProperty( "class", "todo-step-status QLabel" );
1198 _nameLabel->setProperty( "class", "todo-step-name QLabel" );
1203 _statusLabel->setProperty( "class", "done-step-status QLabel" );
1204 _nameLabel->setProperty( "class", "done-step-name QLabel" );
1209 _statusLabel->setProperty( "class", "current-step-status QLabel" );
1210 _nameLabel->setProperty( "class", "current-step-name QLabel" );
1213 qApp->style()->polish( _statusLabel );
1214 qApp->style()->polish( _nameLabel );
1217 #include "YQWizard.moc"