Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 4355bf72 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Widget stack modified so as to make it possible to split the screen in two and...

Widget stack modified so as to make it possible to split the screen in two and to keep the previous widget in one of the two sub-windows.
parent 835264c5
......@@ -939,26 +939,110 @@ void UIMainWindow::releaseCentralWidgetStack()
void UIMainWindow::pushCentralWidget( QWidget* widget )
{
if( !m_CentralWidgetStack.isEmpty() )
m_CentralWidgetStack.last()->hide();
m_CentralWidgetStack.last().widget->hide();
m_CentralWidgetStack.append( widget );
WidgetStackItem stackItem;
stackItem.isSplit = false;
stackItem.widget = widget;
m_CentralWidgetStack.append( stackItem );
centralWidget()->layout()->addWidget( widget );
widget->show();
}
void UIMainWindow::splitCentralWidget( QWidget* widget, Qt::Orientation orientation, Qt::AlignmentFlag location, float spaceRatio )
{
assert( !m_CentralWidgetStack.isEmpty() );
//assert( orientation == Qt::Horizontal && (location == Qt::AlignLeft || location == Qt::AlignRight ) );
//assert( orientation == Qt::Vertical && (location == Qt::AlignTop || location == Qt::AlignBottom) );
QWidget *previous = m_CentralWidgetStack.last().widget;
QGridLayout *layout = new QGridLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 4 );
if( orientation == Qt::Horizontal )
{
widget->setMaximumWidth( spaceRatio*previous->width() );
if( location == Qt::AlignLeft )
{
layout->addWidget( widget , 0,0 );
layout->addWidget( previous, 0,1 );
}
else
{
layout->addWidget( widget , 0,1 );
layout->addWidget( previous, 0,0 );
}
}
else
{
widget->setMaximumHeight( spaceRatio*previous->height() );
if( location == Qt::AlignTop )
{
layout->addWidget( widget , 0,0 );
layout->addWidget( previous, 1,0 );
}
else
{
layout->addWidget( widget , 1,0 );
layout->addWidget( previous, 0,0 );
}
}
WidgetStackItem stackItem;
stackItem.isSplit = true;
stackItem.widget = new QWidget();
stackItem.widget->setLayout( layout );
m_CentralWidgetStack.append( stackItem );
centralWidget()->layout()->addWidget( stackItem.widget );
widget->show();
}
void UIMainWindow::popCentralWidget()
{
QWidget *widget = m_CentralWidgetStack.takeLast();
widget->hide();
WidgetStackItem stackItem = m_CentralWidgetStack.takeLast();
stackItem.widget->hide();
if( !m_CentralWidgetStack.isEmpty() )
m_CentralWidgetStack.last()->show();
if( stackItem.isSplit )
{
QWidget *widgetToDelete, *widgetToKeep;
for( auto obj : stackItem.widget->children() )
if( QWidget *w = dynamic_cast<QWidget*>(obj) )
{
if( w == m_CentralWidgetStack.last().widget )
widgetToKeep = w;
else
widgetToDelete = w;
}
centralWidget()->layout()->removeWidget( stackItem.widget );
stackItem.widget->setParent( NULL );
stackItem.widget->layout()->removeWidget( widgetToKeep );
widgetToKeep->setParent( NULL );
centralWidget()->layout()->addWidget( widgetToKeep );
delete stackItem.widget;
centralWidget()->layout()->removeWidget( widget );
widget->setParent( NULL );
delete widget;
widgetToKeep->show();
}
else
{
centralWidget()->layout()->removeWidget( stackItem.widget );
stackItem.widget->setParent( NULL );
delete stackItem.widget;
if( !m_CentralWidgetStack.isEmpty() )
m_CentralWidgetStack.last().widget->show();
}
}
......
......@@ -75,7 +75,13 @@ class GUIMAIN_API UIMainWindow : public QMainWindow
static const int RECENT_PROJECT_MAX_LIST_SIZE = 8;
QList< QAction* > m_RecentProjects;
QList< QWidget* > m_CentralWidgetStack;
struct WidgetStackItem
{
QWidget* widget;
bool isSplit;
};
QList< WidgetStackItem > m_CentralWidgetStack;
public:
UIMainWindow(QWidget *parent = 0);
......@@ -177,6 +183,7 @@ public slots:
void projectListContentDropped(QDropEvent* evt);
void pushCentralWidget( QWidget* widget );
void splitCentralWidget( QWidget* widget, Qt::Orientation orientation, Qt::AlignmentFlag location, float spaceRatio );
void popCentralWidget();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment