From dd842ff623fd2dc1c42c47c7d2b48814ad948b79 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 27 Sep 2017 17:13:38 +0300 Subject: [PATCH] refs #1332: dynamic layout for profiles dialog --- src/HYDROGUI/HYDROGUI_InputPanel.cxx | 10 ++++++++-- src/HYDROGUI/HYDROGUI_InputPanel.h | 3 ++- src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 14 ++++++++------ src/HYDROGUI/HYDROGUI_ViewerDlg.cxx | 10 +++------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 3ece51e8..2c058db3 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -124,16 +124,22 @@ void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event ) emit panelCancel(); } +void HYDROGUI_InputPanel::insertWidget( QWidget* theWidget, int theIndex, int theStretch ) +{ + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->insertWidget( theIndex, theWidget, theStretch ); +} + void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch ) { QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); aMainLayout->addWidget( theWidget, theStretch ); } -void HYDROGUI_InputPanel::addLayout( QLayout* theLayout ) +void HYDROGUI_InputPanel::addLayout( QLayout* theLayout, int theStretch ) { QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addLayout( theLayout ); + aMainLayout->addLayout( theLayout, theStretch ); } void HYDROGUI_InputPanel::addStretch() diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 414c13f9..351b3cdc 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -40,7 +40,8 @@ public: virtual ~HYDROGUI_InputPanel(); void addWidget( QWidget* theWidget, int theStretch = 0 ); - void addLayout( QLayout* theLayout ); + void insertWidget( QWidget* theWidget, int theIndex, int theStretch = 0 ); + void addLayout( QLayout* theLayout, int theStretch = 0 ); void addStretch(); HYDROGUI_Module* module() const; diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 8e1ed22c..98767efd 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -45,13 +45,15 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr : HYDROGUI_ViewerDlg( theModule, theTitle ), myName( NULL ) { - QHBoxLayout* aNameLayout = new QHBoxLayout(); + QFrame* name_frame = new QFrame( mainFrame() ); + QHBoxLayout* name_layout = new QHBoxLayout( name_frame ); + name_layout->setMargin( 0 ); QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this); - aNameLayout->addWidget(aNameLabel); + name_layout->addWidget(aNameLabel); myName = new QLineEdit(this); - aNameLayout->addWidget(myName); + name_layout->addWidget(myName); - addLayout(aNameLayout); + insertWidget( name_frame, 0, 0); int anActionFlags = CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode | @@ -59,10 +61,10 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr QStringList aCoordTitles; aCoordTitles << tr( "U_TITLE" ) << tr( "Z_TITLE" ); myEditorWidget = new CurveCreator_Widget( this, NULL, anActionFlags, aCoordTitles ); - addWidget( myEditorWidget, 3 ); + insertWidget( myEditorWidget, 1, 1 ); myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this ); - addWidget( myAddElementBox, 2 ); + insertWidget( myAddElementBox, 2, 1 ); QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox ); anAddElementLayout->setMargin( 0 ); diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx index 8be7fa37..1a8a6c36 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -46,10 +46,6 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { - QWidget* viewMain = new QWidget( mainFrame() ); - QVBoxLayout* viewBase = new QVBoxLayout( viewMain ); - viewBase->setMargin( 0 ); - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( true ); @@ -86,7 +82,7 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin anAISContext->Deactivate( aTrihedron ); } */ - viewBase->addWidget( aViewWin ); + addWidget( aViewWin, 1 ); // Coordinates connect( myViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), @@ -99,8 +95,8 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin aViewFrame->getViewPort()->installEventFilter( this ); } - myCoordLabel = new QLabel( viewMain ); - viewBase->addWidget( myCoordLabel ); + myCoordLabel = new QLabel( mainFrame() ); + addWidget( myCoordLabel, 0 ); } HYDROGUI_ViewerDlg::~HYDROGUI_ViewerDlg() -- 2.39.2