libyui-qt  2.52.2
YQDialog.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: YQDialog.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23  Textdomain "qt"
24 
25 /-*/
26 
27 
28 #define YUILogComponent "qt-ui"
29 #include <yui/YUILog.h>
30 #include <qpushbutton.h>
31 #include <qmessagebox.h>
32 #include <QDesktopWidget>
33 #include <QDebug>
34 
35 #include "YQUI.h"
36 #include "YQi18n.h"
37 #include <yui/YEvent.h>
38 #include "YQDialog.h"
39 #include "YQGenericButton.h"
40 #include "YQWizardButton.h"
41 #include "YQWizard.h"
42 #include "YQMainWinDock.h"
43 #include <yui/YDialogSpy.h>
44 #include <yui/YApplication.h>
45 #include "QY2Styler.h"
46 #include "QY2StyleEditor.h"
47 
48 #define YQMainDialogWFlags Qt::Widget
49 #define YQPopupDialogWFlags Qt::Dialog
50 
51 #define VERBOSE_EVENT_LOOP 0
52 
53 
54 
55 YQDialog::YQDialog( YDialogType dialogType,
56  YDialogColorMode colorMode )
57 : QWidget( chooseParent( dialogType ),
58  dialogType == YPopupDialog ? YQPopupDialogWFlags : YQMainDialogWFlags )
59 , YDialog( dialogType, colorMode )
60 {
61  setWidgetRep( this );
62 
63  _userResized = false;
64  _focusButton = 0;
65  _defaultButton = 0;
66  _highlightedChild = 0;
67  _styleEditor = 0;
68 
69  setFocusPolicy( Qt::StrongFocus );
70  setAutoFillBackground( true );
71 
72  if ( colorMode != YDialogNormalColor )
73  {
74  QColor normalBackground ( 240, 100, 36 );
75  QColor inputFieldBackground ( 0xbb, 0xff, 0xbb );
76  QColor text = Qt::black;
77 
78  if ( colorMode == YDialogInfoColor )
79  {
80  normalBackground = QColor ( 238, 232, 170 ); // PaleGoldenrod
81  }
82 
83  QPalette warnPalette( normalBackground );
84  warnPalette.setColor( QPalette::Text, text );
85  warnPalette.setColor( QPalette::Base, inputFieldBackground );
86  setPalette( warnPalette );
87  }
88 
89  qApp->setApplicationName(YQUI::ui()->applicationTitle());
90  topLevelWidget()->setWindowTitle ( YQUI::ui()->applicationTitle() );
91  QGuiApplication::setApplicationDisplayName( YQUI::ui()->applicationTitle() );
92 
93  if ( isMainDialog() && QWidget::parent() != YQMainWinDock::mainWinDock() )
94  {
95  setWindowFlags( YQPopupDialogWFlags );
96  }
97 
98  if ( ! isMainDialog() )
99  setWindowModality( Qt::ApplicationModal );
100 
101  if ( isMainDialog() && QWidget::parent() == YQMainWinDock::mainWinDock() )
102  {
103  YQMainWinDock::mainWinDock()->add( this );
104  }
105 
106  _eventLoop = new QEventLoop( this );
107  YUI_CHECK_NEW( _eventLoop );
108 
109  _waitForEventTimer = new QTimer( this );
110  YUI_CHECK_NEW( _waitForEventTimer );
111  _waitForEventTimer->setSingleShot( true );
112 
113  QObject::connect( _waitForEventTimer, &pclass(_waitForEventTimer)::timeout,
114  this, &pclass(this)::waitForEventTimeout );
115 
116  if ( isMainDialog() && QWidget::parent() == YQMainWinDock::mainWinDock() )
117  QY2Styler::styler()->registerWidget( YQMainWinDock::mainWinDock() );
118  else
119  QY2Styler::styler()->registerWidget( this );
120 }
121 
122 
124 {
125  if ( isMainDialog() )
126  {
128  // orphaned main dialogs are handled gracefully in YQWMainWinDock::remove()
129  }
130 
131  if ( _defaultButton )
132  _defaultButton->forgetDialog();
133 
134  if ( _focusButton )
135  _focusButton->forgetDialog();
136 
137  if ( _styleEditor )
138  delete _styleEditor;
139 
140  if ( isMainDialog() && QWidget::parent() == YQMainWinDock::mainWinDock() )
141  QY2Styler::styler()->unregisterWidget( YQMainWinDock::mainWinDock() );
142  else
143  QY2Styler::styler()->unregisterWidget( this );
144 }
145 
146 
147 QWidget *
148 YQDialog::chooseParent( YDialogType dialogType )
149 {
150  QWidget * parent = YQMainWinDock::mainWinDock()->window();
151 
152  if ( dialogType == YPopupDialog)
153  {
154  YDialog * currentDialog = YDialog::currentDialog( false );
155  if (currentDialog)
156  parent = (QWidget *) currentDialog->widgetRep();
157  }
158 
159  if ( ( dialogType == YMainDialog || dialogType == YWizardDialog ) &&
160  YQMainWinDock::mainWinDock()->couldDock() )
161  {
162  yuiDebug() << "Adding dialog to mainWinDock" << endl;
163  parent = YQMainWinDock::mainWinDock();
164  }
165 
166  return parent;
167 }
168 
169 
170 void
172 {
174  QWidget::show();
175  QWidget::raise(); // FIXME: is this really necessary?
176  QWidget::update();
177 }
178 
179 
180 void
182 {
183  QWidget::raise();
184  QWidget::update();
185 }
186 
187 
188 int
190 {
191  int preferredWidth;
192 
193  if ( isMainDialog() )
194  {
195  if ( userResized() )
196  preferredWidth = _userSize.width();
197  else
198  preferredWidth = YQUI::ui()->defaultSize( YD_HORIZ );
199  }
200  else
201  {
202  preferredWidth = YDialog::preferredWidth();
203  }
204 
205  int screenWidth = qApp->desktop()->width();
206 
207  if ( preferredWidth > screenWidth )
208  {
209  yuiWarning() << "Limiting dialog width to screen width (" << screenWidth
210  << ") instead of " << preferredWidth
211  << " - check the layout!"
212  << endl;
213  }
214 
215  return preferredWidth;
216 }
217 
218 
219 int
221 {
222  int preferredHeight;
223 
224  if ( isMainDialog() )
225  {
226  if ( userResized() )
227  preferredHeight = _userSize.height();
228  else
229  preferredHeight = YQUI::ui()->defaultSize( YD_VERT );
230  }
231  else
232  {
233  preferredHeight = YDialog::preferredHeight();
234  }
235 
236  int screenHeight = qApp->desktop()->height();
237 
238  if ( preferredHeight > screenHeight )
239  {
240  yuiWarning() << "Limiting dialog height to screen height (" << screenHeight
241  << ") instead of " << preferredHeight
242  << " - check the layout!"
243  << endl;
244  }
245 
246  return preferredHeight;
247 }
248 
249 
250 void
251 YQDialog::setEnabled( bool enabled )
252 {
253  QWidget::setEnabled( enabled );
254  YDialog::setEnabled( enabled );
255 }
256 
257 
258 void
259 YQDialog::setSize( int newWidth, int newHeight )
260 {
261  // yuiDebug() << "Resizing dialog to " << newWidth << " x " << newHeight << endl;
262 
263  if ( newWidth > qApp->desktop()->width() )
264  newWidth = qApp->desktop()->width();
265 
266  if ( newHeight > qApp->desktop()->height() )
267  newHeight = qApp->desktop()->height();
268 
269  resize( newWidth, newHeight );
270 
271  if ( hasChildren() )
272  {
273  firstChild()->setSize( newWidth, newHeight );
274  ( ( QWidget* )firstChild()->widgetRep() )->show();
275  }
276 }
277 
278 
279 void
280 YQDialog::resizeEvent( QResizeEvent * event )
281 {
282  if ( event )
283  {
284  // yuiDebug() << "Resize event: " << event->size().width() << " x " << event->size().height() << endl;
285  setSize ( event->size().width(), event->size().height() );
286  _userSize = event->size();
287 
288  if ( QWidget::parent() )
289  _userResized = true;
290  }
291 }
292 
293 
296 {
297  if ( _defaultButton )
298  return _defaultButton;
299 
300  _defaultButton = findDefaultButton( childrenBegin(), childrenEnd() );
301 
302  YDialog::setDefaultButton( 0 ); // prevent complaints about multiple default buttons
303  YDialog::setDefaultButton( _defaultButton );
304 
305  return _defaultButton;
306 }
307 
308 
310 YQDialog::findDefaultButton( YWidgetListConstIterator begin,
311  YWidgetListConstIterator end ) const
312 {
313  for ( YWidgetListConstIterator it = begin; it != end; ++it )
314  {
315  YWidget * widget = *it;
316 
317  //
318  // Check this widget
319  //
320 
321  YQGenericButton * button = dynamic_cast<YQGenericButton *> (widget);
322 
323  if ( button && button->isDefaultButton() )
324  {
325  return button;
326  }
327 
328 
329  //
330  // Recurse over the children of this widget
331  //
332 
333  if ( widget->hasChildren() )
334  {
335  button = findDefaultButton( widget->childrenBegin(),
336  widget->childrenEnd() );
337  if ( button )
338  return button;
339  }
340  }
341 
342  return 0;
343 }
344 
345 
346 YQWizard *
347 YQDialog::ensureOnlyOneDefaultButton( YWidgetListConstIterator begin,
348  YWidgetListConstIterator end )
349 {
350  YQGenericButton * def = _focusButton ? _focusButton : _defaultButton;
351  YQWizard * wizard = 0;
352 
353  for ( YWidgetListConstIterator it = begin; it != end; ++it )
354  {
355  YQGenericButton * button = dynamic_cast<YQGenericButton *> (*it);
356  YQWizardButton * wizardButton = dynamic_cast<YQWizardButton * > (*it);
357 
358  if ( ! wizard )
359  wizard = dynamic_cast<YQWizard *> (*it);
360 
361  if ( wizardButton )
362  {
363  wizardButton->showAsDefault( false );
364  }
365  else if ( button )
366  {
367  if ( button->isDefaultButton() )
368  {
369  if ( _defaultButton && button != _defaultButton )
370  {
371  yuiError() << "Too many default buttons: " << button << endl;
372  yuiError() << "Using old default button: " << _defaultButton << endl;
373  }
374  else
375  {
376  _defaultButton = button;
377  }
378  }
379 
380  if ( button->isShownAsDefault() && button != def )
381  button->showAsDefault( false );
382  }
383 
384  if ( (*it)->hasChildren() )
385  {
386  YQWizard * wiz = ensureOnlyOneDefaultButton( (*it)->childrenBegin(),
387  (*it)->childrenEnd() );
388  if ( wiz )
389  wizard = wiz;
390  }
391  }
392 
393  return wizard;
394 }
395 
396 
397 void
399 {
400  _defaultButton = 0;
401  YQWizard * wizard = ensureOnlyOneDefaultButton( childrenBegin(), childrenEnd() );
402 
403  if ( ! _defaultButton && wizard )
404  {
405  _defaultButton = wizardDefaultButton( wizard );
406  }
407 
408  if ( _defaultButton )
409  {
410  YDialog::setDefaultButton( 0 ); // prevent complaints about multiple default buttons
411  YDialog::setDefaultButton( _defaultButton );
412  }
413 
414 
415  YQGenericButton * def = _focusButton ? _focusButton : _defaultButton;
416 
417  if ( def )
418  def->showAsDefault();
419 }
420 
421 
422 YQWizard *
424 {
425  return findWizard( childrenBegin(), childrenEnd() );
426 }
427 
428 
429 YQWizard *
430 YQDialog::findWizard( YWidgetListConstIterator begin,
431  YWidgetListConstIterator end ) const
432 {
433  for ( YWidgetListConstIterator it = begin; it != end; ++it )
434  {
435  YWidget * widget = *it;
436  YQWizard * wizard = dynamic_cast<YQWizard *> (widget);
437 
438  if ( wizard )
439  return wizard;
440 
441  if ( widget->hasChildren() )
442  {
443  wizard = findWizard( widget->childrenBegin(),
444  widget->childrenEnd() );
445  if ( wizard )
446  return wizard;
447  }
448  }
449 
450  return 0;
451 }
452 
453 
456 {
457  YQGenericButton * def = 0;
458 
459  if ( ! wizard )
460  wizard = findWizard();
461 
462  if ( wizard )
463  {
464  // Pick one of the wizard buttons
465 
466  if ( wizard->direction() == YQWizard::Backward )
467  {
468  if ( wizard->backButton()
469  && wizard->backButton()->isShown()
470  && wizard->backButton()->isEnabled() )
471  {
472  def = wizard->backButton();
473  }
474  }
475 
476  if ( ! def )
477  {
478  if ( wizard->nextButton()
479  && wizard->nextButton()->isShown()
480  && wizard->nextButton()->isEnabled() )
481  {
482  def = wizard->nextButton();
483  }
484  }
485  }
486 
487  return def;
488 }
489 
490 
491 void
492 YQDialog::setDefaultButton( YPushButton * newDefaultButton )
493 {
494  if ( _defaultButton &&
495  newDefaultButton &&
496  newDefaultButton != _defaultButton )
497  {
498  if ( dynamic_cast<YQWizardButton *>( _defaultButton ) )
499  {
500  // Let app defined default buttons override wizard buttons
501  _defaultButton->setDefaultButton( false );
502  }
503  else
504  {
505  yuiError() << "Too many `opt(`default) PushButtons: " << newDefaultButton << endl;
506  newDefaultButton->setDefaultButton( false );
507  return;
508  }
509  }
510 
511  _defaultButton = dynamic_cast<YQGenericButton*>(newDefaultButton);
512 
513  if ( _defaultButton )
514  {
515  _defaultButton->setDefaultButton( true );
516  yuiDebug() << "New default button: " << _defaultButton << endl;
517 
518  if ( _defaultButton && ! _focusButton )
519  {
520  _defaultButton->showAsDefault( true );
521  _defaultButton->setKeyboardFocus();
522  }
523  }
524 
525 
526  YDialog::setDefaultButton( 0 ); // prevent complaints about multiple default buttons
527  YDialog::setDefaultButton( _defaultButton );
528 }
529 
530 
531 bool
533 {
534  // Try the focus button first, if there is any.
535 
536  if ( _focusButton &&
537  _focusButton->isEnabled() &&
538  _focusButton->isShownAsDefault() )
539  {
540  yuiDebug() << "Activating focus button: " << _focusButton << endl;
541  _focusButton->activate();
542  return true;
543  }
544 
545 
546  // No focus button - try the default button, if there is any.
547 
548  _defaultButton = findDefaultButton();
549 
550  if ( _defaultButton &&
551  _defaultButton->isEnabled() &&
552  _defaultButton->isShownAsDefault() )
553  {
554  yuiDebug() << "Activating default button: " << _defaultButton << endl;
555  _defaultButton->activate();
556  return true;
557  }
558  else
559  {
560  if ( warn )
561  {
562  yuiWarning() << "No default button in this dialog - ignoring [Return]" << endl;
563  }
564  }
565 
566  return false;
567 }
568 
569 
570 void
572 {
573  if ( button == _focusButton )
574  {
575  if ( _focusButton && _focusButton != _defaultButton )
576  _focusButton->showAsDefault( false );
577 
578  _focusButton = 0;
579  }
580 
581  if ( ! _focusButton && _defaultButton )
582  _defaultButton->showAsDefault( true );
583 }
584 
585 
586 void
588 {
589  if ( _focusButton && _focusButton != button )
590  _focusButton->showAsDefault( false );
591 
592  if ( _defaultButton && _defaultButton != button )
593  _defaultButton->showAsDefault( false );
594 
595  _focusButton = button;
596 
597  if ( _focusButton )
598  _focusButton->showAsDefault( true );
599 }
600 
601 
602 void
603 YQDialog::keyPressEvent( QKeyEvent * event )
604 {
605  if ( event )
606  {
607  if ( event->key() == Qt::Key_Print )
608  {
609  YQUI::ui()->makeScreenShot( "" );
610  return;
611  }
612  else if ( event->key() == Qt::Key_F4 && // Shift-F4: toggle colors for vision impaired users
613  event->modifiers() == Qt::ShiftModifier )
614  {
615  QY2Styler::styler()->toggleAlternateStyleSheet();
616 
617  if ( QY2Styler::styler()->usingAlternateStyleSheet() )
618  {
619  QWidget* parent = 0;
620  YDialog * currentDialog = YDialog::currentDialog( false );
621  if (currentDialog)
622  parent = (QWidget *) currentDialog->widgetRep();
623 
624  yuiMilestone() << "Switched to vision impaired palette" << endl;
625  QMessageBox::information( parent, // parent
626  _("Color switching"), // caption
627  _( "Switching to color palette for vision impaired users -\n"
628  "press Shift-F4 again to switch back to normal colors." ), // text
629  QMessageBox::Ok | QMessageBox::Default, // button0
630  QMessageBox::NoButton, // button1
631  QMessageBox::NoButton ); // button2
632  }
633  return;
634  }
635  else if ( event->key() == Qt::Key_F6 && // Shift-F6: ask for a widget ID and send it
636  event->modifiers() == Qt::ShiftModifier )
637  {
639  }
640  else if ( event->key() == Qt::Key_F7 && // Shift-F7: toggle debug logging
641  event->modifiers() == Qt::ShiftModifier )
642  {
644  return;
645  }
646  else if ( event->key() == Qt::Key_F8 && // Shift-F8: save y2logs
647  event->modifiers() == Qt::ShiftModifier )
648  {
649  YQUI::ui()->askSaveLogs();
650  return;
651  }
652  else if ( event->modifiers() == Qt::NoModifier ) // No Ctrl / Alt / Shift etc. pressed
653  {
654  if ( event->key() == Qt::Key_Return ||
655  event->key() == Qt::Key_Enter )
656  {
657  (void) activateDefaultButton();
658  return;
659  }
660  }
661  else if ( event->modifiers() == ( Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier ) )
662  {
663  // Qt-UI special keys - all with Ctrl-Shift-Alt
664 
665  yuiMilestone() << "Caught YaST2 magic key combination" << endl;
666 
667  if ( event->key() == Qt::Key_M )
668  {
670  return;
671  }
672  else if ( event->key() == Qt::Key_P )
673  {
674  YQUI::ui()->askPlayMacro();
675  return;
676  }
677  else if ( event->key() == Qt::Key_D )
678  {
679  YQUI::ui()->sendEvent( new YDebugEvent() );
680  return;
681  }
682  else if ( event->key() == Qt::Key_T )
683  {
684  yuiMilestone() << "*** Dumping widget tree ***" << endl;
685  dumpWidgetTree();
686  yuiMilestone() << "*** Widget tree end ***" << endl;
687  return;
688  }
689  else if ( event->key() == Qt::Key_Y )
690  {
691  yuiMilestone() << "Opening dialog spy" << endl;
692  YDialogSpy::showDialogSpy();
693  YQUI::ui()->normalCursor();
694  }
695  else if ( event->key() == Qt::Key_X )
696  {
697  int result;
698  yuiMilestone() << "Starting xterm" << endl;
699  result = system( "/usr/bin/xterm &" );
700  if (result < 0)
701  yuiError() << "/usr/bin/xterm not found" << endl;
702  return;
703  }
704  else if ( event->key() == Qt::Key_S )
705  {
706  yuiMilestone() << "Opening style editor" << endl;
707  _styleEditor = new QY2StyleEditor(this);
708  _styleEditor->show();
709  _styleEditor->raise();
710  _styleEditor->activateWindow();
711  return;
712  }
713 
714  }
715  }
716 
717  QWidget::keyPressEvent( event );
718 }
719 
720 
721 void
722 YQDialog::closeEvent( QCloseEvent * event )
723 {
724  // The window manager "close window" button (and WM menu, e.g. Alt-F4) will be
725  // handled just like the user had clicked on the `id`( `cancel ) button in
726  // that dialog. It's up to the YCP application to handle this (if desired).
727 
728  yuiMilestone() << "Caught window manager close event - returning with YCancelEvent" << endl;
729  event->ignore();
730  YQUI::ui()->sendEvent( new YCancelEvent() );
731 }
732 
733 
734 void
735 YQDialog::focusInEvent( QFocusEvent * event )
736 {
737  // The dialog itself doesn't need or want the keyboard focus, but obviously
738  // (since Qt 2.3?) it needs QFocusPolicy::StrongFocus for the default
739  // button mechanism to work. So let's accept the focus and give it to some
740  // child widget.
741 
742  if ( event->reason() == Qt::TabFocusReason )
743  {
744  focusNextPrevChild( true );
745  }
746  else
747  {
748  if ( _defaultButton )
749  _defaultButton->setKeyboardFocus();
750  else
751  focusNextPrevChild( true );
752  }
753 }
754 
755 
756 YEvent *
757 YQDialog::waitForEventInternal( int timeout_millisec )
758 {
760  _eventLoop->wakeUp();
761 
762  YEvent * event = 0;
763 
764  _waitForEventTimer->stop();
765 
766  if ( timeout_millisec > 0 )
767  _waitForEventTimer->start( timeout_millisec ); // single shot
768 
769  if ( qApp->focusWidget() )
770  qApp->focusWidget()->setFocus();
771 
772  YQUI::ui()->normalCursor();
773 
774  if ( ! _eventLoop->isRunning() )
775  {
776 #if VERBOSE_EVENT_LOOP
777  yuiDebug() << "Executing event loop for " << this << endl;
778 #endif
779  _eventLoop->exec();
780 
781 #if VERBOSE_EVENT_LOOP
782  yuiDebug() << "Event loop finished for " << this << endl;
783 #endif
784  }
785  else
786  {
787 #if VERBOSE_EVENT_LOOP
788  yuiDebug() << "Event loop still running for " << this << endl;
789 #endif
790  }
791 
792  _waitForEventTimer->stop();
793  event = YQUI::ui()->consumePendingEvent();
794 
795 
796  // Prepare a busy cursor if the UI cannot respond to user input within the
797  // next 200 milliseconds (if the application doesn't call waitForEvent()
798  // within this time again)
799 
801 
802  return event;
803 }
804 
805 
806 YEvent *
808 {
809  _eventLoop->wakeUp();
810 
811  YEvent * event = 0;
812 
813  _waitForEventTimer->stop(); // just in case it's still running
814 
815  if ( ! YQUI::ui()->pendingEvent() )
816  {
817  // Very short (10 millisec) event loop
818  _eventLoop->processEvents( QEventLoop::AllEvents, 10 );
819  }
820 
821  if ( YQUI::ui()->pendingEvent() )
822  event = YQUI::ui()->consumePendingEvent();
823 
824  return event;
825 }
826 
827 
828 void
830 {
831  if ( ! YQUI::ui()->pendingEvent() && isTopmostDialog() )
832  {
833  // Don't override a pending event with a timeout event
834  // and don't deliver the timeout event if another dialog opened in the
835  // meantime
836 
837  YQUI::ui()->sendEvent( new YTimeoutEvent() );
838  }
839 }
840 
841 
842 void
843 YQDialog::center( QWidget * dialog, QWidget * parent )
844 {
845  if ( ! dialog || ! parent )
846  return;
847 
848  QPoint pos( ( parent->width() - dialog->width() ) / 2,
849  ( parent->height() - dialog->height() ) / 2 );
850 
851  pos += parent->mapToGlobal( QPoint( 0, 0 ) );
852  pos = dialog->mapToParent( dialog->mapFromGlobal( pos ) );
853  qDebug() << pos;
854  dialog->move( pos );
855 }
856 
857 
858 void
859 YQDialog::highlight( YWidget * child )
860 {
861  if ( _highlightedChild && _highlightedChild->isValid() )
862  {
863  // Un-highlight old highlighted child widget
864 
865  QWidget * qw = (QWidget *) _highlightedChild->widgetRep();
866 
867  if ( qw )
868  {
869  qw->setPalette( _preHighlightPalette );
870  qw->setAutoFillBackground( _preHighlightAutoFill );
871  }
872  }
873 
874  _highlightedChild = child;
875 
876  if ( child )
877  {
878  QWidget * qw = (QWidget *) child->widgetRep();
879 
880  if ( qw )
881  {
882  _preHighlightPalette = qw->palette();
883  _preHighlightAutoFill = qw->autoFillBackground();
884 
885  qw->setAutoFillBackground( true );
886  QPalette pal( QColor( 0xff, 0x66, 0x00 ) ); // Button color
887  pal.setBrush( QPalette::Window, QColor( 0xff, 0xaa, 0x00 ) ); // Window background
888  pal.setBrush( QPalette::Base , QColor( 0xff, 0xee, 0x00 ) ); // Table etc. background
889 
890  qw->setPalette( pal );
891  }
892  }
893 }
int defaultSize(YUIDimension dim) const
Returns size for opt(defaultsize) dialogs (in one dimension).
Definition: YQUI.cc:587
YQWizard * findWizard() const
Find the first wizard in that dialog, if there is any.
Definition: YQDialog.cc:423
YQGenericButton * findDefaultButton()
Return this dialog&#39;s (first) default button or 0 if none.
Definition: YQDialog.cc:295
Stylesheet Editor Dialog.
void activate()
Activate (animated) this button.
void askConfigureLogging()
Open dialog to configure logging.
void forceUnblockEvents()
Force unblocking all events, no matter how many times blockEvents() has This returns 0 if there is no...
Definition: YQUI.cc:548
void remove(YQDialog *dialog=0)
Remove a dialog from the MainWinDock (if it belongs to the MainWinDock).
void showAsDefault(bool show=true)
Show this button as the dialog&#39;s default button.
Direction direction() const
Returns the current direction of wizard operations - going forward or going backward.
Definition: YQWizard.h:101
virtual void highlight(YWidget *child)
Highlight a child widget of this dialog.
Definition: YQDialog.cc:859
virtual void keyPressEvent(QKeyEvent *event)
Qt event handlers.
Definition: YQDialog.cc:603
bool isEnabled() const
Returns &#39;true&#39; if this button is enabled, &#39;false&#39; otherwise.
void makeScreenShot(std::string filename)
Make a screen shot in .png format and save it to &#39;filename&#39;.
void askSaveLogs()
Open file selection box and let the user save y2logs to that location.
virtual ~YQDialog()
Destructor.
Definition: YQDialog.cc:123
void toggleAlternateStyleSheet()
Toggle between default/alternate style sheets.
Definition: QY2Styler.cc:208
void toggleRecordMacro()
Toggle macro recording (activated by Ctrl-Shift-Alt-M): Stop macro recording if it is in progress...
void registerWidget(QWidget *widget)
Registers a widget and applies the style sheet.
Definition: QY2Styler.cc:284
void add(YQDialog *dialog)
Add a dialog (the widgetRep() of a YQDialog) to the MainWinDock (on top of its widget stack...
virtual YQWizardButton * backButton() const
Return internal widgets.
Definition: YQWizard.h:112
virtual int preferredWidth()
Preferred width of the widget.
Definition: YQDialog.cc:189
virtual YEvent * waitForEventInternal(int timeout_millisec)
Wait for a user event.
Definition: YQDialog.cc:757
static void center(QWidget *dialog, QWidget *parent=0)
Center a dialog relative to &#39;parent&#39;.
Definition: YQDialog.cc:843
bool isShown() const
Returns &#39;true&#39; if the associated QPushButton (!) is shown.
void askSendWidgetID()
Open a pop-up dialog to ask the user for a widget ID and then send it with sendWidgetID().
Definition: YQUI.cc:613
virtual bool setKeyboardFocus()
Accept the keyboard focus.
bool isShownAsDefault() const
Returns &#39;true&#39; if this button is shown as a default button - which may mean that this really is the d...
virtual void activate()
Activate this dialog: Make sure that it is shown as the topmost dialog of this application and that i...
Definition: YQDialog.cc:181
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
Definition: YQDialog.cc:251
void gettingFocus(YQGenericButton *button)
Notification that a button gets the keyboard focus.
Definition: YQDialog.cc:587
static YQMainWinDock * mainWinDock()
Static method to access the singleton for this class.
void setDefaultButton(YPushButton *newDefaultButton)
Set the dialog&#39;s default button - the button that is activated with [Return] if no other button has t...
Definition: YQDialog.cc:492
Abstract base class for push button and similar widgets - all that can become a YQDialog&#39;s "default b...
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:480
virtual void openInternal()
Internal open() method, called exactly once during the life time of the dialog in open()...
Definition: YQDialog.cc:171
bool userResized()
Return &#39;true&#39; if the user resized this dialog.
Definition: YQDialog.h:116
YQDialog(YDialogType dialogType, YDialogColorMode colorMode=YDialogNormalColor)
Constructor.
Definition: YQDialog.cc:55
YQGenericButton * wizardDefaultButton(YQWizard *wizard) const
Find a wizard button that would make sense as a default button.
Definition: YQDialog.cc:455
bool activateDefaultButton(bool warn=true)
Activate (i.e.
Definition: YQDialog.cc:532
static QWidget * chooseParent(YDialogType dialogType)
Choose a parent widget for a dialog of the specified type: Either the main window dock (if this is a ...
Definition: YQDialog.cc:148
void losingFocus(YQGenericButton *button)
Notification that a button loses the keyboard focus.
Definition: YQDialog.cc:571
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQDialog.cc:259
YEvent * consumePendingEvent()
Return the pending event, if there is one, and mark it as "consumed".
Definition: YQUI.h:157
virtual YEvent * pollEventInternal()
Check if a user event is pending.
Definition: YQDialog.cc:807
void timeoutBusyCursor()
Show mouse cursor indicating busy state if the UI is unable to respond to user input for more than a ...
Definition: YQUI.cc:578
void ensureOnlyOneDefaultButton()
Ensure presence of no more than one single default button.
Definition: YQDialog.cc:398
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQDialog.cc:220
void normalCursor()
Show normal mouse cursor not indicating busy status.
Definition: YQUI.cc:568
void askPlayMacro()
Open file selection box and ask for a macro file to play (activated by Ctrl-Shift-Alt-P) ...
void closeEvent(QCloseEvent *ev)
Interited from QDialog: The window was closed via the window manager close button.
Definition: YQDialog.cc:722
void unregisterWidget(QWidget *widget)
Unregisters a widget.
Definition: QY2Styler.cc:293
static YQUI * ui()
Access the global Qt-UI.
Definition: YQUI.h:83
void waitForEventTimeout()
Timeout during waitForEvent()
Definition: YQDialog.cc:829