1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
24 #define y2log_component "qt-wizard"
25 #include <ycp/y2log.h>
27 // For the command parser
30 #include <YShortcut.h>
33 #include "ui_QHelpDialog.h"
40 #include <qmenudata.h>
43 #include <q3popupmenu.h>
44 #include <qpushbutton.h>
46 #include <qtabwidget.h>
47 #include <q3textbrowser.h>
48 #include <qtoolbutton.h>
49 #include <q3widgetstack.h>
51 #include "QY2ListView.h"
53 #include <q3boxlayout.h>
54 #include <QGridLayout>
57 #include <q3boxlayout.h>
62 #include "YQApplication.h"
64 #include "YQAlignment.h"
65 #include "YQReplacePoint.h"
68 #include "YQWizardButton.h"
69 #include "YQIconPool.h"
70 #include "YQWidgetFactory.h"
71 #include "YQSignalBlocker.h"
72 #include "QY2LayoutUtils.h"
78 #define PIXMAP_DIR THEMEDIR "/wizard/"
84 #define TEXTDOMAIN "packages-qt"
86 #define USE_ICON_ON_HELP_BUTTON 0
89 YQWizard::YQWizard( YWidget * parent,
90 const string & backButtonLabel,
91 const string & abortButtonLabel,
92 const string & nextButtonLabel,
93 YWizardMode wizardMode )
94 : QFrame( (QWidget *) parent->widgetRep() )
100 , _backButtonLabel( backButtonLabel )
101 , _abortButtonLabel( abortButtonLabel )
102 , _nextButtonLabel( nextButtonLabel )
104 QHBoxLayout* layout = new QHBoxLayout( this );
105 layout->setSpacing( 0 );
106 layout->setMargin( 0 );
108 setWidgetRep( this );
110 _stepsEnabled = (wizardMode == YWizardMode_Steps);
111 _treeEnabled = (wizardMode == YWizardMode_Tree);
114 _direction = YQWizard::Forward;
121 _releaseNotesButton = 0;
132 _sendButtonEvents = true;
133 _contentsReplacePoint = 0;
135 _stepsList.setAutoDelete( true );
136 _stepsIDs.setAutoDelete( false ); // Only for one of both!
138 YQUI::setTextdomain( TEXTDOMAIN );
140 //layoutTitleBar( this );
142 layout->addLayout( layoutSideBar( this ) );
143 layout->addLayout( layoutWorkArea( this ) );
148 YQWizard::~YQWizard()
155 void YQWizard::layoutTitleBar( QWidget * parent )
157 Q3HBox * titleBar = new Q3HBox( parent );
158 YUI_CHECK_NEW( titleBar );
160 titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
166 QLabel * left = new QLabel( titleBar );
167 left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
169 QPixmap leftLogo( PIXMAP_DIR "title-bar-left.png" );
171 if ( ! leftLogo.isNull() )
173 left->setPixmap( leftLogo );
174 left->setFixedSize( leftLogo.size() );
175 left->setBackgroundOrigin( QWidget::ParentOrigin );
180 // Center stretch space
183 addHStretch( titleBar );
190 QLabel * right = new QLabel( titleBar );
191 YUI_CHECK_NEW( right );
193 QPixmap rightLogo( PIXMAP_DIR "title-bar-right.png" );
195 if ( ! rightLogo.isNull() )
197 right->setPixmap( rightLogo );
198 right->setFixedSize( rightLogo.size() );
199 right->setBackgroundOrigin( QWidget::ParentOrigin );
205 QLayout *YQWizard::layoutSideBar( QWidget * parent )
207 _sideBar = new Q3WidgetStack( parent );
208 YUI_CHECK_NEW( _sideBar );
209 _sideBar->setMinimumWidth( YQUI::ui()->defaultSize( YD_HORIZ ) / 5 );
210 _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); // hor/vert
211 _sideBar->setMargin( 0 );
213 QVBoxLayout *vbox = new QVBoxLayout( );
214 vbox->addWidget( _sideBar );
223 else if ( _stepsEnabled )
232 void YQWizard::layoutStepsPanel()
235 _stepsPanel = new QWidget( _sideBar );
236 _sideBar->addWidget( _stepsPanel );
238 // Steps panel bottom buttons ("Help", "Release Notes")
240 // Layouts for the buttons
242 _releaseNotesButton = new QPushButton( _( "Release Notes..." ), _stepsPanel );
243 _releaseNotesButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ) ); // hor/vert
245 connect( _releaseNotesButton, SIGNAL( clicked() ),
246 this, SLOT ( releaseNotesClicked() ) );
248 _releaseNotesButton->hide(); // hidden until showReleaseNotesButton() is called
250 _stepsDirty = true; // no layout yet
255 void YQWizard::addStep( const string & text, const string & id )
257 QString qId = fromUTF8( id );
259 if ( _stepsIDs[ qId ] )
261 y2error( "Step ID \"%s\" (\"%s\") already used for \"%s\"",
264 (const char *) _stepsIDs[ qId ]->name() );
268 if ( _stepsList.last() && _stepsList.last()->name() == fromUTF8( text ) )
270 // Consecutive steps with the same name will be shown as one single step.
272 // Since steps are always added at the end of the list, it is
273 // sufficient to check the last step of the list. If the texts are the
274 // same, the other with the same text needs to get another (additional)
275 // ID to make sure setCurrentStep() works as it should.
276 _stepsList.last()->addID( qId );
280 _stepsList.append( new YQWizard::Step( fromUTF8( text ), qId ) );
284 _stepsIDs.insert( qId, _stepsList.last() );
289 void YQWizard::addStepHeading( const string & text )
291 _stepsList.append( new YQWizard::StepHeading( fromUTF8( text ) ) );
297 void YQWizard::updateSteps()
302 // Create a grid layout for the steps
303 QVBoxLayout *_stepsVBox = new QVBoxLayout( _stepsPanel );
305 QGridLayout *_stepsGrid = new QGridLayout( );
306 YUI_CHECK_NEW( _stepsGrid );
307 _stepsVBox->addLayout( _stepsGrid );
308 _stepsGrid->setColumnMinimumWidth( 0, 10 );
309 _stepsGrid->setRowStretch( 0, 1 );
310 _stepsGrid->setRowStretch( 1, 1 );
311 _stepsGrid->setRowStretch( 2, 99 );
313 const int statusCol = 1;
314 const int nameCol = 2;
319 // Create widgets for all steps and step headings in the internal list
322 YQWizard::Step * step = _stepsList.first();
326 if ( step->isHeading() )
332 QLabel * label = new QLabel( step->name(), _stepsPanel );
333 YUI_CHECK_NEW( label );
334 label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
335 label->setProperty( "class", "steps_heading" );
337 step->setNameLabel( label );
338 _stepsGrid->addMultiCellWidget( label,
339 row, row, // from_row, to_row
340 statusCol, nameCol ); // from_col, to_col
342 else // No heading - ordinary step
348 QLabel * statusLabel = new QLabel( _stepsPanel );
349 YUI_CHECK_NEW( statusLabel );
351 step->setStatusLabel( statusLabel );
352 statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
353 _stepsGrid->addWidget( statusLabel, row, statusCol );
359 QLabel * nameLabel = new QLabel( step->name(), _stepsPanel );
360 YUI_CHECK_NEW( nameLabel );
361 nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
363 step->setNameLabel( nameLabel );
364 _stepsGrid->addWidget( nameLabel, row, nameCol );
367 step = _stepsList.next();
371 _stepsVBox->addStretch( 99 );
372 QVBoxLayout *rbl = new QVBoxLayout();
373 rbl->addWidget( _releaseNotesButton, 0, Qt::AlignCenter );
375 _stepsVBox->addLayout( rbl );
376 _stepsVBox->addStretch( 29 );
382 void YQWizard::updateStepStates()
387 YQWizard::Step * currentStep = findStep( _currentStepID );
388 YQWizard::Step * step = _stepsList.first();
392 // Set status icon and color for the current step
393 currentStep->setStatus( Step::Current );
396 // Set all steps before the current to "done"
399 while ( step && step != currentStep )
401 step->setStatus( Step::Done );
402 step = _stepsList.next();
405 // Skip the current step - continue with the step after it
408 step = _stepsList.next();
412 // Set all steps after the current to "to do"
417 step->setStatus( Step::Todo );
418 step = _stepsList.next();
422 void YQWizard::setCurrentStep( const string & id )
424 _currentStepID = fromUTF8( id );
429 void YQWizard::deleteSteps()
436 YQWizard::Step * YQWizard::findStep( const QString & id )
441 return _stepsIDs[ id ];
445 void YQWizard::layoutHelpPanel()
448 // Button box with bottom gradient
451 QLabel * buttonBox = new QLabel( _sideBar );
452 YUI_CHECK_NEW( buttonBox );
454 QPushButton * button;
459 // "Tree" button - intentionally without keyboard shortcut
460 button = new QPushButton( _( "Tree" ), buttonBox );
461 YUI_CHECK_NEW( button );
462 _treeButton = button;
464 pixmap = QPixmap( PIXMAP_DIR "tree-button.png" );
469 // "Steps" button - intentionally without keyboard shortcut
470 button = new QPushButton( _( "Steps" ), buttonBox );
471 YUI_CHECK_NEW( button );
472 _stepsButton = button;
474 pixmap = QPixmap( PIXMAP_DIR "steps-button.png" );
478 // Create a dummy button just to find out how high it would become
479 button = new QPushButton( "Dummy", buttonBox );
480 YUI_CHECK_NEW( button );
484 #if USE_ICON_ON_HELP_BUTTON
485 if ( ! pixmap.isNull() )
486 button->setPixmap( pixmap );
489 layoutSideBarButtonBox( buttonBox, button );
493 connect( button, SIGNAL( clicked() ),
494 this, SLOT ( showTree() ) );
496 else if ( _stepsEnabled )
498 connect( button, SIGNAL( clicked() ),
499 this, SLOT ( showSteps() ) );
503 // Hide the dummy button - the button box height is fixed now.
510 void YQWizard::layoutSideBarButtonBox( QWidget * parent, QPushButton * button )
512 QVBoxLayout * vbox = new QVBoxLayout( parent, 0, 0 ); // parent, margin, spacing
513 YUI_CHECK_NEW( vbox );
515 QHBoxLayout * hbox = new QHBoxLayout( vbox, 0 ); // parent, spacing
516 YUI_CHECK_NEW( hbox );
518 hbox->addStretch( 99 );
519 hbox->addWidget( button );
520 hbox->addStretch( 99 );
525 void YQWizard::layoutTreePanel()
527 _treePanel = new Q3HBox( _sideBar );
528 YUI_CHECK_NEW( _treePanel );
529 _sideBar->addWidget( _treePanel );
531 Q3VBox * vbox = new Q3VBox( _treePanel );
532 YUI_CHECK_NEW( vbox );
537 _tree = new QY2ListView( vbox );
538 YUI_CHECK_NEW( _tree );
541 // _tree->addColumn( "" );
542 // _tree->header()->hide();
544 _tree->setRootIsDecorated( true );
545 _tree->setSortByInsertionSequence( true );
547 connect( _tree, SIGNAL( selectionChanged ( void ) ),
548 this, SLOT ( treeSelectionChanged ( void ) ) );
550 connect( _tree, SIGNAL( spacePressed ( QTreeWidgetItem * ) ),
551 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
553 connect( _tree, SIGNAL( doubleClicked ( QTreeWidgetItem * ) ),
554 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
559 QLabel * buttonBox = new QLabel( vbox );
560 YUI_CHECK_NEW( buttonBox );
563 // "Help" button - intentionally without keyboard shortcut
564 QPushButton * button = new QPushButton( _( "Help" ), buttonBox );
565 YUI_CHECK_NEW( button );
567 #if USE_ICON_ON_HELP_BUTTON
568 QPixmap pixmap( PIXMAP_DIR "help-button.png" );
570 if ( ! pixmap.isNull() )
571 button->setPixmap( pixmap );
574 layoutSideBarButtonBox( buttonBox, button );
576 connect( button, SIGNAL( clicked() ),
577 this, SLOT ( showHelp() ) );
583 void YQWizard::addTreeItem( const string & parentID, const string & text, const string & id )
585 QString qId = fromUTF8( id );
589 y2error( "YQWizard widget not created with `opt(`treeEnabled) !" );
593 YQWizard::TreeItem * item = 0;
594 YQWizard::TreeItem * parent = 0;
596 if ( ! parentID.empty() )
598 parent = findTreeItem( parentID );
603 item = new YQWizard::TreeItem( parent, fromUTF8( text ), qId );
604 YUI_CHECK_NEW( item );
608 item = new YQWizard::TreeItem( _tree, fromUTF8( text ), qId );
609 YUI_CHECK_NEW( item );
612 if ( ! qId.isEmpty() )
613 _treeIDs.insert( qId, item );
618 void YQWizard::deleteTreeItems()
628 YQWizard::TreeItem * YQWizard::findTreeItem( const string & id )
633 return _treeIDs[ fromUTF8( id ) ];
637 void YQWizard::selectTreeItem( const string & id )
641 YQWizard::TreeItem * item = findTreeItem( id );
645 YQSignalBlocker sigBlocker( _tree );
647 _tree->setCurrentItem(item);
648 _tree->scrollToItem(item);
654 void YQWizard::sendTreeEvent( QTreeWidgetItem * listViewItem )
658 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> ( listViewItem );
660 if ( item && ! item->id().isEmpty() )
661 sendEvent( toUTF8( item->id() ) );
666 void YQWizard::treeSelectionChanged()
667 { //FIXME is currentItem correct or selected.first
669 sendTreeEvent( _tree->currentItem() );
673 string YQWizard::currentTreeSelection()
677 QTreeWidgetItem * sel = _tree->currentItem();
681 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> (sel);
683 if ( item && ! item->id().isEmpty() )
684 return toUTF8( item->id() );
693 QLayout *YQWizard::layoutWorkArea( QFrame * parent )
695 QVBoxLayout *vbox = new QVBoxLayout();
697 _menuBar = new QMenuBar( parent );
698 YUI_CHECK_NEW( _menuBar );
700 _menuBar->hide(); // will be made visible when menus are added
701 vbox->addWidget( _menuBar );
704 // Dialog icon and heading
707 QHBoxLayout * headingHBox = new QHBoxLayout();
708 YUI_CHECK_NEW( headingHBox );
709 //headingHBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
710 vbox->addLayout( headingHBox );
712 _dialogIcon = new QLabel( parent );
713 YUI_CHECK_NEW( _dialogIcon );
714 headingHBox->addWidget( _dialogIcon );
715 _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); // hor/vert
716 _dialogIcon->setObjectName( "DialogIcon" );
718 _dialogHeading = new QLabel( parent );
719 YUI_CHECK_NEW( _dialogHeading );
720 headingHBox->addWidget( _dialogHeading );
721 _dialogHeading->setAlignment( Qt::AlignLeft | Qt::WordBreak );
722 _dialogHeading->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
723 _dialogHeading->setObjectName( "DialogHeading" );
726 // Client area (the part that belongs to the YCP application)
729 layoutClientArea( parent );
730 vbox->addWidget( _clientArea );
736 QLayout *bb = layoutButtonBox( parent );
737 vbox->addLayout( bb );
744 void YQWizard::layoutClientArea( QWidget * parent )
746 _clientArea = new Q3VBox( parent );
747 YUI_CHECK_NEW( _clientArea );
748 _clientArea->layout()->setMargin( 4 );
751 // HVCenter for wizard contents
754 _contents = new YQAlignment( this, _clientArea, YAlignCenter, YAlignCenter );
755 YUI_CHECK_NEW( _contents );
757 _contents->setStretchable( YD_HORIZ, true );
758 _contents->setStretchable( YD_VERT, true );
759 _contents->installEventFilter( this );
760 _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
763 // Replace point for wizard contents
766 _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
769 // Initial YEmpty widget contents of replace point
772 YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
773 _contentsReplacePoint->showChild();
779 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
782 // QHBoxLayout for the buttons
785 QHBoxLayout * hbox = new QHBoxLayout(); // parent, spacing
786 YUI_CHECK_NEW( hbox );
788 hbox->setSpacing( 5 );
789 hbox->setMargin( 5 );
792 // Help button - intentionally without keyboard shortcut
793 _helpButton = new QPushButton( _( "Help" ), parent );
794 YUI_CHECK_NEW( _helpButton );
796 connect( _helpButton, SIGNAL( clicked() ),
797 this, SLOT ( showHelp() ) );
799 #if USE_ICON_ON_HELP_BUTTON
800 QPixmap pixmap = QPixmap( PIXMAP_DIR "help-button.png" );
802 if ( ! pixmap.isNull() )
803 _helpButton->setPixmap( pixmap );
805 hbox->addWidget( _helpButton );
807 hbox->addStretch( 10 );
813 _abortButton = new YQWizardButton( this, parent, _abortButtonLabel );
814 YUI_CHECK_NEW( _abortButton );
816 hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
817 connect( _abortButton, SIGNAL( clicked() ),
818 this, SLOT ( slotAbortClicked() ) );
820 hbox->addSpacing( 10 );
826 _backButton = new YQWizardButton( this, parent, _backButtonLabel );
827 YUI_CHECK_NEW( _backButton );
829 hbox->addWidget( (QWidget *) _backButton->widgetRep() );
830 connect( _backButton, SIGNAL( clicked() ),
831 this, SLOT ( slotBackClicked() ) );
833 if ( _backButton->text().isEmpty() )
840 _nextButton = new YQWizardButton( this, parent, _nextButtonLabel );
841 YUI_CHECK_NEW( _nextButton );
843 hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
844 connect( _nextButton, SIGNAL( clicked() ),
845 this, SLOT ( slotNextClicked() ) );
850 void YQWizard::destroyButtons()
863 void YQWizard::connectNotify ( const char * signal )
865 if ( QString( signal ).contains( "nextClicked()" ) )
867 y2debug( "nextClicked connected, no longer directly sending button events" );
868 _sendButtonEvents = false;
873 void YQWizard::disconnectNotify ( const char * signal )
875 if ( QString( signal ).contains( "nextClicked()" ) )
877 y2debug( "nextClicked disconnected, directly sending button events again" );
878 _sendButtonEvents = true;
883 void YQWizard::setDialogIcon( const string & iconName )
887 if ( ! iconName.empty() )
889 QPixmap icon( iconName.c_str() );
892 y2warning( "Couldn't load dialog icon \"%s\"", iconName.c_str() );
895 _dialogIcon->setPixmap( icon );
896 topLevelWidget()->setIcon( icon );
901 _dialogIcon->clear();
902 topLevelWidget()->setIcon( QPixmap() );
908 void YQWizard::setDialogHeading( const string & headingText )
910 if ( _dialogHeading )
912 if ( ! headingText.empty() )
913 _dialogHeading->setText( fromUTF8( headingText ) );
915 _dialogHeading->clear();
919 string YQWizard::debugLabel()
921 if ( _dialogHeading )
923 QString label = _dialogHeading->text();
924 label.simplifyWhiteSpace(); // Replace any embedded newline with a single blank
926 if ( ! label.isEmpty() )
928 label.prepend( "YQWizard \"" );
929 label.append( "\"" );
931 return toUTF8( label );
935 return "untitled YQWizard";
938 void YQWizard::setHelpText( const string & helpText )
940 _qHelpText = fromUTF8( helpText );
941 _qHelpText.replace( "&product;", YQUI::ui()->productName() );
945 void YQWizard::slotBackClicked()
949 if ( _sendButtonEvents )
950 YQUI::ui()->sendEvent( new YWidgetEvent( _backButton, YEvent::Activated ) );
952 _direction = YQWizard::Backward;
956 void YQWizard::slotAbortClicked()
960 if ( _sendButtonEvents )
961 YQUI::ui()->sendEvent( new YWidgetEvent( _abortButton, YEvent::Activated ) );
965 void YQWizard::slotNextClicked()
969 if ( _sendButtonEvents )
970 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
972 _direction = YQWizard::Forward;
976 void YQWizard::showHelp()
978 QDialog helpDlg( this );
980 ui.setupUi( &helpDlg );
981 ui.textBrowser->setText( _qHelpText );
986 void YQWizard::releaseNotesClicked()
988 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
990 if ( ! _releaseNotesButtonId.empty() )
992 y2milestone( "Release Notes button clicked" );
993 sendEvent( _releaseNotesButtonId );
998 void YQWizard::showSteps()
1000 if ( _sideBar && _stepsPanel )
1002 _sideBar->raiseWidget( _stepsPanel );
1007 void YQWizard::showTree()
1009 if ( _sideBar && _treePanel )
1011 _sideBar->raiseWidget( _treePanel );
1017 void YQWizard::addMenu( const string & text,
1022 Q3PopupMenu * menu = new Q3PopupMenu( _menuBar );
1023 YUI_CHECK_NEW( menu );
1025 _menuIDs.insert( fromUTF8( id ), menu );
1026 _menuBar->insertItem( fromUTF8( text ), menu );
1028 connect( menu, SIGNAL( activated ( int ) ),
1029 this, SLOT ( sendMenuEvent( int ) ) );
1036 void YQWizard::addSubMenu( const string & parentMenuID,
1037 const string & text,
1040 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1044 Q3PopupMenu * menu = new Q3PopupMenu( _menuBar );
1045 YUI_CHECK_NEW( menu );
1047 _menuIDs.insert( fromUTF8( id ), menu );
1048 parentMenu->insertItem( fromUTF8( text ), menu );
1050 connect( menu, SIGNAL( activated ( int ) ),
1051 this, SLOT ( sendMenuEvent( int ) ) );
1055 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1060 void YQWizard::addMenuEntry( const string & parentMenuID,
1061 const string & text,
1062 const string & idString )
1064 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1068 int id = _menuEntryIDs.size();
1069 _menuEntryIDs.push_back( idString );
1070 parentMenu->insertItem( fromUTF8( text ), id );
1074 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1079 void YQWizard::addMenuSeparator( const string & parentMenuID )
1081 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1085 parentMenu->insertSeparator();
1089 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1094 void YQWizard::deleteMenus()
1101 _menuEntryIDs.clear();
1106 void YQWizard::sendMenuEvent( int numID )
1108 if ( numID >= 0 && numID < (int) _menuEntryIDs.size() )
1110 sendEvent( _menuEntryIDs[ numID ] );
1114 y2error( "Invalid menu ID: %d", numID );
1119 void YQWizard::sendEvent( const string & id )
1121 YQUI::ui()->sendEvent( new YMenuEvent( id ) );
1125 int YQWizard::preferredWidth()
1127 return sizeHint().width();
1131 int YQWizard::preferredHeight()
1133 return sizeHint().height();
1137 void YQWizard::setSize( int newWidth, int newHeight )
1139 resize( newWidth, newHeight );
1145 void YQWizard::resizeClientArea()
1147 y2debug( "resizing client area" );
1148 QRect contentsRect = _clientArea->contentsRect();
1149 _contents->setSize( contentsRect.width(), contentsRect.height() );
1154 bool YQWizard::eventFilter( QObject * obj, QEvent * ev )
1156 if ( ev->type() == QEvent::Resize && obj == _contents )
1159 return true; // Event handled
1162 return QWidget::eventFilter( obj, ev );
1166 void YQWizard::setButtonLabel( YPushButton * button, const string & newLabel )
1168 button->setLabel( newLabel );
1169 YDialog::currentDialog()->checkShortcuts();
1171 YQWizardButton * wizardButton = dynamic_cast<YQWizardButton *> (button);
1174 wizardButton->setVisible( !newLabel.empty() );
1178 void YQWizard::showReleaseNotesButton( const string & label, const string & id )
1180 if ( ! _releaseNotesButton )
1182 y2error( "NULL Release Notes button" );
1184 if ( ! _stepsPanel )
1185 y2error( "This works only if there is a \"steps\" panel!" );
1190 // no way to check the shortcut, so strip it
1191 _releaseNotesButton->setText( fromUTF8( YShortcut::cleanShortcutString( label ) ) );
1192 _releaseNotesButtonId = id;
1194 _releaseNotesButton->show();
1198 void YQWizard::hideReleaseNotesButton()
1200 if ( _releaseNotesButton && !_releaseNotesButton->isHidden() )
1201 _releaseNotesButton->hide();
1205 void YQWizard::retranslateInternalButtons()
1207 YQUI::setTextdomain( TEXTDOMAIN );
1210 // "Help" button - intentionally without keyboard shortcut
1211 _helpButton->setText( _( "Help" ) );
1214 // "Steps" button - intentionally without keyboard shortcut
1215 _stepsButton->setText( _( "Steps" ) );
1218 // "Tree" button - intentionally without keyboard shortcut
1219 _treeButton->setText( _( "Tree" ) );
1222 void YQWizard::Step::setStatus( Status s )
1224 if ( !_statusLabel || _status == s )
1230 _statusLabel->setProperty( "class", "todo-step QLabel" );
1233 _statusLabel->setProperty( "class", "done-step QLabel" );
1236 _statusLabel->setProperty( "class", "current-step QLabel" );
1238 qApp->style()->polish( _statusLabel );
1241 #include "YQWizard.moc"