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