[yast-commit] r39830 - in /branches/tmp/sh/qt4-port/qt/src: YQDialog.cc YQUI.h YQUI_core.cc YQUI_x11.cc YQWizard.cc YQWizard.h
Author: sh-sh-sh Date: Tue Jul 31 11:54:04 2007 New Revision: 39830 URL: http://svn.opensuse.org/viewcvs/yast?rev=39830&view=rev Log: fixed events for defaultsize dialogs thanks to dmueller Modified: branches/tmp/sh/qt4-port/qt/src/YQDialog.cc branches/tmp/sh/qt4-port/qt/src/YQUI.h branches/tmp/sh/qt4-port/qt/src/YQUI_core.cc branches/tmp/sh/qt4-port/qt/src/YQUI_x11.cc branches/tmp/sh/qt4-port/qt/src/YQWizard.cc branches/tmp/sh/qt4-port/qt/src/YQWizard.h Modified: branches/tmp/sh/qt4-port/qt/src/YQDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQDialog.cc?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQDialog.cc (original) +++ branches/tmp/sh/qt4-port/qt/src/YQDialog.cc Tue Jul 31 11:54:04 2007 @@ -44,7 +44,7 @@ QWidget * qt_parent, bool default_size ) : QWidget( qt_parent, - default_size ? Qt::Widget : Qt::WType_Dialog ) // WFlags + default_size ? Qt::Widget : Qt::Window ) // WFlags , YDialog( opt ) { _userResized = false; @@ -54,7 +54,9 @@ setWidgetRep( this ); setCaption( hasDefaultSize() ? "YaST2" : "" ); setFocusPolicy( Qt::StrongFocus ); - setWindowModality( Qt::WindowModal ); + + if ( ! default_size ) + setWindowModality( Qt::WindowModal ); if ( hasWarnColor() || hasInfoColor() ) { Modified: branches/tmp/sh/qt4-port/qt/src/YQUI.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQUI.h?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQUI.h (original) +++ branches/tmp/sh/qt4-port/qt/src/YQUI.h Tue Jul 31 11:54:04 2007 @@ -36,8 +36,8 @@ #define YQWidgetSpacing 4 #define YQButtonBorder 3 -class Q3VBox; -class Q3WidgetStack; +class QWidget; +class QStackedWidget; class QCursor; class QEvent; class QEventLoop; @@ -72,12 +72,6 @@ static YQUI * ui() { return _ui; } /** - * Set the parent widget for embedding the UI into a KPart or KCMShell. - * Used by kyast. - **/ - static void setEmbeddingParent( QWidget * p ); - - /** * Returns the UI's default font. **/ const QFont & currentFont(); @@ -204,18 +198,6 @@ bool autoActivateDialogs() const { return _auto_activate_dialogs; } /** - * Are we running embedded into another application, e.g., inside the KDE - * control center? - **/ - bool runningEmbedded() const; - - /** - * Returns true if debugging embedding mode is on, i.e., when cmd line arg - * --debug-embedding was given. - **/ - bool debugEmbedding() const { return _debug_embedding; } - - /** * Block (or unblock) events. If events are blocked, any event sent * should be ignored until events are unblocked again. * @@ -616,7 +598,7 @@ /** * Returns the normal color palette **/ - QPalette normalPalette() const { return _normalPalette; } + QPalette normalPalette() const { return * _normalPalette; } /** * Toggle between the vision impaired and the normal color palette. @@ -739,31 +721,28 @@ bool _decorate_toplevel_window; /** - * Fake embedding mode (for layout debugging in embedding mode) - **/ - bool _debug_embedding; - - /** * Container for the widget stack. QWidgetStack cannot handle a WFlags * argument, so this needs to be embedded into something else - and a QVBox * at least handles all the sizeHint and resize stuff. **/ - Q3VBox * _main_win; + QWidget * _main_win; /** * Stack for the Qt widgets inside the main window. **/ - Q3WidgetStack * _widget_stack; + QStackedWidget * _widget_stack; /** * Stack to keep track of the stacking order of popup dialogs. **/ vector<QWidget *> _popup_stack; +#ifdef FIXME_OBSOLETE /** * Numeric ID for defaultsize dialogs for the widget stack **/ int _main_dialog_id; +#endif /** * Size for `opt(`defaultsize) dialogs. @@ -866,21 +845,10 @@ **/ QTranslator _qtTranslations; - - /** - * Parent widget for embedding in a KPart or KCMShell - **/ - static QWidget * _embeddingParent; - - /** - * Flag that indicates if we are running embedded - **/ - bool _running_embedded; - /** * Saved normal palette **/ - QPalette _normalPalette; + QPalette * _normalPalette; /** * Flag: currently using special palette for vision impaired users? Modified: branches/tmp/sh/qt4-port/qt/src/YQUI_core.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQUI_core.cc?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQUI_core.cc (original) +++ branches/tmp/sh/qt4-port/qt/src/YQUI_core.cc Tue Jul 31 11:54:04 2007 @@ -26,7 +26,7 @@ #include <qmessagebox.h> #include <qsocketnotifier.h> #include <q3vbox.h> -#include <q3widgetstack.h> +#include <qstackedwidget.h> #include <QtGui/qdesktopwidget.h> #include <ycp/YCPTerm.h> @@ -46,20 +46,21 @@ #define BUSY_CURSOR_TIMEOUT 200 // milliseconds -#define KYAST_EMBEDDING 0 -YQUI * YQUI::_ui = 0; -QWidget * YQUI::_embeddingParent = 0; +YQUI * YQUI::_ui = 0; static void qMessageHandler( QtMsgType type, const char * msg ); + YQUI::YQUI( int argc, char **argv, bool with_threads, const char * macro_file ) : QObject() , YUI( with_threads ) , _main_win( NULL ) +#ifdef FIXME , _main_dialog_id(0) +#endif , _eventLoop( 0 ) , _font_family( "Sans Serif" ) , _lang_fonts( 0 ) @@ -77,8 +78,6 @@ _have_wm = true; _fullscreen = false; _decorate_toplevel_window = true; - _debug_embedding = false; - _running_embedded = false; _usingVisionImpairedPalette = false; _leftHandedMouse = false; _askedForLeftHandedMouse = false; @@ -86,14 +85,12 @@ qInstallMsgHandler( qMessageHandler ); - _running_embedded = false; - // DEBUG // DEBUG // DEBUG char ** argv_copy = (char **) malloc( (argc+1) * sizeof( const char * ) ); - + for ( int i=0; i < argc; i++ ) argv_copy[i+1] = strdup( argv[i] ); @@ -110,14 +107,16 @@ int argc_copy = argc; new QApplication( argc_copy, argv_copy, true ); // GUI enabled - + loadPredefinedQtTranslations(); - _normalPalette = qApp->palette(); + _normalPalette = new QPalette( qApp->palette() ); // Qt keeps track to a global QApplication in qApp. Q_CHECK_PTR( qApp ); +#ifdef FIXME qApp->installEventFilter( this ); +#endif processCommandLineArgs( argc_copy, argv_copy ); calcDefaultSize(); @@ -129,33 +128,28 @@ // Create main window for `opt(`defaultsize) dialogs. // - // We have to use something else than QWidgetStack since QWidgetStack + // We have to use something else than QStackedWidget since QStackedWidget // doesn't accept a WFlags arg which we badly need here. - Qt::WFlags wflags = Qt::WType_TopLevel; + Qt::WFlags wflags = Qt::Window; if ( ! _decorate_toplevel_window ) { y2debug( "Suppressing WM decorations for toplevel window" ); - wflags |= Qt::WStyle_Customize | Qt::WStyle_NoBorder; + wflags |= Qt::FramelessWindowHint; } - // if we have a window already, delete it - if (_main_win) - delete _main_win; - - if ( _embeddingParent ) - _main_win = new Q3VBox( _embeddingParent ); - else - _main_win = new Q3VBox( 0, 0, wflags ); // parent, name, wflags - + _main_win = new Q3VBox( 0, 0, wflags ); // parent, name, wflags + _main_win->setFocusPolicy( Qt::StrongFocus ); // Create widget stack for `opt(`defaultsize) dialogs - _widget_stack = new Q3WidgetStack( _main_win ); + _widget_stack = new QStackedWidget( _main_win ); _widget_stack->setFocusPolicy( Qt::StrongFocus ); - qApp->setMainWidget( _main_win ); + +#if 0 _main_win->installEventFilter( this ); +#endif _main_win->resize( _default_size ); if ( _fullscreen || ! _have_wm ) @@ -174,8 +168,7 @@ if ( strlen( hostname ) > 0 ) { if ( ( strcmp( hostname, "(none)" ) != 0 && - strcmp( hostname, "linux" ) != 0 ) - || runningEmbedded() ) + strcmp( hostname, "linux" ) != 0 ) ) { title += "@"; title += hostname; @@ -186,26 +179,13 @@ _main_win->setCaption( title ); - // Hide the main window unless we are running embedded. The first call to - // UI::OpenDialog() on an `opt(`defaultSize) dialog will trigger a - // showDialog() call that shows the main window - there is nothing to - // display yet. - // - // In embedded mode, keep the main window open so the embedding application - // (kcontrol) catches the main window as YaST2's first window and not some - // popup window that may appear before this. An empty grey area for the - // main window (that will appear for a while) is a lot better than a - // "please wait" popup zoomed to near full screen that may be embedded - - // with a large main window that opens somewhere else on the screen. - - if ( ! runningEmbedded() ) - _main_win->hide(); - else - { - _main_win->show(); - y2milestone( "Running in embedded mode - leaving main window open" ); - } + // Hide the main window. The first call to UI::OpenDialog() on an + // `opt(`defaultSize) dialog will trigger a showDialog() call that shows + // the main window - there is nothing to display yet. +#if 0 + _main_win->hide(); +#endif // Ugly hack as a workaround of bug #121872 (Segfault at program exit // if no Qt style defined): @@ -225,7 +205,7 @@ // Workaround: Keep one more reference to libqt-mt open - dlopen() it here // and make sure there is no corresponding dlclose(). -#if 0 +#ifdef FIXME QString qt_lib_name = QString( QTLIBDIR "/libqt-mt.so.%1" ).arg( QT_VERSION >> 16 );; void * qt_lib = dlopen( (const char *) qt_lib_name, RTLD_GLOBAL ); y2milestone( "Forcing %s open %s", (const char *) qt_lib_name, @@ -237,7 +217,9 @@ // Init other stuff +#ifdef FIXME qApp->setFont( currentFont() ); +#endif busyCursor(); connect( & _user_input_timer, SIGNAL( timeout() ), @@ -271,7 +253,6 @@ if ( opt == QString( "-no-wm" ) ) _have_wm = false; else if ( opt == QString( "-fullscreen" ) ) _fullscreen = true; else if ( opt == QString( "-noborder" ) ) _decorate_toplevel_window = false; - else if ( opt == QString( "-debug-embedding") ) _debug_embedding = true; else if ( opt == QString( "-auto-font" ) ) _auto_fonts = true; else if ( opt == QString( "-auto-fonts" ) ) _auto_fonts = true; // --macro is handled by YUI_component @@ -314,6 +295,9 @@ if ( _lang_fonts ) delete _lang_fonts; + if ( _normalPalette ) + delete _normalPalette; + // Intentionally NOT calling dlclose() to libqt-mt // (see constructor for explanation) } @@ -398,22 +382,14 @@ void YQUI::idleLoop( int fd_ycp ) { _leave_idle_loop = false; - const int timeout_millisec = 100; // process Qt events until fd_ycp is readable. QSocketNotifier * notifier = new QSocketNotifier( fd_ycp, QSocketNotifier::Read ); QObject::connect(notifier, SIGNAL( activated( int ) ), this, SLOT( leaveIdleLoop( int ) ) ); notifier->setEnabled( true ); - y2debug( "Entering loop" ); - while ( !_leave_idle_loop ) - { - // qApp->processOneEvent(); - qApp->processEvents( QEventLoop::AllEvents, timeout_millisec ); - } - - y2debug( "loop done" ); + qApp->processOneEvent(); delete notifier; } @@ -456,8 +432,6 @@ qApp->focusWidget()->setFocus(); normalCursor(); - - y2debug( "Processing events" ); _do_exit_loop = true; // should exit_loop() be called in sendEvent()? while ( ! pendingEvent() ) @@ -466,8 +440,7 @@ } _do_exit_loop = false; - y2debug( "QApp::processEvents() done" ); - + event = _event_handler.consumePendingEvent(); dialog->activate( false ); @@ -498,7 +471,7 @@ if ( dialog ) { dialog->activate( true ); - qApp->processEvents(); + //qApp->processEvents(); event = _event_handler.consumePendingEvent(); dialog->activate( false ); } @@ -521,18 +494,10 @@ YDialog * YQUI::createDialog( YWidgetOpt & opt ) { bool has_defaultsize = opt.hasDefaultSize.value(); - QWidget * qt_parent = _main_win; - - - // Popup dialogs get the topmost other popup dialog as their parent since - // some window managers (e.g., fvwm2 as used in the inst-sys) otherwise - // tend to confuse the stacking order of popup dialogs. - // - // This _popup_stack handling would be better placed in showDialog(), but we - // need the parent here for QWidget creation. libyui guarantees that each - // createDialog() will be followed by showDialog() for the same dialog - // without any chance for other dialogs to get in between. + QWidget * qt_parent = + has_defaultsize ? _widget_stack : _main_win; + // FIXME: Probably obsolete if ( ! has_defaultsize && ! _popup_stack.empty() ) qt_parent = _popup_stack.back(); @@ -558,8 +523,8 @@ if ( dialog->hasDefaultSize() ) { - _widget_stack->addWidget ( qw, ++_main_dialog_id ); - _widget_stack->raiseWidget( qw ); // maybe this is not necessary (?) + _widget_stack->addWidget ( qw ); + _widget_stack->setCurrentWidget( qw ); if ( ! _main_win->isVisible() ) { @@ -580,9 +545,7 @@ ( (YQDialog *) dialog)->ensureOnlyOneDefaultButton(); - y2debug( "processing events" ); - qApp->processEvents(); - y2debug( "processing events done" ); + //qApp->processEvents(); } @@ -600,24 +563,17 @@ { _widget_stack->removeWidget( qw ); - if ( --_main_dialog_id < 1 ) // nothing left on the stack + if ( _widget_stack->count() < 0 ) // nothing left on the stack { - if ( ! runningEmbedded() ) - { - // y2milestone( "Hiding main window" ); - _main_win->hide(); - } - else - { - y2milestone( "Running embedded - keeping (empty) main window open" ); - } - - _main_dialog_id = 0; // this should not be necessary - but better be safe than sorry + // y2milestone( "Hiding main window" ); + _main_win->hide(); } +#ifdef FIXME_OBSOLETE else { _widget_stack->raiseWidget( _main_dialog_id ); } +#endif } else // non-defaultsize dialog { @@ -656,22 +612,6 @@ } -void YQUI::setEmbeddingParent( QWidget * p ) -{ - _embeddingParent = p; -} - - -bool YQUI::runningEmbedded() const -{ -#if KYAST_EMBEDDING - return _embeddingParent != 0; -#else - return _running_embedded; -#endif -} - - void YQUI::setTextdomain( const char * domain ) { Modified: branches/tmp/sh/qt4-port/qt/src/YQUI_x11.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQUI_x11.cc?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQUI_x11.cc (original) +++ branches/tmp/sh/qt4-port/qt/src/YQUI_x11.cc Tue Jul 31 11:54:04 2007 @@ -369,23 +369,24 @@ { if ( obj == _main_win ) { - if ( _main_dialog_id > 0 ) +#ifdef FIXME_PROBABLY_OBSOLETE + if ( _widget_stack->count() > 0 ) { // Work around QWidgetStack bug: The last raiseWidget() call // (from closeDialog() ) might have failed if the widget was // invisible at that time, e.g., because the user had switched to // some other virtual desktop (bugzilla bug #11310) - _widget_stack->raiseWidget( _main_dialog_id ); + _widget_stack->setCurrentWidget( whatever ); } +#endif } else { return showEventFilter( obj, ev ); } } - - return false; // Don't stop event processing + return QObject::eventFilter( obj, ev ); } Modified: branches/tmp/sh/qt4-port/qt/src/YQWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQWizard.cc?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQWizard.cc (original) +++ branches/tmp/sh/qt4-port/qt/src/YQWizard.cc Tue Jul 31 11:54:04 2007 @@ -147,11 +147,6 @@ _protectNextButton = false; _stepsDirty = false; _direction = YQWizard::Forward; - _runningEmbedded = YQUI::ui()->runningEmbedded() || YQUI::ui()->debugEmbedding(); - - if ( _treeEnabled ) - _runningEmbedded = false; - _sideBar = 0; _stepsPanel = 0; _stepsBox = 0; @@ -187,41 +182,32 @@ // Load graphics // - if ( ! runningEmbedded() ) - { #if ENABLE_GRADIENTS - loadGradientPixmaps(); + loadGradientPixmaps(); #endif - if ( _stepsEnabled ) - loadStepsIcons(); - } - + if ( _stepsEnabled ) + loadStepsIcons(); // // Create widgets // - if ( ! runningEmbedded() ) - { #if ENABLE_TITLEBAR - layoutTitleBar( this ); + layoutTitleBar( this ); #else - QWidget * spacer = addVSpacing( this, WORK_AREA_TOP_MARGIN ); - Q_CHECK_PTR( spacer ); + QWidget * spacer = addVSpacing( this, WORK_AREA_TOP_MARGIN ); + Q_CHECK_PTR( spacer ); -# if ENABLE_GRADIENTS - spacer->setPaletteBackgroundColor( _gradientCenterColor ); -# endif +# if ENABLE_GRADIENTS + spacer->setPaletteBackgroundColor( _gradientCenterColor ); +# endif #endif - } Q3HBox * hBox = new Q3HBox( this ); Q_CHECK_PTR( hBox ); - if ( ! runningEmbedded() ) - layoutSideBar( hBox ); - + layoutSideBar( hBox ); layoutWorkArea( hBox ); y2debug( "Constructor finished." ); @@ -1079,14 +1065,11 @@ layoutButtonBox( workAreaVBox ); - if ( ! runningEmbedded() ) - { - // - // Spacer (purely decorative) at the right of the client area - // - - addGradientColumn( parentHBox, WORK_AREA_RIGHT_MARGIN ); - } + // + // Spacer (purely decorative) at the right of the client area + // + + addGradientColumn( parentHBox, WORK_AREA_RIGHT_MARGIN ); } @@ -1247,8 +1230,7 @@ vbox->addSpacing( WORK_AREA_BOTTOM_MARGIN ); #if ENABLE_GRADIENTS - if ( ! runningEmbedded() ) - setBottomCroppedGradient( buttonBox, _bottomGradientPixmap, buttonBox->sizeHint().height() ); + setBottomCroppedGradient( buttonBox, _bottomGradientPixmap, buttonBox->sizeHint().height() ); #endif buttonBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) ); // hor/vert Modified: branches/tmp/sh/qt4-port/qt/src/YQWizard.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/qt4-port/qt/src/YQWizard.h?rev=39830&r1=39829&r2=39830&view=diff ============================================================================== --- branches/tmp/sh/qt4-port/qt/src/YQWizard.h (original) +++ branches/tmp/sh/qt4-port/qt/src/YQWizard.h Tue Jul 31 11:54:04 2007 @@ -442,14 +442,6 @@ **/ void sendEvent( YCPValue id ); - - /** - * Check if we are running embedded as a KCMShell or KPart or something - * similar. This is really just a (chached) shortcut to - * YQUI::runningEmbedded(). - **/ - bool runningEmbedded() const { return _runningEmbedded; } - /** * Returns 'true' if the application is running on a high-color display, * i.e., on an X visual with more than 8 bit depth. @@ -580,7 +572,6 @@ bool _verboseCommands; bool _protectNextButton; bool _stepsDirty; - bool _runningEmbedded; bool _sendButtonEvents; Direction _direction; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
sh-sh-sh@svn.opensuse.org