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