adding session wizard

parent c861f530
......@@ -62,6 +62,8 @@ set( Redstart_Sources
"src/RedstartSessionExperimentalTalkthroughDialog.h"
"src/RedstartSessionImportDialog.cpp"
"src/RedstartSessionImportDialog.h"
"src/RedstartSessionWizardDialog.cpp"
"src/RedstartSessionWizardDialog.h"
"src/RedstartSessionList.h"
"src/RedstartSessionDetailsTreeView.h"
)
......@@ -71,6 +73,7 @@ set( Redstart_UIs
"ui/RedstartSessionBinauralHeadphonesDialog.ui"
"ui/RedstartSessionExperimentalTalkthroughDialog.ui"
"ui/RedstartSessionImportDialog.ui"
"ui/RedstartSessionWizardDialog.ui"
)
# Qt UI form compiler
......@@ -78,6 +81,7 @@ 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" )
qt5_wrap_ui( "ui_RedstartSessionWizardDialog.h" "ui/RedstartSessionWizardDialog.ui" )
include_directories( "${CMAKE_CURRENT_BINARY_DIR}" ) # Qt UI form compiler generates files into this folder
......
......@@ -74,7 +74,7 @@ public:
}
if( m_pModel->rowCount() > 0 )
m_pModel->index( 0, 0 );
this->setCurrentIndex( m_pModel->index( 0, 0 ) );
};
inline void UpdateSessionList()
......@@ -115,9 +115,41 @@ public:
setCurrentIndex( m_pModel->index( 0, 0 ) );
};
inline bool SessionNameExists( const QString& sID )
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
return ( sessions.find( sID ) != sessions.end() );
};
inline void AddSession( const QString& sID, const QVariantHash& oCoreConfig, const bool bMakeCurrent = true )
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
sessions[ sID ] = oCoreConfig; // More secure than insert, will also overwrite
m_qSettings.setValue( "Redstart/Sessions", sessions );
UpdateSessionList();
if( bMakeCurrent )
SetCurrentSession( sID );
};
inline void RenameSession( const QString& sCurrentID, const QString& sNewID )
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
sessions[ sNewID ] = sessions[ sCurrentID ];
sessions.remove( sCurrentID );
m_qSettings.setValue( "Redstart/Sessions", sessions );
UpdateSessionList();
};
inline void UpdateSession( const QString& sID, const QVariantHash& oCoreConfig, const bool bMakeCurrent = true )
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
if( sessions.find( sID ) == sessions.end() )
return;
sessions[ sID ] = oCoreConfig;
m_qSettings.setValue( "Redstart/Sessions", sessions );
......
/*
* --------------------------------------------------------------------------------------------
*
* 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 "RedstartSessionWizardDialog.h"
#include <ui_RedstartSessionWizardDialog.h>
#include "RedstartUtils.h"
#include <VAException.h>
#include <VAStruct.h>
#include <VACore.h>
#include <QFileDialog>
#include <QSettings>
RedstartSessionWizardDialog::RedstartSessionWizardDialog( QWidget *parent )
: QDialog( parent ),
ui( new Ui::RedstartSessionWizardDialog )
{
ui->setupUi( this );
QDialog::setWindowTitle( "Session wizard" );
QSettings qSettings;
QString sLastBrowseFolder = qSettings.value( "Redstart/last_browse_folder" ).toString();
std::string s = sLastBrowseFolder.toStdString();
if( QDir( sLastBrowseFolder ).exists() )
m_oLastBasePath.setCurrent( sLastBrowseFolder );
}
RedstartSessionWizardDialog::~RedstartSessionWizardDialog()
{
if( m_oLastBasePath.exists() )
m_qSettings.setValue( "Redstart/last_browse_folder", m_oLastBasePath.absolutePath() );
delete ui;
}
QString RedstartSessionWizardDialog::GetSessionName() const
{
return ui->lineEdit_session_name->text();
}
void RedstartSessionWizardDialog::SetSession( const QString& sSessionName, const QVariantHash& oConfig )
{
ui->lineEdit_session_name->setText( sSessionName );
m_oCurrentConfig = oConfig;
}
bool RedstartSessionWizardDialog::GetDuplicationRequested() const
{
return ui->checkBox_duplicate->isChecked();
}
void RedstartSessionWizardDialog::SetDuplicationOptionDeactivated()
{
ui->checkBox_duplicate->setChecked( false );
ui->checkBox_duplicate->setEnabled( false );
}
void RedstartSessionWizardDialog::SetDuplicationOptionActivated()
{
ui->checkBox_duplicate->setChecked( true );
ui->checkBox_duplicate->setEnabled( true );
}
QVariantHash RedstartSessionWizardDialog::GetCoreConfig() const
{
return m_oCurrentConfig;
}
void RedstartSessionWizardDialog::on_pushButton_Save_clicked()
{
accept();
close();
}
/*
* --------------------------------------------------------------------------------------------
*
* 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_WIZARD_DIALOG
#define IW_REDSTART_SESSION_WIZARD_DIALOG
#include <QDialog>
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QSettings>
#include <QVariantHash>
namespace Ui
{
class RedstartSessionWizardDialog;
}
class RedstartSessionWizardDialog : public QDialog
{
Q_OBJECT
public:
explicit RedstartSessionWizardDialog( QWidget *parent );
~RedstartSessionWizardDialog();
QVariantHash GetCoreConfig() const;
QString GetSessionName() const;
void SetSession( const QString& sSessionName, const QVariantHash& oConfig );
bool GetDuplicationRequested() const;
void SetDuplicationOptionDeactivated();
void SetDuplicationOptionActivated();
private slots:
void on_pushButton_Save_clicked();
private:
Ui::RedstartSessionWizardDialog* ui;
QDir m_oLastBasePath;
QSettings m_qSettings;
QVariantHash m_oCurrentConfig;
};
#endif // IW_REDSTART_SESSION_WIZARD_DIALOG
......@@ -25,6 +25,7 @@
#include "RedstartSessionBinauralHeadphonesDialog.h"
#include "RedstartSessionExperimentalTalkthroughDialog.h"
#include "RedstartSessionImportDialog.h"
#include "RedstartSessionWizardDialog.h"
#include "RedstartUtils.h"
#include <VA.h>
......@@ -73,6 +74,8 @@ RedstartWindow::RedstartWindow( bool bFailSafeMode, bool bAutoStart, bool bSkipC
if( !bSkipConfig )
LoadConfiguration();
ui->listView_redstart_session_list;
if( ui->checkBox_redstart_network_connect_as_client->isChecked() )
ui->groupBox_redstart_audio_iface->setEnabled( false );
......@@ -631,7 +634,12 @@ void RedstartWindow::on_actionBinauralHeadphones_triggered()
RedstartSessionBinauralHeadphonesDialog d( this );
if( d.exec() )
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
// Enforce unique session id if id is already existing
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_new";
ui->listView_redstart_session_list->AddSession( sNewID, d.GetCoreConfig() ); // In any case save the session so no data is lost
CVAStruct oStruct = ui->listView_redstart_session_list->GetCurrentConfig();
ui->treeView_session_details->SetStruct( oStruct );
}
......@@ -644,7 +652,11 @@ void RedstartWindow::on_actionImport_session_triggered()
{
try
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
// Enforce unique session id if id is already existing
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_new";
ui->listView_redstart_session_list->AddSession( sNewID, d.GetCoreConfig() ); // In any case save the session so no data is lost
CVAStruct oStruct = ui->listView_redstart_session_list->GetCurrentConfig();
ui->treeView_session_details->SetStruct( oStruct );
......@@ -664,7 +676,12 @@ void RedstartWindow::on_actionDefault_experimental_session_triggered()
RedstartSessionExperimentalTalkthroughDialog d( this );
if( d.exec() )
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
// Enforce unique session id if id is already existing
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_new";
ui->listView_redstart_session_list->AddSession( sNewID, d.GetCoreConfig() ); // In any case save the session so no data is lost
CVAStruct oStruct = ui->listView_redstart_session_list->GetCurrentConfig();
ui->treeView_session_details->SetStruct( oStruct );
}
......@@ -740,32 +757,97 @@ void RedstartWindow::on_actionEdit_session_triggered()
QString sCurrentSessionID = ui->listView_redstart_session_list->GetCurrentSessionID();
CVAStruct oCurrentConfig;
if( !sCurrentSessionID.isEmpty() )
if( sCurrentSessionID.isEmpty() )
return;
oCurrentConfig = ui->listView_redstart_session_list->GetCurrentConfig();
d.SetSession( sCurrentSessionID, ConvertVAStructToQHash( oCurrentConfig ) );
if( d.exec() )
{
oCurrentConfig = ui->listView_redstart_session_list->GetCurrentConfig();
d.SetSession( sCurrentSessionID, ConvertVAStructToQHash( oCurrentConfig ) );
bool bEnforceDuplicate = true;
if( sCurrentSessionID != d.GetSessionName() && !ui->listView_redstart_session_list->SessionNameExists( d.GetSessionName() ) )
{
ui->listView_redstart_session_list->RenameSession( sCurrentSessionID, d.GetSessionName() );
bEnforceDuplicate = false;
}
QVariantHash oNewConfig = d.GetCoreConfig();
if( d.GetDuplicationRequested() || bEnforceDuplicate )
{
// Enforce unique session id if duplicate requested or session should be renamed to an already existing session
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_copy";
ui->listView_redstart_session_list->AddSession( sNewID, oNewConfig );
}
else
{
ui->listView_redstart_session_list->UpdateSession( d.GetSessionName(), oNewConfig );
}
ui->treeView_session_details->SetStruct( ConvertQHashToVAStruct( oNewConfig ) );
}
}
void RedstartWindow::on_actionSession_wizard_triggered()
{
RedstartSessionWizardDialog d( this );
d.SetDuplicationOptionDeactivated();
if( d.exec() )
{
QVariantHash oNewConfig = d.GetCoreConfig();
if( d.GetSessionName() != sCurrentSessionID )
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), oNewConfig );
if( ui->listView_redstart_session_list->SessionNameExists( d.GetSessionName() ) )
{
// Enforce unique session id if id is already existing
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_new";
ui->listView_redstart_session_list->AddSession( sNewID, oNewConfig ); // In any case save the session so no data is lost
}
else
ui->listView_redstart_session_list->UpdateSession( d.GetSessionName(), oNewConfig );
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), oNewConfig );
}
ui->treeView_session_details->SetStruct( ConvertQHashToVAStruct( oNewConfig ) );
}
}
void RedstartWindow::on_actionDuplicate_current_session_triggered()
void RedstartWindow::on_actionDuplicate_session_triggered()
{
RedstartSessionDuplicateCurrentDialog d( this );
RedstartSessionWizardDialog d( this );
QString sCurrentSessionID = ui->listView_redstart_session_list->GetCurrentSessionID();
CVAStruct oCurrentConfig;
if( sCurrentSessionID.isEmpty() )
return;
oCurrentConfig = ui->listView_redstart_session_list->GetCurrentConfig();
d.SetSession( sCurrentSessionID, ConvertVAStructToQHash( oCurrentConfig ) );
d.SetDuplicationOptionActivated();
if( d.exec() )
{
CVAStruct oStruct = ui->listView_redstart_session_list->GetCurrentConfig();
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), ConvertVAStructToQHash( oStruct ) );
ui->treeView_session_details->SetStruct( oStruct );
QVariantHash oNewConfig = d.GetCoreConfig();
if( ui->listView_redstart_session_list->SessionNameExists( d.GetSessionName() ) )
{
// Enforce unique session id if id is already existing
QString sNewID = d.GetSessionName();
while( ui->listView_redstart_session_list->SessionNameExists( sNewID ) )
sNewID += "_copy";
ui->listView_redstart_session_list->AddSession( sNewID, oNewConfig ); // In any case save the session so no data is lost
}
else
{
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), oNewConfig );
}
ui->treeView_session_details->SetStruct( ConvertQHashToVAStruct( oNewConfig ) );
}
}
......
......@@ -149,7 +149,8 @@ private slots:
void on_actionExport_to_file_triggered();
void on_actionRemove_triggered();
void on_actionEdit_session_triggered();
void on_actionDuplicate_current_session_triggered();
void on_actionSession_wizard_triggered();
void on_actionDuplicate_session_triggered();
private:
void PostCoreStart();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RedstartSessionWizardDialog</class>
<widget class="QDialog" name="RedstartSessionWizardDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>574</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_session_name">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 10pt &quot;MS Shell Dlg 2&quot;;</string>
</property>
<property name="text">
<string>MyNewSession</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="3">
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Available in future release</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabMedium">
<attribute name="title">
<string>Propagation medium</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Available in future release</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabRenderers">
<attribute name="title">
<string>Renderering modules</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Available in future release</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabReproductions">
<attribute name="title">
<string>Reproduction modules</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Available in future release</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Hardware setup</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Available in future release</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_duplicate">
<property name="toolTip">
<string>If a session should be duplicated, the session name has to be unique. If unchecked, the current session will be renamed and configuration of this wizard will override.</string>
</property>
<property name="text">
<string>Duplicate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Save">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -71,8 +71,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1015</width>
<height>709</height>
<width>1012</width>
<height>671</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="1,0,0,0,1">
......@@ -472,6 +472,12 @@ background-color: rgb(208, 255, 188);</string>
</item>
<item row="1" column="1">
<widget class="QDial" name="dial_core_control_output_gain">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="minimum">
<number>-60</number>
</property>
......@@ -506,6 +512,12 @@ background-color: rgb(208, 255, 188);</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="minimum">
<number>-60</number>
</property>
......@@ -848,7 +860,6 @@ background-color: rgb(208, 255, 188);</string>
<addaction name="separator"/>
<addaction name="actionSession_wizard"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionImport_session"/>
</widget>
<widget class="QMenu" name="menuCrurrent_session">
......@@ -859,6 +870,7 @@ background-color: rgb(208, 255, 188);</string>
<string>Current session</string>
</property>
<addaction name="actionEdit_session"/>
<addaction name="actionDuplicate_session"/>
<addaction name="actionRemove"/>
<addaction name="separator"/>
<addaction name="actionExport_to_file"/>
......@@ -937,13 +949,13 @@ background-color: rgb(208, 255, 188);</string>
</action>
<action name="actionSession_wizard">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Session wizard</string>
</property>
<property name="shortcut">
<string>N, W</string>
<string>N, N</string>
</property>
</action>
<action name="actionRunSimpleExample">
......@@ -1116,6 +1128,14 @@ background-color: rgb(208, 255, 188);</string>
<string>N, A</string>
</property>
</action>
<action name="actionDuplicate_session">
<property name="text">
<string>Duplicate session</string>
</property>
<property name="shortcut">
<string>N, D</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
......
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