libyui-qt  2.50.2
YQWizard.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQWizard.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23  Textdomain "qt"
24 
25 /-*/
26 
27 #include "YQWizard.h"
28 #define YUILogComponent "qt-wizard"
29 #include <yui/YUILog.h>
30 
31 #include <string>
32 #include <yui/YShortcut.h>
33 
34 #include <QDialog>
35 #include <QSvgRenderer>
36 #include <QPainter>
37 #include <QStackedWidget>
38 #include <qimage.h>
39 #include <qlabel.h>
40 #include <qlayout.h>
41 #include <qmenubar.h>
42 #include <qobject.h>
43 #include <qpixmap.h>
44 #include <qpushbutton.h>
45 #include <qregexp.h>
46 #include <qtabwidget.h>
47 #include <qtoolbutton.h>
48 #include <QGraphicsDropShadowEffect>
49 #include <QFileInfo>
50 
51 #include "QY2ListView.h"
52 #include "QY2Styler.h"
53 #include "QY2HelpDialog.h"
54 #include "QY2RelNotesDialog.h"
55 #include <QGridLayout>
56 #include <QHeaderView>
57 #include <qevent.h>
58 
59 #include "utf8.h"
60 #include "YQi18n.h"
61 #include "YQUI.h"
62 #include "YQApplication.h"
63 #include "YQDialog.h"
64 #include "YQAlignment.h"
65 #include "YQReplacePoint.h"
66 #include "YQEmpty.h"
67 #include "YQLabel.h"
68 #include "YQWizardButton.h"
69 #include "YQWidgetFactory.h"
70 #include "YQSignalBlocker.h"
71 #include <yui/YEvent.h>
72 #include "YQMainWinDock.h"
73 
74 
75 using std::string;
76 
77 #ifdef TEXTDOMAIN
78 # undef TEXTDOMAIN
79 #endif
80 
81 #define TEXTDOMAIN "qt"
82 
83 #define USE_ICON_ON_HELP_BUTTON 0
84 
85 YQWizard *YQWizard::main_wizard = 0;
86 std::string YQWizard::_releaseNotesButtonId = "";
87 std::string YQWizard::_releaseNotesButtonLabel = "";
88 
89 YQWizard::YQWizard( YWidget * parent,
90  const std::string & backButtonLabel,
91  const std::string & abortButtonLabel,
92  const std::string & nextButtonLabel,
93  YWizardMode wizardMode )
94  : QSplitter( Qt::Horizontal, (QWidget *) parent->widgetRep() )
95 
96  , YWizard( parent,
97  backButtonLabel,
98  abortButtonLabel,
99  nextButtonLabel,
100  wizardMode )
101  , _backButtonLabel( backButtonLabel )
102  , _abortButtonLabel( abortButtonLabel )
103  , _nextButtonLabel( nextButtonLabel )
104  , _helpDlg ( NULL )
105  , _hotkeysDlg ( NULL )
106  , _relNotesDlg ( NULL )
107 {
108  setObjectName( "wizard" );
109  setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
110 
111  QHBoxLayout* layout = new QHBoxLayout( this );
112  layout->setSpacing( 0 );
113  layout->setMargin( 0 );
114 
115  setWidgetRep( this );
116 
117  //either main wizard with `opt(`stepsEnabled), or sub-wizard of steps-enabled wizard
118  _stepsEnabled = (wizardMode == YWizardMode_Steps);
119  _treeEnabled = (wizardMode == YWizardMode_Tree);
120 
121  _stepsRegistered = false;
122  _stepsDirty = false;
123  _direction = YQWizard::Forward;
124 
125  _sideBar = 0;
126  _stepsPanel = 0;
127  _helpButton = 0;
128  _stepsButton = 0;
129  _treeButton = 0;
130  _releaseNotesButton = 0;
131  _treePanel = 0;
132  _tree = 0;
133  _workArea = 0;
134  _clientArea = 0;
135  _menuBar = 0;
136  _dialogIcon = 0;
137  _dialogLogo = 0;
138  _dialogHeading = 0;
139  _contents = 0;
140  _backButton = 0;
141  _abortButton = 0;
142  _nextButton = 0;
143  _sendButtonEvents = true;
144  _contentsReplacePoint = 0;
145 
146  _previousWindowIcon = topLevelWidget()->windowIcon();
147 
148  YQUI::setTextdomain( TEXTDOMAIN );
149 
150  if( topLevelWidget()->windowTitle().isEmpty() )
151  {
152  topLevelWidget()->setWindowTitle ( YQUI::ui()->applicationTitle() );
153  QString icon_name = QFileInfo( YUI::app()->applicationIcon().c_str() ).baseName();
154  setWindowIcon ( QIcon::fromTheme( icon_name, QIcon( YUI::app()->applicationIcon().c_str() ) ) );
155  }
156 
157  layout->addLayout( layoutSideBar( this ) );
158  layout->addWidget( layoutWorkArea( this ) );
159 
160  setStretchFactor( indexOf( _sideBar ), 0 );
161  setStretchFactor( indexOf( _workArea ), 1 );
162  setCollapsible( indexOf( _sideBar ), false );
163 
164  /* If steps are enabled, we want to delay
165  the registering for after we have steps registered */
166  if ( !_stepsEnabled )
167  QY2Styler::styler()->registerWidget( this );
168 
169  if ( !main_wizard )
170  {
171  main_wizard = this;
172  }
173  else if ( main_wizard )
174  {
175  copySteps( main_wizard );
177  }
178 
179  if ( YQUI::ui()->fullscreen() )
180  topLevelWidget()->activateWindow();
181 
182 }
183 
184 
186 {
187  deleteSteps();
188  if ( this == main_wizard )
189  {
190  main_wizard = 0;
191  }
192  else if ( main_wizard )
193  {
194  //transfer the widget ratio to the main wizard
195  main_wizard->setSizes( sizes() );
196  }
197 
198  delete _helpDlg;
199  delete _hotkeysDlg;
200  delete _relNotesDlg;
201 
202  QY2Styler::styler()->unregisterWidget( this );
203  topLevelWidget()->setWindowIcon( _previousWindowIcon );
204 }
205 
206 
208 {
209  return this != main_wizard;
210 }
211 
212 
213 void YQWizard::layoutTitleBar( QWidget * parent )
214 {
215  QFrame * titleBar = new QFrame( parent );
216  YUI_CHECK_NEW( titleBar );
217 
218  QHBoxLayout *layout = new QHBoxLayout( titleBar );
219  titleBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
220 
221  //
222  // Left logo
223  //
224 
225  QLabel * left = new QLabel( titleBar );
226  layout->addWidget( left );
227  left->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
228  left->setObjectName( "titleBar-left" );
229 
230  //
231  // Center stretch space
232  //
233 
234  layout->addStretch( 10 );
235 
236 
237  //
238  // Right logo
239  //
240 
241  QLabel * right = new QLabel( titleBar );
242  YUI_CHECK_NEW( right );
243 
244  layout->addWidget( right );
245  right->setObjectName( "titleBar-right" );
246 }
247 
248 
249 QLayout *YQWizard::layoutSideBar( QWidget * parent )
250 {
251  _sideBar = new QStackedWidget( parent );
252  YUI_CHECK_NEW( _sideBar );
253  // _sideBar->setMinimumWidth( YQUI::ui()->defaultSize( YD_HORIZ ) / 5 );
254  _sideBar->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) ); // hor/vert
255  _sideBar->setObjectName( QString( "_sideBar-%1" ).arg( long( this ) ) );
256  _sideBar->installEventFilter( this );
257 
258  QVBoxLayout *vbox = new QVBoxLayout( );
259  vbox->addWidget( _sideBar );
260 
261  if ( _treeEnabled )
262  {
263  layoutTreePanel();
264  showTree();
265  }
266  else if ( _stepsEnabled )
267  {
268  layoutStepsPanel();
269  showSteps();
270  } else {
271  _sideBar->hide();
272  }
273 
274  return vbox;
275 }
276 
277 
278 void YQWizard::layoutStepsPanel()
279 {
280  // Steps
281  _stepsPanel = new QFrame( _sideBar );
282  _sideBar->addWidget( _stepsPanel );
283  _sideBar->setObjectName( "steps" );
284  _sideBar->setProperty( "class", "steps" );
285  QY2Styler::styler()->registerChildWidget( this, _stepsPanel );
286 
287  _stepsDirty = true; // no layout yet
288 }
289 
290 
291 void YQWizard::addStep( const std::string & text, const std::string & id )
292 {
293  QString qId = fromUTF8( id );
294 
295  if ( _stepsIDs[ qId ] )
296  {
297  yuiError() << "Step ID \"" << id << "\" (\"" << text
298  <<"\") already used for \"" << _stepsIDs[ qId ]->name() <<"\""
299  << std::endl;
300  return;
301  }
302 
303  if ( !_stepsList.empty() && _stepsList.last()->name() == fromUTF8( text ) )
304  {
305  // Consecutive steps with the same name will be shown as one single step.
306  //
307  // Since steps are always added at the end of the list, it is
308  // sufficient to check the last step of the list. If the texts are the
309  // same, the other with the same text needs to get another (additional)
310  // ID to make sure setCurrentStep() works as it should.
311  _stepsList.last()->addID( qId );
312  }
313  else
314  {
315  _stepsList.append( new YQWizard::Step( fromUTF8( text ), qId ) );
316  _stepsDirty = true;
317  }
318 
319  _stepsIDs.insert( qId, _stepsList.last() );
320 
321  // make sure we always have a current step if we have steps
322  if ( _currentStepID.isNull() )
323  _currentStepID = qId;
324 }
325 
326 
327 void YQWizard::addStepHeading( const std::string & text )
328 {
329  _stepsList.append( new YQWizard::StepHeading( fromUTF8( text ) ) );
330  _stepsDirty = true;
331 }
332 
333 
335 {
336  if ( ! _stepsPanel )
337  return;
338 
339  yuiDebug() << "updateSteps" << std::endl;
340 
341  if ( !_stepsRegistered )
342  setUpdatesEnabled(false);
343 
344  // Create a grid layout for the steps
345  delete _stepsPanel->layout();
346  _stepsPanel->setMaximumWidth( 65000 );
347 
348  QVBoxLayout *_stepsVBox = new QVBoxLayout( _stepsPanel );
349 
350  QGridLayout *_stepsGrid = new QGridLayout( );
351  _stepsGrid->setObjectName( QString( "_stepsGrid_%1" ).arg( long( this ) ) );
352  YUI_CHECK_NEW( _stepsGrid );
353  _stepsVBox->addLayout( _stepsGrid );
354  _stepsGrid->setColumnMinimumWidth( 0, 10 );
355  _stepsGrid->setRowStretch( 0, 1 );
356  _stepsGrid->setRowStretch( 1, 1 );
357  _stepsGrid->setRowStretch( 2, 99 );
358 
359  const int statusCol = 1;
360  const int nameCol = 2;
361 
362  int row = 0;
363 
364  //
365  // Create widgets for all steps and step headings in the internal list
366  //
367 
368  for ( QList<Step*>::iterator i = _stepsList.begin(); i != _stepsList.end(); ++i)
369  {
370  YQWizard::Step * step = *i;
371 
372  step->deleteLabels();
373 
374  if ( step->isHeading() )
375  {
376  //
377  // Heading
378  //
379 
380  yuiDebug() << "Adding StepHeading \"" << step->name() << "\"" << std::endl;
381  QLabel * label = new QLabel( step->name(), _stepsPanel );
382  YUI_CHECK_NEW( label );
383  label->setObjectName( step->name() );
384  label->setAlignment( Qt::AlignLeft | Qt::AlignTop );
385  label->setProperty( "class", "steps_heading" );
386 
387  step->setNameLabel( label );
388  _stepsGrid->addWidget( label,
389  row, statusCol,
390  1, nameCol - statusCol + 1);
391  }
392  else // No heading - ordinary step
393  {
394  //
395  // Step status
396  //
397 
398  yuiDebug() << "Adding Step \"" << step->name() << "\"" << std::endl;
399 
400  QLabel * statusLabel = new QLabel( _stepsPanel );
401  YUI_CHECK_NEW( statusLabel );
402 
403  step->setStatusLabel( statusLabel );
404  statusLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
405  _stepsGrid->addWidget( statusLabel, row, statusCol );
406 
407  //
408  // Step name
409  //
410 
411  QLabel * nameLabel = new QLabel( step->name(), _stepsPanel );
412  YUI_CHECK_NEW( nameLabel );
413  nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignTop );
414  nameLabel->setObjectName( step->name() );
415 
416  step->setNameLabel( nameLabel );
417  _stepsGrid->addWidget( nameLabel, row, nameCol );
418  }
419 
420  step->setStatus( Step::Todo );
421  row++;
422  }
423 
424  _stepsVBox->addStretch( 99 );
425  QVBoxLayout *rbl = new QVBoxLayout();
426  rbl->addWidget( (QWidget *) _releaseNotesButton->widgetRep(), 0, Qt::AlignCenter );
427 
428  _stepsVBox->addLayout( rbl );
429  _stepsVBox->addStretch( 1 );
430 
431  _stepsDirty = false;
432 
433  if ( !_stepsRegistered )
434  {
435  QY2Styler::styler()->registerWidget( this );
436  setUpdatesEnabled( true );
437  QY2Styler::styler()->updateRendering( this );
438  _stepsRegistered = true;
439  }
440 }
441 
442 
444 {
445  yuiDebug() << "steps dirty: " << _stepsDirty << std::endl;
446 
447  if ( _stepsDirty )
448  updateSteps();
449 
450  YQWizard::Step * currentStep = findStep( _currentStepID );
451  QList<YQWizard::Step*>::iterator step = _stepsList.begin();
452 
453  if ( currentStep )
454  {
455  // Set status icon and color for the current step
456  currentStep->setStatus( Step::Current );
457 
458  //
459  // Set all steps before the current to "done"
460  //
461 
462  while ( step != _stepsList.end() && *step != currentStep )
463  {
464  ( *step )->setStatus( Step::Done );
465  step++;
466  }
467 
468  // Skip the current step - continue with the step after it
469 
470  if ( step != _stepsList.end() )
471  step++;
472  }
473 
474  //
475  // Set all steps after the current to "to do"
476  //
477 
478  while ( step != _stepsList.end() )
479  {
480  ( *step )->setStatus( Step::Todo );
481  step++;
482  }
483 }
484 
485 
486 void YQWizard::setCurrentStep( const std::string & id )
487 {
488  yuiDebug() << "Setting current step to \"" << id << "\"" << std::endl;
489 
490  _currentStepID = fromUTF8( id );
492 }
493 
495 {
496  QList<Step*> _oldSteps = wizard->stepsList();
497 
498  if (_oldSteps.empty())
499  return;
500 
501  foreach( Step *oldStep, _oldSteps)
502  {
503  Step *newStep;
504 
505  if( !oldStep->isHeading() )
506  newStep = new Step( oldStep->name());
507  else
508  newStep = new StepHeading( oldStep->name());
509 
510  foreach( QString oneId, oldStep->id())
511  {
512  newStep->addID( oneId);
513  _stepsIDs.insert( oneId, newStep );
514  }
515 
516  newStep->setEnabled( oldStep->isEnabled());
517  _stepsList.append(newStep);
518 
519  }
520 
521  setCurrentStep( wizard->currentStep().toStdString() );
522  setSizes( main_wizard->sizes());
523 }
524 
525 
527 {
528  yuiDebug() << "Deleting steps" << std::endl;
529 
530  if ( _stepsPanel )
531  _stepsPanel->setFixedWidth( _stepsPanel->width() );
532 
533  qDeleteAll(_stepsList);
534  _stepsList.clear();
535  _stepsIDs.clear();
536  _currentStepID = QString();
537  _stepsDirty = true;
538 }
539 
540 
541 YQWizard::Step * YQWizard::findStep( const QString & id )
542 {
543  if ( id.isEmpty() )
544  return 0;
545 
546  return _stepsIDs[ id ];
547 }
548 
549 
550 void YQWizard::layoutTreePanel()
551 {
552  _treePanel = new QFrame( _sideBar );
553  YUI_CHECK_NEW( _treePanel );
554  QHBoxLayout *layout = new QHBoxLayout( _treePanel );
555  _sideBar->addWidget( _treePanel );
556 
557  QVBoxLayout * vbox = new QVBoxLayout();
558  YUI_CHECK_NEW( vbox );
559  layout->addLayout( vbox );
560 
561  // Selection tree
562 
563  _tree = new QY2ListView( _treePanel );
564  YUI_CHECK_NEW( _tree );
565  vbox->addWidget( _tree );
566 
567  _tree->header()->hide();
568  _tree->header()->setSectionResizeMode( 0, QHeaderView::Stretch );
569 
570  _tree->setRootIsDecorated( true );
571  _tree->setSortByInsertionSequence( true );
572 
573  connect( _tree, &pclass(_tree)::itemSelectionChanged,
574  this, &pclass(this)::treeSelectionChanged );
575 
576  connect( _tree, &pclass(_tree)::itemDoubleClicked,
577  this, &pclass(this)::sendTreeEvent );
578 
579 }
580 
581 
582 void YQWizard::addTreeItem( const std::string & parentID, const std::string & text, const std::string & id )
583 {
584  QString qId = fromUTF8( id );
585 
586  if ( ! _tree )
587  {
588  yuiError() << "YQWizard widget not created with `opt(`treeEnabled) !" << std::endl;
589  return;
590  }
591 
592  YQWizard::TreeItem * item = 0;
593  YQWizard::TreeItem * parent = 0;
594 
595  if ( ! parentID.empty() )
596  {
597  parent = findTreeItem( parentID );
598  }
599 
600  if ( parent )
601  {
602  item = new YQWizard::TreeItem( parent, fromUTF8( text ), qId );
603  YUI_CHECK_NEW( item );
604  }
605  else
606  {
607  item = new YQWizard::TreeItem( _tree, fromUTF8( text ), qId );
608  YUI_CHECK_NEW( item );
609  }
610 
611  if ( ! qId.isEmpty() )
612  _treeIDs.insert( qId, item );
613 }
614 
615 
616 
618 {
619  if ( _tree )
620  _tree->clear();
621 
622  _treeIDs.clear();
623 }
624 
625 
626 
627 YQWizard::TreeItem * YQWizard::findTreeItem( const std::string & id )
628 {
629  if ( id.empty() )
630  return 0;
631 
632  return _treeIDs[ fromUTF8( id ) ];
633 }
634 
635 
636 void YQWizard::selectTreeItem( const std::string & id )
637 {
638  if ( _tree )
639  {
640  YQWizard::TreeItem * item = findTreeItem( id );
641 
642  if ( item )
643  {
644  YQSignalBlocker sigBlocker( _tree );
645 
646  _tree->setCurrentItem(item);
647  _tree->scrollToItem(item);
648  }
649  }
650 }
651 
652 
653 void YQWizard::sendTreeEvent( QTreeWidgetItem * listViewItem )
654 {
655  if ( listViewItem )
656  {
657  YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> ( listViewItem );
658 
659  if ( item && ! item->id().isEmpty() )
660  sendEvent( toUTF8( item->id() ) );
661  }
662 }
663 
664 
666 { //FIXME is currentItem correct or selected.first
667  if ( _tree )
668  sendTreeEvent( _tree->currentItem() );
669 }
670 
671 
673 {
674  if ( _tree )
675  {
676  QTreeWidgetItem * sel = _tree->currentItem();
677 
678  if ( sel )
679  {
680  YQWizard::TreeItem * item = dynamic_cast<YQWizard::TreeItem *> (sel);
681 
682  if ( item && ! item->id().isEmpty() )
683  return toUTF8( item->id() );
684  }
685  }
686 
687  return std::string();
688 }
689 
690 
691 
692 QWidget *YQWizard::layoutWorkArea( QWidget * parent )
693 {
694  _workArea = new QFrame( parent );
695 
696  QVBoxLayout *vbox = new QVBoxLayout( _workArea );
697  YUI_CHECK_NEW( vbox );
698 
699  // add the logo on the top
700  if (YUI::application()->showProductLogo())
701  {
702  QWidget * logoWidget = new QWidget;
703  logoWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); // hor/vert
704  logoWidget->setObjectName("LogoHBox");
705  vbox->addWidget( logoWidget );
706 
707  QHBoxLayout * logoHBox = new QHBoxLayout(logoWidget);
708  YUI_CHECK_NEW( logoHBox );
709 
710  _dialogLogo = new QLabel( _workArea );
711  YUI_CHECK_NEW( _dialogLogo );
712  logoHBox->addWidget( _dialogLogo );
713  _dialogLogo->setObjectName( "DialogLogo" );
714  _dialogLogo->setAlignment( Qt::AlignLeft );
715  QY2Styler::styler()->registerChildWidget( this, _dialogLogo );
716  _dialogLogo->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
717  _dialogLogo->setMinimumHeight(59); // FIXME: control size via stylesheet, did not find how
718  _dialogLogo->setMinimumWidth(100);
719  logoHBox->addStretch();
720  }
721 
722  //
723  // Menu bar
724  //
725 
726  _menuBar = new QMenuBar( _workArea );
727  YUI_CHECK_NEW( _menuBar );
728 
729  _menuBar->hide(); // will be made visible when menus are added
730  vbox->addWidget( _menuBar );
731 
732  QWidget * dialog_inner_area = new QWidget (_workArea);
733  dialog_inner_area->setObjectName( "work_area" );
734 
735  QY2Styler::styler()->registerChildWidget( this, dialog_inner_area );
736  QVBoxLayout * inner_vbox = new QVBoxLayout(dialog_inner_area);
737  YUI_CHECK_NEW( inner_vbox );
738  vbox->addWidget (dialog_inner_area);
739 
740  QVBoxLayout *innerbox = new QVBoxLayout( _workArea );
741  QVBoxLayout *leftInnerBox = innerbox;
742  QVBoxLayout *rightInnerBox = innerbox;
743  YUI_CHECK_NEW( innerbox );
744 
745  innerbox->setMargin ( YQWidgetMargin );
746 
747  inner_vbox->addLayout(innerbox);
748  vbox->setMargin( 0 );
749 
750 
751  //
752  // Dialog icon and heading
753  //
754 
755  if (titleIsOnTheLeft()) {
756  QHBoxLayout *bigHBox = new QHBoxLayout();
757  innerbox->addLayout( bigHBox );
758 
759  leftInnerBox = new QVBoxLayout();
760  leftInnerBox->setObjectName( "LeftInnerBox" );
761  bigHBox->addLayout( leftInnerBox );
762  bigHBox->setStretchFactor( leftInnerBox, 1 );
763 
764  rightInnerBox = new QVBoxLayout();
765  rightInnerBox->setObjectName( "RightInnerBox" );
766  bigHBox->addLayout( rightInnerBox );
767  bigHBox->setStretchFactor( rightInnerBox, 2 );
768  }
769 
770  QHBoxLayout * headingHBox = new QHBoxLayout();
771  YUI_CHECK_NEW( headingHBox );
772  //headingHBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
773  leftInnerBox->addLayout( headingHBox );
774 
775  _dialogIcon = new QLabel( _workArea );
776  YUI_CHECK_NEW( _dialogIcon );
777  headingHBox->addWidget( _dialogIcon );
778  _dialogIcon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); // hor/vert
779  _dialogIcon->setObjectName( "DialogIcon" );
780  _dialogIcon->hide();
781 
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 ) ); // hor/vert
788  _dialogHeading->setObjectName( (titleIsOnTheLeft())? "DialogHeadingLeft" : "DialogHeadingTop" ) ;
789 
790  //
791  // Client area (the part that belongs to the YCP application)
792  //
793 
794  layoutClientArea( _workArea );
795  rightInnerBox->addWidget( _clientArea );
796 
797  //
798  // Button box
799  //
800 
801  QLayout *bb = layoutButtonBox( _workArea );
802  innerbox->addLayout( bb );
803 
804  return _workArea;
805 }
806 
807 
808 
809 void YQWizard::layoutClientArea( QWidget * parent )
810 {
811  _clientArea = new QFrame( parent );
812  YUI_CHECK_NEW( _clientArea );
813  _clientArea->setObjectName("_clientArea");
814  QVBoxLayout *layout = new QVBoxLayout( _clientArea );
815  layout->setMargin( 0 );
816 
817  //
818  // HVCenter for wizard contents
819  //
820 
821  _contents = new YQAlignment( this, _clientArea, YAlignCenter, YAlignCenter );
822  YUI_CHECK_NEW( _contents );
823  layout->addWidget( _contents );
824  _contents->QObject::setProperty( "class", "Contents" );
825 
826  _contents->setStretchable( YD_HORIZ, true );
827  _contents->setStretchable( YD_VERT, true );
828  _contents->installEventFilter( this );
829  _contents->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
830 
831  //
832  // Replace point for wizard contents
833  //
834 
835  _contentsReplacePoint = YUI::widgetFactory()->createReplacePoint( _contents );
836 
837  //
838  // Initial YEmpty widget contents of replace point
839  //
840 
841  YUI::widgetFactory()->createEmpty( _contentsReplacePoint );
842  _contentsReplacePoint->showChild();
843 
844 }
845 
846 
847 
848 QLayout *YQWizard::layoutButtonBox( QWidget * parent )
849 {
850  //
851  // QHBoxLayout for the buttons
852  //
853 
854  QHBoxLayout * hbox = new QHBoxLayout(); // parent, spacing
855  YUI_CHECK_NEW( hbox );
856 
857  hbox->setSpacing( 0 );
858  hbox->setMargin( 0 );
859 
860  // Help button
861  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
862  _helpButton = new YQWizardButton( this, parent, _( "&Help" ).toStdString());
863  YUI_CHECK_NEW( _helpButton );
864 
865  connect( _helpButton, &pclass(_helpButton)::clicked,
866  this, &pclass(this)::showHelp );
867 
868  hbox->addWidget( (QWidget *) _helpButton->widgetRep() );
869 
870  // Help action to be able to react to F1 and Alt-H (bnc#973389)
871  _helpAction = new QAction( this );
872  _helpAction->setShortcut( Qt::Key_F1 );
873  addAction( _helpAction );
874 
875  connect( _helpAction, &pclass( _helpAction )::triggered,
876  this, &pclass( this )::showHelp );
877 
878  // Help action to be able to react to Shift-F1 to show hotkeys
879  _hotkeysAction = new QAction( this );
880  _hotkeysAction->setShortcut( Qt::ShiftModifier + Qt::Key_F1 );
881  addAction( _hotkeysAction );
882 
883  connect( _hotkeysAction, &pclass( _hotkeysAction )::triggered,
884  this, &pclass( this )::showHotkeys );
885 
886  hbox->addSpacing( 10 );
887 
888  //
889  // "Release Notes" button
890  //
891 
892  // Release Notes button
893  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
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,
898  this, &pclass(this)::showReleaseNotes );
899 
900 
901  if (_releaseNotesButtonId == "")
902  {
903  _releaseNotesButton->hide(); // hidden until showReleaseNotesButton() is called
904  }
905  else
906  {
907  showReleaseNotesButton( _releaseNotesButtonLabel, _releaseNotesButtonId );
908  }
909 
910  hbox->addStretch( 10 );
911 
912  //
913  // "Abort" button
914  //
915 
916  _abortButton = new YQWizardButton( this, parent, _abortButtonLabel );
917  YUI_CHECK_NEW( _abortButton );
918 
919  hbox->addWidget( (QWidget *) _abortButton->widgetRep() );
920  connect( _abortButton, &pclass(_abortButton)::clicked,
921  this, &pclass(this)::slotAbortClicked );
922 
923  hbox->addSpacing( 10 );
924 
925  //
926  // "Back" button
927  //
928 
929  _backButton = new YQWizardButton( this, parent, _backButtonLabel );
930  YUI_CHECK_NEW( _backButton );
931 
932  hbox->addWidget( (QWidget *) _backButton->widgetRep() );
933  connect( _backButton, &pclass(_backButton)::clicked,
934  this, &pclass(this)::slotBackClicked );
935 
936  if ( _backButton->text().isEmpty() )
937  _backButton->hide();
938 
939  //
940  // "Next" button
941  //
942 
943  hbox->addSpacing( 5 );
944 
945  _nextButton = new YQWizardButton( this, parent, _nextButtonLabel );
946  YUI_CHECK_NEW( _nextButton );
947 
948  hbox->addWidget( (QWidget *) _nextButton->widgetRep() );
949  connect( _nextButton, &pclass(_nextButton)::clicked,
950  this, &pclass(this)::slotNextClicked );
951 
952  return hbox;
953 }
954 
955 bool YQWizard::titleIsOnTheLeft()
956 {
957  return wizardMode() == YWizardMode_TitleOnLeft;
958 }
959 
961 {
962  delete _backButton;
963  _backButton = 0;
964 
965  delete _abortButton;
966  _abortButton = 0;
967 
968  delete _nextButton;
969  _nextButton = 0;
970 }
971 
972 
973 void YQWizard::connectNotify ( const char * signal )
974 {
975  if ( QString( signal ).contains( "nextClicked()" ) )
976  {
977  yuiDebug() << "nextClicked connected, no longer directly sending button events" << std::endl;
978  _sendButtonEvents = false;
979  }
980 }
981 
982 
983 void YQWizard::disconnectNotify ( const char * signal )
984 {
985  if ( QString( signal ).contains( "nextClicked()" ) )
986  {
987  yuiDebug() << "nextClicked disconnected, directly sending button events again" << std::endl;
988  _sendButtonEvents = true;
989  }
990 }
991 
992 
993 void YQWizard::setDialogIcon( const std::string & iconName )
994 {
995  if ( _dialogIcon )
996  {
997  if ( ! iconName.empty() )
998  {
999  QPixmap icon( iconName.c_str() );
1000 
1001  if ( icon.isNull() )
1002  {
1003  _dialogIcon->hide();
1004  yuiWarning() << "Couldn't load dialog icon \"" << iconName << "\"" << std::endl;
1005  }
1006  else
1007  {
1008  _dialogIcon->show();
1009  _dialogIcon->setPixmap( icon );
1010  topLevelWidget()->setWindowIcon( icon );
1011  }
1012  }
1013  else
1014  {
1015  _dialogIcon->hide();
1016  _dialogIcon->clear();
1017  topLevelWidget()->setWindowIcon( QIcon() );
1018  }
1019  }
1020 }
1021 
1022 
1023 void YQWizard::setDialogTitle( const std::string & titleText )
1024 {
1025  QString title = fromUTF8( titleText.c_str() );
1026 
1027  if ( !title.isEmpty() )
1028  topLevelWidget()->setWindowTitle( YQUI::ui()->applicationTitle() + QString(" - ") + title );
1029  else
1030  topLevelWidget()->setWindowTitle( YQUI::ui()->applicationTitle() );
1031 }
1032 
1034 {
1035  return toUTF8(topLevelWidget()->windowTitle());
1036 }
1037 
1038 void YQWizard::setDialogHeading( const std::string & headingText )
1039 {
1040  if ( _dialogHeading )
1041  {
1042  if ( ! headingText.empty() )
1043  _dialogHeading->setText( fromUTF8( headingText ) );
1044  else
1045  _dialogHeading->clear();
1046  }
1047 }
1048 
1050 {
1051  if (_dialogHeading)
1052  return toUTF8(_dialogHeading->text());
1053  else
1054  return "";
1055 }
1056 
1057 string YQWizard::debugLabel() const
1058 {
1059  if ( _dialogHeading )
1060  {
1061  QString label = _dialogHeading->text();
1062  label = label.simplified(); // Replace any embedded newline with a single blank
1063 
1064  if ( ! label.isEmpty() )
1065  return toUTF8( label );
1066  }
1067 
1068  return "untitled YQWizard";
1069 }
1070 
1071 
1072 void YQWizard::setHelpText( const std::string & helpText )
1073 {
1074  _qHelpText = fromUTF8( helpText );
1075  _qHelpText.replace( "&product;", fromUTF8( YUI::app()->productName() ) );
1076 }
1077 
1078 
1080 {
1081  emit backClicked();
1082 
1083  if ( _sendButtonEvents )
1084  YQUI::ui()->sendEvent( new YWidgetEvent( _backButton, YEvent::Activated ) );
1085 
1086  _direction = YQWizard::Backward;
1087 }
1088 
1089 
1091 {
1092  emit abortClicked();
1093 
1094  if ( _sendButtonEvents )
1095  YQUI::ui()->sendEvent( new YWidgetEvent( _abortButton, YEvent::Activated ) );
1096 }
1097 
1098 
1100 {
1101  emit nextClicked();
1102 
1103  if ( _sendButtonEvents )
1104  YQUI::ui()->sendEvent( new YWidgetEvent( _nextButton, YEvent::Activated ) );
1105 
1106  _direction = YQWizard::Forward;
1107 }
1108 
1109 
1111 {
1112  if (!_helpDlg)
1113  _helpDlg = new QY2HelpDialog ( _qHelpText, NULL );
1114  else
1115  {
1116  _helpDlg->setHelpText( _qHelpText );
1117  _helpDlg->hide(); // workaround for icewm (see: bnc #397083)
1118  }
1119 
1120  _helpDlg->show();
1121  _helpDlg->raise();
1122  _helpDlg->activateWindow();
1123 }
1124 
1125 
1127 {
1128  /**
1129  * Help text to be shown after pressing Shift-F1 listing the advanced
1130  * keyboard shortcuts available in the Qt-UI
1131  **/
1132  _qHotkeysText = _(
1133  "<h1>Advanced Hotkeys</h1>"
1134  "<dl>"
1135  "<dt>Print Screen</dt>"
1136  "<dd>Take and save a screenshot. May not be available when YaST is running under "
1137  "some desktop environments.</dd>"
1138  "<dt>Shift-F4</dt>"
1139  "<dd>Enable/disable the color palette optimized for vision impaired users.</dd>"
1140  "<dt>Shift-F7</dt>"
1141  "<dd>Enable/disable logging of debug messages.</dd>"
1142  "<dt>Shift-F8</dt>"
1143  "<dd>Open a file dialog to save log files to a non-standard location.</dd>"
1144  "<dt>Ctrl-Shift-Alt-D</dt>"
1145  "<dd>Send a DebugEvent. YaST modules can react on this by executing "
1146  "special debugging actions. Result depends on the specific YaST-module.</dd>"
1147  "<dt>Ctrl-Shift-Alt-M</dt>"
1148  "<dd>Start/Stop macro recorder.</dd>"
1149  "<dt>Ctrl-Shift-Alt-P</dt>"
1150  "<dd>Replay macro.</dd>"
1151  "<dt>Ctrl-Shift-Alt-S</dt>"
1152  "<dd>Show style sheet editor.</dd>"
1153  "<dt>Ctrl-Shift-Alt-T</dt>"
1154  "<dd>Dump widget tree to the log file.</dd>"
1155  "<dt>Ctrl-Alt-Shift-X</dt>"
1156  "<dd>Open a terminal window (xterm). Useful for VNC installations.</dd>"
1157  "<dt>Ctrl-Shift-Alt-Y</dt>"
1158  "<dd>Show widget tree browser.</dd>"
1159  "</dl>"
1160  );
1161 
1162  if (!_hotkeysDlg)
1163  _hotkeysDlg = new QY2HelpDialog ( _qHotkeysText , NULL );
1164 
1165  _hotkeysDlg->show();
1166  _hotkeysDlg->raise();
1167  _hotkeysDlg->activateWindow();
1168 }
1169 
1170 
1172 {
1173  if (!_relNotesDlg)
1174  _relNotesDlg = new QY2RelNotesDialog ( NULL );
1175  else
1176  {
1177  _relNotesDlg->hide(); // workaround for icewm (see: bnc #397083)
1178  }
1179 
1180  std::map<std::string,std::string> relnotes = YUI::application()->releaseNotes();
1181  if ( relnotes.size() == 0)
1182  {
1183  return;
1184  }
1185  _relNotesDlg->setRelNotes( relnotes );
1186  _relNotesDlg->show();
1187  _relNotesDlg->raise();
1188  _relNotesDlg->activateWindow();
1189 }
1190 
1191 
1193 {
1194  if ( _sideBar && _stepsPanel )
1195  {
1196  _sideBar->setCurrentWidget( _stepsPanel );
1197  }
1198 }
1199 
1200 
1202 {
1203  if ( _sideBar && _treePanel )
1204  {
1205  _sideBar->setCurrentWidget( _treePanel );
1206  }
1207 }
1208 
1209 
1210 void YQWizard::addMenu( const std::string & text,
1211  const std::string & id )
1212 {
1213  if ( _menuBar )
1214  {
1215  QMenu * menu = new QMenu( _menuBar );
1216  YUI_CHECK_NEW( menu );
1217 
1218  _menuIDs.insert( fromUTF8( id ), menu );
1219  _menuBar->addMenu( menu );
1220  menu->setTitle( fromUTF8( text ) );
1221 
1222  connect( menu, &pclass(menu)::triggered,
1223  this, &pclass(this)::sendMenuEvent );
1224 
1225  _menuBar->show();
1226  }
1227 }
1228 
1229 
1230 void YQWizard::addSubMenu( const std::string & parentMenuID,
1231  const std::string & text,
1232  const std::string & id )
1233 {
1234  QMenu* parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1235 
1236  if ( parentMenu )
1237  {
1238  QMenu * menu = new QMenu( _menuBar );
1239  YUI_CHECK_NEW( menu );
1240 
1241  _menuIDs.insert( fromUTF8( id ), menu );
1242  //FIXME parentMenu->insertItem( fromUTF8( text ), menu );
1243 
1244  connect( menu, &pclass(menu)::triggered,
1245  this, &pclass(this)::sendMenuEvent );
1246  }
1247  else
1248  {
1249  yuiError() << "Can't find menu with ID " << parentMenuID << std::endl;
1250  }
1251 }
1252 
1253 
1254 void YQWizard::addMenuEntry( const std::string & parentMenuID,
1255  const std::string & text,
1256  const std::string & idString )
1257 {
1258  QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1259 
1260  if ( parentMenu )
1261  {
1262 #if 0
1263  int id = _menuEntryIDs.size();
1264 #endif
1265  QAction *action;
1266  action = parentMenu->addAction( fromUTF8( text ) );
1267  _menuEntryIDs[ action ] = idString ;
1268 
1269  }
1270  else
1271  {
1272  yuiError() << "Can't find menu with ID " << parentMenuID << std::endl;
1273  }
1274 }
1275 
1276 
1277 void YQWizard::addMenuSeparator( const std::string & parentMenuID )
1278 {
1279  QMenu * parentMenu = _menuIDs[ fromUTF8( parentMenuID ) ];
1280 
1281  if ( parentMenu )
1282  {
1283  parentMenu->addSeparator();
1284  }
1285  else
1286  {
1287  yuiError() << "Can't find menu with ID " << parentMenuID << std::endl;
1288  }
1289 }
1290 
1291 
1293 {
1294  if ( _menuBar )
1295  {
1296  _menuBar->hide();
1297  _menuBar->clear();
1298  _menuIDs.clear();
1299  _menuEntryIDs.clear();
1300  }
1301 }
1302 
1303 
1304 void YQWizard::sendMenuEvent( QAction *action )
1305 {
1306  if ( _menuEntryIDs.contains( action ) )
1307  {
1308  sendEvent( _menuEntryIDs[ action ] );
1309  }
1310  else
1311  {
1312  yuiError() << "Invalid menu ID " << std::endl;
1313  }
1314 }
1315 
1316 
1317 void YQWizard::sendEvent( const std::string & id )
1318 {
1319  YQUI::ui()->sendEvent( new YMenuEvent( id ) );
1320 }
1321 
1322 
1324 {
1325  return sizeHint().width();
1326 }
1327 
1328 
1330 {
1331  return sizeHint().height();
1332 }
1333 
1334 
1335 void YQWizard::setSize( int newWidth, int newHeight )
1336 {
1337  resize( newWidth, newHeight );
1338  resizeClientArea();
1339 }
1340 
1342 {
1343  QSize contentsRect = _clientArea->contentsRect().size();
1344  _contents->setSize( contentsRect.width(), contentsRect.height() );
1345 }
1346 
1347 bool YQWizard::eventFilter( QObject * obj, QEvent * ev )
1348 {
1349  if ( ev->type() == QEvent::Resize && obj == _contents )
1350  {
1351  resizeClientArea();
1352  return true; // Event handled
1353  }
1354 
1355  if ( ev->type() == QEvent::Resize && obj == _sideBar && main_wizard == this && _stepsPanel )
1356  {
1357  YQMainWinDock::mainWinDock()->setSideBarWidth( _sideBar->width() );
1358  return true; // Event handled
1359  }
1360 
1361  return QWidget::eventFilter( obj, ev );
1362 }
1363 
1364 
1365 void YQWizard::setButtonLabel( YPushButton * button, const std::string & newLabel )
1366 {
1367  button->setLabel( newLabel );
1368  YDialog::currentDialog()->checkShortcuts();
1369 
1370  YQWizardButton * wizardButton = dynamic_cast<YQWizardButton *> (button);
1371 
1372  if ( wizardButton ) {
1373  // QWizardButton only implements hide and show, not setVisible
1374  if ( newLabel.empty() )
1375  wizardButton->hide();
1376  else
1377  wizardButton->show();
1378  }
1379 }
1380 
1381 
1382 void YQWizard::showReleaseNotesButton( const std::string & label, const std::string & id )
1383 {
1384  if ( ! _releaseNotesButton )
1385  {
1386  yuiError() << "NULL Release Notes button" << std::endl;
1387 
1388  if ( ! _stepsPanel )
1389  yuiError() << "This works only if there is a \"steps\" panel!" << std::endl;
1390 
1391  return;
1392  }
1393 
1394  // Qt handles duplicate shortcuts, it can be kept
1395  _releaseNotesButton->setLabel( fromUTF8( label ) );
1396  _releaseNotesButtonId = id;
1397  _releaseNotesButtonLabel = label;
1398 
1399  _releaseNotesButton->show();
1400 }
1401 
1402 
1404 {
1405  if ( _releaseNotesButton && !_releaseNotesButton->isHidden() )
1406  {
1407  _releaseNotesButton->hide();
1408  _releaseNotesButtonId = "";
1409  _releaseNotesButtonLabel = "";
1410  }
1411 }
1412 
1413 
1415 {
1416  YQUI::setTextdomain( TEXTDOMAIN );
1417 
1418  if ( _helpButton )
1419  // "Help" button
1420  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
1421  _helpButton->setLabel( _( "&Help" ) );
1422 
1423  if ( _stepsButton )
1424  // "Steps" button
1425  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
1426  _stepsButton->setText( _( "&Steps" ) );
1427 
1428  if ( _treeButton )
1429  // "Tree" button
1430  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
1431  _treeButton->setText( _( "&Tree" ) );
1432 
1433  if ( _releaseNotesButton )
1434  // "Release Notes" button
1435  // Qt handles duplicate shortcuts, it can be kept (bnc#880983)
1436  _releaseNotesButton->setLabel( _( "&Release Notes" ) );
1437 
1438  if ( _helpDlg )
1439  _helpDlg->retranslate();
1440 
1441  if ( _hotkeysDlg )
1442  _hotkeysDlg->retranslate();
1443 
1444  if ( _relNotesDlg )
1445  _relNotesDlg->retranslate();
1446 
1447 }
1448 
1449 
1450 void YQWizard::Step::deleteLabels()
1451 {
1452  delete _statusLabel;
1453  _statusLabel = 0;
1454  delete _nameLabel;
1455  _nameLabel = 0;
1456 }
1457 
1458 
1460 {
1461  deleteLabels();
1462 }
1463 
1464 
1466 {
1467  if ( !_statusLabel || !_nameLabel || _status == s )
1468  return;
1469 
1470  _status = s;
1471 
1472  if ( s == Todo )
1473  {
1474  _statusLabel->setProperty( "class", "todo-step-status QLabel" );
1475  _nameLabel->setProperty ( "class", "todo-step-name QLabel" );
1476  }
1477 
1478  if ( s == Done )
1479  {
1480  _statusLabel->setProperty( "class", "done-step-status QLabel" );
1481  _nameLabel->setProperty ( "class", "done-step-name QLabel" );
1482  }
1483 
1484  if ( s == Current )
1485  {
1486  _statusLabel->setProperty( "class", "current-step-status QLabel" );
1487  _nameLabel->setProperty ( "class", "current-step-name QLabel" );
1488  }
1489 
1490  _statusLabel->style()->unpolish( _statusLabel );
1491  _statusLabel->style()->polish( _statusLabel );
1492  _nameLabel->style()->unpolish( _nameLabel );
1493  _nameLabel->style()->polish( _nameLabel );
1494 }
virtual std::string currentTreeSelection()
Returns the current tree selection or an empty std::string if nothing is selected or there is no tree...
Definition: YQWizard.cc:672
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.
Definition: YQWizard.cc:1171
virtual void setSortByInsertionSequence(bool sortByInsertionSequence)
Enforce sorting by item insertion order (true) or let user change sorting by clicking on a column hea...
Definition: QY2ListView.cc:355
virtual void setCurrentStep(const std::string &id)
Set the current step.
Definition: YQWizard.cc:486
void resizeClientArea()
Adapt the size of the client area (the ReplacePoint(id(contents)) to fit in its current space...
Definition: YQWizard.cc:1341
virtual ~Step()
Destructor.
Definition: YQWizard.cc:1459
virtual void setDialogIcon(const std::string &iconName)
Set the dialog icon.
Definition: YQWizard.cc:993
void setSideBarWidth(int width)
For secondary wizards.
void destroyButtons()
Destroy the button box&#39;s buttons.
Definition: YQWizard.cc:960
virtual void deleteTreeItems()
Delete all tree items.
Definition: YQWizard.cc:617
void sendTreeEvent(QTreeWidgetItem *item)
Internal notification that [Space] or [Return] has been pressed on a tree item.
Definition: YQWizard.cc:653
void showSteps()
Show the current wizard steps, if there are any.
Definition: YQWizard.cc:1192
Helper class to represent a wizard step heading internally.
Definition: YQWizard.h:696
virtual void setHelpText(const std::string &helpText)
Set the help text.
Definition: YQWizard.cc:1072
virtual void setButtonLabel(YPushButton *button, const std::string &newLabel)
Set the label of one of the wizard buttons (backButton(), abortButton(), nextButton() ) if that butto...
Definition: YQWizard.cc:1365
void registerWidget(QWidget *widget)
Registers a widget and applies the style sheet.
Definition: QY2Styler.cc:268
virtual std::string getDialogTitle()
Get the current dialog title shown in the window manager&#39;s title bar.
Definition: YQWizard.cc:1033
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQWizard.cc:1335
void connectNotify(const char *signal)
Notification that a signal is being connected.
Definition: YQWizard.cc:973
virtual void clear()
Reimplemented from Q3ListView: Adjust header sizes after clearing contents.
Definition: QY2ListView.cc:102
virtual void deleteSteps()
Delete all steps and step headings from the internal lists.
Definition: YQWizard.cc:526
bool isSecondary() const
Returns true if the wizard should follow the first wizard with steps.
Definition: YQWizard.cc:207
QString applicationTitle()
Returns the application name for the window title (e.g.
Definition: YQUI.h:285
Helper class for wizard tree item.
Definition: YQWizard.h:716
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...
Definition: YQWizard.cc:1382
virtual bool eventFilter(QObject *obj, QEvent *ev)
Event filter.
Definition: YQWizard.cc:1347
void slotAbortClicked()
Internal notification that the "Abort" button has been clicked.
Definition: YQWizard.cc:1090
virtual void selectTreeItem(const std::string &id)
Select the tree item with the specified ID, if such an item exists.
Definition: YQWizard.cc:636
YQWizard(YWidget *parent, const std::string &backButtonLabel, const std::string &abortButtonLabel, const std::string &nextButtonLabel, YWizardMode wizardMode=YWizardMode_Standard)
Constructor.
Definition: YQWizard.cc:89
void copySteps(YQWizard *wizard)
Create a copy of given wizard&#39;s steps set (names & IDs) Populates _stepsList structure of current wiz...
Definition: YQWizard.cc:494
virtual void addStepHeading(const std::string &text)
Add a step heading for the steps panel on the side bar.
Definition: YQWizard.cc:327
void treeSelectionChanged()
Internal notification that the tree selection has changed.
Definition: YQWizard.cc:665
virtual void setDialogHeading(const std::string &headingText)
Set the dialog heading.
Definition: YQWizard.cc:1038
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&#39;s title bar.
Definition: YQWizard.cc:1023
virtual ~YQWizard()
Destructor.
Definition: YQWizard.cc:185
virtual void addMenuEntry(const std::string &parentMenuID, const std::string &text, const std::string &id)
Add a menu entry to the menu with ID &#39;parentMenuID&#39;.
Definition: YQWizard.cc:1254
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.
Definition: YQWizard.cc:627
void abortClicked()
Emitted when the "Abort" button is clicked.
void setStatus(Status s)
Set text color and status icon for one wizard step.
Definition: YQWizard.cc:1465
virtual void hideReleaseNotesButton()
Hide an existing "Release Notes" button.
Definition: YQWizard.cc:1403
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
Definition: YQUI.cc:472
void slotBackClicked()
Internal notification that the "Back" button has been clicked.
Definition: YQWizard.cc:1079
virtual void retranslateInternalButtons()
Retranslate internal buttons that are not accessible from the outside:
Definition: YQWizard.cc:1414
virtual void addMenuSeparator(const std::string &parentMenuID)
Add a menu separator to a menu.
Definition: YQWizard.cc:1277
QString currentStep()
Return QString ID of currently active step.
Definition: YQWizard.h:225
virtual void addStep(const std::string &text, const std::string &id)
Add a step for the steps panel on the side bar.
Definition: YQWizard.cc:291
virtual void deleteMenus()
Delete all menus and hide the menu bar.
Definition: YQWizard.cc:1292
Enhanced QTreeWidget.
Definition: QY2ListView.h:47
void showHotkeys()
Show an overview of the power-user hotkeys.
Definition: YQWizard.cc:1126
QString text() const
Returns the button&#39;s text (label) - useful for log messages etc.
void showHelp()
Show the current help text.
Definition: YQWizard.cc:1110
virtual void addSubMenu(const std::string &parentMenuID, const std::string &text, const std::string &id)
Add a submenu to the menu with ID &#39;parentMenuID&#39;.
Definition: YQWizard.cc:1230
void slotNextClicked()
Internal notification that the "Next" button has been clicked.
Definition: YQWizard.cc:1099
YQWizard::Step * findStep(const QString &id)
Find a step with the specified ID.
Definition: YQWizard.cc:541
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQWizard.cc:1329
bool fullscreen() const
Return &#39;true&#39; if defaultsize windows should use the full screen.
Definition: YQUI.h:169
void showTree()
Show the current selection tree in the side panel, if there is any.
Definition: YQWizard.cc:1201
void sendEvent(const std::string &id)
Send a wizard event with the specified ID.
Definition: YQWizard.cc:1317
Helper class to represent a wizard step internally.
Definition: YQWizard.h:638
void registerChildWidget(QWidget *parent, QWidget *widget)
Registers a child widget.
Definition: QY2Styler.cc:284
virtual void addMenu(const std::string &text, const std::string &id)
Add a menu to the menu bar.
Definition: YQWizard.cc:1210
void setLabel(const QString &label)
Changes the label (the text) of the button.
QList< YQWizard::Step * > stepsList()
Return list of pointers to steps.
Definition: YQWizard.h:197
virtual void addTreeItem(const std::string &parentID, const std::string &text, const std::string &id)
Add a tree item.
Definition: YQWizard.cc:582
void nextClicked()
Emitted when the "Next" or "OK" button is clicked.
void hide()
Hide the associated QPushButton.
void disconnectNotify(const char *signal)
Notification that a signal is being disconnected.
Definition: YQWizard.cc:983
void updateStepStates()
Update all step - use appropriate icons and colors.
Definition: YQWizard.cc:443
void sendMenuEvent(QAction *action)
Internal notification that a menu item with numeric ID &#39;numID&#39; has been activated.
Definition: YQWizard.cc:1304
virtual int preferredWidth()
Preferred width of the widget.
Definition: YQWizard.cc:1323
virtual std::string getDialogHeading()
Get the dialog heading.
Definition: YQWizard.cc:1049
void unregisterWidget(QWidget *widget)
Unregisters a widget.
Definition: QY2Styler.cc:277
static void setTextdomain(const char *domain)
Initialize and set a textdomain for gettext()
Definition: YQUI.cc:492
bool isHidden() const
Returns &#39;true&#39; if the associated QPushButton (!) is hidden.
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.
Definition: YQAlignment.cc:70
static YQUI * ui()
Access the global Qt-UI.
Definition: YQUI.h:83
void show()
Show the associated QPushButton - not this widget itself (!).
virtual void updateSteps()
Update the steps display: Reflect the internal steps and heading lists in the layout.
Definition: YQWizard.cc:334
virtual std::string debugLabel() const
Returns a descriptive label of this dialog instance for debugging.
Definition: YQWizard.cc:1057