From: vsr Date: Wed, 11 Jul 2007 14:19:01 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f69fdbb2fdbd575693c85d16b744a11e624ff58c;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index d32f6da9b..92a7c2325 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1667,7 +1667,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) PyConsole_Console* pyCons = new PyConsole_Console( desktop() ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); wid = pyCons; - // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); + pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } #endif else if ( flag == WT_LogWindow ) diff --git a/src/Qtx/Makefile.am b/src/Qtx/Makefile.am index d6b553513..36c435bea 100755 --- a/src/Qtx/Makefile.am +++ b/src/Qtx/Makefile.am @@ -49,6 +49,7 @@ salomeinclude_HEADERS= \ QtxLogoMgr.h \ QtxMainWindow.h \ QtxMap.h \ + QtxMultiAction.h \ QtxMRUAction.h \ QtxPagePrefMgr.h \ QtxPathDialog.h \ @@ -100,6 +101,7 @@ dist_libqtx_la_SOURCES= \ QtxListAction.cxx \ QtxLogoMgr.cxx \ QtxMainWindow.cxx \ + QtxMultiAction.cxx \ QtxMRUAction.cxx \ QtxPagePrefMgr.cxx \ QtxPathDialog.cxx \ @@ -145,6 +147,7 @@ MOC_FILES= \ QtxListAction_moc.cxx \ QtxLogoMgr_moc.cxx \ QtxMainWindow_moc.cxx \ + QtxMultiAction_moc.cxx \ QtxMRUAction_moc.cxx \ QtxPagePrefMgr_moc.cxx \ QtxPathDialog_moc.cxx \ diff --git a/src/Qtx/QtxActionSet.cxx b/src/Qtx/QtxActionSet.cxx index 7625022ec..6f6ab940c 100644 --- a/src/Qtx/QtxActionSet.cxx +++ b/src/Qtx/QtxActionSet.cxx @@ -377,6 +377,11 @@ void QtxActionSet::updateAction( QWidget* w ) } } +/*! + \brief Check if the action itself should be invisible + (only child action are shown) + \return \c true if the action itself should be visible +*/ bool QtxActionSet::isEmptyAction() const { return true; diff --git a/src/Qtx/QtxMultiAction.cxx b/src/Qtx/QtxMultiAction.cxx index c0f00bb4a..30b0c5550 100644 --- a/src/Qtx/QtxMultiAction.cxx +++ b/src/Qtx/QtxMultiAction.cxx @@ -16,6 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File: QtxMultiAction.cxx +// Author: Sergey TELKOV +// #include "QtxMultiAction.h" @@ -27,13 +30,48 @@ #include #include +/*! + \class QtxMultiAction::Filter + \brief Waches for the buttons in the popup menu + to update the tool buttons state. + \internal +*/ + +class QtxMultiAction::Filter : public QObject +{ +public: + //! \brief Constructor + Filter( QObject* parent ) : QObject( parent ) {} + //! \brief Destructor + ~Filter() {} + //! \brief Process events from the child tool buttons + bool eventFilter( QObject* o, QEvent* e ) + { + if ( e->type() == QEvent::Leave ) { + QToolButton* tb = qobject_cast( o ); + if ( tb ) + tb->setDown( false ); + } + return QObject::eventFilter( o, e ); + } +}; + +/*! + \class QtxMultiAction::Button + \brief Custom button to be used in the toolbar. + \internal +*/ + class QtxMultiAction::Button : public QToolButton { public: + //! \brief Constructor Button( QWidget* parent = 0 ) : QToolButton( parent ) {} + //! \brief Destructor ~Button() {}; protected: + //! \brief Paint the button virtual void paintEvent( QPaintEvent* e ) { QToolButton::paintEvent( e ); @@ -56,11 +94,26 @@ protected: }; /*! - Constructor + \class QtxMultiAction + \brief The class QtxMultiAction implements modifiable action. + + The QtxMultiAction class provides a possibility to assign a set of actions + (insertAction() function). The action can be used in the toolbar (and even + in the menu) to show drop-down menu with the list of the assigned actions. + + Initially the first action from the list becomes current and it is activated + when the tool button is clicked by the user. If user presses and holds the mouse + button at the tool button, it shows the popup menu with all the assigned actions. + When the user selects any action from the popup menu, it becames current. +*/ + +/*! + \brief Constructor. + \param parent parent object */ QtxMultiAction::QtxMultiAction( QObject* parent ) : QtxActionSet( parent ), -myCurrent( 0 ) + myCurrent( 0 ) { setVisible( true ); setMenu( new QMenu( 0 ) ); @@ -68,9 +121,14 @@ myCurrent( 0 ) connect( this, SIGNAL( triggered( QAction* ) ), this, SLOT( onTriggered( QAction* ) ) ); } +/*! + \brief Constructor. + \param txt action menu text + \param parent parent object +*/ QtxMultiAction::QtxMultiAction( const QString& txt, QObject* parent ) : QtxActionSet( parent ), -myCurrent( 0 ) + myCurrent( 0 ) { setText( txt ); setVisible( true ); @@ -79,9 +137,15 @@ myCurrent( 0 ) connect( this, SIGNAL( triggered( QAction* ) ), this, SLOT( onTriggered( QAction* ) ) ); } +/*! + \brief Constructor. + \param ico action menu icon + \param txt action menu text + \param parent parent object +*/ QtxMultiAction::QtxMultiAction( const QIcon& ico, const QString& txt, QObject* parent ) : QtxActionSet( parent ), -myCurrent( 0 ) + myCurrent( 0 ) { setIcon( ico ); setText( txt ); @@ -91,16 +155,29 @@ myCurrent( 0 ) connect( this, SIGNAL( triggered( QAction* ) ), this, SLOT( onTriggered( QAction* ) ) ); } +/*! + \brief Destructor +*/ QtxMultiAction::~QtxMultiAction() { } -void QtxMultiAction::onClicked( bool ) +/*! + \brief Called when the user activates the current action + (for example by clicking the tool button). + \param on (not used) +*/ +void QtxMultiAction::onClicked( bool /*on*/ ) { if ( myCurrent ) myCurrent->activate( QAction::Trigger ); } +/*! + \brief Called when user activates any action from the + dropdown menu. + \param a action being activated +*/ void QtxMultiAction::onTriggered( QAction* a ) { if ( !a ) @@ -121,6 +198,9 @@ void QtxMultiAction::onTriggered( QAction* a ) } } +/*! + \brief Update action. +*/ void QtxMultiAction::updateAction() { QtxActionSet::updateAction(); @@ -130,6 +210,10 @@ void QtxMultiAction::updateAction() updateButton( ::qobject_cast( *it ) ); } +/*! + \brief Update child (popup menu) action. + \param w widget menu widget +*/ void QtxMultiAction::updateAction( QWidget* w ) { if ( !w ) @@ -147,11 +231,21 @@ void QtxMultiAction::updateAction( QWidget* w ) } } +/*! + \brief Check if the action itself should be invisible + (only child action are shown) + \return \c true if the action itself should be visible +*/ bool QtxMultiAction::isEmptyAction() const { return false; } +/*! + \brief Create widget to be displayed in the toolbar. + \param parent parent widget (should be toolbar) + \return toolbar button +*/ QWidget* QtxMultiAction::createWidget( QWidget* parent ) { QToolBar* tb = ::qobject_cast( parent ); @@ -173,12 +267,20 @@ QWidget* QtxMultiAction::createWidget( QWidget* parent ) return w; } +/*! + \brief Called when the child action is added to this action. + \param a child action being added +*/ void QtxMultiAction::actionAdded( QAction* a ) { if ( !myCurrent ) myCurrent = a; } +/*! + \brief Called when the child action is removed from this action. + \param a child action being removed +*/ void QtxMultiAction::actionRemoved( QAction* a ) { if ( myCurrent != a ) @@ -189,6 +291,10 @@ void QtxMultiAction::actionRemoved( QAction* a ) updateAction(); } +/*! + \brief Update toolbar button. + \param btn toolbar button +*/ void QtxMultiAction::updateButton( QToolButton* btn ) { if ( !btn ) @@ -212,7 +318,7 @@ void QtxMultiAction::updateButton( QToolButton* btn ) QVBoxLayout* vbox = new QVBoxLayout( pm ); vbox->setMargin( 1 ); vbox->setSpacing( 0 ); - + Filter* filter = new Filter( vbox ); QList actList = actions(); for ( QList::iterator itr = actList.begin(); itr != actList.end(); ++itr ) { @@ -223,12 +329,7 @@ void QtxMultiAction::updateButton( QToolButton* btn ) b->setIconSize( btn->iconSize() ); b->setToolButtonStyle( btn->toolButtonStyle() ); b->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + b->installEventFilter( filter ); vbox->addWidget( b ); } - -/* - QList actList = actions(); - for ( QList::iterator itr = actList.begin(); itr != actList.end(); ++itr ) - pm->addAction( *itr ); -*/ } diff --git a/src/Qtx/QtxMultiAction.h b/src/Qtx/QtxMultiAction.h index e778efd17..fbf239836 100644 --- a/src/Qtx/QtxMultiAction.h +++ b/src/Qtx/QtxMultiAction.h @@ -16,6 +16,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File: QtxMultiAction.h +// Author: Sergey TELKOV +// + #ifndef QTXMULTIACTION_H #define QTXMULTIACTION_H @@ -28,6 +32,7 @@ class QTX_EXPORT QtxMultiAction : public QtxActionSet Q_OBJECT class Button; + class Filter; public: QtxMultiAction( QObject* parent = 0 ); @@ -56,4 +61,4 @@ private: QAction* myCurrent; }; -#endif +#endif // QTXMULTIACTION_H diff --git a/src/Qtx/QtxSplash.cxx b/src/Qtx/QtxSplash.cxx index 1de1ba6a0..c954e9b0c 100644 --- a/src/Qtx/QtxSplash.cxx +++ b/src/Qtx/QtxSplash.cxx @@ -41,7 +41,7 @@ public: \param msg progress message \param progress current progress (for example, in %) */ - ProgressEvent( const QString& msg, const int progress = 0 ) + ProgressEvent( const QString& msg, const int progress ) : QEvent( (QEvent::Type)id() ), myMessage( msg ), myProgress( progress ) @@ -143,6 +143,11 @@ private: The displayed message text includes constant info and status message. The constant info is set by setConstantInfo() method and status message is set by setMessage(). + + Sometimes it is useful to splay an error message above the splash screen window. + For example, it can be necessary if an error occurs when loading the application. + Method setError() can be used to show the error message and set the error code which + can be then retrieved with the error() function. */ //! The only one instance of splash screen @@ -203,8 +208,9 @@ QtxSplash* QtxSplash::splash( const QPixmap& px ) \brief Send the status message and (optionally) current progress to the splash screen. - This function can be used, for example, from an external thread - which checks the application loading progress. + If the second parameter is less than 0 (default) than it is ignored + and only the status message is changed. If you want to modify progress + also, pass positive value to the \a progress parameter explicitly. \param msg progress status message \param progress current progress @@ -223,8 +229,9 @@ void QtxSplash::setStatus( const QString& msg, const int progress ) \param error error message \param title message box title \param code error code + \sa error() */ -void QtxSplash::error( const QString& error, const QString& title, const int code ) +void QtxSplash::setError( const QString& error, const QString& title, const int code ) { if ( mySplash ) { mySplash->setError( code ); @@ -662,6 +669,7 @@ QString QtxSplash::message() const If no error code has been set, 0 is returned. \return last error code + \sa setError() */ int QtxSplash::error() const { @@ -799,7 +807,8 @@ void QtxSplash::customEvent( QEvent* ce ) if ( ce->type() == ProgressEvent::id() ) { ProgressEvent* pe = (ProgressEvent*)ce; pe->message().isEmpty() ? clear() : setMessage( pe->message() ); - setProgress( pe->progress() ); + if ( pe->progress() >= 0 ) + setProgress( pe->progress() ); QApplication::instance()->processEvents(); } } diff --git a/src/Qtx/QtxSplash.h b/src/Qtx/QtxSplash.h index d59c38c68..280851166 100644 --- a/src/Qtx/QtxSplash.h +++ b/src/Qtx/QtxSplash.h @@ -61,8 +61,8 @@ public: static QtxSplash* splash( const QPixmap& = QPixmap() ); - static void setStatus( const QString&, const int = 0 ); - static void error( const QString&, const QString& = QString::null, const int = -1 ); + static void setStatus( const QString&, const int = -1 ); + static void setError( const QString&, const QString& = QString::null, const int = -1 ); void setPixmap( const QPixmap& ); QPixmap pixmap() const; diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 78caf6a05..1b4668852 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -475,7 +475,7 @@ int main( int argc, char **argv ) QString msg = sc.currentMessage(); QString err = sc.error(); if ( !err.isEmpty() ) { - QtxSplash::error( err ); + QtxSplash::setError( err ); QApplication::instance()->processEvents(); result = -1; break; diff --git a/src/Session/Session_ServerCheck.cxx b/src/Session/Session_ServerCheck.cxx index d037a5b76..27535f84f 100644 --- a/src/Session/Session_ServerCheck.cxx +++ b/src/Session/Session_ServerCheck.cxx @@ -158,6 +158,8 @@ Session_ServerCheck::Session_ServerCheck( QMutex* mutex, QWaitCondition* wc ) */ Session_ServerCheck::~Session_ServerCheck() { + terminate(); + while( isRunning() ); } /*!