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

Last tool used is now saved in user settings and restored when loading the application.

parent a8ffa68a
......@@ -244,6 +244,24 @@ void AlgorithmSelector::selectTool( int n )
}
void AlgorithmSelector::selectTool( int categoryId, const QString& toolName )
{
m_CategoryButtonGroup->button( categoryId )->setChecked( true );
selectCategory( categoryId );
for( int i=0; i<m_ToolsByCategory[m_SelectedCategory].size(); ++i )
{
auto &tool = m_ToolsByCategory[m_SelectedCategory][i];
if( tool.plugin->name( tool.id ) == toolName )
{
m_ui->comboAvailableTools->setCurrentIndex( i );
selectTool( i );
return;
}
}
}
void AlgorithmSelector::emitApplySignal()
{
if( m_SelectedTool )
......
......@@ -64,6 +64,7 @@ public:
void releaseAllTools();
void finalizeTools();
inline QString currentToolName() const { return m_SelectedTool->plugin->name( m_SelectedTool->id ); }
inline int currentCategoryId() const { return m_SelectedCategory; }
inline QList<ToolDescriptor> allTools() const { return m_ToolsByName.values(); }
inline const ToolDescriptor* getToolByName( const QString& name ) const { auto found = m_ToolsByName.find(name); return (found==m_ToolsByName.end())? NULL : &*found; }
......@@ -77,6 +78,7 @@ private slots:
void deleteProgressBars();
public slots:
void selectTool( int categoryId, const QString& toolName );
void emitApplySignal();
void emitActionSignal();
void applyCurrentToolOn( const QList<GenericUIData*> &items,
......
......@@ -70,6 +70,11 @@ bool UIMainWindow::saveUISettings() const
recents.push_back( r->text() );
settings->setValue( "recent", recents );
// Store the last category/tool used.
settings->setValue( "lastCategory", ui->toolSelector->currentCategoryId() );
settings->setValue( "lastTool", ui->toolSelector->currentToolName() );
return true;
}
......@@ -94,6 +99,11 @@ bool UIMainWindow::loadUISettings()
for( auto r=recents.rbegin(); r!=recents.rend(); ++r )
updateRecentListEntry( *r );
// Load the last category/tool used.
if( settings->contains("lastCategory") && settings->contains("lastTool") )
ui->toolSelector->selectTool( settings->value("lastCategory").toInt(), settings->value("lastTool").toString() );
return true;
}
......
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