[yast-commit] r42730 - in /trunk/qt/src: Makefile.am YQDialog.cc YQDialog.h YQMainWinDock.cc YQMainWinDock.h YQUI.h YQUI_core.cc YQUI_x11.cc
Author: sh-sh-sh Date: Wed Dec 5 19:28:34 2007 New Revision: 42730 URL: http://svn.opensuse.org/viewcvs/yast?rev=42730&view=rev Log: Moved main dialog docking out of UI to separate class Modified: trunk/qt/src/Makefile.am trunk/qt/src/YQDialog.cc trunk/qt/src/YQDialog.h trunk/qt/src/YQMainWinDock.cc trunk/qt/src/YQMainWinDock.h trunk/qt/src/YQUI.h trunk/qt/src/YQUI_core.cc trunk/qt/src/YQUI_x11.cc Modified: trunk/qt/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/Makefile.am?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/Makefile.am (original) +++ trunk/qt/src/Makefile.am Wed Dec 5 19:28:34 2007 @@ -71,7 +71,6 @@ YQDialog.cc \ YQDownloadProgress.cc \ YQDumbTab.cc \ - YQEBunny.cc \ YQEmpty.cc \ YQFrame.cc \ YQGenericButton.cc \ @@ -81,6 +80,7 @@ YQLabel.cc \ YQLayoutBox.cc \ YQLogView.cc \ + YQMainWinDock.cc \ YQMenuButton.cc \ YQMultiLineEdit.cc \ YQMultiProgressMeter.cc \ @@ -145,6 +145,7 @@ YQLabel.moc \ YQLayoutBox.moc \ YQLogView.moc \ + YQMainWinDock.moc \ YQMenuButton.moc \ YQMultiLineEdit.moc \ YQMultiProgressMeter.moc \ @@ -196,6 +197,7 @@ YQLabel.o YQLabel.lo: YQLabel.moc YQLayoutBox.o YQLayoutBox.lo: YQLayoutBox.moc YQLogView.o YQLogView.lo: YQLogView.moc +YQMainWinDock.o YQMainWinDock.lo: YQMainWinDock.moc YQMenuButton.o YQMenuButton.lo: YQMenuButton.moc YQMultiLineEdit.o YQMultiLineEdit.lo: YQMultiLineEdit.moc YQMultiProgressMeter.o YQMultiProgressMeter.lo: YQMultiProgressMeter.moc @@ -245,6 +247,7 @@ YQLabel.moc: YQLabel.h YQLayoutBox.moc: YQLayoutBox.h YQLogView.moc: YQLogView.h +YQMainWinDock.moc: YQMainWinDock.h YQMenuButton.moc: YQMenuButton.h YQMultiLineEdit.moc: YQMultiLineEdit.h YQMultiProgressMeter.moc: YQMultiProgressMeter.h Modified: trunk/qt/src/YQDialog.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQDialog.cc?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQDialog.cc (original) +++ trunk/qt/src/YQDialog.cc Wed Dec 5 19:28:34 2007 @@ -22,7 +22,6 @@ #define y2log_component "qt-ui" #include <ycp/y2log.h> #include <qpushbutton.h> -#include <qframe.h> #include <qmessagebox.h> #include "YQUI.h" @@ -32,26 +31,28 @@ #include "YQGenericButton.h" #include "YQWizardButton.h" #include "YQWizard.h" +#include "YQMainWinDock.h" // Include low-level X headers AFTER Qt headers: // X.h pollutes the global namespace (!!!) with pretty useless #defines // like "Above", "Below" etc. that clash with some Qt headers. #include <X11/Xlib.h> + #define YQMainDialogWFlags 0 -#define YQPopupDialogWFlags \ - ( WStyle_Customize | \ - WStyle_Dialog | \ - WType_Modal | \ + +#define YQPopupDialogWFlags \ + ( Qt::WStyle_Customize | \ + Qt::WStyle_Dialog | \ + Qt::WShowModal | \ WStyle_Title | \ - WStyle_DialogBorder ) + Qt::WStyle_DialogBorder ) -YQDialog::YQDialog( QWidget * qParent, - YDialogType dialogType, +YQDialog::YQDialog( YDialogType dialogType, YDialogColorMode colorMode ) - : QWidget( qParent, + : QWidget( chooseParent( dialogType ), 0, // name dialogType == YMainDialog ? YQMainDialogWFlags : YQPopupDialogWFlags ) , YDialog( dialogType, colorMode ) @@ -60,9 +61,8 @@ _focusButton = 0; _defaultButton = 0; - setWidgetRep( this ); - setCaption( dialogType == YMainDialog ? "YaST2" : "" ); + setCaption( dialogType == YMainDialog ? "YaST2*" : "" ); setFocusPolicy( QWidget::StrongFocus ); if ( colorMode != YDialogNormalColor ) @@ -83,15 +83,42 @@ warnPalette.setNormal( normalColors ); setPalette( warnPalette ); } + + if ( dialogType == YMainDialog && + QWidget::parent() != YQMainWinDock::mainWinDock() ) + { + setWFlags( YQPopupDialogWFlags ); + } } YQDialog::~YQDialog() { + if ( dialogType() == YMainDialog ) + { + YQMainWinDock::mainWinDock()->remove( (QWidget *) widgetRep() ); + } } -int YQDialog::preferredWidth() +QWidget * +YQDialog::chooseParent( YDialogType dialogType ) +{ + QWidget * parent = 0; + + if ( dialogType == YMainDialog && + YQMainWinDock::mainWinDock()->couldDock() ) + { + y2debug( "Adding dialog to mainWinDock" ); + parent = YQMainWinDock::mainWinDock(); + } + + return parent; +} + + +int +YQDialog::preferredWidth() { int preferredWidth; @@ -119,7 +146,8 @@ } -int YQDialog::preferredHeight() +int +YQDialog::preferredHeight() { int preferredHeight; @@ -147,15 +175,19 @@ } -void YQDialog::setEnabled( bool enabled ) +void +YQDialog::setEnabled( bool enabled ) { QWidget::setEnabled( enabled ); YDialog::setEnabled( enabled ); } -void YQDialog::setSize( int newWidth, int newHeight ) +void +YQDialog::setSize( int newWidth, int newHeight ) { + // y2debug( "Resizing dialog to %d x %d", newWidth, newHeight ); + if ( newWidth > qApp->desktop()->width() ) newWidth = qApp->desktop()->width(); @@ -171,19 +203,11 @@ } - -void YQDialog::activate( bool active ) +void +YQDialog::activate( bool active ) { if ( active ) { - if ( ! YQUI::ui()->haveWM() ) - { - if ( YQUI::ui()->autoActivateDialogs() ) - setActiveWindow(); - else - y2milestone( "Auto-activating dialog window turned off" ); - } - ensureOnlyOneDefaultButton(); } } @@ -194,9 +218,12 @@ { if ( event ) { + // y2debug( "Resize event: %d x %d", event->size().width(), event->size().height() ); setSize ( event->size().width(), event->size().height() ); - _userSize = event->size(); - _userResized = true; + _userSize = event->size(); + + if ( QWidget::parent() ) + _userResized = true; } } @@ -324,7 +351,7 @@ YDialog::setDefaultButton( _defaultButton ); } - + YQGenericButton * def = _focusButton ? _focusButton : _defaultButton; if ( def ) @@ -342,7 +369,6 @@ YQWizard * YQDialog::findWizard( YWidgetListConstIterator begin, YWidgetListConstIterator end ) const - { for ( YWidgetListConstIterator it = begin; it != end; ++it ) { @@ -434,7 +460,7 @@ _defaultButton->showAsDefault( true ); } - + YDialog::setDefaultButton( 0 ); // prevent complaints about multiple default buttons YDialog::setDefaultButton( _defaultButton ); } @@ -521,11 +547,6 @@ YQUI::ui()->makeScreenShot( "" ); return; } - else if ( event->key() == Qt::Key_F5 ) // No matter if Ctrl/Alt/Shift pressed - { - YQUI::ui()->easterEgg(); - return; - } else if ( event->key() == Qt::Key_F4 && // Shift-F4: toggle colors for vision impaired users event->state() == Qt::ShiftButton ) { @@ -599,19 +620,49 @@ } -void YQDialog::closeEvent( QCloseEvent * event ) +#if 0 +void +YQDialog::showEvent( QShowEvent * event ) +{ + y2debug( "Showing dialog %p", this ); + // y2debug( "Size: %d x %d", size().width(), size().height() ); + + QWidget::showEvent( event ); +} +#endif + + +#if 0 +void +YQDialog::paintEvent( QPaintEvent * event ) +{ + if ( event ) + { + QRect rect = event->rect(); + y2debug( "Repainting dialog %p: rect (%d, %d) w: %d h: %d", + this, rect.x(), rect.y(), rect.width(), rect.height() ); + } + + QWidget::paintEvent( event ); +} +#endif + + +void +YQDialog::closeEvent( QCloseEvent * event ) { // The window manager "close window" button (and WM menu, e.g. Alt-F4) will be // handled just like the user had clicked on the `id`( `cancel ) button in // that dialog. It's up to the YCP application to handle this (if desired). - y2debug( "Ignoring window manager close button." ); + y2milestone( "Caught window manager close event - returning with YCancelEvent" ); event->ignore(); YQUI::ui()->sendEvent( new YCancelEvent() ); } -void YQDialog::focusInEvent( QFocusEvent * event ) +void +YQDialog::focusInEvent( QFocusEvent * event ) { // The dialog itself doesn't need or want the keyboard focus, but obviously @@ -634,29 +685,11 @@ void -YQDialog::show() -{ - if ( ! dialogType() == YMainDialog && qApp->mainWidget()->isVisible() ) - center( this, qApp->mainWidget() ); - - QWidget::show(); -} - - -void YQDialog::center( QWidget * dialog, QWidget * parent ) { - if ( ! dialog ) + if ( ! dialog || ! parent ) return; - if ( ! parent ) - { - if ( dialog == qApp->mainWidget() ) - parent = qApp->desktop(); - else - parent = qApp->mainWidget(); - } - QPoint pos( ( parent->width() - dialog->width() ) / 2, ( parent->height() - dialog->height() ) / 2 ); Modified: trunk/qt/src/YQDialog.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQDialog.h?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQDialog.h (original) +++ trunk/qt/src/YQDialog.h Wed Dec 5 19:28:34 2007 @@ -42,8 +42,7 @@ * colors or YDialogInfoColor to use more prominent, yet not quite as * bright as "warning" colors. Use both only very rarely. **/ - YQDialog( QWidget * qParent, - YDialogType dialogType, + YQDialog( YDialogType dialogType, YDialogColorMode colorMode = YDialogNormalColor ); protected: @@ -100,7 +99,7 @@ YQGenericButton * findDefaultButton(); /** - * Returns whether or not the user has resized this dialog. + * Return 'true' if the user resized this dialog. **/ bool userResized() { return _userResized; } @@ -175,6 +174,13 @@ protected: /** + * Choose a parent widget for a dialog of the specified type: + * Either the main window dock (if this is a YMainDialog and the dock + * currently accepts child dialogs) or 0. + **/ + static QWidget * chooseParent( YDialogType dialogType ); + + /** * Return the (first) default button between 'begin' and 'end' * or 0 if there is none. **/ @@ -198,44 +204,29 @@ YWidgetListConstIterator end ); /** - * Event handler for keyboard input. - * Only very special keys are processed here. - * - * Inherited from QWidget. - **/ - void keyPressEvent( QKeyEvent * e ); - - - /** - * Event handler for focusIn event. + * Qt event handlers. * - * Inherited from QWidget. - **/ - void focusInEvent( QFocusEvent * event ); - - /** - * Event handler for window resize. - * - * Inherited from QWidget. - **/ - void resizeEvent ( QResizeEvent * ev ); - - - /** - * Inherited from QWidget: Called when the dialog is shown. + * All reimplemented from QWidget. **/ - void show(); + virtual void keyPressEvent ( QKeyEvent * event ); + virtual void focusInEvent ( QFocusEvent * event ); + virtual void resizeEvent ( QResizeEvent * event ); + +#if 0 + virtual void showEvent ( QShowEvent * event ); + virtual void paintEvent ( QPaintEvent * event ); +#endif // // Data members // - bool _userResized; - QSize _userSize; + bool _userResized; + QSize _userSize; - YQGenericButton * _focusButton; - YQGenericButton * _defaultButton; + YQGenericButton * _focusButton; + YQGenericButton * _defaultButton; }; Modified: trunk/qt/src/YQMainWinDock.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQMainWinDock.cc?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQMainWinDock.cc (original) +++ trunk/qt/src/YQMainWinDock.cc Wed Dec 5 19:28:34 2007 @@ -19,7 +19,6 @@ #define y2log_component "qt-ui" #include <ycp/y2log.h> -#include <qwidgetstack.h> #include <qtimer.h> #include <YDialog.h> @@ -35,22 +34,24 @@ static YQMainWinDock * mainWinDock = 0; if ( ! mainWinDock ) - { mainWinDock = new YQMainWinDock(); - mainWinDock->show(); - } return mainWinDock; } YQMainWinDock::YQMainWinDock() - : QVBox() + : QWidget( 0, 0, Qt::WType_TopLevel ) // parent, name, WFlags { - _qWidgetStack = new QWidgetStack( this ); + setCaption( "YaST2" ); + setFocusPolicy( QWidget::StrongFocus ); + resize( YQUI::ui()->defaultSize( YD_HORIZ ), YQUI::ui()->defaultSize( YD_VERT ) ); + + y2debug( "MainWinDock initial size: %d x %d", + size().width(), size().height() ); } @@ -61,16 +62,58 @@ void -YQMainWinDock::show() +YQMainWinDock::childEvent( QChildEvent * event ) { - y2debug( "Showing" ); + if ( event ) + { + QWidget * widget = dynamic_cast<QWidget *> ( event->child() ); + + if ( widget && event->inserted() ) + { + add( widget ); + } + } + QWidget::childEvent( event ); +} + + +void +YQMainWinDock::resizeEvent( QResizeEvent * event ) +{ + if ( event ) + { + resize( event->size() ); + resizeVisibleChild(); + } +} + + +void +YQMainWinDock::resizeVisibleChild() +{ + if ( ! _widgetStack.empty() ) + { + QWidget * dialog = _widgetStack.back(); + + if ( dialog->size() != size() ) + { + // y2debug( "Resizing child dialog %p to %d x %d", dialog, size().width(), size().height() ); + dialog->resize( size() ); + } + } +} + + +void +YQMainWinDock::show() +{ QWidget::show(); if ( ! _widgetStack.empty() ) { QWidget * dialog = _widgetStack.back(); - dialog->raise(); + dialog->raise(); if ( ! dialog->isShown() ) dialog->show(); @@ -83,27 +126,15 @@ { YUI_CHECK_PTR( dialog ); -#if 0 - if ( dialog->parent() ) - { - y2error( "Dialog already has a parent" ); - return; - } -#endif - if ( ! dialog->isShown() ) dialog->show(); - + + y2debug( "Adding dialog %p to mainWinDock", dialog ); _widgetStack.push_back( dialog ); - _qWidgetStack->addWidget( dialog ); - _qWidgetStack->raiseWidget( dialog ); + resizeVisibleChild(); if ( ! isShown() ) show(); - -#if 0 - QTimer::singleShot( 3*1000, this, SLOT( showCurrentDialog() ) ); -#endif } @@ -114,9 +145,6 @@ { QWidget * dialog = _widgetStack.back(); y2debug( "Showing dialog %p", dialog ); -#if 0 - _qWidgetStack->raiseWidget( dialog ); -#endif dialog->raise(); update(); } @@ -138,9 +166,8 @@ // The topmost dialog is to be removed _widgetStack.pop_back(); - _qWidgetStack->removeWidget( dialog ); - y2debug( "removing dialog %p", dialog ); + y2debug( "Removing dialog %p from mainWinDock", dialog ); } else // The less common (but more generic) case: Remove any dialog { @@ -150,18 +177,18 @@ return; y2warning( "Found dialog somewhere in the middle of the widget stack" ); - + y2debug( "Removing dialog %p from mainWinDock", dialog ); + _widgetStack.erase( pos ); - _qWidgetStack->removeWidget( dialog ); - - y2debug( "removing dialog %p", dialog ); } - if ( _widgetStack.empty() ) - hide(); + if ( _widgetStack.empty() ) // No more main dialog? + hide(); // -> hide dock else { - _qWidgetStack->raiseWidget( _widgetStack.back() ); + dialog = _widgetStack.back(); // Get the next dialog from the stack + dialog->raise(); // and raise it + resizeVisibleChild(); } } @@ -214,7 +241,7 @@ // handled just like the user had clicked on the `id`( `cancel ) button in // that dialog. It's up to the YCP application to handle this (if desired). - y2debug( "Caught window manager close event - returning with YCancelEvent" ); + y2milestone( "Caught window manager close event - returning with YCancelEvent" ); event->ignore(); YQUI::ui()->sendEvent( new YCancelEvent() ); } Modified: trunk/qt/src/YQMainWinDock.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQMainWinDock.h?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQMainWinDock.h (original) +++ trunk/qt/src/YQMainWinDock.h Wed Dec 5 19:28:34 2007 @@ -21,7 +21,7 @@ #define YQMainWinDock_h #include <deque> -#include <qvbox.h> +#include <qwidget.h> class QWidgetStack; @@ -42,7 +42,7 @@ * This widget can swallow an arbitrary number of main dialogs as they are * opened as long as there is no popup dialog in between. **/ -class YQMainWinDock : public QVBox +class YQMainWinDock : public QWidget { Q_OBJECT @@ -103,7 +103,8 @@ * Reimplemented from QWidget. **/ virtual void closeEvent( QCloseEvent * event ); - + + protected: /** * Constructor. @@ -118,14 +119,35 @@ **/ virtual ~YQMainWinDock(); +protected: + /** * Paint event. * - * Reimplemented from YWidget. + * Reimplemented from QWidget. **/ virtual void paintEvent( QPaintEvent * event ); - + /** + * Child inserted/removed event. + * + * Reimplemented from QObject. + **/ + virtual void childEvent( QChildEvent * event ); + + /** + * Resize event. + * + * Reimplemented from QWidget. + **/ + virtual void resizeEvent( QResizeEvent * event ); + + /** + * Resize the visible child to the current size of the dock. + **/ + void resizeVisibleChild(); + + protected slots: /** @@ -137,7 +159,7 @@ private: typedef std::deque<QWidget *> YQWidgetStack; - + /** * Return an iterator to the specified dialog in the internal * widgetstack or _widgetStack::end() if not found. @@ -145,8 +167,7 @@ YQWidgetStack::iterator findInStack( QWidget * dialog ); - YQWidgetStack _widgetStack; - QWidgetStack * _qWidgetStack; + YQWidgetStack _widgetStack; }; Modified: trunk/qt/src/YQUI.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI.h?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQUI.h (original) +++ trunk/qt/src/YQUI.h Wed Dec 5 19:28:34 2007 @@ -131,24 +131,11 @@ YEvent * pendingEvent() const { return _event_handler.pendingEvent(); } /** - * Returns 'false" if the "--no-wm" was specified on the command line, i.e. - * we should assume no window manager is running. - **/ - bool haveWM() const { return _have_wm; } - - /** * Returns 'true' if defaultsize windows should use the full screen. **/ bool fullscreen() const { return _fullscreen; } /** - * Returns 'false' if toplevel (defaultsize) windows should not get window - * manager decorations, i.e. "--noborder" was specified on the command - * line. - **/ - bool decorateToplevelWindow() const { return _decorate_toplevel_window; } - - /** * Returns 'true' if the UI had a fatal error that requires the application * to abort. **/ @@ -201,17 +188,6 @@ **/ void internalError( const char * msg ); - - /** - * Block WM_CLOSE events for the main window. - **/ - void blockWmClose() { _wm_close_blocked = true; } - - /** - * Unblock WM_CLOSE events for the main window. - **/ - void unblockWmClose() { _wm_close_blocked = false; } - /** * Check if dialogs are to be activated automatically **/ @@ -284,11 +260,6 @@ void askConfigureLogging(); /** - * Fun stuff (release dependent) - **/ - void easterEgg(); - - /** * A mouse click with the wrong mouse button was detected - e.g., a right * click on a push button. The user might be left-handed, but his mouse * might not (yet) be configured for left-handed use - e.g., during @@ -300,13 +271,6 @@ void maybeLeftHandedUser(); -signals: - /** - * Emitted upon WM_CLOSE - **/ - void wmClose(); - - protected: /** @@ -353,21 +317,6 @@ **/ void closeDialog( YDialog * dialog ); - /** - * Grab show events and work around QWidgetStack bug. - * - * Reimplemented from QObject. - **/ - bool eventFilter( QObject * obj, QEvent * ev ); - - /** - * Make all UI windows usable without a mouse - even predefined Qt dialogs - * that don't know the UI's dialogs' activate() magic. - * - * Reimplemented from QObject. - **/ - bool showEventFilter( QObject * obj, QEvent * ev ); - public: @@ -551,21 +500,11 @@ // /** - * Assume presence of a window manager - **/ - bool _have_wm; - - /** * Use the entire available screen **/ bool _fullscreen; /** - * Decorate the toplevel window - **/ - bool _decorate_toplevel_window; - - /** * 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. @@ -573,21 +512,6 @@ QVBox * _main_win; /** - * Stack for the Qt widgets inside the main window. - **/ - QWidgetStack * _widget_stack; - - /** - * Stack to keep track of the stacking order of popup dialogs. - **/ - vector<QWidget *> _popup_stack; - - /** - * Numeric ID for defaultsize dialogs for the widget stack - **/ - int _main_dialog_id; - - /** * Size for `opt(`defaultsize) dialogs. **/ QSize _default_size; @@ -607,11 +531,6 @@ bool _do_exit_loop; /** - * Window manager close events blocked? - **/ - bool _wm_close_blocked; - - /** * Force new dialogs to the foreground and grab the keyboard focus? * (Only if running without a window manager) **/ Modified: trunk/qt/src/YQUI_core.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_core.cc?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQUI_core.cc (original) +++ trunk/qt/src/YQUI_core.cc Wed Dec 5 19:28:34 2007 @@ -38,7 +38,6 @@ #include "YQOptionalWidgetFactory.h" #include "YEvent.h" #include "YUISymbols.h" -#include "YQEBunny.h" #include "utf8.h" #include "YQDialog.h" @@ -58,18 +57,14 @@ : QObject() , YUI( with_threads ) , _main_win( NULL ) - , _main_dialog_id(0) , _do_exit_loop( false ) - , _wm_close_blocked( false ) , _auto_activate_dialogs( true ) { y2debug( "YQUI constructor start" ); _ui = this; _fatal_error = false; - _have_wm = true; _fullscreen = false; - _decorate_toplevel_window = true; _usingVisionImpairedPalette = false; _leftHandedMouse = false; _askedForLeftHandedMouse = false; @@ -85,7 +80,6 @@ // Qt keeps track to a global QApplication in qApp. CHECK_PTR( qApp ); - qApp->installEventFilter( this ); processCommandLineArgs( argc, argv ); calcDefaultSize(); @@ -95,30 +89,21 @@ // We have to use something else than QWidgetStack since QWidgetStack // doesn't accept a WFlags arg which we badly need here. - WFlags wflags = WType_TopLevel; - - if ( ! _decorate_toplevel_window ) - { - y2debug( "Suppressing WM decorations for toplevel window" ); - wflags |= WStyle_Customize | WStyle_NoBorder; - } - // if we have a window already, delete it if (_main_win) delete _main_win; - _main_win = new QVBox( 0, 0, wflags ); // parent, name, wflags - + _main_win = new QVBox( 0, 0, WType_TopLevel ); // parent, name, wflags - // Create widget stack for `opt(`defaultsize) dialogs - _widget_stack = new QWidgetStack( _main_win ); +#if 0 + // still needed? _widget_stack->setFocusPolicy( QWidget::StrongFocus ); - qApp->setMainWidget( _main_win ); - _main_win->installEventFilter( this ); +#endif + _main_win->resize( _default_size ); - if ( _fullscreen || ! _have_wm ) + if ( _fullscreen ) _main_win->move( 0, 0 ); @@ -219,9 +204,7 @@ if ( opt.startsWith( "--" ) ) opt.remove(0, 1); - if ( opt == QString( "-no-wm" ) ) _have_wm = false; - else if ( opt == QString( "-fullscreen" ) ) _fullscreen = true; - else if ( opt == QString( "-noborder" ) ) _decorate_toplevel_window = false; + if ( opt == QString( "-fullscreen" ) ) _fullscreen = true; else if ( opt == QString( "-auto-font" ) ) yqApp()->setAutoFonts( true ); else if ( opt == QString( "-auto-fonts" ) ) yqApp()->setAutoFonts( true ); // --macro is handled by YUI_component @@ -231,7 +214,6 @@ "Command line options for the YaST2 Qt UI:\n" "\n" "--nothreads run without additional UI threads\n" - "--no-wm assume no window manager is running\n" "--fullscreen use full screen for `opt(`defaultsize) dialogs\n" "--noborder no window manager border for `opt(`defaultsize) dialogs\n" "--auto-fonts automatically pick fonts, disregard Qt standard settings\n" @@ -309,10 +291,11 @@ y2milestone( "-fullscreen: using %dx%d for `opt(`defaultsize)", _default_size.width(), _default_size.height() ); } - else if ( _have_wm ) + else { // Get _default_size via -geometry command line option (if set) + // FIXME there must be a better and simpler way to do this QWidget * dummy = new QWidget(); dummy->hide(); qApp->setMainWidget( dummy ); @@ -342,11 +325,6 @@ _default_size.width(), _default_size.height() ); } } - else // ! _have_wm - { - _default_size = primaryScreenSize; - } - y2milestone( "Default size: %dx%d", _default_size.width(), _default_size.height() ); } @@ -421,7 +399,9 @@ if ( timeout_millisec > 0 ) _user_input_timer.start( timeout_millisec, true ); // single shot +#if 0 dialog->activate( true ); +#endif if ( qApp->focusWidget() ) qApp->focusWidget()->setFocus(); @@ -436,7 +416,9 @@ _do_exit_loop = false; event = _event_handler.consumePendingEvent(); +#if 0 dialog->activate( false ); +#endif // Display a busy cursor, but only if there is no other activity within // BUSY_CURSOR_TIMEOUT milliseconds (avoid cursor flicker) @@ -464,10 +446,14 @@ if ( dialog ) { +#if 0 dialog->activate( true ); +#endif qApp->processEvents(); event = _event_handler.consumePendingEvent(); +#if 0 dialog->activate( false ); +#endif } } @@ -485,66 +471,15 @@ } -#warning obsolete -#if 0 -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. - - if ( ! has_defaultsize && ! _popup_stack.empty() ) - qt_parent = _popup_stack.back(); - - YQDialog * dialog = new YQDialog( opt, qt_parent, has_defaultsize ); - CHECK_PTR( dialog ); - - if ( ! has_defaultsize ) - _popup_stack.push_back( (QWidget *) dialog->widgetRep() ); - - return dialog; -} -#endif - - void YQUI::showDialog( YDialog * dialog ) { QWidget * qw = (QWidget *) dialog->widgetRep(); - - if ( ! qw ) - { - y2error( "No widgetRep() for dialog" ); - return; - } - - if ( dialog->dialogType() == YMainDialog ) - { - _widget_stack->addWidget ( qw, ++_main_dialog_id ); - _widget_stack->raiseWidget( qw ); // maybe this is not necessary (?) - - if ( ! _main_win->isVisible() ) - { - // y2milestone( "Showing main window" ); - _main_win->resize( _default_size ); - - if ( ! _have_wm ) - _main_win->move( 0, 0 ); - - _main_win->show(); - qw->setFocus(); - } - } - else // non-defaultsize dialog + + if ( qw ) { qw->show(); + qw->raise(); + qw->update(); } ( (YQDialog *) dialog)->ensureOnlyOneDefaultButton(); @@ -554,61 +489,6 @@ void YQUI::closeDialog( YDialog * dialog ) { - QWidget * qw = (QWidget *) dialog->widgetRep(); - - if ( ! qw ) - { - y2error( "No widgetRep() for dialog" ); - return; - } - - if ( dialog->dialogType() == YMainDialog ) - { - _widget_stack->removeWidget( qw ); - - if ( --_main_dialog_id < 1 ) // nothing left on the stack - { - // y2milestone( "Hiding main window" ); - _main_win->hide(); - _main_dialog_id = 0; // this should not be necessary - but better be safe than sorry - } - else - { - // FIXME: This is anti-social behaviour - do this only in the inst-sys - _widget_stack->raiseWidget( _main_dialog_id ); - } - } - else // non-defaultsize dialog - { - qw->hide(); - -#warning FIXME -#if 0 - // Clean up the popup stack. libyui guarantees that a dialog will be - // deleted after closeDialog() so it is safe to pop that dialog from - // the popup stack here. - - if ( ! _popup_stack.empty() && _popup_stack.back() == qw ) - _popup_stack.pop_back(); - else - y2error( "Popup dialog stack corrupted!" ); -#endif - } -} - - -void YQUI::easterEgg() -{ - y2milestone( "Starting easter egg..." ); - - - YQEasterBunny::layEgg(); - y2milestone( "Done." ); - -#if 0 - // desktop()->repaint() has no effect - we need to do it the hard way. - system( "/usr/X11R6/bin/xrefresh" ); -#endif } Modified: trunk/qt/src/YQUI_x11.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_x11.cc?rev=42730&r1=42729&r2=42730&view=diff ============================================================================== --- trunk/qt/src/YQUI_x11.cc (original) +++ trunk/qt/src/YQUI_x11.cc Wed Dec 5 19:28:34 2007 @@ -82,10 +82,7 @@ int YQUI::defaultSize(YUIDimension dim) const { - if ( haveWM() ) - return dim == YD_HORIZ ? _default_size.width() : _default_size.height(); - else - return dim == YD_HORIZ ? qApp->desktop()->width() : qApp->desktop()->height(); + return dim == YD_HORIZ ? _default_size.width() : _default_size.height(); } @@ -184,81 +181,6 @@ } -bool YQUI::eventFilter( QObject * obj, QEvent * ev ) -{ - if ( ev->type() == QEvent::Close ) - { - // Handle WM_CLOSE - but only if it comes from a dialog that is managed by the UI, - // not from an independent Qt dialog (such as the package selector popups) - - QWidget * objDialog = 0; - - if ( obj && obj->isWidgetType() ) - { - objDialog = (QWidget *) obj; - objDialog = objDialog->topLevelWidget(); - } - - if ( objDialog && - ( objDialog == mainWidget() || - objDialog == (QObject *) YDialog::currentDialog()->widgetRep() ) ) - { - emit wmClose(); - - if ( ! _wm_close_blocked ) - { - // Don't simply close the application window, return from UserInput() - // with `id(`cancel) and let the YCP application decide how to handle - // that (e.g., ask for confirmation). - - y2debug( "Caught window close event - returning with `cancel" ); - sendEvent( new YCancelEvent() ); - } - - return true; // Event processed - } - } - else if ( ev->type() == QEvent::Show ) - { - if ( obj == _main_win ) - { - if ( _main_dialog_id > 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 ); - } - } - else - { - return showEventFilter( obj, ev ); - } - } - - return false; // Don't stop event processing -} - - -bool YQUI::showEventFilter( QObject * obj, QEvent * ev ) -{ - if ( ! haveWM() ) - { - // Make sure newly opened windows get the keyboard focus even without a - // window manager. Otherwise the app might be unusable without a mouse. - - QWidget * widget = dynamic_cast<QWidget *> (obj); - - if ( widget ) - widget->setActiveWindow(); - } - - return false; // Don't stop event processing -} - - /** * UI-specific conversion from logical layout spacing units (80x25) * to device dependent units (640x480). -- 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