Fix keeping an history of open files
This commit is contained in:
+28
-22
@@ -212,7 +212,7 @@ void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> stream
|
|||||||
streamInfoOpt = m_aRecentFileStreamInfo.at( idx );
|
streamInfoOpt = m_aRecentFileStreamInfo.at( idx );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto streamInfo = streamInfoOpt.has_value() ? *streamInfoOpt : CalypFileInfo{ .m_cFilename = fileName };
|
auto streamInfo = streamInfoOpt.has_value() ? *streamInfoOpt : CalypFileInfo{ .m_cFilename = std::move( fileName ) };
|
||||||
|
|
||||||
auto videoResource = std::make_unique<VideostreamResource>();
|
auto videoResource = std::make_unique<VideostreamResource>();
|
||||||
|
|
||||||
@@ -232,19 +232,20 @@ void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> stream
|
|||||||
ConfigureFormatDialog formatDialog( this );
|
ConfigureFormatDialog formatDialog( this );
|
||||||
if( streamInfo.m_uiWidth == 0 )
|
if( streamInfo.m_uiWidth == 0 )
|
||||||
{
|
{
|
||||||
streamInfo.m_uiWidth = m_cLastWidth;
|
streamInfo.m_uiWidth = m_lastOpenWidth;
|
||||||
}
|
}
|
||||||
if( streamInfo.m_uiHeight == 0 )
|
if( streamInfo.m_uiHeight == 0 )
|
||||||
{
|
{
|
||||||
streamInfo.m_uiHeight = m_cLastHeight;
|
streamInfo.m_uiHeight = m_lastOpenHeight;
|
||||||
}
|
}
|
||||||
if( streamInfo.m_uiBitsPelPixel == 0 )
|
if( streamInfo.m_uiBitsPelPixel == 0 )
|
||||||
{
|
{
|
||||||
streamInfo.m_uiBitsPelPixel = m_cLastBitPerPixel;
|
streamInfo.m_uiBitsPelPixel = m_lastOpenBitPerPixel;
|
||||||
}
|
}
|
||||||
if( formatDialog.runConfigureFormatDialog(
|
if( formatDialog.runConfigureFormatDialog( QFileInfo( streamInfo.m_cFilename ).fileName(), streamInfo.m_uiWidth,
|
||||||
QFileInfo( fileName ).fileName(), streamInfo.m_uiWidth, streamInfo.m_uiHeight, streamInfo.m_iPelFormat,
|
streamInfo.m_uiHeight, streamInfo.m_iPelFormat,
|
||||||
streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness, streamInfo.m_uiFrameRate ) != QDialog::Accepted )
|
streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness,
|
||||||
|
streamInfo.m_uiFrameRate ) != QDialog::Accepted )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -254,6 +255,7 @@ void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> stream
|
|||||||
|
|
||||||
if( opened )
|
if( opened )
|
||||||
{
|
{
|
||||||
|
const auto openedStreamInfo = videoResource->getStreamInfo();
|
||||||
auto resource_id = m_appResourceHandle->appendResource( std::move( videoResource ) );
|
auto resource_id = m_appResourceHandle->appendResource( std::move( videoResource ) );
|
||||||
|
|
||||||
auto* videoSubWindow = new VideoStreamSubWindow( m_appResourceHandle.get() ); // createSubWindow();
|
auto* videoSubWindow = new VideoStreamSubWindow( m_appResourceHandle.get() ); // createSubWindow();
|
||||||
@@ -267,10 +269,13 @@ void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> stream
|
|||||||
|
|
||||||
updateZoomFactorSBox();
|
updateZoomFactorSBox();
|
||||||
|
|
||||||
addStreamInfoToRecentList( std::move( streamInfo ) );
|
addStreamInfoToRecentList( std::move( openedStreamInfo ) );
|
||||||
|
|
||||||
printMessage( "File loaded", CLP_LOG_INFO );
|
printMessage( "File loaded", CLP_LOG_INFO );
|
||||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
m_lastOpenPath = QFileInfo( streamInfo.m_cFilename ).path();
|
||||||
|
m_lastOpenWidth = streamInfo.m_uiWidth;
|
||||||
|
m_lastOpenHeight = streamInfo.m_uiHeight;
|
||||||
|
m_lastOpenBitPerPixel = streamInfo.m_uiBitsPelPixel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( CalypFailure& e )
|
catch( CalypFailure& e )
|
||||||
@@ -322,11 +327,11 @@ QStringList MainWindow::showFileDialog( bool bRead )
|
|||||||
fileNameList.clear();
|
fileNameList.clear();
|
||||||
if( bRead )
|
if( bRead )
|
||||||
{
|
{
|
||||||
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
|
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_lastOpenPath, filter.join( ";;" ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_cLastOpenPath, filter.join( ";;" ) );
|
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_lastOpenPath, filter.join( ";;" ) );
|
||||||
if( !fileName.isEmpty() )
|
if( !fileName.isEmpty() )
|
||||||
fileNameList.append( fileName );
|
fileNameList.append( fileName );
|
||||||
}
|
}
|
||||||
@@ -369,7 +374,7 @@ void MainWindow::saveFrame()
|
|||||||
if( fileNameList.size() == 1 )
|
if( fileNameList.size() == 1 )
|
||||||
{
|
{
|
||||||
QString fileName = fileNameList[0];
|
QString fileName = fileNameList[0];
|
||||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
saveWindow->save( fileName );
|
saveWindow->save( fileName );
|
||||||
@@ -397,7 +402,7 @@ void MainWindow::saveStream()
|
|||||||
if( fileNameList.size() == 1 )
|
if( fileNameList.size() == 1 )
|
||||||
{
|
{
|
||||||
QString fileName = fileNameList[0];
|
QString fileName = fileNameList[0];
|
||||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
saveWindow->save( fileName );
|
saveWindow->save( fileName );
|
||||||
@@ -557,7 +562,7 @@ void MainWindow::dropEvent( QDropEvent* event )
|
|||||||
if( urlList.size() == 1 )
|
if( urlList.size() == 1 )
|
||||||
{
|
{
|
||||||
QString fileName = urlList.at( 0 ).toLocalFile();
|
QString fileName = urlList.at( 0 ).toLocalFile();
|
||||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||||
loadFile( fileName );
|
loadFile( fileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -964,6 +969,7 @@ void MainWindow::checkRecentFileActions()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned long long int fileSize = QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).size();
|
unsigned long long int fileSize = QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).size();
|
||||||
|
std::cout << m_aRecentFileStreamInfo.at( i ).m_uiFileSize << std::endl;
|
||||||
if( m_aRecentFileStreamInfo.at( i ).m_uiFileSize != fileSize )
|
if( m_aRecentFileStreamInfo.at( i ).m_uiFileSize != fileSize )
|
||||||
{
|
{
|
||||||
m_aRecentFileStreamInfo.remove( i );
|
m_aRecentFileStreamInfo.remove( i );
|
||||||
@@ -983,10 +989,10 @@ void MainWindow::readSettings()
|
|||||||
move( pos );
|
move( pos );
|
||||||
resize( size );
|
resize( size );
|
||||||
|
|
||||||
m_cLastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString();
|
m_lastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString();
|
||||||
m_cLastWidth = appSettings.value( "MainWindow/LastWidth" ).value<unsigned int>();
|
m_lastOpenWidth = appSettings.value( "MainWindow/LastWidth" ).value<unsigned int>();
|
||||||
m_cLastHeight = appSettings.value( "MainWindow/LastHeight" ).value<unsigned int>();
|
m_lastOpenHeight = appSettings.value( "MainWindow/LastHeight" ).value<unsigned int>();
|
||||||
m_cLastBitPerPixel = appSettings.value( "MainWindow/LastBitsPerPixel" ).value<unsigned int>();
|
m_lastOpenBitPerPixel = appSettings.value( "MainWindow/LastBitsPerPixel" ).value<unsigned int>();
|
||||||
|
|
||||||
QVariant value = appSettings.value( "MainWindow/RecentFileList" );
|
QVariant value = appSettings.value( "MainWindow/RecentFileList" );
|
||||||
m_aRecentFileStreamInfo = value.value<CalypFileInfoVector>();
|
m_aRecentFileStreamInfo = value.value<CalypFileInfoVector>();
|
||||||
@@ -1005,10 +1011,10 @@ void MainWindow::writeSettings()
|
|||||||
|
|
||||||
appSettings.setValue( "MainWindow/Position", pos() );
|
appSettings.setValue( "MainWindow/Position", pos() );
|
||||||
appSettings.setValue( "MainWindow/Size", size() );
|
appSettings.setValue( "MainWindow/Size", size() );
|
||||||
appSettings.setValue( "MainWindow/LastOpenPath", m_cLastOpenPath );
|
appSettings.setValue( "MainWindow/LastOpenPath", m_lastOpenPath );
|
||||||
appSettings.setValue( "MainWindow/LastWidth", m_cLastWidth );
|
appSettings.setValue( "MainWindow/LastWidth", m_lastOpenWidth );
|
||||||
appSettings.setValue( "MainWindow/LastHeight", m_cLastHeight );
|
appSettings.setValue( "MainWindow/LastHeight", m_lastOpenHeight );
|
||||||
appSettings.setValue( "MainWindow/LastBitsPerPixel", m_cLastBitPerPixel );
|
appSettings.setValue( "MainWindow/LastBitsPerPixel", m_lastOpenBitPerPixel );
|
||||||
|
|
||||||
QVariant var;
|
QVariant var;
|
||||||
var.setValue<CalypFileInfoVector>( m_aRecentFileStreamInfo );
|
var.setValue<CalypFileInfoVector>( m_aRecentFileStreamInfo );
|
||||||
|
|||||||
+4
-4
@@ -132,10 +132,10 @@ private:
|
|||||||
SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set
|
SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set
|
||||||
VideoSubWindow* m_pcCurrentVideoSubWindow;
|
VideoSubWindow* m_pcCurrentVideoSubWindow;
|
||||||
|
|
||||||
QString m_cLastOpenPath;
|
QString m_lastOpenPath;
|
||||||
unsigned int m_cLastWidth;
|
unsigned int m_lastOpenWidth;
|
||||||
unsigned int m_cLastHeight;
|
unsigned int m_lastOpenHeight;
|
||||||
unsigned int m_cLastBitPerPixel;
|
unsigned int m_lastOpenBitPerPixel;
|
||||||
QStringList showFileDialog( bool bRead );
|
QStringList showFileDialog( bool bRead );
|
||||||
|
|
||||||
static VideoStreamSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
static VideoStreamSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
auto loadFile( const QString& cFilename ) -> bool;
|
auto loadFile( const QString& cFilename ) -> bool;
|
||||||
auto loadFile( const CalypFileInfo& streamInfo, bool optimistic = true ) -> bool;
|
auto loadFile( const CalypFileInfo& streamInfo, bool optimistic = true ) -> bool;
|
||||||
|
auto getStreamInfo() const -> CalypFileInfo { return m_sStreamInfo; }
|
||||||
|
|
||||||
auto getResource() -> CalypStream* override { return &m_currStream; };
|
auto getResource() -> CalypStream* override { return &m_currStream; };
|
||||||
auto getStream() const -> const CalypStream& { return m_currStream; };
|
auto getStream() const -> const CalypStream& { return m_currStream; };
|
||||||
|
|||||||
Reference in New Issue
Block a user