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 <QSvgRenderer>
35 #include <QStackedWidget>
36 #include "ui_QHelpDialog.h"
43 #include <qmenudata.h>
46 #include <q3popupmenu.h>
47 #include <qpushbutton.h>
49 #include <qtabwidget.h>
50 #include <q3textbrowser.h>
51 #include <qtoolbutton.h>
52 #include <q3widgetstack.h>
54 #include "QY2ListView.h"
56 #include <q3boxlayout.h>
57 #include <QGridLayout>
60 #include <q3boxlayout.h>
65 #include "YQApplication.h"
67 #include "YQAlignment.h"
68 #include "YQReplacePoint.h"
71 #include "YQWizardButton.h"
72 #include "YQIconPool.h"
73 #include "YQWidgetFactory.h"
74 #include "YQSignalBlocker.h"
75 #include "QY2LayoutUtils.h"
81 #define PIXMAP_DIR THEMEDIR "/wizard/"
87 #define TEXTDOMAIN "packages-qt"
89 #define USE_ICON_ON_HELP_BUTTON 0
92 YQWizard::YQWizard( YWidget * parent,
93 const string & backButtonLabel,
94 const string & abortButtonLabel,
95 const string & nextButtonLabel,
96 YWizardMode wizardMode )
97 : QFrame( (QWidget *) parent->widgetRep() )
103 , _backButtonLabel( backButtonLabel )
104 , _abortButtonLabel( abortButtonLabel )
105 , _nextButtonLabel( nextButtonLabel )
107 QHBoxLayout* layout = new QHBoxLayout( this );
108 layout->setSpacing( 0 );
109 layout->setMargin( 0 );
111 setWidgetRep( this );
113 _stepsEnabled = (wizardMode == YWizardMode_Steps);
114 _treeEnabled = (wizardMode == YWizardMode_Tree);
117 _direction = YQWizard::Forward;
124 _releaseNotesButton = 0;
135 _sendButtonEvents = true;
136 _contentsReplacePoint = 0;
138 _stepsList.setAutoDelete( true );
139 _stepsIDs.setAutoDelete( false ); // Only for one of both!
141 YQUI::setTextdomain( TEXTDOMAIN );
143 //layoutTitleBar( this );
145 layout->addLayout( layoutSideBar( this ) );
146 layout->addWidget( layoutWorkArea( this ) );
151 YQWizard::~YQWizard()
158 void YQWizard::layoutTitleBar( QWidget * parent )
160 Q3HBox * titleBar = new Q3HBox( parent );
161 YUI_CHECK_NEW( titleBar );
163 titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
169 QLabel * left = new QLabel( titleBar );
170 left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
172 QPixmap leftLogo( PIXMAP_DIR "title-bar-left.png" );
174 if ( ! leftLogo.isNull() )
176 left->setPixmap( leftLogo );
177 left->setFixedSize( leftLogo.size() );
178 left->setBackgroundOrigin( QWidget::ParentOrigin );
183 // Center stretch space
186 addHStretch( titleBar );
193 QLabel * right = new QLabel( titleBar );
194 YUI_CHECK_NEW( right );
196 QPixmap rightLogo( PIXMAP_DIR "title-bar-right.png" );
198 if ( ! rightLogo.isNull() )
200 right->setPixmap( rightLogo );
201 right->setFixedSize( rightLogo.size() );
202 right->setBackgroundOrigin( QWidget::ParentOrigin );
208 QLayout *YQWizard::layoutSideBar( QWidget * parent )
210 _sideBar = new QStackedWidget( parent );
211 YUI_CHECK_NEW( _sideBar );
212 _sideBar->setMinimumWidth( YQUI::ui()->defaultSize( YD_HORIZ ) / 5 );
213 _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); // hor/vert
215 QVBoxLayout *vbox = new QVBoxLayout( );
216 vbox->addWidget( _sideBar );
225 else if ( _stepsEnabled )
234 void YQWizard::layoutStepsPanel()
237 _stepsPanel = new QFrame( _sideBar );
238 _sideBar->addWidget( _stepsPanel );
239 _sideBar->setObjectName( "steps" );
240 _stepsPanel->setProperty( "class", "steps QFrame" );
242 // Steps panel bottom buttons ("Help", "Release Notes")
244 // Layouts for the buttons
246 _releaseNotesButton = new QPushButton( _( "Release Notes..." ), _stepsPanel );
247 _releaseNotesButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ) ); // hor/vert
249 connect( _releaseNotesButton, SIGNAL( clicked() ),
250 this, SLOT ( releaseNotesClicked() ) );
252 _releaseNotesButton->hide(); // hidden until showReleaseNotesButton() is called
254 _stepsDirty = true; // no layout yet
259 void YQWizard::addStep( const string & text, const string & id )
261 QString qId = fromUTF8( id );
263 if ( _stepsIDs[ qId ] )
265 y2error( "Step ID \"%s\" (\"%s\") already used for \"%s\"",
268 (const char *) _stepsIDs[ qId ]->name() );
272 if ( _stepsList.last() && _stepsList.last()->name() == fromUTF8( text ) )
274 // Consecutive steps with the same name will be shown as one single step.
276 // Since steps are always added at the end of the list, it is
277 // sufficient to check the last step of the list. If the texts are the
278 // same, the other with the same text needs to get another (additional)
279 // ID to make sure setCurrentStep() works as it should.
280 _stepsList.last()->addID( qId );
284 _stepsList.append( new YQWizard::Step( fromUTF8( text ), qId ) );
288 _stepsIDs.insert( qId, _stepsList.last() );
293 void YQWizard::addStepHeading( const string & text )
295 _stepsList.append( new YQWizard::StepHeading( fromUTF8( text ) ) );
301 void YQWizard::updateSteps()
306 // Create a grid layout for the steps
307 QVBoxLayout *_stepsVBox = new QVBoxLayout( _stepsPanel );
309 QGridLayout *_stepsGrid = new QGridLayout( );
310 YUI_CHECK_NEW( _stepsGrid );
311 _stepsVBox->addLayout( _stepsGrid );
312 _stepsGrid->setColumnMinimumWidth( 0, 10 );
313 _stepsGrid->setRowStretch( 0, 1 );
314 _stepsGrid->setRowStretch( 1, 1 );
315 _stepsGrid->setRowStretch( 2, 99 );
317 const int statusCol = 1;
318 const int nameCol = 2;
323 // Create widgets for all steps and step headings in the internal list
326 YQWizard::Step * step = _stepsList.first();
330 if ( step->isHeading() )
336 QLabel * label = new QLabel( step->name(), _stepsPanel );
337 YUI_CHECK_NEW( label );
338 label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
339 label->setProperty( "class", "steps_heading" );
341 step->setNameLabel( label );
342 _stepsGrid->addMultiCellWidget( label,
343 row, row, // from_row, to_row
344 statusCol, nameCol ); // from_col, to_col
346 else // No heading - ordinary step
352 QLabel * statusLabel = new QLabel( _stepsPanel );
353 YUI_CHECK_NEW( statusLabel );
355 step->setStatusLabel( statusLabel );
356 statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
357 _stepsGrid->addWidget( statusLabel, row, statusCol );
363 QLabel * nameLabel = new QLabel( step->name(), _stepsPanel );
364 YUI_CHECK_NEW( nameLabel );
365 nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
367 step->setNameLabel( nameLabel );
368 _stepsGrid->addWidget( nameLabel, row, nameCol );
371 step = _stepsList.next();
375 _stepsVBox->addStretch( 99 );
376 QVBoxLayout *rbl = new QVBoxLayout();
377 rbl->addWidget( _releaseNotesButton, 0, Qt::AlignCenter );
379 _stepsVBox->addLayout( rbl );
380 _stepsVBox->addStretch( 29 );
386 void YQWizard::updateStepStates()
391 YQWizard::Step * currentStep = findStep( _currentStepID );
392 YQWizard::Step * step = _stepsList.first();
396 // Set status icon and color for the current step
397 currentStep->setStatus( Step::Current );
400 // Set all steps before the current to "done"
403 while ( step && step != currentStep )
405 step->setStatus( Step::Done );
406 step = _stepsList.next();
409 // Skip the current step - continue with the step after it
412 step = _stepsList.next();
416 // Set all steps after the current to "to do"
421 step->setStatus( Step::Todo );
422 step = _stepsList.next();
426 void YQWizard::setCurrentStep( const string & id )
428 _currentStepID = fromUTF8( id );
433 void YQWizard::deleteSteps()
440 YQWizard::Step * YQWizard::findStep( const QString & id )
445 return _stepsIDs[ id ];
449 void YQWizard::layoutHelpPanel()
454 // Button box with bottom gradient
457 QLabel * buttonBox = new QLabel( _sideBar );
458 YUI_CHECK_NEW( buttonBox );
460 QPushButton * button;
465 // "Tree" button - intentionally without keyboard shortcut
466 button = new QPushButton( _( "Tree" ), buttonBox );
467 YUI_CHECK_NEW( button );
468 _treeButton = button;
470 pixmap = QPixmap( PIXMAP_DIR "tree-button.png" );
475 // "Steps" button - intentionally without keyboard shortcut
476 button = new QPushButton( _( "Steps" ), buttonBox );
477 YUI_CHECK_NEW( button );
478 _stepsButton = button;
479 _stepsButton->hide();
481 pixmap = QPixmap( PIXMAP_DIR "steps-button.png" );
485 // Create a dummy button just to find out how high it would become
486 button = new QPushButton( "Dummy", buttonBox );
487 YUI_CHECK_NEW( button );
491 #if USE_ICON_ON_HELP_BUTTON
492 if ( ! pixmap.isNull() )
493 button->setPixmap( pixmap );
496 layoutSideBarButtonBox( buttonBox, button );
500 connect( button, SIGNAL( clicked() ),
501 this, SLOT ( showTree() ) );
503 else if ( _stepsEnabled )
505 connect( button, SIGNAL( clicked() ),
506 this, SLOT ( showSteps() ) );
510 // Hide the dummy button - the button box height is fixed now.
517 void YQWizard::layoutSideBarButtonBox( QWidget * parent, QPushButton * button )
519 QVBoxLayout * vbox = new QVBoxLayout( parent, 0, 0 ); // parent, margin, spacing
520 YUI_CHECK_NEW( vbox );
522 QHBoxLayout * hbox = new QHBoxLayout( vbox, 0 ); // parent, spacing
523 YUI_CHECK_NEW( hbox );
525 hbox->addStretch( 99 );
526 hbox->addWidget( button );
527 hbox->addStretch( 99 );
532 void YQWizard::layoutTreePanel()
534 _treePanel = new Q3HBox( _sideBar );
535 YUI_CHECK_NEW( _treePanel );
536 _sideBar->addWidget( _treePanel );
538 Q3VBox * vbox = new Q3VBox( _treePanel );
539 YUI_CHECK_NEW( vbox );
544 _tree = new QY2ListView( vbox );
545 YUI_CHECK_NEW( _tree );
548 // _tree->addColumn( "" );
549 // _tree->header()->hide();
551 _tree->setRootIsDecorated( true );
552 _tree->setSortByInsertionSequence( true );
554 connect( _tree, SIGNAL( selectionChanged ( void ) ),
555 this, SLOT ( treeSelectionChanged ( void ) ) );
557 connect( _tree, SIGNAL( spacePressed ( QTreeWidgetItem * ) ),
558 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
560 connect( _tree, SIGNAL( doubleClicked ( QTreeWidgetItem * ) ),
561 this, SLOT ( sendTreeEvent ( QTreeWidgetItem * ) ) );
566 QLabel * buttonBox = new QLabel( vbox );
567 YUI_CHECK_NEW( buttonBox );
570 // "Help" button - intentionally without keyboard shortcut
571 QPushButton * button = new QPushButton( _( "Help" ), buttonBox );
572 YUI_CHECK_NEW( button );
574 #if USE_ICON_ON_HELP_BUTTON
575 QPixmap pixmap( PIXMAP_DIR "help-button.png" );
577 if ( ! pixmap.isNull() )
578 button->setPixmap( pixmap );
581 layoutSideBarButtonBox( buttonBox, button );
583 connect( button, SIGNAL( clicked() ),
584 this, SLOT ( showHelp() ) );
590 void YQWizard::addTreeItem( const string & parentID, const string & text, const string & id )
592 QString qId = fromUTF8( id );
596 y2error( "YQWizard widget not created with `opt(`treeEnabled) !" );
600 YQWizard::TreeItem * item = 0;
601 YQWizard::TreeItem * parent = 0;
603 if ( ! parentID.empty() )
605 parent = findTreeItem( parentID );
610 item = new YQWizard::TreeItem( parent, fromUTF8( text ), qId );
611 YUI_CHECK_NEW( item );
615 item = new YQWizard::TreeItem( _tree, fromUTF8( text ), qId );
616 YUI_CHECK_NEW( item );
619 if ( ! qId.isEmpty() )
620 _treeIDs.insert( qId, item );
625 void YQWizard::deleteTreeItems()
635 YQWizard::TreeItem * YQWizard::findTreeItem( const string & id )
640 return _treeIDs[ fromUTF8( id ) ];
644 void YQWizard::selectTreeItem( const string & id )
648 YQWizard::TreeItem * item = findTreeItem( id );
652 YQSignalBlocker sigBlocker( _tree );
654 _tree->setCurrentItem(item);
655 _tree->scrollToItem(item);
661 void YQWizard::sendTreeEvent( QTreeWidgetItem * listViewItem )
665 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> ( listViewItem );
667 if ( item && ! item->id().isEmpty() )
668 sendEvent( toUTF8( item->id() ) );
673 void YQWizard::treeSelectionChanged()
674 { //FIXME is currentItem correct or selected.first
676 sendTreeEvent( _tree->currentItem() );
680 string YQWizard::currentTreeSelection()
684 QTreeWidgetItem * sel = _tree->currentItem();
688 YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> (sel);
690 if ( item && ! item->id().isEmpty() )
691 return toUTF8( item->id() );
700 QWidget *YQWizard::layoutWorkArea( QWidget * parent )
702 QFrame *workArea = new QFrame( parent );
703 workArea->setObjectName( "work_area" );
705 QVBoxLayout *vbox = new QVBoxLayout( workArea );
707 _menuBar = new QMenuBar( workArea );
708 YUI_CHECK_NEW( _menuBar );
710 _menuBar->hide(); // will be made visible when menus are added
711 vbox->addWidget( _menuBar );
714 // Dialog icon and heading
717 QHBoxLayout * headingHBox = new QHBoxLayout();
718 YUI_CHECK_NEW( headingHBox );
719 //headingHBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
720 vbox->addLayout( headingHBox );
722 _dialogIcon = new QLabel( workArea );
723 YUI_CHECK_NEW( _dialogIcon );
724 headingHBox->addWidget( _dialogIcon );
725 _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); // hor/vert
726 _dialogIcon->setObjectName( "DialogIcon" );
728 _dialogHeading = new QLabel( workArea );
729 YUI_CHECK_NEW( _dialogHeading );
730 headingHBox->addWidget( _dialogHeading );
731 _dialogHeading->setAlignment( Qt::AlignLeft | Qt::WordBreak );
732 _dialogHeading->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
733 _dialogHeading->setObjectName( "DialogHeading" );
736 // Client area (the part that belongs to the YCP application)
739 layoutClientArea( workArea );
740 vbox->addWidget( _clientArea );
746 QLayout *bb = layoutButtonBox( workArea );
747 vbox->addLayout( bb );
754 void YQWizard::layoutClientArea( QWidget * parent )
756 _clientArea = new Q3VBox( parent );
757 YUI_CHECK_NEW( _clientArea );
758 // _clientArea->layout()->setMargin( 4 );
761 // HVCenter for wizard contents
764 _contents = new YQAlignment( this, _clientArea, YAlignCenter, YAlignCenter );
765 YUI_CHECK_NEW( _contents );
766 _contents->QObject::setProperty( "class", "Contents" );
768 _contents->setStretchable( YD_HORIZ, true );
769 _contents->setStretchable( YD_VERT, true );
770 _contents->installEventFilter( this );
771 _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
774 // Replace point for wizard contents
777 _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
780 // Initial YEmpty widget contents of replace point
783 YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
784 _contentsReplacePoint->showChild();
790 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
793 // QHBoxLayout for the buttons
796 QHBoxLayout * hbox = new QHBoxLayout(); // parent, spacing
797 YUI_CHECK_NEW( hbox );
799 hbox->setSpacing( 0 );
800 hbox->setMargin( 0 );
802 // Help button - intentionally without keyboard shortcut
803 _helpButton = new QPushButton( _( "Help" ), parent );
804 YUI_CHECK_NEW( _helpButton );
806 connect( _helpButton, SIGNAL( clicked() ),
807 this, SLOT ( showHelp() ) );
809 #if USE_ICON_ON_HELP_BUTTON
810 QPixmap pixmap = QPixmap( PIXMAP_DIR "help-button.png" );
812 if ( ! pixmap.isNull() )
813 _helpButton->setPixmap( pixmap );
815 hbox->addWidget( _helpButton );
817 hbox->addStretch( 10 );
823 _abortButton = new YQWizardButton( this, parent, _abortButtonLabel );
824 YUI_CHECK_NEW( _abortButton );
826 hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
827 connect( _abortButton, SIGNAL( clicked() ),
828 this, SLOT ( slotAbortClicked() ) );
830 hbox->addSpacing( 10 );
836 _backButton = new YQWizardButton( this, parent, _backButtonLabel );
837 YUI_CHECK_NEW( _backButton );
839 hbox->addWidget( (QWidget *) _backButton->widgetRep() );
840 connect( _backButton, SIGNAL( clicked() ),
841 this, SLOT ( slotBackClicked() ) );
843 if ( _backButton->text().isEmpty() )
850 hbox->addSpacing( 5 );
852 _nextButton = new YQWizardButton( this, parent, _nextButtonLabel );
853 YUI_CHECK_NEW( _nextButton );
855 hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
856 connect( _nextButton, SIGNAL( clicked() ),
857 this, SLOT ( slotNextClicked() ) );
862 void YQWizard::destroyButtons()
875 void YQWizard::connectNotify ( const char * signal )
877 if ( QString( signal ).contains( "nextClicked()" ) )
879 y2debug( "nextClicked connected, no longer directly sending button events" );
880 _sendButtonEvents = false;
885 void YQWizard::disconnectNotify ( const char * signal )
887 if ( QString( signal ).contains( "nextClicked()" ) )
889 y2debug( "nextClicked disconnected, directly sending button events again" );
890 _sendButtonEvents = true;
895 void YQWizard::setDialogIcon( const string & iconName )
899 if ( ! iconName.empty() )
901 QPixmap icon( iconName.c_str() );
904 y2warning( "Couldn't load dialog icon \"%s\"", iconName.c_str() );
907 _dialogIcon->setPixmap( icon );
908 topLevelWidget()->setIcon( icon );
913 _dialogIcon->clear();
914 topLevelWidget()->setIcon( QPixmap() );
920 void YQWizard::setDialogHeading( const string & headingText )
922 if ( _dialogHeading )
924 if ( ! headingText.empty() )
925 _dialogHeading->setText( fromUTF8( headingText ) );
927 _dialogHeading->clear();
931 string YQWizard::debugLabel()
933 if ( _dialogHeading )
935 QString label = _dialogHeading->text();
936 label.simplifyWhiteSpace(); // Replace any embedded newline with a single blank
938 if ( ! label.isEmpty() )
940 label.prepend( "YQWizard \"" );
941 label.append( "\"" );
943 return toUTF8( label );
947 return "untitled YQWizard";
950 void YQWizard::setHelpText( const string & helpText )
952 _qHelpText = fromUTF8( helpText );
953 _qHelpText.replace( "&product;", YQUI::ui()->productName() );
957 void YQWizard::slotBackClicked()
961 if ( _sendButtonEvents )
962 YQUI::ui()->sendEvent( new YWidgetEvent( _backButton, YEvent::Activated ) );
964 _direction = YQWizard::Backward;
968 void YQWizard::slotAbortClicked()
972 if ( _sendButtonEvents )
973 YQUI::ui()->sendEvent( new YWidgetEvent( _abortButton, YEvent::Activated ) );
977 void YQWizard::slotNextClicked()
981 if ( _sendButtonEvents )
982 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
984 _direction = YQWizard::Forward;
988 void YQWizard::showHelp()
990 QDialog helpDlg( this );
992 ui.setupUi( &helpDlg );
993 ui.textBrowser->setText( _qHelpText );
998 void YQWizard::releaseNotesClicked()
1000 YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
1002 if ( ! _releaseNotesButtonId.empty() )
1004 y2milestone( "Release Notes button clicked" );
1005 sendEvent( _releaseNotesButtonId );
1010 void YQWizard::showSteps()
1012 if ( _sideBar && _stepsPanel )
1014 _sideBar->setCurrentWidget( _stepsPanel );
1019 void YQWizard::showTree()
1021 if ( _sideBar && _treePanel )
1023 _sideBar->setCurrentWidget( _treePanel );
1029 void YQWizard::addMenu( const string & text,
1034 Q3PopupMenu * menu = new Q3PopupMenu( _menuBar );
1035 YUI_CHECK_NEW( menu );
1037 _menuIDs.insert( fromUTF8( id ), menu );
1038 _menuBar->insertItem( fromUTF8( text ), menu );
1040 connect( menu, SIGNAL( activated ( int ) ),
1041 this, SLOT ( sendMenuEvent( int ) ) );
1048 void YQWizard::addSubMenu( const string & parentMenuID,
1049 const string & text,
1052 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1056 Q3PopupMenu * menu = new Q3PopupMenu( _menuBar );
1057 YUI_CHECK_NEW( menu );
1059 _menuIDs.insert( fromUTF8( id ), menu );
1060 parentMenu->insertItem( fromUTF8( text ), menu );
1062 connect( menu, SIGNAL( activated ( int ) ),
1063 this, SLOT ( sendMenuEvent( int ) ) );
1067 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1072 void YQWizard::addMenuEntry( const string & parentMenuID,
1073 const string & text,
1074 const string & idString )
1076 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1080 int id = _menuEntryIDs.size();
1081 _menuEntryIDs.push_back( idString );
1082 parentMenu->insertItem( fromUTF8( text ), id );
1086 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1091 void YQWizard::addMenuSeparator( const string & parentMenuID )
1093 Q3PopupMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1097 parentMenu->insertSeparator();
1101 y2error( "Can't find menu with ID %s", parentMenuID.c_str() );
1106 void YQWizard::deleteMenus()
1113 _menuEntryIDs.clear();
1118 void YQWizard::sendMenuEvent( int numID )
1120 if ( numID >= 0 && numID < (int) _menuEntryIDs.size() )
1122 sendEvent( _menuEntryIDs[ numID ] );
1126 y2error( "Invalid menu ID: %d", numID );
1131 void YQWizard::sendEvent( const string & id )
1133 YQUI::ui()->sendEvent( new YMenuEvent( id ) );
1137 int YQWizard::preferredWidth()
1139 return sizeHint().width();
1143 int YQWizard::preferredHeight()
1145 return sizeHint().height();
1149 void YQWizard::setSize( int newWidth, int newHeight )
1151 resize( newWidth, newHeight );
1157 void YQWizard::resizeClientArea()
1159 y2debug( "resizing client area" );
1160 QRect contentsRect = _clientArea->contentsRect();
1161 _contents->setSize( contentsRect.width(), contentsRect.height() );
1164 bool YQWizard::eventFilter( QObject * obj, QEvent * ev )
1166 if ( ev->type() == QEvent::Resize && obj == _contents )
1169 return true; // Event handled
1172 return QWidget::eventFilter( obj, ev );
1176 void YQWizard::setButtonLabel( YPushButton * button, const string & newLabel )
1178 button->setLabel( newLabel );
1179 YDialog::currentDialog()->checkShortcuts();
1181 YQWizardButton * wizardButton = dynamic_cast<YQWizardButton *> (button);
1184 wizardButton->setVisible( !newLabel.empty() );
1188 void YQWizard::showReleaseNotesButton( const string & label, const string & id )
1190 return; // no longer supported!
1192 if ( ! _releaseNotesButton )
1194 y2error( "NULL Release Notes button" );
1196 if ( ! _stepsPanel )
1197 y2error( "This works only if there is a \"steps\" panel!" );
1202 // no way to check the shortcut, so strip it
1203 _releaseNotesButton->setText( fromUTF8( YShortcut::cleanShortcutString( label ) ) );
1204 _releaseNotesButtonId = id;
1206 _releaseNotesButton->show();
1210 void YQWizard::hideReleaseNotesButton()
1212 if ( _releaseNotesButton && !_releaseNotesButton->isHidden() )
1213 _releaseNotesButton->hide();
1217 void YQWizard::retranslateInternalButtons()
1219 YQUI::setTextdomain( TEXTDOMAIN );
1222 // "Help" button - intentionally without keyboard shortcut
1223 _helpButton->setText( _( "Help" ) );
1226 // "Steps" button - intentionally without keyboard shortcut
1227 _stepsButton->setText( _( "Steps" ) );
1230 // "Tree" button - intentionally without keyboard shortcut
1231 _treeButton->setText( _( "Tree" ) );
1234 void YQWizard::Step::setStatus( Status s )
1236 if ( !_statusLabel || !_nameLabel || _status == s )
1243 _statusLabel->setProperty( "class", "todo-step-status QLabel" );
1244 _nameLabel->setProperty( "class", "todo-step-name QLabel" );
1249 _statusLabel->setProperty( "class", "done-step-status QLabel" );
1250 _nameLabel->setProperty( "class", "done-step-name QLabel" );
1255 _statusLabel->setProperty( "class", "current-step-status QLabel" );
1256 _nameLabel->setProperty( "class", "current-step-name QLabel" );
1259 qApp->style()->polish( _statusLabel );
1260 qApp->style()->polish( _nameLabel );
1263 #include "YQWizard.moc"