From ca2a0e8478e84f8b0ea3e5ddab4daac32784bf2b Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 19 Nov 2020 15:35:51 +0300 Subject: [PATCH] InfoPanel introduction v5. --- src/LightApp/LightApp_Application.cxx | 44 +++++++++---- src/LightApp/LightApp_Application.h | 1 + src/LightApp/resources/LightApp.xml | 9 +-- src/LightApp/resources/LightApp_msg_en.ts | 16 +++++ src/LightApp/resources/LightApp_msg_fr.ts | 16 +++++ src/LightApp/resources/LightApp_msg_ja.ts | 16 +++++ src/Qtx/QtxInfoPanel.cxx | 80 +++++++++++++---------- src/Qtx/QtxInfoPanel.h | 6 +- src/STD/resources/STD_msg_en.ts | 8 +-- 9 files changed, 141 insertions(+), 55 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index bb80f17f6..72b13bda9 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -605,26 +605,24 @@ void LightApp_Application::createActions() QString url = resMgr->stringValue("GUI", "site_url"); if ( !url.isEmpty() ) { QString title = tr ( "SALOME_SITE" ); - QAction* as = createAction( id, title, + QAction* as = createAction( WebSiteId, title, resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ), title, title, 0, desk, false, this, SLOT( onHelpContentsModule() ) ); as->setData( url ); createMenu( as, helpMenu, -1, 0 ); - id++; } // b) Link to Forum url = resMgr->stringValue("GUI", "forum_url"); if ( !url.isEmpty() ) { QString title = tr ( "SALOME_FORUM" ); - QAction* af = createAction( helpMenu, title, + QAction* af = createAction( ForumId, title, resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ), title, title, 0, desk, false, this, SLOT( onHelpContentsModule() ) ); af->setData( url ); createMenu( af, helpMenu, -1, 0 ); - id++; } // c) Link to YouTube channel @@ -632,16 +630,28 @@ void LightApp_Application::createActions() if ( !url.isEmpty() ) { createMenu( separator(), helpMenu, -1, 0 ); QString title = tr ( "SALOME_VIDEO_TUTORIALS" ); - QAction* av = createAction( helpMenu, title, + QAction* av = createAction( VideosId, title, resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ), - title, title, + title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ), 0, desk, false, this, SLOT( onHelpContentsModule() ) ); av->setData( url ); createMenu( av, helpMenu, -1, 0 ); - id++; } - // d) Help for modules + // d) Link to Tutorials + + url = resMgr->stringValue("GUI", "tutorials_url"); + if ( !url.isEmpty() ) { + QString title = tr ( "SALOME_TUTORIALS" ); + QAction* as = createAction( TutorialsId, title, + resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ), + title, tr( "PRP_SALOME_TUTORIALS" ), + 0, desk, false, this, SLOT( onHelpContentsModule() ) ); + as->setData( url ); + createMenu( as, helpMenu, -1, 0 ); + } + + // e) Help for modules // - First create top-level menus to preserve correct order QString userGuide = "User's Guide"; @@ -4154,14 +4164,26 @@ void LightApp_Application::updateWindows() loadDockWindowsState(); - if (!activeModule() && infoPanel() ) + if ( !activeModule() && infoPanel() ) { infoPanel()->clear(); + infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) ); + + int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) ); + infoPanel()->addAction( action( FileNewId ), grp ); + infoPanel()->addLabel( action( FileNewId )->statusTip(), grp ); + infoPanel()->addAction( action( FileOpenId ), grp ); + infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp ); + infoPanel()->addAction( action( TutorialsId ), grp ); + infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp ); + infoPanel()->addAction( action( VideosId ), grp ); + infoPanel()->addLabel( action( VideosId )->statusTip(), grp ); + LightApp_ModuleAction* ma = qobject_cast(action(ModulesListId)); if ( ma && ma->count() > 0 ) { - int grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) ); - foreach(QString mname, ma->modules()) + grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) ); + foreach ( QString mname, ma->modules() ) { infoPanel()->addAction( ma->moduleAction( mname ), grp ); if ( !moduleDescription( mname ).isEmpty() ) diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index b2df3e1d5..8f15d63b0 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -91,6 +91,7 @@ public: PreferencesId, MRUId, ModulesListId, NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, StyleId, FullScreenId, + WebSiteId, ForumId, VideosId, TutorialsId, UserID }; protected: diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 3371eec9f..aed32a11a 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -221,6 +221,7 @@
+
@@ -274,11 +275,11 @@
- - + +
- - + +
diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index afee886f9..8a2ffb82c 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -58,6 +58,18 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASSALOME_VIDEO_TUTORIALS Video Tutorials + + PRP_SALOME_VIDEO_TUTORIALS + Visit YouTube channel with some videos + + + SALOME_TUTORIALS + Tutorials + + + PRP_SALOME_TUTORIALS + Try tutorials from SALOME site + ENTRY_COLUMN Entry @@ -1125,6 +1137,10 @@ File does not exist PREF_PY_NUM_COLUMNS Number of columns: + + INFO_WELCOME_TO_SALOME + Welcome to SALOME + INFO_GETTING_STARTED Getting started diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index 899f3bd49..ad5568fc2 100644 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -58,6 +58,18 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASSALOME_VIDEO_TUTORIALS Video Tutorials + + PRP_SALOME_VIDEO_TUTORIALS + Visit YouTube channel with some videos + + + SALOME_TUTORIALS + Tutorials + + + PRP_SALOME_TUTORIALS + Try tutorials from SALOME site + ENTRY_COLUMN Entrée @@ -1125,6 +1137,10 @@ Le fichier n'existe pas PREF_PY_NUM_COLUMNS Nombre de colonnes: + + INFO_WELCOME_TO_SALOME + Welcome to SALOME + INFO_GETTING_STARTED Getting started diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index 06eadeb99..5688c2296 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -58,6 +58,18 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASSALOME_VIDEO_TUTORIALS Video Tutorials + + PRP_SALOME_VIDEO_TUTORIALS + Visit YouTube channel with some videos + + + SALOME_TUTORIALS + Tutorials + + + PRP_SALOME_TUTORIALS + Try tutorials from SALOME site + ENTRY_COLUMN エントリ @@ -1123,6 +1135,10 @@ Pythonファイルは、文字、数字、アンダースコアが含まれて PREF_PY_NUM_COLUMNS 列数 + + INFO_WELCOME_TO_SALOME + Welcome to SALOME + INFO_GETTING_STARTED Getting started diff --git a/src/Qtx/QtxInfoPanel.cxx b/src/Qtx/QtxInfoPanel.cxx index 43fde26a9..c90adb3e8 100644 --- a/src/Qtx/QtxInfoPanel.cxx +++ b/src/Qtx/QtxInfoPanel.cxx @@ -20,23 +20,23 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : InfoPanel.cxx -// Author : Viktor UZLOV, Open CASCADE S.A.S. (viktor.uzlov@opencascade.com) -// - #include "QtxInfoPanel.h" #include +#include #include #include #include -#include #include -#include +#include #include #include - +/*! + \class QtxInfoPanel::Container + \short Container to store widgets within info panel + \internal +*/ class QtxInfoPanel::Container: public QWidget { public: @@ -59,23 +59,6 @@ private: QGroupBox* group; }; -class QtxInfoPanel::TitleLabel: public QLabel -{ -public: - TitleLabel(const QString &text, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) : - QLabel(text, parent, f){ - this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QString color_bg = this->palette().color(QPalette::Highlight).darker().name(); - QString color_fg = this->palette().color(QPalette::HighlightedText).name(); - this->setStyleSheet(QString("QLabel {{background:%1; color:%2;}}").arg(color_bg).arg(color_fg)); - this->setTextFormat(Qt::PlainText); - QFont font= QFont(); - font.setBold(true); - this->setFont(font); - this->setContentsMargins(2, 5, 2, 5); - } -}; - QtxInfoPanel::Container::Container( QWidget* parent ) : QWidget( parent ), group( 0 ) { @@ -101,6 +84,9 @@ void QtxInfoPanel::Container::put( QWidget* widget ) void QtxInfoPanel::Container::addLabel( const QString& text, Qt::Alignment alignment, const int id ) { QLabel* label = new QLabel( text ); + QFont f = label->font(); + f.setItalic( true ); + label->setFont( f ); label->setAlignment( alignment ); label->setWordWrap( true ); put( label ); @@ -110,6 +96,7 @@ void QtxInfoPanel::Container::addLabel( const QString& text, Qt::Alignment align void QtxInfoPanel::Container::addAction( QAction* action, const int id ) { QToolButton* button = new QToolButton( this ); + button->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setAutoRaise( true ); button->setDefaultAction( action ); @@ -169,17 +156,47 @@ void QtxInfoPanel::Container::clear() } +/*! + \class QtxInfoPanel::Title + \short Info panel's title widget + \internal +*/ +class QtxInfoPanel::Title: public QLabel +{ +public: + Title( QWidget* parent = 0 ); +}; + +QtxInfoPanel::Title::Title( QWidget* parent ) + : QLabel( parent ) +{ + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + QString bg = palette().color( QPalette::Highlight ).name(); + QString fg = palette().color( QPalette::HighlightedText ).name(); + setStyleSheet( QString( "QLabel { background:%1; color:%2; }" ).arg( bg ).arg( fg ) ); + setTextFormat( Qt::PlainText ); + QFont f = font(); + f.setBold( true ); + setFont( f ); + setContentsMargins( 2, 5, 2, 5 ); +} + + +/*! + \class QtxInfoPanel + \short Info panel. +*/ QtxInfoPanel::QtxInfoPanel( QWidget* parent ) : QWidget( parent ) { + title = new Title( this ); container = new Container( this ); - QVBoxLayout* layout = new QVBoxLayout(this); - title = new TitleLabel(""); + QVBoxLayout* layout = new QVBoxLayout( this ); layout->setMargin( 0 ); layout->addWidget( title ); layout->addWidget( container ); layout->addStretch(); - title->setVisible(!title->text().isEmpty()); + setTitle( "" ); } QtxInfoPanel::~QtxInfoPanel() @@ -229,8 +246,8 @@ int QtxInfoPanel::addGroup( const QString& text, const int groupId ) void QtxInfoPanel::setTitle( const QString& text ) { - title->setText(text); - title->setVisible(!title->text().isEmpty()); + title->setText( text ); + title->setVisible( !title->text().isEmpty() ); } void QtxInfoPanel::remove( const int id ) @@ -240,11 +257,8 @@ void QtxInfoPanel::remove( const int id ) { Container* group = dynamic_cast( widget->parentWidget() ); if ( !group ) - { group = dynamic_cast( widget->parentWidget()->parentWidget() ); - group->remove( id ); - } - else + if ( group ) group->remove( id ); } } diff --git a/src/Qtx/QtxInfoPanel.h b/src/Qtx/QtxInfoPanel.h index 3c725d33f..4f4120dd6 100644 --- a/src/Qtx/QtxInfoPanel.h +++ b/src/Qtx/QtxInfoPanel.h @@ -38,17 +38,17 @@ class QTX_EXPORT QtxInfoPanel : public QWidget Q_OBJECT class Container; - class TitleLabel; + class Title; public: QtxInfoPanel( QWidget* = 0 ); ~QtxInfoPanel(); + void setTitle( const QString& ); int addLabel( const QString&, const int = -1 ); int addLabel( const QString&, Qt::Alignment, const int = -1 ); int addAction( QAction*, const int = -1 ); int addGroup( const QString&, const int = -1 ); - void setTitle( const QString& ); void remove( const int ); void clear( const int = -1 ); @@ -61,8 +61,8 @@ private: QWidget* find( const int ) const; private: + Title* title; Container* container; - TitleLabel* title; }; #ifdef WIN32 diff --git a/src/STD/resources/STD_msg_en.ts b/src/STD/resources/STD_msg_en.ts index 382d9db5a..0956e8f71 100644 --- a/src/STD/resources/STD_msg_en.ts +++ b/src/STD/resources/STD_msg_en.ts @@ -144,11 +144,11 @@ Directory with this name exist on disc. Try to use another name PRP_DESK_FILE_NEW - Creates a new document + Create a new document PRP_DESK_FILE_MRU - Opens a document + Open a document MEN_DESK_FILE_NEW @@ -376,7 +376,7 @@ Do you want to overwrite it? PRP_DESK_FILE_OPEN - Opens an existing document + Open an existing document PRP_DESK_FILE_REOPEN @@ -384,7 +384,7 @@ Do you want to overwrite it? PRP_DESK_FILE_SAVE - Saves the active document + Save the active document PRP_DESK_WINDOW_HTILE -- 2.39.2