Commit b4111356 authored by Frédéric Larue's avatar Frédéric Larue

Context menu added to rename the current project.

parent 9fb9b44d
......@@ -221,6 +221,10 @@ void UIMainWindow::init()
initializeCentralWidgetStack();
setViewerMode( DISPLAY_DOF_3D );
ui->comboProject->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui->comboProject, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showProjectContextMenu(QPoint)) );
connect( ui->comboProject, SIGNAL(currentIndexChanged(int)), this, SLOT(currentProjectChanged()) );
connect( ui->projectViewButtonCollapseAll, SIGNAL(clicked(bool)), ui->tableCurrentProjContent, SLOT(collapseAll()) );
connect( ui->projectViewButtonExpandAll, SIGNAL(clicked(bool)), ui->tableCurrentProjContent, SLOT(expandAll()) );
connect( ui->projectViewButtonExpandSelected, SIGNAL(clicked(bool)), ui->tableCurrentProjContent, SLOT(expandCollapseSelectedData()) );
......@@ -261,8 +265,6 @@ void UIMainWindow::init()
connect( m_CurrentViewer, SIGNAL(dataSelected(GenericUIData*,Qt::KeyboardModifiers)), ui->tableCurrentProjContent, SLOT(updateSelection(GenericUIData*,Qt::KeyboardModifiers)) );
connect( ui->tableCurrentProjContent, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()) );
connect( ui->comboProject, SIGNAL(currentIndexChanged(int)), this, SLOT(currentProjectChanged()) );
connect( ui->toolSelector, SIGNAL(askItemsToApplyToolOn()), this, SLOT(giveSelectionToTool()) );
connect( ui->toolSelector, SIGNAL(toolExecutionFinished(bool)), this, SLOT(toolExecutionFinished(bool)) );
......@@ -1787,6 +1789,37 @@ UIProject* UIMainWindow::getCurrentProject() const
void UIMainWindow::currentProjectChanged()
{
// Project renaming: the combo box has been edited in order to provide a new name to the current project.
if( ui->comboProject->isEditable() )
{
disconnect( ui->comboProject, SIGNAL(currentIndexChanged(int)), this, SLOT(currentProjectChanged()) );
QString newProjectName = ui->comboProject->currentText();
m_CurrentProject->project->SetName( newProjectName );
int currentProjectId = -1;
for( int i=0; i<ui->comboProject->count(); ++i )
if( i != ui->comboProject->currentIndex() && ui->comboProject->itemData(i).value<void*>() == m_CurrentProject )
{
currentProjectId = i;
break;
}
ui->comboProject->setItemText( currentProjectId, newProjectName );
ui->comboProject->removeItem( ui->comboProject->currentIndex() );
ui->comboProject->setCurrentIndex( currentProjectId );
ui->comboProject->setEditable( false );
connect( ui->comboProject, SIGNAL(currentIndexChanged(int)), this, SLOT(currentProjectChanged()) );
}
// Project changing: another project has been selected in the combo box.
else
{
if( m_CurrentProject )
{
m_CurrentViewer->getRenderState( m_CurrentProject->viewerState );
......@@ -1808,6 +1841,12 @@ void UIMainWindow::currentProjectChanged()
m_CurrentProject->hasBackup = false;
}
updateTypeFilters();
updateCurrentProjectContent();
}
// The window title is updated according to the new current project name.
QString title;
if( getCurrentProject() )
{
......@@ -1817,9 +1856,6 @@ void UIMainWindow::currentProjectChanged()
title += " [" + projectFullPath + "]";
}
setMainWindowTitleInfos( title );
updateTypeFilters();
updateCurrentProjectContent();
}
......@@ -2181,3 +2217,31 @@ void UIMainWindow::renderOptionParameterModified( UIParam *p )
updateRenderOptions();
getCurrentViewer()->update();
}
void UIMainWindow::showProjectContextMenu( const QPoint& pos )
{
if( getCurrentProject() )
{
QAction *actRename = new QAction( "Rename" );
//QAction *actReOpen = new QAction( "Re-open" );
QAction *actSave = new QAction( "Save" );
QAction *actClose = new QAction( "Close" );
connect( actRename, SIGNAL(triggered()), this, SLOT(enableProjectRenamingMode()) );
QMenu menu;
menu.addAction( actRename );
//menu.addAction( actReOpen );
menu.addAction( actSave );
menu.addAction( actClose );
menu.exec( ui->comboProject->mapToGlobal(pos) );
}
}
void UIMainWindow::enableProjectRenamingMode()
{
ui->comboProject->setEditable( true );
}
......@@ -204,6 +204,9 @@ public slots:
void showRenderingOptionDialog();
void renderOptionParameterModified( UIParam *p );
void showProjectContextMenu( const QPoint& pos );
void enableProjectRenamingMode();
};
......
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