Adding session import feature

parent f85b5ce1
......@@ -60,6 +60,8 @@ set( Redstart_Sources
"src/RedstartSessionBinauralHeadphonesDialog.h"
"src/RedstartSessionExperimentalTalkthroughDialog.cpp"
"src/RedstartSessionExperimentalTalkthroughDialog.h"
"src/RedstartSessionImportDialog.cpp"
"src/RedstartSessionImportDialog.h"
"src/RedstartSessionList.h"
"src/RedstartSessionDetailsTreeView.h"
)
......@@ -68,12 +70,14 @@ set( Redstart_UIs
"ui/RedstartWindow.ui"
"ui/RedstartSessionBinauralHeadphonesDialog.ui"
"ui/RedstartSessionExperimentalTalkthroughDialog.ui"
"ui/RedstartSessionImportDialog.ui"
)
# Qt UI form compiler
qt5_wrap_ui( "ui_RedstartWindow.h" "ui/RedstartWindow.ui" )
qt5_wrap_ui( "ui_RedstartSessionBinauralHeadphonesDialog.h" "ui/RedstartSessionBinauralHeadphonesDialog.ui" )
qt5_wrap_ui( "ui_RedstartSessionExperimentalTalkthroughDialog.h" "ui/RedstartSessionExperimentalTalkthroughDialog.ui" )
qt5_wrap_ui( "ui_RedstartSessionImportDialog.h" "ui/RedstartSessionImportDialog.ui" )
include_directories( "${CMAKE_CURRENT_BINARY_DIR}" ) # Qt UI form compiler generates files into this folder
......
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2017
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#include "RedstartSessionImportDialog.h"
#include <ui_RedstartSessionImportDialog.h>
#include "RedstartUtils.h"
#include <VAException.h>
#include <VAStruct.h>
#include <VACore.h>
#include <QFileDialog>
#include <QSettings>
RedstartSessionImportDialog::RedstartSessionImportDialog( QWidget *parent )
: QDialog( parent ),
ui( new Ui::RedstartSessionImportDialog )
{
ui->setupUi( this );
QDialog::setWindowTitle( "Import session" );
QSettings qSettings;
QString sLastBrowseFolder = qSettings.value( "Redstart/last_browse_folder" ).toString();
std::string s = sLastBrowseFolder.toStdString();
if( QDir( sLastBrowseFolder ).exists() )
m_oLastBasePath.setCurrent( sLastBrowseFolder );
}
RedstartSessionImportDialog::~RedstartSessionImportDialog()
{
if( m_oLastBasePath.exists() )
m_qSettings.setValue( "Redstart/last_browse_folder", m_oLastBasePath.absolutePath() );
delete ui;
}
QString RedstartSessionImportDialog::GetSessionName() const
{
return ui->lineEdit_session_name->text();
}
bool RedstartSessionImportDialog::ValidFile() const
{
return m_oConfigFileBasePath.exists() && !m_oConfigFileBasePath.isDir();
}
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() );
return ConvertVAStructToQHash( oCoreConfig );
}
void RedstartSessionImportDialog::on_pushButton_CreateSession_clicked()
{
accept();
close();
}
void RedstartSessionImportDialog::on_pushButton_select_import_file_clicked()
{
QFileDialog fd;
fd.setNameFilters( QStringList() << "INI files (*.ini)" << "Any file (*.*)" );
fd.setViewMode( QFileDialog::Detail );
if( m_oLastBasePath.exists() )
fd.setDirectory( m_oLastBasePath );
else
fd.setDirectory( QDir( QApplication::applicationDirPath() ) );
if( fd.exec() )
{
QStringList lFiles = fd.selectedFiles();
if( lFiles.empty() == false )
{
QString sFilePath = lFiles[ 0 ];
m_oConfigFileBasePath.setFile( sFilePath );
if( m_oConfigFileBasePath.exists() )
m_oLastBasePath = fd.directory();
ui->lineEdit_import_config_file->setText( m_oConfigFileBasePath.fileName() );
}
}
}
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2017
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_REDSTART_SESSION_IMPORT_DIALOG
#define IW_REDSTART_SESSION_IMPORT_DIALOG
#include <QDialog>
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QSettings>
#include <QHash>
namespace Ui
{
class RedstartSessionImportDialog;
}
class RedstartSessionImportDialog : public QDialog
{
Q_OBJECT
public:
explicit RedstartSessionImportDialog( QWidget *parent );
~RedstartSessionImportDialog();
QVariantHash GetCoreConfig() const;
QString GetSessionName() const;
bool ValidFile() const;
private slots:
void on_pushButton_CreateSession_clicked();
void on_pushButton_select_import_file_clicked();
private:
Ui::RedstartSessionImportDialog* ui;
QDir m_oLastBasePath;
QFileInfo m_oConfigFileBasePath;
QSettings m_qSettings;
};
#endif // IW_REDSTART_SESSION_IMPORT_DIALOG
......@@ -23,6 +23,7 @@
#include "RedstartRunSimpleExample.h"
#include "RedstartSessionBinauralHeadphonesDialog.h"
#include "RedstartSessionExperimentalTalkthroughDialog.h"
#include "RedstartSessionImportDialog.h"
#include "RedstartUtils.h"
#include <VA.h>
......@@ -238,7 +239,7 @@ void RedstartWindow::HandleVAEvent( const CVAEvent* pEvent )
switch( pEvent->iEventType )
{
case CVAEvent::VA_EVENT_PROGRESS_UPDATE:
ui->statusBar->showMessage( pEvent->sParam.c_str() );
//ui->statusBar->showMessage( pEvent->sParam.c_str() );
break;
case CVAEvent::VA_EVENT_MEASURES_UPDATE:
UpdateMeasures( pEvent->vfInputRMSs, pEvent->vfInputPeaks, pEvent->vfOutputRMSs, pEvent->vfOutputPeaks );
......@@ -628,6 +629,25 @@ void RedstartWindow::on_actionBinauralHeadphones_triggered()
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
}
void RedstartWindow::on_actionImport_session_triggered()
{
RedstartSessionImportDialog d( this );
if( d.exec() )
{
try
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not run simple example scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
}
}
}
void RedstartWindow::on_actionDefault_experimental_session_triggered()
{
RedstartSessionExperimentalTalkthroughDialog d( this );
......@@ -637,7 +657,6 @@ void RedstartWindow::on_actionDefault_experimental_session_triggered()
void RedstartWindow::on_actionRunSimpleExample_triggered()
{
try
{
if( !m_pVAInterface )
......
......@@ -135,6 +135,7 @@ private slots:
void on_listView_redstart_session_list_clicked( const QModelIndex &index );
void on_actionBinauralHeadphones_triggered();
void on_actionImport_session_triggered();
void on_actionDefault_experimental_session_triggered();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RedstartSessionImportDialog</class>
<widget class="QDialog" name="RedstartSessionImportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>625</width>
<height>133</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_import_config_file">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Import</string>
</property>
<property name="buddy">
<cstring>lineEdit_import_config_file</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_session_name">
<property name="text">
<string>MyImportedSession</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Session name</string>
</property>
<property name="buddy">
<cstring>lineEdit_session_name</cstring>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QPushButton" name="pushButton_CreateSession">
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_select_import_file">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pushButton_CreateSession</tabstop>
<tabstop>lineEdit_session_name</tabstop>
<tabstop>lineEdit_import_config_file</tabstop>
<tabstop>pushButton_select_import_file</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -70,7 +70,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-45</y>
<y>0</y>
<width>1015</width>
<height>709</height>
</rect>
......@@ -646,7 +646,7 @@ background-color: rgb(208, 255, 188);</string>
<property name="title">
<string>Core</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,0,0,0,0">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,0,0,0">
<item row="1" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_core_settings">
<item row="3" column="0">
......@@ -902,7 +902,7 @@ background-color: rgb(208, 255, 188);</string>
</widget>
<action name="actionImport_session">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Import session from file</string>
......
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