libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQUI.cc
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:         YQUI.cc
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #include <rpc/types.h>          // MAXHOSTNAMELEN
00026 #include <dlfcn.h>
00027 #include <libintl.h>
00028 #include <algorithm>
00029 #include <stdio.h>
00030 
00031 #include <QWidget>
00032 #include <QThread>
00033 #include <QSocketNotifier>
00034 #include <QDesktopWidget>
00035 #include <QEvent>
00036 #include <QCursor>
00037 #include <QLocale>
00038 
00039 
00040 #define YUILogComponent "qt-ui"
00041 #include <yui/YUILog.h>
00042 #include <yui/Libyui_config.h>
00043 
00044 #include "YQUI.h"
00045 
00046 #include <yui/YEvent.h>
00047 #include <yui/YCommandLine.h>
00048 #include <yui/YButtonBox.h>
00049 #include <yui/YUISymbols.h>
00050 
00051 #include "QY2Styler.h"
00052 #include "YQApplication.h"
00053 #include "YQDialog.h"
00054 #include "YQWidgetFactory.h"
00055 #include "YQOptionalWidgetFactory.h"
00056 
00057 #include "YQi18n.h"
00058 #include "utf8.h"
00059 
00060 // Include low-level X headers AFTER Qt headers:
00061 // X.h pollutes the global namespace (!!!) with pretty useless #defines
00062 // like "Above", "Below" etc. that clash with some Qt headers.
00063 #include <X11/Xlib.h>
00064 
00065 
00066 using std::max;
00067 
00068 #define BUSY_CURSOR_TIMEOUT     200     // milliseconds
00069 #define VERBOSE_EVENT_LOOP      0
00070 
00071 
00072 
00073 static void qMessageHandler( QtMsgType type, const char * msg );
00074 YQUI * YQUI::_ui = 0;
00075 
00076 
00077 YUI * createUI( bool withThreads )
00078 {
00079     if ( ! YQUI::ui() )
00080     {
00081         YQUI * ui = new YQUI( withThreads );
00082 
00083         if ( ui && ! withThreads )
00084             ui->initUI();
00085     }
00086 
00087     return YQUI::ui();
00088 }
00089 
00090 
00091 YQUI::YQUI( bool withThreads )
00092     : YUI( withThreads )
00093 #if 0
00094     , _main_win( NULL )
00095 #endif
00096     , _do_exit_loop( false )
00097 {
00098     yuiDebug() << "YQUI constructor start" << std::endl;
00099     yuiMilestone() << "This is libyui-qt " << VERSION << std::endl;
00100 
00101     _ui                         = this;
00102     _uiInitialized              = false;
00103     _fatalError                 = false;
00104     _fullscreen                 = false;
00105     _usingVisionImpairedPalette = false;
00106     _noborder                   = false;
00107     screenShotNameTemplate      = "";
00108     _blockedLevel               = 0;
00109 
00110     qInstallMsgHandler( qMessageHandler );
00111 
00112     yuiDebug() << "YQUI constructor finished" << std::endl;
00113 
00114     topmostConstructorHasFinished();
00115 }
00116 
00117 
00118 void YQUI::initUI()
00119 {
00120     if ( _uiInitialized )
00121         return;
00122 
00123     _uiInitialized = true;
00124     yuiDebug() << "Initializing Qt part" << std::endl;
00125 
00126     YCommandLine cmdLine; // Retrieve command line args from /proc/<pid>/cmdline
00127     std::string progName;
00128 
00129     if ( cmdLine.argc() > 0 )
00130     {
00131         progName = cmdLine[0];
00132         std::size_t lastSlashPos = progName.find_last_of( '/' );
00133 
00134         if ( lastSlashPos != std::string::npos )
00135             progName = progName.substr( lastSlashPos+1 );
00136 
00137         // Qt will display argv[0] as the window manager title.
00138         // For YaST2, display "YaST2" instead of "y2base".
00139         // For other applications, leave argv[0] alone.
00140 
00141         if ( progName == "y2base" )
00142             cmdLine.replace( 0, "YaST2" );
00143     }
00144 
00145     _ui_argc     = cmdLine.argc();
00146     char ** argv = cmdLine.argv();
00147 
00148     // Probe X11 display for better error handling if it can't be opened
00149     probeX11Display( cmdLine );
00150 
00151     yuiDebug() << "Creating QApplication" << std::endl;
00152     new QApplication( _ui_argc, argv );
00153     Q_CHECK_PTR( qApp );
00154     // Qt keeps track to a global QApplication in qApp.
00155 
00156     _signalReceiver = new YQUISignalReceiver();
00157     _busyCursorTimer = new QTimer( _signalReceiver );
00158     _busyCursorTimer->setSingleShot( true );
00159 
00160     _normalPalette = qApp->palette();
00161     (void) QY2Styler::styler(); // Make sure QY2Styler singleton is created
00162 
00163     setButtonOrderFromEnvironment();
00164     processCommandLineArgs( _ui_argc, argv );
00165     calcDefaultSize();
00166 
00167     _do_exit_loop = false;
00168 
00169 #if 0
00170     // Create main window for `opt(`defaultsize) dialogs.
00171     //
00172     // We have to use something else than QWidgetStack since QWidgetStack
00173     // doesn't accept a WFlags arg which we badly need here.
00174 
00175     _main_win = new QWidget( 0, Qt::Window ); // parent, wflags
00176     _main_win->setFocusPolicy( Qt::StrongFocus );
00177     _main_win->setObjectName( "main_window" );
00178 
00179     _main_win->resize( _defaultSize );
00180 
00181     if ( _fullscreen )
00182         _main_win->move( 0, 0 );
00183 #endif
00184 
00185 
00186     //
00187     // Set application title (used by YQDialog and YQWizard)
00188     //
00189 
00190     // for YaST2, display "YaST2" instead of "y2base"
00191     if ( progName == "y2base" )
00192         _applicationTitle = QString( "YaST2" );
00193     else
00194         _applicationTitle = fromUTF8( progName );
00195 
00196     // read x11 display from commandline or environment variable
00197     int displayArgPos = cmdLine.find( "-display" );
00198     QString displayName;
00199 
00200     if ( displayArgPos > 0 && displayArgPos+1 < cmdLine.argc() )
00201         displayName = cmdLine[ displayArgPos+1 ].c_str();
00202     else
00203         displayName = getenv( "DISPLAY" );
00204 
00205     // identify hostname
00206     char hostname[ MAXHOSTNAMELEN+1 ];
00207     if ( gethostname( hostname, sizeof( hostname )-1 ) == 0 )
00208         hostname[ sizeof( hostname ) -1 ] = '\0'; // make sure it's terminated
00209     else
00210         hostname[0] = '\0';
00211 
00212     // add hostname to the window title if it's not a local display
00213     if ( !displayName.startsWith( ":" ) && strlen( hostname ) > 0 )
00214     {
00215         _applicationTitle += QString( "@" );
00216         _applicationTitle += fromUTF8( hostname );
00217     }
00218 
00219 
00220 #if 0
00221     // Hide the main window for now. The first call to UI::OpenDialog() on an
00222     // `opt(`defaultSize) dialog will trigger a dialog->open() call that shows
00223     // the main window - there is nothing to display yet.
00224 
00225     _main_win->hide();
00226 #endif
00227 
00228     YButtonBoxMargins buttonBoxMargins;
00229     buttonBoxMargins.left   = 8;
00230     buttonBoxMargins.right  = 8;
00231     buttonBoxMargins.top    = 6;
00232     buttonBoxMargins.bottom = 6;
00233 
00234     buttonBoxMargins.spacing = 4;
00235     buttonBoxMargins.helpButtonExtraSpacing = 16;
00236     YButtonBox::setDefaultMargins( buttonBoxMargins );
00237 
00238 
00239 
00240     // Ugly hack as a workaround of bug #121872 (Segfault at program exit
00241     // if no Qt style defined):
00242     //
00243     // Qt does not seem to be designed for use in plugin libs. It loads some
00244     // add-on libs dynamically with dlopen() and unloads them at program exit
00245     // (QGPluginManager). Unfortunately, since they all depend on the Qt master
00246     // lib (libqt-mt) themselves, when they are unloading the last call to
00247     // dlclose() for them causes the last reference to libqt-mt to vanish as
00248     // well. Since libqt-mt is already in the process of destruction there is
00249     // no more reference from the caller of libqt-mt, and the GLIBC decides
00250     // that libqt-mt is not needed any more (zero references) and unmaps
00251     // libqt-mt. When the static destructor of libqt-mt that triggered the
00252     // cleanup in QGPluginManager returns, the code it is to return to is
00253     // already unmapped, causing a segfault.
00254     //
00255     // Workaround: Keep one more reference to libqt-mt open - dlopen() it here
00256     // and make sure there is no corresponding dlclose().
00257 
00258     QString qt_lib_name = QString( QTLIBDIR "/libQtGui.so.%1" ).arg( QT_VERSION >> 16 );;
00259     void * qt_lib = dlopen( qt_lib_name.toUtf8().constData(), RTLD_LAZY | RTLD_GLOBAL );
00260     if (qt_lib)
00261         yuiMilestone() << "Forcing " << qt_lib_name.toUtf8().constData() << " open successful" << std::endl;
00262     else
00263         yuiError() << "Forcing " << qt_lib_name.toUtf8().constData() << " open failed" << std::endl;
00264 
00265     //  Init other stuff
00266 
00267     qApp->setFont( yqApp()->currentFont() );
00268     busyCursor();
00269 
00270 
00271     QObject::connect(  _busyCursorTimer,        SIGNAL( timeout()       ),
00272                        _signalReceiver,         SLOT  ( slotBusyCursor() ) );
00273 
00274     yuiMilestone() << "YQUI initialized. Thread ID: 0x"
00275                    << hex << QThread::currentThreadId () << dec
00276                    << std::endl;
00277 
00278     qApp->processEvents();
00279 }
00280 
00281 
00282 YQApplication *
00283 YQUI::yqApp()
00284 {
00285     return static_cast<YQApplication *>( app() );
00286 }
00287 
00288 
00289 void YQUI::processCommandLineArgs( int argc, char **argv )
00290 {
00291     if ( argv )
00292     {
00293         for( int i=0; i < argc; i++ )
00294         {
00295             QString opt = argv[i];
00296 
00297             yuiMilestone() << "Qt argument: " << argv[i] << std::endl;
00298 
00299             // Normalize command line option - accept "--xy" as well as "-xy"
00300 
00301             if ( opt.startsWith( "--" ) )
00302                 opt.remove(0, 1);
00303 
00304             if      ( opt == QString( "-fullscreen"     ) )     _fullscreen     = true;
00305             else if ( opt == QString( "-noborder"       ) )     _noborder       = true;
00306             else if ( opt == QString( "-auto-font"      ) )     yqApp()->setAutoFonts( true );
00307             else if ( opt == QString( "-auto-fonts"     ) )     yqApp()->setAutoFonts( true );
00308             else if ( opt == QString( "-gnome-button-order" ) ) YButtonBox::setLayoutPolicy( YButtonBox::gnomeLayoutPolicy() );
00309             else if ( opt == QString( "-kde-button-order"   ) ) YButtonBox::setLayoutPolicy( YButtonBox::kdeLayoutPolicy() );
00310             // --macro is handled by YUI_component
00311             else if ( opt == QString( "-help"  ) )
00312             {
00313                 fprintf( stderr,
00314                          "Command line options for the YaST2 Qt UI:\n"
00315                          "\n"
00316                          "--nothreads   run without additional UI threads\n"
00317                          "--fullscreen  use full screen for `opt(`defaultsize) dialogs\n"
00318                          "--noborder    no window manager border for `opt(`defaultsize) dialogs\n"
00319                          "--auto-fonts  automatically pick fonts, disregard Qt standard settings\n"
00320                          "--help        this help text\n"
00321                          "\n"
00322                          "--macro <macro-file>        play a macro right on startup\n"
00323                          "\n"
00324                          "-no-wm, -noborder etc. are accepted as well as --no-wm, --noborder\n"
00325                          "to maintain backwards compatibility.\n"
00326                          "\n"
00327                          );
00328 
00329                 raiseFatalError();
00330             }
00331         }
00332     }
00333 
00334     // Qt handles command line option "-reverse" for Arabic / Hebrew
00335 }
00336 
00337 
00338 
00339 YQUI::~YQUI()
00340 {
00341     yuiDebug() <<"Closing down Qt UI." << std::endl;
00342 
00343     // Intentionally NOT calling dlclose() to libqt-mt
00344     // (see constructor for explanation)
00345 
00346     if ( qApp ) // might already be reset to 0 internally from Qt
00347     {
00348         qApp->exit();
00349         qApp->deleteLater();
00350     }
00351 
00352     delete _signalReceiver;
00353 }
00354 
00355 
00356 
00357 YWidgetFactory *
00358 YQUI::createWidgetFactory()
00359 {
00360     YQWidgetFactory * factory = new YQWidgetFactory();
00361     YUI_CHECK_NEW( factory );
00362 
00363     return factory;
00364 }
00365 
00366 
00367 
00368 YOptionalWidgetFactory *
00369 YQUI::createOptionalWidgetFactory()
00370 {
00371     YQOptionalWidgetFactory * factory = new YQOptionalWidgetFactory();
00372     YUI_CHECK_NEW( factory );
00373 
00374     return factory;
00375 }
00376 
00377 
00378 YApplication *
00379 YQUI::createApplication()
00380 {
00381     YQApplication * app = new YQApplication();
00382     YUI_CHECK_NEW( app );
00383 
00384     return app;
00385 }
00386 
00387 
00388 void YQUI::calcDefaultSize()
00389 {
00390     QSize primaryScreenSize     = qApp->desktop()->screenGeometry( qApp->desktop()->primaryScreen() ).size();
00391     QSize availableSize         = qApp->desktop()->availableGeometry( qApp->desktop()->primaryScreen() ).size();
00392 
00393     if ( _fullscreen )
00394     {
00395         _defaultSize = availableSize;
00396 
00397         yuiMilestone() << "-fullscreen: using "
00398                        << _defaultSize.width() << " x " << _defaultSize.height()
00399                        << "for `opt(`defaultsize)"
00400                        << std::endl;
00401     }
00402     else
00403     {
00404         // Get _defaultSize via -geometry command line option (if set)
00405 
00406         // Set min defaultsize or figure one out if -geometry was not used
00407 
00408         if ( _defaultSize.width()  < 800 ||
00409              _defaultSize.height() < 600   )
00410         {
00411             if ( primaryScreenSize.width() >= 1024 && primaryScreenSize.height() >= 768  )
00412             {
00413                 // Scale down to 70% of screen size
00414 
00415                 _defaultSize.setWidth ( max( (int) (availableSize.width()  * 0.7), 800 ) );
00416                 _defaultSize.setHeight( max( (int) (availableSize.height() * 0.7), 600 ) );
00417             }
00418             else
00419             {
00420                 _defaultSize = availableSize;
00421             }
00422         }
00423         else
00424         {
00425             yuiMilestone() << "Forced size (via -geometry): "
00426                            << _defaultSize.width() << " x " << _defaultSize.height()
00427                            << std::endl;
00428         }
00429     }
00430 
00431     yuiMilestone() << "Default size: "
00432                    << _defaultSize.width() << " x " << _defaultSize.height()
00433                    << std::endl;
00434 }
00435 
00436 
00437 void YQUI::idleLoop( int fd_ycp )
00438 {
00439     initUI();
00440 
00441     _received_ycp_command = false;
00442     QSocketNotifier * notifier = new QSocketNotifier( fd_ycp, QSocketNotifier::Read );
00443     QObject::connect( notifier,         SIGNAL( activated( int )         ),
00444                       _signalReceiver,  SLOT  ( slotReceivedYCPCommand() ) );
00445 
00446     notifier->setEnabled( true );
00447 
00448 
00449     //
00450     // Process Qt events until fd_ycp is readable
00451     //
00452 
00453 #if VERBOSE_EVENT_LOOP
00454     yuiDebug() << "Entering idle loop" << std::endl;
00455 #endif
00456 
00457     QEventLoop eventLoop( qApp );
00458 
00459     while ( !_received_ycp_command )
00460         eventLoop.processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents );
00461 
00462 #if VERBOSE_EVENT_LOOP
00463     yuiDebug() << "Leaving idle loop" << std::endl;
00464 #endif
00465 
00466     delete notifier;
00467 }
00468 
00469 
00470 void YQUI::receivedYCPCommand()
00471 {
00472     _received_ycp_command = true;
00473 }
00474 
00475 
00476 void YQUI::sendEvent( YEvent * event )
00477 {
00478     if ( event )
00479     {
00480         _eventHandler.sendEvent( event );
00481         YQDialog * dialog = (YQDialog *) YDialog::currentDialog( false ); // don't throw
00482 
00483         if ( dialog )
00484         {
00485             if ( dialog->eventLoop()->isRunning() )
00486                 dialog->eventLoop()->exit( 0 );
00487         }
00488         else
00489         {
00490             yuiError() << "No dialog" << std::endl;
00491         }
00492     }
00493 }
00494 
00495 
00496 void YQUI::setTextdomain( const char * domain )
00497 {
00498     bindtextdomain( domain, YSettings::localeDir().c_str() );
00499     bind_textdomain_codeset( domain, "utf8" );
00500     textdomain( domain );
00501 
00502     // Make change known.
00503     {
00504         extern int _nl_msg_cat_cntr;
00505         ++_nl_msg_cat_cntr;
00506     }
00507 }
00508 
00509 
00510 void YQUI::blockEvents( bool block )
00511 {
00512     initUI();
00513 
00514     if ( block )
00515     {
00516         if ( ++_blockedLevel == 1 )
00517         {
00518             _eventHandler.blockEvents( true );
00519 
00520             YQDialog * dialog = (YQDialog *) YDialog::currentDialog( false ); // don't throw
00521 
00522             if ( dialog && dialog->eventLoop()->isRunning() )
00523             {
00524                 yuiWarning() << "blocking events in active event loop of " << dialog << std::endl;
00525                 dialog->eventLoop()->exit();
00526             }
00527         }
00528     }
00529     else
00530     {
00531         if ( --_blockedLevel == 0 )
00532         {
00533             _eventHandler.blockEvents( false );
00534 
00535             YQDialog * dialog = (YQDialog *) YDialog::currentDialog( false ); // don't throw
00536 
00537             if ( dialog )
00538                 dialog->eventLoop()->wakeUp();
00539         }
00540     }
00541 }
00542 
00543 
00544 void YQUI::forceUnblockEvents()
00545 {
00546     initUI();
00547     _blockedLevel = 0;
00548     _eventHandler.blockEvents( false );
00549 }
00550 
00551 
00552 bool YQUI::eventsBlocked() const
00553 {
00554     return _eventHandler.eventsBlocked();
00555 }
00556 
00557 
00558 void YQUI::busyCursor()
00559 {
00560     qApp->setOverrideCursor( Qt::BusyCursor );
00561 }
00562 
00563 
00564 void YQUI::normalCursor()
00565 {
00566     if ( _busyCursorTimer->isActive() )
00567         _busyCursorTimer->stop();
00568 
00569     while ( qApp->overrideCursor() )
00570         qApp->restoreOverrideCursor();
00571 }
00572 
00573 
00574 void YQUI::timeoutBusyCursor()
00575 {
00576     // Display a busy cursor, but only if there is no other activity within
00577     // BUSY_CURSOR_TIMEOUT milliseconds: Avoid cursor flicker.
00578 
00579     _busyCursorTimer->start( BUSY_CURSOR_TIMEOUT ); // single shot
00580 }
00581 
00582 
00583 int YQUI::defaultSize(YUIDimension dim) const
00584 {
00585     return dim == YD_HORIZ ? _defaultSize.width() : _defaultSize.height();
00586 }
00587 
00588 
00589 void YQUI::probeX11Display( const YCommandLine & cmdLine )
00590 {
00591     int displayArgPos = cmdLine.find( "-display" );
00592     std::string displayNameStr;
00593 
00594     if ( displayArgPos > 0 && displayArgPos+1 < cmdLine.argc() )
00595     {
00596         displayNameStr = cmdLine[ displayArgPos+1 ];
00597         yuiMilestone() << "Using X11 display \"" << displayNameStr << "\"" << std::endl;
00598     }
00599 
00600     const char * displayName = ( displayNameStr.empty() ? 0 : displayNameStr.c_str() );
00601     Display * display = XOpenDisplay( displayName );
00602 
00603     if ( display )
00604     {
00605         yuiDebug() << "Probing X11 display successful" << std::endl;
00606         XCloseDisplay( display );
00607     }
00608     else
00609     {
00610         string msg = "Can't open display " + displayNameStr;
00611         YUI_THROW( YUIException( msg ) );
00612     }
00613 }
00614 
00615 
00616 void YQUI::deleteNotify( YWidget * widget )
00617 {
00618     _eventHandler.deletePendingEventsFor( widget );
00619 }
00620 
00621 
00622 void YQUI::toggleVisionImpairedPalette()
00623 {
00624     if ( _usingVisionImpairedPalette )
00625     {
00626         qApp->setPalette( normalPalette());  // informWidgets
00627 
00628         _usingVisionImpairedPalette = false;
00629     }
00630     else
00631     {
00632         qApp->setPalette( visionImpairedPalette() );  // informWidgets
00633 
00634         _usingVisionImpairedPalette = true;
00635     }
00636 }
00637 
00638 
00639 QPalette
00640 YQUI::visionImpairedPalette()
00641 {
00642     const QColor dark  ( 0x20, 0x20, 0x20 );
00643     QPalette pal;
00644 
00645     // for the active window (the one with the keyboard focus)
00646     pal.setColor( QPalette::Active, QPalette::Background,       Qt::black       );
00647     pal.setColor( QPalette::Active, QPalette::Foreground,       Qt::cyan        );
00648     pal.setColor( QPalette::Active, QPalette::Text,             Qt::cyan        );
00649     pal.setColor( QPalette::Active, QPalette::Base,             dark            );
00650     pal.setColor( QPalette::Active, QPalette::Button,           dark            );
00651     pal.setColor( QPalette::Active, QPalette::ButtonText,       Qt::green       );
00652     pal.setColor( QPalette::Active, QPalette::Highlight,        Qt::yellow      );
00653     pal.setColor( QPalette::Active, QPalette::HighlightedText,  Qt::black       );
00654 
00655     // for other windows (those that don't have the keyboard focus)
00656     pal.setColor( QPalette::Inactive, QPalette::Background,     Qt::black       );
00657     pal.setColor( QPalette::Inactive, QPalette::Foreground,     Qt::cyan        );
00658     pal.setColor( QPalette::Inactive, QPalette::Text,           Qt::cyan        );
00659     pal.setColor( QPalette::Inactive, QPalette::Base,           dark            );
00660     pal.setColor( QPalette::Inactive, QPalette::Button,         dark            );
00661     pal.setColor( QPalette::Inactive, QPalette::ButtonText,     Qt::green       );
00662 
00663     // for disabled widgets
00664     pal.setColor( QPalette::Disabled, QPalette::Background,     Qt::black       );
00665     pal.setColor( QPalette::Disabled, QPalette::Foreground,     Qt::gray        );
00666     pal.setColor( QPalette::Disabled, QPalette::Text,           Qt::gray        );
00667     pal.setColor( QPalette::Disabled, QPalette::Base,           dark            );
00668     pal.setColor( QPalette::Disabled, QPalette::Button,         dark            );
00669     pal.setColor( QPalette::Disabled, QPalette::ButtonText,     Qt::gray        );
00670 
00671     return pal;
00672 }
00673 
00674 
00675 // FIXME: Does this still do anything now that YQUI is no longer a QObject?
00676 bool YQUI::close()
00677 {
00678     yuiMilestone() << "Closing application" << std::endl;
00679     sendEvent( new YCancelEvent() );
00680     return true;
00681 }
00682 
00683 
00684 
00685 
00686 YQUISignalReceiver::YQUISignalReceiver()
00687     : QObject()
00688 {
00689 }
00690 
00691 
00692 void YQUISignalReceiver::slotBusyCursor()
00693 {
00694     YQUI::ui()->busyCursor();
00695 }
00696 
00697 
00698 void YQUISignalReceiver::slotReceivedYCPCommand()
00699 {
00700     YQUI::ui()->receivedYCPCommand();
00701 }
00702 
00703 
00704 
00705 static void
00706 qMessageHandler( QtMsgType type, const char * msg )
00707 {
00708     switch (type)
00709     {
00710         case QtDebugMsg:
00711             yuiMilestone() <<  "<libqt-debug> " << msg << std::endl;
00712             break;
00713 
00714         case QtWarningMsg:
00715             yuiWarning() <<  "<libqt-warning> " << msg << std::endl;
00716             break;
00717 
00718         case QtCriticalMsg:
00719             yuiError() <<  "<libqt-critical>" << msg << std::endl;
00720             break;
00721 
00722         case QtFatalMsg:
00723             yuiError() << "<libqt-fatal> " << msg << std::endl;
00724             abort();
00725             exit(1);            // Qt does the same
00726     }
00727 
00728     if ( QString( msg ).contains( "Fatal IO error",  Qt::CaseInsensitive ) &&
00729          QString( msg ).contains( "client killed", Qt::CaseInsensitive ) )
00730         yuiError() << "Client killed. Possibly caused by X server shutdown or crash." << std::endl;
00731 }
00732 
00733 
00734 
00735 #include "YQUI.moc"
 All Classes Functions Variables