]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/STD/STD_Application.cxx
Salome HOME
Merge V9_dev branch into master
[modules/gui.git] / src / STD / STD_Application.cxx
index 1dcd838cfdc53e86202571cd4c08e6aadab5ff59..b4f329fe75c4ca1fb9e5115adb06e043b5bb2d8c 100755 (executable)
@@ -53,6 +53,7 @@ extern "C" STD_EXPORT SUIT_Application* createApplication()
 STD_Application::STD_Application()
 : SUIT_Application(),
   myActiveViewMgr( 0 ),
+  myNotify( 0 ),
   myExitConfirm( true ),
   myEditEnabled( true )
 {
@@ -205,7 +206,8 @@ void STD_Application::createActions()
   createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(),
                 tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk  );
 
-  createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIcon(),
+  createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ),
+                resMgr->loadPixmap( "STD", tr( "ICON_DESK_ABOUT" ) ),
                 tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
                 Qt::ALT+Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) );
 
@@ -717,6 +719,56 @@ void STD_Application::updateCommandsStatus()
     action( NewWindowId )->setEnabled( aHasStudy );
 }
 
+/*!
+  \brief Show notification with specified text and title.
+  
+  Notification will be automatically hidden after specified \a timeout
+  (given in milliseconds). If \a timeout is zero, the notification
+  is not automatically hidden; it can be only closed by the user manually.
+  
+  \param text - Notification text
+  \param title - Notification title
+  \param timeout - Timeout in milliseconds
+  \return Notification's unique identifier
+*/
+int STD_Application::showNotification(const QString& message, const QString& title, int timeout)
+{
+  QtxNotify* ntfMgr = notifyMgr();
+  if (ntfMgr)
+  {
+    int delay = timeout;
+    if (delay < 0)
+    {
+      SUIT_ResourceMgr* aResMgr = resourceMgr();
+      if (aResMgr)
+       delay = aResMgr->integerValue("notification", "timeout", 0) * 1000;
+    }
+    ntfMgr->showNotification(message, title, qMax(delay, 0));
+  }
+}
+
+/*!
+  \brief Close notifications with specified text.
+  \param text - Notification text
+*/
+void STD_Application::hideNotification(const QString& message)
+{
+  QtxNotify* ntfMgr = notifyMgr();
+  if (ntfMgr)
+    ntfMgr->hideNotification(message);
+}
+
+/*!
+  \brief Closes the notifications with specified identifier.
+  \param id - Notification identifier
+*/
+void STD_Application::hideNotification(int id)
+{
+  QtxNotify* ntfMgr = notifyMgr();
+  if (ntfMgr)
+    ntfMgr->hideNotification(id);
+}
+
 /*!\retval SUIT_ViewManager by viewer manager type name.*/
 SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
 {
@@ -1033,3 +1085,27 @@ bool STD_Application::abortAllOperations()
 {
   return true;
 }
+
+/*!
+  \brief Gets the notification manager. Creates it if not exists.
+  \return \c notification manager instance
+*/
+QtxNotify* STD_Application::notifyMgr()
+{
+  if ( !myNotify )
+  {
+    myNotify = new QtxNotify(desktop());
+    myNotify->setWindow(desktop());
+
+    SUIT_ResourceMgr* aResMgr = resourceMgr();
+    if (aResMgr)
+    {
+      int anim = aResMgr->integerValue("notification", "animation", 0);
+      myNotify->setAnimationTime(anim);
+
+      double size = aResMgr->integerValue("notification", "size", 250);
+      myNotify->setNotificationSize(size);
+    }
+  }
+  return myNotify;
+}