28 #define YUILogComponent "qt-wizard" 29 #include <yui/YUILog.h> 32 #include <yui/YShortcut.h> 35 #include <QSvgRenderer> 37 #include <QStackedWidget> 44 #include <qpushbutton.h> 46 #include <qtabwidget.h> 47 #include <qtoolbutton.h> 48 #include <QGraphicsDropShadowEffect> 50 #include "QY2ListView.h" 51 #include "QY2Styler.h" 52 #include "QY2HelpDialog.h" 53 #include "QY2RelNotesDialog.h" 54 #include <QGridLayout> 55 #include <QHeaderView> 61 #include "YQApplication.h" 63 #include "YQAlignment.h" 64 #include "YQReplacePoint.h" 67 #include "YQWizardButton.h" 68 #include "YQWidgetFactory.h" 69 #include "YQSignalBlocker.h" 70 #include <yui/YEvent.h> 71 #include "YQMainWinDock.h" 80 #define TEXTDOMAIN "qt" 82 #define USE_ICON_ON_HELP_BUTTON 0 85 std::string YQWizard::_releaseNotesButtonId =
"";
86 std::string YQWizard::_releaseNotesButtonLabel =
"";
89 const std::string & backButtonLabel,
90 const std::string & abortButtonLabel,
91 const std::string & nextButtonLabel,
92 YWizardMode wizardMode )
93 : QSplitter( Qt::Horizontal, (QWidget *) parent->widgetRep() )
100 , _backButtonLabel( backButtonLabel )
101 , _abortButtonLabel( abortButtonLabel )
102 , _nextButtonLabel( nextButtonLabel )
104 , _hotkeysDlg ( NULL )
105 , _relNotesDlg ( NULL )
107 setObjectName(
"wizard" );
108 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
110 QHBoxLayout* layout =
new QHBoxLayout(
this );
111 layout->setSpacing( 0 );
112 layout->setMargin( 0 );
114 setWidgetRep(
this );
117 _stepsEnabled = ( (wizardMode == YWizardMode_Steps) || main_wizard );
118 _treeEnabled = (wizardMode == YWizardMode_Tree);
120 _stepsRegistered =
false;
122 _direction = YQWizard::Forward;
129 _releaseNotesButton = 0;
142 _sendButtonEvents =
true;
143 _contentsReplacePoint = 0;
145 _previousWindowIcon = topLevelWidget()->windowIcon();
151 if( topLevelWidget()->windowTitle().isEmpty() )
154 QPixmap pixmap ( YUI::app()->applicationIcon().c_str() );
155 if ( !pixmap.isNull() )
156 setWindowIcon ( QIcon ( pixmap ) );
159 layout->addLayout( layoutSideBar(
this ) );
160 layout->addWidget( layoutWorkArea(
this ) );
162 setStretchFactor(indexOf(_sideBar),0);
163 setStretchFactor(indexOf(_workArea),1);
167 if ( !_stepsEnabled )
170 if ( !main_wizard && _stepsEnabled )
174 else if ( main_wizard )
181 topLevelWidget()->activateWindow();
189 if (
this == main_wizard )
193 else if ( main_wizard )
196 main_wizard->setSizes( sizes() );
204 topLevelWidget()->setWindowIcon( _previousWindowIcon );
210 return this != main_wizard;
214 void YQWizard::layoutTitleBar( QWidget * parent )
216 QFrame * titleBar =
new QFrame( parent );
217 YUI_CHECK_NEW( titleBar );
219 QHBoxLayout *layout =
new QHBoxLayout( titleBar );
220 titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
226 QLabel * left =
new QLabel( titleBar );
227 layout->addWidget( left );
228 left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
229 left->setObjectName(
"titleBar-left" );
235 layout->addStretch( 10 );
242 QLabel * right =
new QLabel( titleBar );
243 YUI_CHECK_NEW( right );
245 layout->addWidget( right );
246 right->setObjectName(
"titleBar-right" );
250 QLayout *YQWizard::layoutSideBar( QWidget * parent )
252 _sideBar =
new QStackedWidget( parent );
253 YUI_CHECK_NEW( _sideBar );
255 _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
256 _sideBar->setObjectName( QString(
"_sideBar-%1" ).arg(
long(
this ) ) );
257 _sideBar->installEventFilter(
this );
259 QVBoxLayout *vbox =
new QVBoxLayout( );
260 vbox->addWidget( _sideBar );
267 else if ( _stepsEnabled )
279 void YQWizard::layoutStepsPanel()
282 _stepsPanel =
new QFrame( _sideBar );
283 _sideBar->addWidget( _stepsPanel );
284 _stepsPanel->setObjectName(
"steps" );
286 _stepsPanel->setProperty(
"class",
"steps QFrame" );
294 QString qId = fromUTF8(
id );
296 if ( _stepsIDs[ qId ] )
298 yuiError() <<
"Step ID \"" <<
id <<
"\" (\"" << text
299 <<
"\") already used for \"" << _stepsIDs[ qId ]->name() <<
"\"" 304 if ( !_stepsList.empty() && _stepsList.last()->name() == fromUTF8( text ) )
312 _stepsList.last()->addID( qId );
320 _stepsIDs.insert( qId, _stepsList.last() );
323 if ( _currentStepID.isNull() )
324 _currentStepID = qId;
340 yuiDebug() <<
"updateSteps" << std::endl;
342 if ( !_stepsRegistered )
343 setUpdatesEnabled(
false);
346 delete _stepsPanel->layout();
347 _stepsPanel->setMaximumWidth( 65000 );
349 QVBoxLayout *_stepsVBox =
new QVBoxLayout( _stepsPanel );
351 QGridLayout *_stepsGrid =
new QGridLayout( );
352 _stepsGrid->setObjectName( QString(
"_stepsGrid_%1" ).arg(
long(
this ) ) );
353 YUI_CHECK_NEW( _stepsGrid );
354 _stepsVBox->addLayout( _stepsGrid );
355 _stepsGrid->setColumnMinimumWidth( 0, 10 );
356 _stepsGrid->setRowStretch( 0, 1 );
357 _stepsGrid->setRowStretch( 1, 1 );
358 _stepsGrid->setRowStretch( 2, 99 );
360 const int statusCol = 1;
361 const int nameCol = 2;
369 for ( QList<Step*>::iterator i = _stepsList.begin(); i != _stepsList.end(); ++i)
373 step->deleteLabels();
375 if ( step->isHeading() )
381 yuiDebug() <<
"Adding StepHeading \"" << step->name() <<
"\"" << std::endl;
382 QLabel * label =
new QLabel( step->name(), _stepsPanel );
383 YUI_CHECK_NEW( label );
384 label->setObjectName( step->name() );
385 label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
386 label->setProperty(
"class",
"steps_heading" );
388 step->setNameLabel( label );
389 _stepsGrid->addWidget( label,
391 1, nameCol - statusCol + 1);
399 yuiDebug() <<
"Adding Step \"" << step->name() <<
"\"" << std::endl;
401 QLabel * statusLabel =
new QLabel( _stepsPanel );
402 YUI_CHECK_NEW( statusLabel );
404 step->setStatusLabel( statusLabel );
405 statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
406 _stepsGrid->addWidget( statusLabel, row, statusCol );
412 QLabel * nameLabel =
new QLabel( step->name(), _stepsPanel );
413 YUI_CHECK_NEW( nameLabel );
414 nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
415 nameLabel->setObjectName( step->name() );
417 step->setNameLabel( nameLabel );
418 _stepsGrid->addWidget( nameLabel, row, nameCol );
425 _stepsVBox->addStretch( 99 );
426 QVBoxLayout *rbl =
new QVBoxLayout();
427 rbl->addWidget( (QWidget *) _releaseNotesButton->widgetRep(), 0, Qt::AlignCenter );
429 _stepsVBox->addLayout( rbl );
430 _stepsVBox->addStretch( 29 );
434 if ( !_stepsRegistered )
437 setUpdatesEnabled(
true );
438 QY2Styler::styler()->updateRendering(
this );
439 _stepsRegistered =
true;
446 yuiDebug() <<
"steps dirty: " << _stepsDirty << std::endl;
452 QList<YQWizard::Step*>::iterator step = _stepsList.begin();
463 while ( step != _stepsList.end() && *step !=
currentStep )
465 ( *step )->setStatus( Step::Done );
471 if ( step != _stepsList.end() )
479 while ( step != _stepsList.end() )
481 ( *step )->setStatus( Step::Todo );
489 yuiDebug() <<
"Setting current step to \"" <<
id <<
"\"" << std::endl;
491 _currentStepID = fromUTF8(
id );
497 QList<Step*> _oldSteps = wizard->
stepsList();
499 if (_oldSteps.empty())
502 foreach(
Step *oldStep, _oldSteps)
506 if( !oldStep->isHeading() )
507 newStep =
new Step( oldStep->name());
511 foreach( QString oneId, oldStep->id())
513 newStep->addID( oneId);
514 _stepsIDs.insert( oneId, newStep );
517 newStep->setEnabled( oldStep->isEnabled());
518 _stepsList.append(newStep);
523 setSizes( main_wizard->sizes());
529 yuiDebug() <<
"Deleting steps" << std::endl;
532 _stepsPanel->setFixedWidth( _stepsPanel->width() );
534 qDeleteAll(_stepsList);
537 _currentStepID = QString::null;
547 return _stepsIDs[ id ];
551 void YQWizard::layoutTreePanel()
553 _treePanel =
new QFrame( _sideBar );
554 YUI_CHECK_NEW( _treePanel );
555 QHBoxLayout *layout =
new QHBoxLayout( _treePanel );
556 _sideBar->addWidget( _treePanel );
558 QVBoxLayout * vbox =
new QVBoxLayout();
559 YUI_CHECK_NEW( vbox );
560 layout->addLayout( vbox );
565 YUI_CHECK_NEW( _tree );
566 vbox->addWidget( _tree );
568 _tree->header()->hide();
569 _tree->header()->setSectionResizeMode( 0, QHeaderView::Stretch );
571 _tree->setRootIsDecorated(
true );
574 connect( _tree, &pclass(_tree)::itemSelectionChanged,
577 connect( _tree, &pclass(_tree)::itemDoubleClicked,
585 QString qId = fromUTF8(
id );
589 yuiError() <<
"YQWizard widget not created with `opt(`treeEnabled) !" << std::endl;
596 if ( ! parentID.empty() )
604 YUI_CHECK_NEW( item );
609 YUI_CHECK_NEW( item );
612 if ( ! qId.isEmpty() )
613 _treeIDs.insert( qId, item );
633 return _treeIDs[ fromUTF8(
id ) ];
647 _tree->setCurrentItem(item);
648 _tree->scrollToItem(item);
660 if ( item && ! item->id().isEmpty() )
677 QTreeWidgetItem * sel = _tree->currentItem();
683 if ( item && ! item->id().isEmpty() )
684 return toUTF8( item->id() );
688 return std::string();
693 QWidget *YQWizard::layoutWorkArea( QWidget * parent )
695 _workArea =
new QFrame( parent );
697 QVBoxLayout *vbox =
new QVBoxLayout( _workArea );
698 YUI_CHECK_NEW( vbox );
701 if (YUI::application()->showProductLogo())
703 QWidget * logoWidget =
new QWidget;
704 logoWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
705 logoWidget->setObjectName(
"LogoHBox");
706 vbox->addWidget( logoWidget );
708 QHBoxLayout * logoHBox =
new QHBoxLayout(logoWidget);
709 YUI_CHECK_NEW( logoHBox );
711 _dialogLogo =
new QLabel( _workArea );
712 YUI_CHECK_NEW( _dialogLogo );
713 logoHBox->addWidget( _dialogLogo );
714 _dialogLogo->setObjectName(
"DialogLogo" );
715 _dialogLogo->setAlignment( Qt::AlignLeft );
717 _dialogLogo->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
718 _dialogLogo->setMinimumHeight(59);
719 _dialogLogo->setMinimumWidth(100);
720 logoHBox->addStretch();
727 _menuBar =
new QMenuBar( _workArea );
728 YUI_CHECK_NEW( _menuBar );
731 vbox->addWidget( _menuBar );
733 QWidget * dialog_inner_area =
new QWidget (_workArea);
734 dialog_inner_area->setObjectName(
"work_area" );
737 QVBoxLayout * inner_vbox =
new QVBoxLayout(dialog_inner_area);
738 YUI_CHECK_NEW( inner_vbox );
739 vbox->addWidget (dialog_inner_area);
741 QVBoxLayout *innerbox =
new QVBoxLayout( _workArea );
742 QVBoxLayout *leftInnerBox = innerbox;
743 QVBoxLayout *rightInnerBox = innerbox;
744 YUI_CHECK_NEW( innerbox );
746 innerbox->setMargin ( YQWidgetMargin );
748 inner_vbox->addLayout(innerbox);
749 vbox->setMargin( 0 );
756 if (titleIsOnTheLeft()) {
757 QHBoxLayout *bigHBox =
new QHBoxLayout();
758 innerbox->addLayout( bigHBox );
760 leftInnerBox =
new QVBoxLayout();
761 leftInnerBox->setObjectName(
"LeftInnerBox" );
762 bigHBox->addLayout( leftInnerBox );
763 bigHBox->setStretchFactor( leftInnerBox, 1 );
765 rightInnerBox =
new QVBoxLayout();
766 rightInnerBox->setObjectName(
"RightInnerBox" );
767 bigHBox->addLayout( rightInnerBox );
768 bigHBox->setStretchFactor( rightInnerBox, 2 );
771 QHBoxLayout * headingHBox =
new QHBoxLayout();
772 YUI_CHECK_NEW( headingHBox );
774 leftInnerBox->addLayout( headingHBox );
776 _dialogIcon =
new QLabel( _workArea );
777 YUI_CHECK_NEW( _dialogIcon );
778 headingHBox->addWidget( _dialogIcon );
779 _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
780 _dialogIcon->setObjectName(
"DialogIcon" );
782 _dialogHeading =
new QLabel( _workArea );
783 YUI_CHECK_NEW( _dialogHeading );
784 headingHBox->addWidget( _dialogHeading );
785 _dialogHeading->setWordWrap(
true );
786 _dialogHeading->setTextFormat( Qt::PlainText );
787 _dialogHeading->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
788 _dialogHeading->setObjectName( (titleIsOnTheLeft())?
"DialogHeadingLeft" :
"DialogHeadingTop" ) ;
794 layoutClientArea( _workArea );
795 rightInnerBox->addWidget( _clientArea );
801 QLayout *bb = layoutButtonBox( _workArea );
802 innerbox->addLayout( bb );
809 void YQWizard::layoutClientArea( QWidget * parent )
811 _clientArea =
new QFrame( parent );
812 YUI_CHECK_NEW( _clientArea );
813 _clientArea->setObjectName(
"_clientArea");
814 QVBoxLayout *layout =
new QVBoxLayout( _clientArea );
815 layout->setMargin( 0 );
821 _contents =
new YQAlignment(
this, _clientArea, YAlignCenter, YAlignCenter );
822 YUI_CHECK_NEW( _contents );
823 layout->addWidget( _contents );
824 _contents->QObject::setProperty(
"class",
"Contents" );
826 _contents->setStretchable( YD_HORIZ,
true );
827 _contents->setStretchable( YD_VERT,
true );
828 _contents->installEventFilter(
this );
829 _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
835 _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
841 YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
842 _contentsReplacePoint->showChild();
848 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
854 QHBoxLayout * hbox =
new QHBoxLayout();
855 YUI_CHECK_NEW( hbox );
857 hbox->setSpacing( 0 );
858 hbox->setMargin( 0 );
862 _helpButton =
new YQWizardButton(
this, parent, _(
"&Help" ).toStdString());
863 YUI_CHECK_NEW( _helpButton );
865 connect( _helpButton, &pclass(_helpButton)::clicked,
868 hbox->addWidget( (QWidget *) _helpButton->widgetRep() );
871 _helpAction =
new QAction(
this );
872 _helpAction->setShortcut( Qt::Key_F1 );
873 addAction( _helpAction );
875 connect( _helpAction, &pclass( _helpAction )::triggered,
879 _hotkeysAction =
new QAction(
this );
880 _hotkeysAction->setShortcut( Qt::ShiftModifier + Qt::Key_F1 );
881 addAction( _hotkeysAction );
883 connect( _hotkeysAction, &pclass( _hotkeysAction )::triggered,
886 hbox->addSpacing( 10 );
894 _releaseNotesButton =
new YQWizardButton(
this, parent, _(
"&Release Notes" ).toStdString ());
895 YUI_CHECK_NEW( _releaseNotesButton );
896 hbox->addWidget( (QWidget *) _releaseNotesButton->widgetRep() );
897 connect( _releaseNotesButton, &pclass(_releaseNotesButton)::clicked,
901 if (_releaseNotesButtonId ==
"")
903 _releaseNotesButton->
hide();
910 hbox->addStretch( 10 );
916 _abortButton =
new YQWizardButton(
this, parent, _abortButtonLabel );
917 YUI_CHECK_NEW( _abortButton );
919 hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
920 connect( _abortButton, &pclass(_abortButton)::clicked,
923 hbox->addSpacing( 10 );
929 _backButton =
new YQWizardButton(
this, parent, _backButtonLabel );
930 YUI_CHECK_NEW( _backButton );
932 hbox->addWidget( (QWidget *) _backButton->widgetRep() );
933 connect( _backButton, &pclass(_backButton)::clicked,
936 if ( _backButton->
text().isEmpty() )
943 hbox->addSpacing( 5 );
945 _nextButton =
new YQWizardButton(
this, parent, _nextButtonLabel );
946 YUI_CHECK_NEW( _nextButton );
948 hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
949 connect( _nextButton, &pclass(_nextButton)::clicked,
955 bool YQWizard::titleIsOnTheLeft()
957 return wizardMode() == YWizardMode_TitleOnLeft;
975 if ( QString( signal ).contains(
"nextClicked()" ) )
977 yuiDebug() <<
"nextClicked connected, no longer directly sending button events" << std::endl;
978 _sendButtonEvents =
false;
985 if ( QString( signal ).contains(
"nextClicked()" ) )
987 yuiDebug() <<
"nextClicked disconnected, directly sending button events again" << std::endl;
988 _sendButtonEvents =
true;
997 if ( ! iconName.empty() )
999 QPixmap icon( iconName.c_str() );
1001 if ( icon.isNull() )
1002 yuiWarning() <<
"Couldn't load dialog icon \"" << iconName <<
"\"" << std::endl;
1005 _dialogIcon->setPixmap( icon );
1006 topLevelWidget()->setWindowIcon( icon );
1011 _dialogIcon->clear();
1012 topLevelWidget()->setWindowIcon( QIcon() );
1020 QString title = fromUTF8( titleText.c_str() );
1022 if ( !title.isEmpty() )
1031 if ( _dialogHeading )
1033 if ( ! headingText.empty() )
1034 _dialogHeading->setText( fromUTF8( headingText ) );
1036 _dialogHeading->clear();
1042 if ( _dialogHeading )
1044 QString label = _dialogHeading->text();
1045 label = label.simplified();
1047 if ( ! label.isEmpty() )
1048 return toUTF8( label );
1051 return "untitled YQWizard";
1057 _qHelpText = fromUTF8( helpText );
1058 _qHelpText.replace(
"&product;", fromUTF8( YUI::app()->productName() ) );
1066 if ( _sendButtonEvents )
1069 _direction = YQWizard::Backward;
1077 if ( _sendButtonEvents )
1086 if ( _sendButtonEvents )
1089 _direction = YQWizard::Forward;
1099 _helpDlg->setHelpText( _qHelpText );
1105 _helpDlg->activateWindow();
1116 "<h1>Advanced Hotkeys</h1>" 1118 "<dt>Print Screen</dt>" 1119 "<dd>Take and save a screenshot. May not be available when YaST is running under " 1120 "some desktop environments.</dd>" 1122 "<dd>Enable/disable the color palette optimized for vision impaired users.</dd>" 1124 "<dd>Enable/disable logging of debug messages.</dd>" 1126 "<dd>Open a file dialog to save log files to a non-standard location.</dd>" 1127 "<dt>Ctrl-Shift-Alt-D</dt>" 1128 "<dd>Send a DebugEvent. YaST modules can react on this by executing " 1129 "special debugging actions. Result depends on the specific YaST-module.</dd>" 1130 "<dt>Ctrl-Shift-Alt-M</dt>" 1131 "<dd>Start/Stop macro recorder.</dd>" 1132 "<dt>Ctrl-Shift-Alt-P</dt>" 1133 "<dd>Replay macro.</dd>" 1134 "<dt>Ctrl-Shift-Alt-S</dt>" 1135 "<dd>Show style sheet editor.</dd>" 1136 "<dt>Ctrl-Shift-Alt-T</dt>" 1137 "<dd>Dump widget tree to the log file.</dd>" 1138 "<dt>Ctrl-Alt-Shift-X</dt>" 1139 "<dd>Open a terminal window (xterm). Useful for VNC installations.</dd>" 1140 "<dt>Ctrl-Shift-Alt-Y</dt>" 1141 "<dd>Show widget tree browser.</dd>" 1148 _hotkeysDlg->show();
1149 _hotkeysDlg->raise();
1150 _hotkeysDlg->activateWindow();
1160 _relNotesDlg->hide();
1163 std::map<std::string,std::string> relnotes = YUI::application()->releaseNotes();
1164 if ( relnotes.size() == 0)
1168 _relNotesDlg->setRelNotes( relnotes );
1169 _relNotesDlg->show();
1170 _relNotesDlg->raise();
1171 _relNotesDlg->activateWindow();
1177 if ( _sideBar && _stepsPanel )
1179 _sideBar->setCurrentWidget( _stepsPanel );
1186 if ( _sideBar && _treePanel )
1188 _sideBar->setCurrentWidget( _treePanel );
1194 const std::string &
id )
1198 QMenu * menu =
new QMenu( _menuBar );
1199 YUI_CHECK_NEW( menu );
1201 _menuIDs.insert( fromUTF8(
id ), menu );
1202 _menuBar->addMenu( menu );
1203 menu->setTitle( fromUTF8( text ) );
1205 connect( menu, &pclass(menu)::triggered,
1214 const std::string & text,
1215 const std::string &
id )
1217 QMenu* parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1221 QMenu * menu =
new QMenu( _menuBar );
1222 YUI_CHECK_NEW( menu );
1224 _menuIDs.insert( fromUTF8(
id ), menu );
1227 connect( menu, &pclass(menu)::triggered,
1232 yuiError() <<
"Can't find menu with ID " << parentMenuID << std::endl;
1238 const std::string & text,
1239 const std::string & idString )
1241 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1246 int id = _menuEntryIDs.size();
1249 action = parentMenu->addAction( fromUTF8( text ) );
1250 _menuEntryIDs[ action ] = idString ;
1255 yuiError() <<
"Can't find menu with ID " << parentMenuID << std::endl;
1262 QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1266 parentMenu->addSeparator();
1270 yuiError() <<
"Can't find menu with ID " << parentMenuID << std::endl;
1282 _menuEntryIDs.clear();
1289 if ( _menuEntryIDs.contains( action ) )
1295 yuiError() <<
"Invalid menu ID " << std::endl;
1308 return sizeHint().width();
1314 return sizeHint().height();
1320 resize( newWidth, newHeight );
1326 QSize contentsRect = _clientArea->contentsRect().size();
1327 _contents->
setSize( contentsRect.width(), contentsRect.height() );
1332 if ( ev->type() == QEvent::Resize && obj == _contents )
1338 if ( ev->type() == QEvent::Resize && obj == _sideBar && main_wizard ==
this && _stepsPanel )
1344 return QWidget::eventFilter( obj, ev );
1350 button->setLabel( newLabel );
1351 YDialog::currentDialog()->checkShortcuts();
1355 if ( wizardButton ) {
1357 if ( newLabel.empty() )
1358 wizardButton->
hide();
1360 wizardButton->
show();
1367 if ( ! _releaseNotesButton )
1369 yuiError() <<
"NULL Release Notes button" << std::endl;
1371 if ( ! _stepsPanel )
1372 yuiError() <<
"This works only if there is a \"steps\" panel!" << std::endl;
1378 _releaseNotesButton->
setLabel( fromUTF8( label ) );
1379 _releaseNotesButtonId = id;
1380 _releaseNotesButtonLabel = label;
1382 _releaseNotesButton->
show();
1388 if ( _releaseNotesButton && !_releaseNotesButton->
isHidden() )
1390 _releaseNotesButton->
hide();
1391 _releaseNotesButtonId =
"";
1392 _releaseNotesButtonLabel =
"";
1404 _helpButton->
setLabel( _(
"&Help" ) );
1409 _stepsButton->setText( _(
"&Steps" ) );
1414 _treeButton->setText( _(
"&Tree" ) );
1416 if ( _releaseNotesButton )
1419 _releaseNotesButton->
setLabel( _(
"&Release Notes" ) );
1422 _helpDlg->retranslate();
1425 _hotkeysDlg->retranslate();
1428 _relNotesDlg->retranslate();
1433 void YQWizard::Step::deleteLabels()
1435 delete _statusLabel;
1450 if ( !_statusLabel || !_nameLabel || _status == s )
1457 _statusLabel->setProperty(
"class",
"todo-step-status QLabel" );
1458 _nameLabel->setProperty (
"class",
"todo-step-name QLabel" );
1463 _statusLabel->setProperty(
"class",
"done-step-status QLabel" );
1464 _nameLabel->setProperty (
"class",
"done-step-name QLabel" );
1469 _statusLabel->setProperty(
"class",
"current-step-status QLabel" );
1470 _nameLabel->setProperty (
"class",
"current-step-name QLabel" );
1473 _statusLabel->style()->unpolish( _statusLabel );
1474 _statusLabel->style()->polish( _statusLabel );
1475 _nameLabel->style()->unpolish( _nameLabel );
1476 _nameLabel->style()->polish( _nameLabel );
1479 #include "YQWizard.moc" virtual std::string currentTreeSelection()
Returns the current tree selection or an empty std::string if nothing is selected or there is no tree...
Helper class to block Qt signals for QWidgets or QObjects as long as this object exists.
void showReleaseNotes()
Propagate button clicked event of release notes button to the application.
virtual void setSortByInsertionSequence(bool sortByInsertionSequence)
Enforce sorting by item insertion order (true) or let user change sorting by clicking on a column hea...
virtual void setCurrentStep(const std::string &id)
Set the current step.
void resizeClientArea()
Adapt the size of the client area (the ReplacePoint(id(contents)) to fit in its current space...
virtual ~Step()
Destructor.
virtual void setDialogIcon(const std::string &iconName)
Set the dialog icon.
void setSideBarWidth(int width)
For secondary wizards.
void destroyButtons()
Destroy the button box's buttons.
virtual void deleteTreeItems()
Delete all tree items.
void sendTreeEvent(QTreeWidgetItem *item)
Internal notification that [Space] or [Return] has been pressed on a tree item.
void showSteps()
Show the current wizard steps, if there are any.
Helper class to represent a wizard step heading internally.
virtual void setHelpText(const std::string &helpText)
Set the help text.
virtual void setButtonLabel(YPushButton *button, const std::string &newLabel)
Set the label of one of the wizard buttons (backButton(), abortButton(), nextButton() ) if that butto...
void registerWidget(QWidget *widget)
Registers a widget and applies the style sheet.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
void connectNotify(const char *signal)
Notification that a signal is being connected.
virtual void clear()
Reimplemented from Q3ListView: Adjust header sizes after clearing contents.
virtual void deleteSteps()
Delete all steps and step headings from the internal lists.
bool isSecondary() const
Returns true if the wizard should follow the first wizard with steps.
QString applicationTitle()
Returns the application name for the window title (e.g.
Helper class for wizard tree item.
virtual void showReleaseNotesButton(const std::string &label, const std::string &id)
Show a "Release Notes" button above the "Help" button in the steps panel with the specified label tha...
virtual bool eventFilter(QObject *obj, QEvent *ev)
Event filter.
void slotAbortClicked()
Internal notification that the "Abort" button has been clicked.
virtual void selectTreeItem(const std::string &id)
Select the tree item with the specified ID, if such an item exists.
YQWizard(YWidget *parent, const std::string &backButtonLabel, const std::string &abortButtonLabel, const std::string &nextButtonLabel, YWizardMode wizardMode=YWizardMode_Standard)
Constructor.
void copySteps(YQWizard *wizard)
Create a copy of given wizard's steps set (names & IDs) Populates _stepsList structure of current wiz...
virtual void addStepHeading(const std::string &text)
Add a step heading for the steps panel on the side bar.
void treeSelectionChanged()
Internal notification that the tree selection has changed.
virtual void setDialogHeading(const std::string &headingText)
Set the dialog heading.
void resizeVisibleChild()
Resize the visible child to the current size of the dock.
virtual void setDialogTitle(const std::string &titleText)
Set the dialog title shown in window manager's title bar.
virtual ~YQWizard()
Destructor.
virtual void addMenuEntry(const std::string &parentMenuID, const std::string &text, const std::string &id)
Add a menu entry to the menu with ID 'parentMenuID'.
static YQMainWinDock * mainWinDock()
Static method to access the singleton for this class.
YQWizard::TreeItem * findTreeItem(const std::string &id)
Find a tree item with the specified ID.
void abortClicked()
Emitted when the "Abort" button is clicked.
void setStatus(Status s)
Set text color and status icon for one wizard step.
virtual void hideReleaseNotesButton()
Hide an existing "Release Notes" button.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
void slotBackClicked()
Internal notification that the "Back" button has been clicked.
virtual void retranslateInternalButtons()
Retranslate internal buttons that are not accessible from the outside:
virtual void addMenuSeparator(const std::string &parentMenuID)
Add a menu separator to a menu.
QString currentStep()
Return QString ID of currently active step.
virtual void addStep(const std::string &text, const std::string &id)
Add a step for the steps panel on the side bar.
virtual void deleteMenus()
Delete all menus and hide the menu bar.
void showHotkeys()
Show an overview of the power-user hotkeys.
void showHelp()
Show the current help text.
virtual void addSubMenu(const std::string &parentMenuID, const std::string &text, const std::string &id)
Add a submenu to the menu with ID 'parentMenuID'.
void slotNextClicked()
Internal notification that the "Next" button has been clicked.
YQWizard::Step * findStep(const QString &id)
Find a step with the specified ID.
virtual int preferredHeight()
Preferred height of the widget.
bool fullscreen() const
Return 'true' if defaultsize windows should use the full screen.
void showTree()
Show the current selection tree in the side panel, if there is any.
void sendEvent(const std::string &id)
Send a wizard event with the specified ID.
Helper class to represent a wizard step internally.
void registerChildWidget(QWidget *parent, QWidget *widget)
Registers a child widget.
virtual void addMenu(const std::string &text, const std::string &id)
Add a menu to the menu bar.
QList< YQWizard::Step * > stepsList()
Return list of pointers to steps.
virtual void addTreeItem(const std::string &parentID, const std::string &text, const std::string &id)
Add a tree item.
void nextClicked()
Emitted when the "Next" or "OK" button is clicked.
void disconnectNotify(const char *signal)
Notification that a signal is being disconnected.
void updateStepStates()
Update all step - use appropriate icons and colors.
void sendMenuEvent(QAction *action)
Internal notification that a menu item with numeric ID 'numID' has been activated.
virtual int preferredWidth()
Preferred width of the widget.
void unregisterWidget(QWidget *widget)
Unregisters a widget.
static void setTextdomain(const char *domain)
Initialize and set a textdomain for gettext()
void backClicked()
Emitted when the "Back" or "Cancel" button is clicked.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
static YQUI * ui()
Access the global Qt-UI.
virtual void updateSteps()
Update the steps display: Reflect the internal steps and heading lists in the layout.
virtual std::string debugLabel() const
Returns a descriptive label of this dialog instance for debugging.