Adding feature to export a Redstart session

parent 1bd72b6c
......@@ -59,7 +59,7 @@ QVariantHash RedstartSessionImportDialog::GetCoreConfig() const
{
if( !ValidFile() )
VA_EXCEPT2( INVALID_PARAMETER, "Can not import from a directory or non-existing file" );
CVAStruct oCoreConfig = VACore::GetCoreConfigFromFile( m_oConfigFileBasePath.absoluteFilePath().toStdString() );
CVAStruct oCoreConfig = VACore::LoadCoreConfigFromFile( m_oConfigFileBasePath.absoluteFilePath().toStdString() );
return ConvertVAStructToQHash( oCoreConfig );
}
......
......@@ -16,6 +16,7 @@
#include <QDesktopServices>
#include <QHash>
#include <QShortcut>
#include <QFileDialog>
#include "RedstartWindow.h"
#include <ui_RedstartWindow.h>
......@@ -682,3 +683,48 @@ void RedstartWindow::on_actionAmbisonics_triggered()
{
}
void RedstartWindow::on_actionExport_to_file_triggered()
{
QFileDialog fd;
fd.setNameFilters( QStringList() << "INI files (*.ini)" << "Any file (*.*)" );
fd.setViewMode( QFileDialog::Detail );
fd.setAcceptMode( QFileDialog::AcceptSave );
QDir oLastDir( m_qSettings.value( "Redstart/last_browse_folder" ).toString() );
if( oLastDir.exists() )
fd.setDirectory( oLastDir );
else
fd.setDirectory( QDir( QApplication::applicationDirPath() ) );
QString sFileName = ui->listView_redstart_session_list->GetCurrentSessionID();
if( sFileName.isEmpty() == false )
fd.selectFile( sFileName + ".ini" );
if( fd.exec() )
{
QStringList lFiles = fd.selectedFiles();
if( lFiles.empty() == false )
{
QString sFilePath = lFiles[ 0 ];
QFileInfo oFile( sFilePath );
if( fd.directory().exists() )
m_qSettings.setValue( "Redstart/last_browse_folder", oFile.absolutePath() );
try
{
CVAStruct oConfig = ui->listView_redstart_session_list->GetCurrentConfig();
VACore::StoreCoreConfigToFile( oConfig, sFilePath.toStdString() );
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not export session configuration: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
}
}
}
}
......@@ -146,6 +146,8 @@ private slots:
void on_actionAmbisonics_triggered();
void on_actionExport_to_file_triggered();
private:
void PostCoreStart();
void PostCoreStop();
......
......@@ -855,7 +855,7 @@ background-color: rgb(208, 255, 188);</string>
</widget>
<widget class="QMenu" name="menuCrurrent_session">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="title">
<string>Current session</string>
......@@ -864,7 +864,6 @@ background-color: rgb(208, 255, 188);</string>
<addaction name="actionRemove"/>
<addaction name="separator"/>
<addaction name="actionExport_to_file"/>
<addaction name="actionExport_VA_core_configuration"/>
</widget>
<addaction name="separator"/>
<addaction name="menuNew_session"/>
......@@ -1023,13 +1022,13 @@ background-color: rgb(208, 255, 188);</string>
</action>
<action name="actionExport_to_file">
<property name="text">
<string>Export session to file</string>
<string>Export session</string>
</property>
<property name="toolTip">
<string>Export current session to file</string>
</property>
<property name="shortcut">
<string>S, F</string>
<string>S, X</string>
</property>
</action>
<action name="actionRemove">
......@@ -1076,6 +1075,9 @@ background-color: rgb(208, 255, 188);</string>
</property>
</action>
<action name="actionEdit_session">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Edit session</string>
</property>
......
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