From b507b61ce41c87659c5db29043ef9ae03db8dbd3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 2 Feb 2021 00:03:29 +0000 Subject: [PATCH] Pre fill configuration dialog with the last used values --- app/VideoSubWindow.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index ed9484f..af20c8b 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -1,5 +1,5 @@ /* This file is a part of Calyp project - * Copyright (C) 2014-2019 by Joao Carreira (jfmcarreira@gmail.com) + * Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com) * Luis Lucas (luisfrlucas@gmail.com) * * This program is free software; you can redistribute it and/or modify @@ -23,15 +23,17 @@ */ #include "VideoSubWindow.h" + #include +#include #include +#include + #include "ConfigureFormatDialog.h" #include "ModulesHandle.h" #include "QtConcurrent/qtconcurrentrun.h" #include "SubWindowAbstract.h" -#include - #define QT_NO_CONCURRENT /** @@ -313,6 +315,7 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog ) unsigned int Width = 0, Height = 0, BitsPel = 8, FrameRate = 30; int Endianness = CLP_LITTLE_ENDIAN; int InputFormat = CLP_YUV420P; + QSettings appSettings; if( m_pCurrStream ) m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, Endianness, FrameRate ); @@ -323,7 +326,16 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog ) } bool bConfig = true; if( !bForceDialog ) + { bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness, FrameRate ); + if( bConfig ) + { + // Pre-load values with last opened file + Width = appSettings.value( "VideoSubWindow/LastWidth" ).value(); + Height = appSettings.value( "VideoSubWindow/LastHeight" ).value(); + BitsPel = appSettings.value( "VideoSubWindow/LastBitsPerPixel" ).value(); + } + } bool bRet = false; for( int iPass = 0; iPass < 2 && !bRet; iPass++ ) { @@ -355,6 +367,14 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog ) m_sStreamInfo.m_uiFrameRate = FrameRate; m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size(); + QVariant var; + var.setValue( Width ); + appSettings.setValue( "VideoSubWindow/LastWidth", var ); + var.setValue( Height ); + appSettings.setValue( "VideoSubWindow/LastHeight", var ); + var.setValue( BitsPel ); + appSettings.setValue( "VideoSubWindow/LastBitsPerPixel", var ); + QApplication::restoreOverrideCursor(); refreshFrame();