libyui-qt  2.49.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 <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 ) &&
163  YQMainWinDock::mainWinDock()->couldDock() )
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_F6 && // Shift-F6: ask for a widget ID and send it
639  event->modifiers() == Qt::ShiftModifier )
640  {
642  }
643  else if ( event->key() == Qt::Key_F7 && // Shift-F7: toggle debug logging
644  event->modifiers() == Qt::ShiftModifier )
645  {
647  return;
648  }
649  else if ( event->key() == Qt::Key_F8 && // Shift-F8: save y2logs
650  event->modifiers() == Qt::ShiftModifier )
651  {
652  YQUI::ui()->askSaveLogs();
653  return;
654  }
655  else if ( event->modifiers() == Qt::NoModifier ) // No Ctrl / Alt / Shift etc. pressed
656  {
657  if ( event->key() == Qt::Key_Return ||
658  event->key() == Qt::Key_Enter )
659  {
660  (void) activateDefaultButton();
661  return;
662  }
663  }
664  else if ( event->modifiers() == ( Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier ) )
665  {
666  // Qt-UI special keys - all with Ctrl-Shift-Alt
667 
668  yuiMilestone() << "Caught YaST2 magic key combination" << std::endl;
669 
670  if ( event->key() == Qt::Key_M )
671  {
673  return;
674  }
675  else if ( event->key() == Qt::Key_P )
676  {
677  YQUI::ui()->askPlayMacro();
678  return;
679  }
680  else if ( event->key() == Qt::Key_D )
681  {
682  YQUI::ui()->sendEvent( new YDebugEvent() );
683  return;
684  }
685  else if ( event->key() == Qt::Key_T )
686  {
687  yuiMilestone() << "*** Dumping widget tree ***" << std::endl;
688  dumpWidgetTree();
689  yuiMilestone() << "*** Widget tree end ***" << std::endl;
690  return;
691  }
692  else if ( event->key() == Qt::Key_Y )
693  {
694  yuiMilestone() << "Opening dialog spy" << std::endl;
695  YDialogSpy::showDialogSpy();
696  YQUI::ui()->normalCursor();
697  }
698  else if ( event->key() == Qt::Key_X )
699  {
700  int result;
701  yuiMilestone() << "Starting xterm" << std::endl;
702  result = system( "/usr/bin/xterm &" );
703  if (result < 0)
704  yuiError() << "/usr/bin/xterm not found" << std::endl;
705  return;
706  }
707  else if ( event->key() == Qt::Key_S )
708  {
709  yuiMilestone() << "Opening style editor" << std::endl;
710  _styleEditor = new QY2StyleEditor(this);
711  _styleEditor->show();
712  _styleEditor->raise();
713  _styleEditor->activateWindow();
714  return;
715  }
716 
717  }
718  }
719 
720  QWidget::keyPressEvent( event );
721 }
722 
723 
724 void
725 YQDialog::closeEvent( QCloseEvent * event )
726 {
727  // The window manager "close window" button (and WM menu, e.g. Alt-F4) will be
728  // handled just like the user had clicked on the `id`( `cancel ) button in
729  // that dialog. It's up to the YCP application to handle this (if desired).
730 
731  yuiMilestone() << "Caught window manager close event - returning with YCancelEvent" << std::endl;
732  event->ignore();
733  YQUI::ui()->sendEvent( new YCancelEvent() );
734 }
735 
736 
737 void
738 YQDialog::focusInEvent( QFocusEvent * event )
739 {
740  // The dialog itself doesn't need or want the keyboard focus, but obviously
741  // (since Qt 2.3?) it needs QFocusPolicy::StrongFocus for the default
742  // button mechanism to work. So let's accept the focus and give it to some
743  // child widget.
744 
745  if ( event->reason() == Qt::TabFocusReason )
746  {
747  focusNextPrevChild( true );
748  }
749  else
750  {
751  if ( _defaultButton )
752  _defaultButton->setKeyboardFocus();
753  else
754  focusNextPrevChild( true );
755  }
756 }
757 
758 
759 YEvent *
760 YQDialog::waitForEventInternal( int timeout_millisec )
761 {
763  _eventLoop->wakeUp();
764 
765  YEvent * event = 0;
766 
767  _waitForEventTimer->stop();
768 
769  if ( timeout_millisec > 0 )
770  _waitForEventTimer->start( timeout_millisec ); // single shot
771 
772  if ( qApp->focusWidget() )
773  qApp->focusWidget()->setFocus();
774 
775  YQUI::ui()->normalCursor();
776 
777  if ( ! _eventLoop->isRunning() )
778  {
779 #if VERBOSE_EVENT_LOOP
780  yuiDebug() << "Executing event loop for " << this << std::endl;
781 #endif
782  _eventLoop->exec();
783 
784 #if VERBOSE_EVENT_LOOP
785  yuiDebug() << "Event loop finished for " << this << std::endl;
786 #endif
787  }
788  else
789  {
790 #if VERBOSE_EVENT_LOOP
791  yuiDebug() << "Event loop still running for " << this << std::endl;
792 #endif
793  }
794 
795  _waitForEventTimer->stop();
796  event = YQUI::ui()->consumePendingEvent();
797 
798 
799  // Prepare a busy cursor if the UI cannot respond to user input within the
800  // next 200 milliseconds (if the application doesn't call waitForEvent()
801  // within this time again)
802 
804 
805  return event;
806 }
807 
808 
809 YEvent *
811 {
812  YEvent * event = 0;
813 
814  _waitForEventTimer->stop(); // just in case it's still running
815 
816  if ( ! YQUI::ui()->pendingEvent() )
817  {
818  // Very short (10 millisec) event loop
819  _eventLoop->processEvents( QEventLoop::AllEvents, 10 );
820  }
821 
822  if ( YQUI::ui()->pendingEvent() )
823  event = YQUI::ui()->consumePendingEvent();
824 
825  return event;
826 }
827 
828 
829 void
831 {
832  if ( ! YQUI::ui()->pendingEvent() && isTopmostDialog() )
833  {
834  // Don't override a pending event with a timeout event
835  // and don't deliver the timeout event if another dialog opened in the
836  // meantime
837 
838  YQUI::ui()->sendEvent( new YTimeoutEvent() );
839  }
840 }
841 
842 
843 void
844 YQDialog::center( QWidget * dialog, QWidget * parent )
845 {
846  if ( ! dialog || ! parent )
847  return;
848 
849  QPoint pos( ( parent->width() - dialog->width() ) / 2,
850  ( parent->height() - dialog->height() ) / 2 );
851 
852  pos += parent->mapToGlobal( QPoint( 0, 0 ) );
853  pos = dialog->mapToParent( dialog->mapFromGlobal( pos ) );
854  qDebug() << pos;
855  dialog->move( pos );
856 }
857 
858 
859 void
860 YQDialog::highlight( YWidget * child )
861 {
862  if ( _highlightedChild && _highlightedChild->isValid() )
863  {
864  // Un-highlight old highlighted child widget
865 
866  QWidget * qw = (QWidget *) _highlightedChild->widgetRep();
867 
868  if ( qw )
869  {
870  qw->setPalette( _preHighlightPalette );
871  qw->setAutoFillBackground( _preHighlightAutoFill );
872  }
873  }
874 
875  _highlightedChild = child;
876 
877  if ( child )
878  {
879  QWidget * qw = (QWidget *) child->widgetRep();
880 
881  if ( qw )
882  {
883  _preHighlightPalette = qw->palette();
884  _preHighlightAutoFill = qw->autoFillBackground();
885 
886  qw->setAutoFillBackground( true );
887  QPalette pal( QColor( 0xff, 0x66, 0x00 ) ); // Button color
888  pal.setBrush( QPalette::Window, QColor( 0xff, 0xaa, 0x00 ) ); // Window background
889  pal.setBrush( QPalette::Base , QColor( 0xff, 0xee, 0x00 ) ); // Table etc. background
890 
891  qw->setPalette( pal );
892  }
893  }
894 }
895 
896 
897 #include "YQDialog.moc"
int defaultSize(YUIDimension dim) const
Returns size for opt(defaultsize) dialogs (in one dimension).
Definition: YQUI.cc:575
YQWizard * findWizard() const
Find the first wizard in that dialog, if there is any.
Definition: YQDialog.cc:426
YQGenericButton * findDefaultButton()
Return this dialog&#39;s (first) default button or 0 if none.
Definition: YQDialog.cc:298
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:536
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:860
virtual void keyPressEvent(QKeyEvent *event)
Qt event handlers.
Definition: YQDialog.cc:606
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:126
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:192
virtual YEvent * waitForEventInternal(int timeout_millisec)
Wait for a user event.
Definition: YQDialog.cc:760
static void center(QWidget *dialog, QWidget *parent=0)
Center a dialog relative to &#39;parent&#39;.
Definition: YQDialog.cc:844
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:601
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:184
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
Definition: YQDialog.cc:254
void gettingFocus(YQGenericButton *button)
Notification that a button gets the keyboard focus.
Definition: YQDialog.cc:590
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:495
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:468
virtual void openInternal()
Internal open() method, called exactly once during the life time of the dialog in open()...
Definition: YQDialog.cc:174
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:60
YQGenericButton * wizardDefaultButton(YQWizard *wizard) const
Find a wizard button that would make sense as a default button.
Definition: YQDialog.cc:458
bool activateDefaultButton(bool warn=true)
Activate (i.e.
Definition: YQDialog.cc:535
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
void losingFocus(YQGenericButton *button)
Notification that a button loses the keyboard focus.
Definition: YQDialog.cc:574
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
Definition: YQDialog.cc:262
YEvent * consumePendingEvent()
Return the pending event, if there is one, and mark it as "consumed".
Definition: YQUI.h:154
virtual YEvent * pollEventInternal()
Check if a user event is pending.
Definition: YQDialog.cc:810
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:566
void ensureOnlyOneDefaultButton()
Ensure presence of no more than one single default button.
Definition: YQDialog.cc:401
virtual int preferredHeight()
Preferred height of the widget.
Definition: YQDialog.cc:223
void normalCursor()
Show normal mouse cursor not indicating busy status.
Definition: YQUI.cc:556
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:725
void unregisterWidget(QWidget *widget)
Unregisters a widget.
Definition: QY2Styler.cc:277
static YQUI * ui()
Access the global Qt-UI.
Definition: YQUI.h:80
void waitForEventTimeout()
Timeout during waitForEvent()
Definition: YQDialog.cc:830