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