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"
69 #define PIXMAP_DIR THEMEDIR "/wizard/"
75 #define TEXTDOMAIN "packages-qt"
77 #define USE_ICON_ON_HELP_BUTTON 0
80 YQWizard::YQWizard( YWidget * parent,
81 const string & backButtonLabel,
82 const string & abortButtonLabel,
83 const string & nextButtonLabel,
84 YWizardMode wizardMode )
85 : QFrame( (QWidget *) parent->widgetRep() )
91 , _backButtonLabel( backButtonLabel )
92 , _abortButtonLabel( abortButtonLabel )
93 , _nextButtonLabel( nextButtonLabel )
95 QHBoxLayout* layout = new QHBoxLayout( this );
96 layout->setSpacing( 0 );
97 layout->setMargin( 0 );
101 _stepsEnabled = (wizardMode == YWizardMode_Steps);
102 _treeEnabled = (wizardMode == YWizardMode_Tree);
105 _direction = YQWizard::Forward;
112 _releaseNotesButton = 0;
123 _sendButtonEvents = true;
124 _contentsReplacePoint = 0;
126 //FIXME _stepsList.setAutoDelete( true );
127 //FIXME _stepsIDs.setAutoDelete( false ); // Only for one of both!
129 YQUI::setTextdomain( TEXTDOMAIN );
131 //layoutTitleBar( this );
133 layout->addLayout( layoutSideBar( this ) );
134 layout->addWidget( layoutWorkArea( this ) );
139 YQWizard::~YQWizard()
146 void YQWizard::layoutTitleBar( QWidget * parent )
148 QFrame * titleBar = new QFrame( parent );
149 YUI_CHECK_NEW( titleBar );
151 QHBoxLayout *layout = new QHBoxLayout( titleBar );
152 titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
158 QLabel * left = new QLabel( titleBar );
159 layout->addWidget( left );
160 left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
162 QPixmap leftLogo( PIXMAP_DIR "title-bar-left.png" );
164 if ( ! leftLogo.isNull() )
166 left->setPixmap( leftLogo );
167 left->setFixedSize( leftLogo.size() );
172 // Center stretch space
175 layout->addStretch( 10 );
182 QLabel * right = new QLabel( titleBar );
183 YUI_CHECK_NEW( right );
185 layout->addWidget( right );
187 QPixmap rightLogo( PIXMAP_DIR "title-bar-right.png" );
189 if ( ! rightLogo.isNull() )
191 right->setPixmap( rightLogo );
192 right->setFixedSize( rightLogo.size() );
198 QLayout *YQWizard::layoutSideBar( QWidget * parent )
200 _sideBar = new QStackedWidget( parent );
201 YUI_CHECK_NEW( _sideBar );
202 _sideBar->setMinimumWidth( YQUI::ui()->defaultSize( YD_HORIZ ) / 5 );
203 _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); // hor/vert
205 QVBoxLayout *vbox = new QVBoxLayout( );
206 vbox->addWidget( _sideBar );
215 else if ( _stepsEnabled )
224 void YQWizard::layoutStepsPanel()
227 _stepsPanel = new QFrame( _sideBar );
228 _sideBar->addWidget( _stepsPanel );
229 _sideBar->setObjectName( "steps" );
230 _stepsPanel->setProperty( "class", "steps QFrame" );
232 // Steps panel bottom buttons ("Help", "Release Notes")
234 // Layouts for the buttons
236 _releaseNotesButton = new QPushButton( _( "Release Notes..." ), _stepsPanel );
237 _releaseNotesButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ) ); // hor/vert
239 connect( _releaseNotesButton, SIGNAL( clicked() ),
240 this, SLOT ( releaseNotesClicked() ) );
242 _releaseNotesButton->hide(); // hidden until showReleaseNotesButton() is called
244 _stepsDirty = true; // no layout yet
249 void YQWizard::addStep( const string & text, const string & id )
251 QString qId = fromUTF8( id );
253 if ( _stepsIDs[ qId ] )
255 y2error( "Step ID \"%s\" (\"%s\") already used for \"%s\"",
258 qPrintable( _stepsIDs[ qId ]->name() ) );
262 if ( _stepsList.last() && _stepsList.last()->name() == fromUTF8( text ) )
264 // Consecutive steps with the same name will be shown as one single step.
266 // Since steps are always added at the end of the list, it is
267 // sufficient to check the last step of the list. If the texts are the
268 // same, the other with the same text needs to get another (additional)
269 // ID to make sure setCurrentStep() works as it should.
270 _stepsList.last()->addID( qId );
274 _stepsList.append( new YQWizard::Step( fromUTF8( text ), qId ) );
278 _stepsIDs.insert( qId, _stepsList.last() );
283 void YQWizard::addStepHeading( const string & text )
285 _stepsList.append( new YQWizard::StepHeading( fromUTF8( text ) ) );
291 void YQWizard::updateSteps()
296 // Create a grid layout for the steps
297 QVBoxLayout *_stepsVBox = new QVBoxLayout( _stepsPanel );
299 QGridLayout *_stepsGrid = new QGridLayout( );
300 YUI_CHECK_NEW( _stepsGrid );
301 _stepsVBox->addLayout( _stepsGrid );
302 _stepsGrid->setColumnMinimumWidth( 0, 10 );
303 _stepsGrid->setRowStretch( 0, 1 );
304 _stepsGrid->setRowStretch( 1, 1 );
305 _stepsGrid->setRowStretch( 2, 99 );
307 const int statusCol = 1;
308 const int nameCol = 2;
313 // Create widgets for all steps and step headings in the internal list
316 for ( QList<Step*>::iterator i = _stepsList.begin(); i != _stepsList.end(); ++i)
318 YQWizard::Step * step = *i;
319 if ( step->isHeading() )
325 QLabel * label = new QLabel( step->name(), _stepsPanel );
326 YUI_CHECK_NEW( label );
327 label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
328 label->setProperty( "class", "steps_heading" );
330 step->setNameLabel( label );
331 _stepsGrid->addWidget( label,
333 1, nameCol - statusCol + 1);
335 else // No heading - ordinary step
341 QLabel * statusLabel = new QLabel( _stepsPanel );
342 YUI_CHECK_NEW( statusLabel );
344 step->setStatusLabel( statusLabel );
345 statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
346 _stepsGrid->addWidget( statusLabel, row, statusCol );
352 QLabel * nameLabel = new QLabel( step->name(), _stepsPanel );
353 YUI_CHECK_NEW( nameLabel );
354 nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
356 step->setNameLabel( nameLabel );
357 _stepsGrid->addWidget( nameLabel, row, nameCol );
363 _stepsVBox->addStretch( 99 );
364 QVBoxLayout *rbl = new QVBoxLayout();
365 rbl->addWidget( _releaseNotesButton, 0, Qt::AlignCenter );
367 _stepsVBox->addLayout( rbl );
368 _stepsVBox->addStretch( 29 );
374 void YQWizard::updateStepStates()
379 YQWizard::Step * currentStep = findStep( _currentStepID );
380 QList<YQWizard::Step*>::iterator step = _stepsList.begin();
384 // Set status icon and color for the current step
385 currentStep->setStatus( Step::Current );
388 // Set all steps before the current to "done"
391 while ( step != _stepsList.end() && *step != currentStep )
393 ( *step )->setStatus( Step::Done );
397 // Skip the current step - continue with the step after it
399 if ( step != _stepsList.end() )
404 // Set all steps after the current to "to do"
407 while ( step != _stepsList.end() )
409 ( *step )->setStatus( Step::Todo );
414 void YQWizard::setCurrentStep( const string & id )
416 _currentStepID = fromUTF8( id );
421 void YQWizard::deleteSteps()
428 YQWizard::Step * YQWizard::findStep( const QString & id )
433 return _stepsIDs[ id ];
437 void YQWizard::layoutHelpPanel()
442 // Button box with bottom gradient
445 QLabel * buttonBox = new QLabel( _sideBar );
446 YUI_CHECK_NEW( buttonBox );
448 QPushButton * button;
453 // "Tree" button - intentionally without keyboard shortcut
454 button = new QPushButton( _( "Tree" ), buttonBox );
455 YUI_CHECK_NEW( button );
456 _treeButton = button;
458 pixmap = QPixmap( PIXMAP_DIR "tree-button.png" );
463 // "Steps" button - intentionally without keyboard shortcut
464 button = new QPushButton( _( "Steps" ), buttonBox );
465 YUI_CHECK_NEW( button );
466 _stepsButton = button;
467 _stepsButton->hide();
469 pixmap = QPixmap( PIXMAP_DIR "steps-button.png" );
473 // Create a dummy button just to find out how high it would become
474 button = new QPushButton( "Dummy", buttonBox );
475 YUI_CHECK_NEW( button );
479 #if USE_ICON_ON_HELP_BUTTON
480 if ( ! pixmap.isNull() )
481 button->setPixmap( pixmap );
484 layoutSideBarButtonBox( buttonBox, button );
488 connect( button, SIGNAL( clicked() ),
489 this, SLOT ( showTree() ) );
491 else if ( _stepsEnabled )
493 connect( button, SIGNAL( clicked() ),
494 this, SLOT ( showSteps() ) );
498 // Hide the dummy button - the button box height is fixed now.
504 void YQWizard::layoutTreePanel()
506 _treePanel = new QFrame( _sideBar );
507 YUI_CHECK_NEW( _treePanel );
508 QHBoxLayout *layout = new QHBoxLayout( _treePanel );
509 _sideBar->addWidget( _treePanel );
511 QVBoxLayout * vbox = new QVBoxLayout();
512 YUI_CHECK_NEW( vbox );
513 layout->addLayout( vbox );
517 _tree = new QY2ListView( _treePanel );
518 YUI_CHECK_NEW( _tree );
519 vbox->addWidget( _tree );
522 // _tree->addColumn( "" );
523 // _tree->header()->hide();
525 _tree->setRootIsDecorated( true );
526 _tree->setSortByInsertionSequence( true );
528 connect( _tree, SIGNAL( selectionChanged ( void ) ),
529 this, SLOT ( treeSelectionChanged ( void ) ) );
531 connect( _tree, SIGNAL( spacePressed ( QTreeWidgetItem * ) ),
532 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
534 connect( _tree, SIGNAL( doubleClicked ( QTreeWidgetItem * ) ),
535 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
540 void YQWizard::addTreeItem( const string & parentID, const string & text, const string & id )
542 QString qId = fromUTF8( id );
546 y2error( "YQWizard widget not created with `opt(`treeEnabled) !" );
550 YQWizard::TreeItem * item = 0;
551 YQWizard::TreeItem * parent = 0;
553 if ( ! parentID.empty() )
555 parent = findTreeItem( parentID );
560 item = new YQWizard::TreeItem( parent, fromUTF8( text ), qId );
561 YUI_CHECK_NEW( item );
565 item = new YQWizard::TreeItem( _tree, fromUTF8( text ), qId );
566 YUI_CHECK_NEW( item );
569 if ( ! qId.isEmpty() )
570 _treeIDs.insert( qId, item );
575 void YQWizard::deleteTreeItems()
585 YQWizard::TreeItem * YQWizard::findTreeItem( const string & id )
590 return _treeIDs[ fromUTF8( id ) ];
594 void YQWizard::selectTreeItem( const string & id )
598 YQWizard::TreeItem * item = findTreeItem( id );
602 YQSignalBlocker sigBlocker( _tree );
604 _tree->setCurrentItem(item);
605 _tree->scrollToItem(item);
611 void YQWizard::sendTreeEvent( QTreeWidgetItem * listViewItem )
615 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> ( listViewItem );
617 if ( item && ! item->id().isEmpty() )
618 sendEvent( toUTF8( item->id() ) );
623 void YQWizard::treeSelectionChanged()
624 { //FIXME is currentItem correct or selected.first
626 sendTreeEvent( _tree->currentItem() );
630 string YQWizard::currentTreeSelection()
634 QTreeWidgetItem * sel = _tree->currentItem();
638 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> (sel);
640 if ( item && ! item->id().isEmpty() )
641 return toUTF8( item->id() );
650 QWidget *YQWizard::layoutWorkArea( QWidget * parent )
652 QFrame *workArea = new QFrame( parent );
653 workArea->setObjectName( "work_area" );
655 QVBoxLayout *vbox = new QVBoxLayout( workArea );
657 _menuBar = new QMenuBar( workArea );
658 YUI_CHECK_NEW( _menuBar );
660 _menuBar->hide(); // will be made visible when menus are added
661 vbox->addWidget( _menuBar );
664 // Dialog icon and heading
667 QHBoxLayout * headingHBox = new QHBoxLayout();
668 YUI_CHECK_NEW( headingHBox );
669 //headingHBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
670 vbox->addLayout( headingHBox );
672 _dialogIcon = new QLabel( workArea );
673 YUI_CHECK_NEW( _dialogIcon );
674 headingHBox->addWidget( _dialogIcon );
675 _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); // hor/vert
676 _dialogIcon->setObjectName( "DialogIcon" );
678 _dialogHeading = new QLabel( workArea );
679 YUI_CHECK_NEW( _dialogHeading );
680 headingHBox->addWidget( _dialogHeading );
681 _dialogHeading->setAlignment( Qt::AlignLeft );
682 _dialogHeading->setWordWrap( true );
683 _dialogHeading->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
684 _dialogHeading->setObjectName( "DialogHeading" );
687 // Client area (the part that belongs to the YCP application)
690 layoutClientArea( workArea );
691 vbox->addWidget( _clientArea );
697 QLayout *bb = layoutButtonBox( workArea );
698 vbox->addLayout( bb );
705 void YQWizard::layoutClientArea( QWidget * parent )
707 _clientArea = new QFrame( parent );
708 YUI_CHECK_NEW( _clientArea );
709 QVBoxLayout *layout = new QVBoxLayout( _clientArea );
710 // _clientArea->layout()->setMargin( 4 );
713 // HVCenter for wizard contents
716 _contents = new YQAlignment( this, _clientArea, YAlignCenter, YAlignCenter );
717 YUI_CHECK_NEW( _contents );
718 layout->addWidget( _contents );
719 _contents->QObject::setProperty( "class", "Contents" );
721 _contents->setStretchable( YD_HORIZ, true );
722 _contents->setStretchable( YD_VERT, true );
723 _contents->installEventFilter( this );
724 _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
727 // Replace point for wizard contents
730 _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
733 // Initial YEmpty widget contents of replace point
736 YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
737 _contentsReplacePoint->showChild();
743 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
746 // QHBoxLayout for the buttons
749 QHBoxLayout * hbox = new QHBoxLayout(); // parent, spacing
750 YUI_CHECK_NEW( hbox );
752 hbox->setSpacing( 0 );
753 hbox->setMargin( 0 );
755 // Help button - intentionally without keyboard shortcut
756 _helpButton = new QPushButton( _( "Help" ), parent );
757 YUI_CHECK_NEW( _helpButton );
759 connect( _helpButton, SIGNAL( clicked() ),
760 this, SLOT ( showHelp() ) );
762 #if USE_ICON_ON_HELP_BUTTON
763 QPixmap pixmap = QPixmap( PIXMAP_DIR "help-button.png" );
765 if ( ! pixmap.isNull() )
766 _helpButton->setPixmap( pixmap );
768 hbox->addWidget( _helpButton );
770 hbox->addStretch( 10 );
776 _abortButton = new YQWizardButton( this, parent, _abortButtonLabel );
777 YUI_CHECK_NEW( _abortButton );
779 hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
780 connect( _abortButton, SIGNAL( clicked() ),
781 this, SLOT ( slotAbortClicked() ) );
783 hbox->addSpacing( 10 );
789 _backButton = new YQWizardButton( this, parent, _backButtonLabel );
790 YUI_CHECK_NEW( _backButton );
792 hbox->addWidget( (QWidget *) _backButton->widgetRep() );
793 connect( _backButton, SIGNAL( clicked() ),
794 this, SLOT ( slotBackClicked() ) );
796 if ( _backButton->text().isEmpty() )
803 hbox->addSpacing( 5 );
805 _nextButton = new YQWizardButton( this, parent, _nextButtonLabel );
806 YUI_CHECK_NEW( _nextButton );
808 hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
809 connect( _nextButton, SIGNAL( clicked() ),
810 this, SLOT ( slotNextClicked() ) );
815 void YQWizard::destroyButtons()
828 void YQWizard::connectNotify ( const char * signal )
830 if ( QString( signal ).contains( "nextClicked()" ) )
832 y2debug( "nextClicked connected, no longer directly sending button events" );
833 _sendButtonEvents = false;
838 void YQWizard::disconnectNotify ( const char * signal )
840 if ( QString( signal ).contains( "nextClicked()" ) )
842 y2debug( "nextClicked disconnected, directly sending button events again" );
843 _sendButtonEvents = true;
848 void YQWizard::setDialogIcon( const string & iconName )
852 if ( ! iconName.empty() )
854 QPixmap icon( iconName.c_str() );
857 y2warning( "Couldn't load dialog icon \"%s\"", iconName.c_str() );
860 _dialogIcon->setPixmap( icon );
861 topLevelWidget()->setWindowIcon( icon );
866 _dialogIcon->clear();
867 topLevelWidget()->setWindowIcon( QIcon() );
873 void YQWizard::setDialogHeading( const string & headingText )
875 if ( _dialogHeading )
877 if ( ! headingText.empty() )
878 _dialogHeading->setText( fromUTF8( headingText ) );
880 _dialogHeading->clear();
884 string YQWizard::debugLabel()
886 if ( _dialogHeading )
888 QString label = _dialogHeading->text();
889 label = label.simplified(); // Replace any embedded newline with a single blank
891 if ( ! label.isEmpty() )
893 label.prepend( "YQWizard \"" );
894 label.append( "\"" );
896 return toUTF8( label );
900 return "untitled YQWizard";
903 void YQWizard::setHelpText( const string & helpText )
905 _qHelpText = fromUTF8( helpText );
906 _qHelpText.replace( "&product;", YQUI::ui()->productName() );
910 void YQWizard::slotBackClicked()
914 if ( _sendButtonEvents )
915 YQUI::ui()->sendEvent( new YWidgetEvent( _backButton, YEvent::Activated ) );
917 _direction = YQWizard::Backward;
921 void YQWizard::slotAbortClicked()
925 if ( _sendButtonEvents )
926 YQUI::ui()->sendEvent( new YWidgetEvent( _abortButton, YEvent::Activated ) );
930 void YQWizard::slotNextClicked()
934 if ( _sendButtonEvents )
935 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
937 _direction = YQWizard::Forward;
941 void YQWizard::showHelp()
943 QDialog helpDlg( this );
945 ui.setupUi( &helpDlg );
946 ui.textBrowser->setText( _qHelpText );
951 void YQWizard::releaseNotesClicked()
953 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
955 if ( ! _releaseNotesButtonId.empty() )
957 y2milestone( "Release Notes button clicked" );
958 sendEvent( _releaseNotesButtonId );
963 void YQWizard::showSteps()
965 if ( _sideBar && _stepsPanel )
967 _sideBar->setCurrentWidget( _stepsPanel );
972 void YQWizard::showTree()
974 if ( _sideBar && _treePanel )
976 _sideBar->setCurrentWidget( _treePanel );
982 void YQWizard::addMenu( const string & text,
987 QMenu * menu = new QMenu( _menuBar );
988 YUI_CHECK_NEW( menu );
990 _menuIDs.insert( fromUTF8( id ), menu );
991 //FIXME _menuBar->insertItem( fromUTF8( text ), menu );
993 connect( menu, SIGNAL( activated ( int ) ),
994 this, SLOT ( sendMenuEvent( int ) ) );
1001 void YQWizard::addSubMenu( const string & parentMenuID,
1002 const string & text,
1005 QMenu* parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1009 QMenu * menu = new QMenu( _menuBar );
1010 YUI_CHECK_NEW( menu );
1012 _menuIDs.insert( fromUTF8( id ), menu );
1013 //FIXME parentMenu->insertItem( fromUTF8( text ), menu );
1015 connect( menu, SIGNAL( activated ( int ) ),
1016 this, SLOT ( sendMenuEvent( int ) ) );
1020 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1025 void YQWizard::addMenuEntry( const string & parentMenuID,
1026 const string & text,
1027 const string & idString )
1029 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1033 int id = _menuEntryIDs.size();
1034 _menuEntryIDs.push_back( idString );
1035 //FIXME parentMenu->insertItem( fromUTF8( text ), id );
1039 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1044 void YQWizard::addMenuSeparator( const string & parentMenuID )
1046 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1050 parentMenu->addSeparator();
1054 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1059 void YQWizard::deleteMenus()
1066 _menuEntryIDs.clear();
1071 void YQWizard::sendMenuEvent( int numID )
1073 if ( numID >= 0 && numID < (int) _menuEntryIDs.size() )
1075 sendEvent( _menuEntryIDs[ numID ] );
1079 y2error( "Invalid menu ID: %d", numID );
1084 void YQWizard::sendEvent( const string & id )
1086 YQUI::ui()->sendEvent( new YMenuEvent( id ) );
1090 int YQWizard::preferredWidth()
1092 return sizeHint().width();
1096 int YQWizard::preferredHeight()
1098 return sizeHint().height();
1102 void YQWizard::setSize( int newWidth, int newHeight )
1104 resize( newWidth, newHeight );
1110 void YQWizard::resizeClientArea()
1112 y2debug( "resizing client area" );
1113 QRect contentsRect = _clientArea->contentsRect();
1114 _contents->setSize( contentsRect.width(), contentsRect.height() );
1117 bool YQWizard::eventFilter( QObject * obj, QEvent * ev )
1119 if ( ev->type() == QEvent::Resize && obj == _contents )
1122 return true; // Event handled
1125 return QWidget::eventFilter( obj, ev );
1129 void YQWizard::setButtonLabel( YPushButton * button, const string & newLabel )
1131 button->setLabel( newLabel );
1132 YDialog::currentDialog()->checkShortcuts();
1134 YQWizardButton * wizardButton = dynamic_cast<YQWizardButton *> (button);
1137 wizardButton->setVisible( !newLabel.empty() );
1141 void YQWizard::showReleaseNotesButton( const string & label, const string & id )
1143 return; // no longer supported!
1145 if ( ! _releaseNotesButton )
1147 y2error( "NULL Release Notes button" );
1149 if ( ! _stepsPanel )
1150 y2error( "This works only if there is a \"steps\" panel!" );
1155 // no way to check the shortcut, so strip it
1156 _releaseNotesButton->setText( fromUTF8( YShortcut::cleanShortcutString( label ) ) );
1157 _releaseNotesButtonId = id;
1159 _releaseNotesButton->show();
1163 void YQWizard::hideReleaseNotesButton()
1165 if ( _releaseNotesButton && !_releaseNotesButton->isHidden() )
1166 _releaseNotesButton->hide();
1170 void YQWizard::retranslateInternalButtons()
1172 YQUI::setTextdomain( TEXTDOMAIN );
1175 // "Help" button - intentionally without keyboard shortcut
1176 _helpButton->setText( _( "Help" ) );
1179 // "Steps" button - intentionally without keyboard shortcut
1180 _stepsButton->setText( _( "Steps" ) );
1183 // "Tree" button - intentionally without keyboard shortcut
1184 _treeButton->setText( _( "Tree" ) );
1187 void YQWizard::Step::setStatus( Status s )
1189 if ( !_statusLabel || !_nameLabel || _status == s )
1196 _statusLabel->setProperty( "class", "todo-step-status QLabel" );
1197 _nameLabel->setProperty( "class", "todo-step-name QLabel" );
1202 _statusLabel->setProperty( "class", "done-step-status QLabel" );
1203 _nameLabel->setProperty( "class", "done-step-name QLabel" );
1208 _statusLabel->setProperty( "class", "current-step-status QLabel" );
1209 _nameLabel->setProperty( "class", "current-step-name QLabel" );
1212 qApp->style()->polish( _statusLabel );
1213 qApp->style()->polish( _nameLabel );
1216 #include "YQWizard.moc"