summaryrefslogtreecommitdiffstats
path: root/Examples
diff options
context:
space:
mode:
authorKonstantin <const@const.me>2023-01-20 20:23:35 +0100
committerKonstantin <const@const.me>2023-01-20 20:23:35 +0100
commite7716954cb681c531132a342b4b486a28179f792 (patch)
tree359f2140ca10f7a5132dea36aa5bbbf16bd21cdd /Examples
parent9c30dd0f95a11cb24f97b7eabd8eebb7ebdd5134 (diff)
Minor, UX enhancements
Diffstat (limited to 'Examples')
-rw-r--r--Examples/WhisperDesktop/AppState.cpp13
-rw-r--r--Examples/WhisperDesktop/AppState.h2
-rw-r--r--Examples/WhisperDesktop/TranscribeDlg.cpp26
-rw-r--r--Examples/WhisperDesktop/TranscribeDlg.h12
4 files changed, 47 insertions, 6 deletions
diff --git a/Examples/WhisperDesktop/AppState.cpp b/Examples/WhisperDesktop/AppState.cpp
index 651e8ae..b478546 100644
--- a/Examples/WhisperDesktop/AppState.cpp
+++ b/Examples/WhisperDesktop/AppState.cpp
@@ -203,4 +203,17 @@ void AppState::gpuFlagsStore( uint32_t flags )
registryKey.DeleteValue( regValGpuFlags );
else
dwordStore( regValGpuFlags, flags );
+}
+
+bool AppState::boolLoad( LPCTSTR name )
+{
+ return dwordLoad( name, 0 ) != 0;
+}
+
+void AppState::boolStore( LPCTSTR name, bool val )
+{
+ if( val )
+ dwordStore( name, 1 );
+ else
+ registryKey.DeleteValue( name );
} \ No newline at end of file
diff --git a/Examples/WhisperDesktop/AppState.h b/Examples/WhisperDesktop/AppState.h
index 9824b42..76688d8 100644
--- a/Examples/WhisperDesktop/AppState.h
+++ b/Examples/WhisperDesktop/AppState.h
@@ -37,6 +37,8 @@ public:
void stringStore( LPCTSTR name, LPCTSTR value );
uint32_t dwordLoad( LPCTSTR name, uint32_t fallback );
void dwordStore( LPCTSTR name, uint32_t value );
+ bool boolLoad( LPCTSTR name );
+ void boolStore( LPCTSTR name, bool val );
bool automaticallyLoadModel = true;
diff --git a/Examples/WhisperDesktop/TranscribeDlg.cpp b/Examples/WhisperDesktop/TranscribeDlg.cpp
index bfdb6f1..0e05827 100644
--- a/Examples/WhisperDesktop/TranscribeDlg.cpp
+++ b/Examples/WhisperDesktop/TranscribeDlg.cpp
@@ -22,6 +22,7 @@ constexpr int progressMaxInteger = 1024 * 8;
static const LPCTSTR regValInput = L"sourceMedia";
static const LPCTSTR regValOutFormat = L"resultFormat";
static const LPCTSTR regValOutPath = L"resultPath";
+static const LPCTSTR regValUseInputFolder = L"useInputFolder";
LRESULT TranscribeDlg::OnInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
@@ -61,8 +62,10 @@ LRESULT TranscribeDlg::OnInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam
sourceMediaPath.SetWindowText( appState.stringLoad( regValInput ) );
transcribeOutFormat.SetCurSel( (int)appState.dwordLoad( regValOutFormat, 0 ) );
transcribeOutputPath.SetWindowText( appState.stringLoad( regValOutPath ) );
+ if( appState.boolLoad( regValUseInputFolder ) )
+ useInputFolder.SetCheck( BST_CHECKED );
BOOL unused;
- OnOutFormatChange( 0, 0, nullptr, unused );
+ onOutFormatChange( 0, 0, nullptr, unused );
appState.lastScreenSave( SCREEN_TRANSCRIBE );
appState.setupIcon( this );
@@ -118,7 +121,8 @@ enum struct TranscribeDlg::eOutputFormat : uint8_t
WebVTT = 3
};
-LRESULT TranscribeDlg::OnOutFormatChange( UINT, INT, HWND, BOOL& bHandled )
+// CBN_SELCHANGE notification for IDC_OUTPUT_FORMAT combobox
+LRESULT TranscribeDlg::onOutFormatChange( UINT, INT, HWND, BOOL& bHandled )
{
BOOL enabled = transcribeOutFormat.GetCurSel() != 0;
useInputFolder.EnableWindow( enabled );
@@ -134,6 +138,17 @@ LRESULT TranscribeDlg::OnOutFormatChange( UINT, INT, HWND, BOOL& bHandled )
return 0;
}
+// EN_CHANGE notification for IDC_PATH_MEDIA edit box
+LRESULT TranscribeDlg::onInputChange( UINT, INT, HWND, BOOL& )
+{
+ if( !useInputFolder.IsWindowEnabled() )
+ return 0;
+ if( !isChecked( useInputFolder ) )
+ return 0;
+ setOutputPath();
+ return 0;
+}
+
void TranscribeDlg::onBrowseMedia()
{
LPCTSTR title = L"Input audio file to transcribe";
@@ -255,12 +270,19 @@ void TranscribeDlg::onTranscribe()
transcribeError( L"Please select an output text file" );
return;
}
+ if( PathFileExists( transcribeArgs.pathOutput ) )
+ {
+ const int resp = MessageBox( L"The output file is already there.\nOverwrite the file?", L"Confirm Overwrite", MB_ICONQUESTION | MB_YESNO );
+ if( resp != IDYES )
+ return;
+ }
appState.stringStore( regValOutPath, transcribeArgs.pathOutput );
}
else
cbConsole.ensureChecked();
appState.dwordStore( regValOutFormat, (uint32_t)(int)transcribeArgs.format );
+ appState.boolStore( regValUseInputFolder, isChecked( useInputFolder ) );
languageSelector.saveSelection( appState );
cbTranslate.saveSelection( appState );
appState.stringStore( regValInput, transcribeArgs.pathMedia );
diff --git a/Examples/WhisperDesktop/TranscribeDlg.h b/Examples/WhisperDesktop/TranscribeDlg.h
index 9a90510..800d8eb 100644
--- a/Examples/WhisperDesktop/TranscribeDlg.h
+++ b/Examples/WhisperDesktop/TranscribeDlg.h
@@ -32,8 +32,9 @@ public:
ON_BUTTON_CLICK( IDC_BROWSE_MEDIA, onBrowseMedia )
ON_BUTTON_CLICK( IDC_BROWSE_RESULT, onBrowseOutput )
ON_BUTTON_CLICK( IDC_TRANSCRIBE, onTranscribe )
- ON_BUTTON_CLICK( IDC_CAPTURE, onCapture );
- COMMAND_HANDLER( IDC_OUTPUT_FORMAT, CBN_SELCHANGE, OnOutFormatChange )
+ ON_BUTTON_CLICK( IDC_CAPTURE, onCapture )
+ COMMAND_HANDLER( IDC_OUTPUT_FORMAT, CBN_SELCHANGE, onOutFormatChange )
+ COMMAND_HANDLER( IDC_PATH_MEDIA, EN_CHANGE, onInputChange )
MESSAGE_HANDLER( WM_CALLBACK_STATUS, onCallbackStatus )
MSG_WM_CLOSE( onWmClose )
END_MSG_MAP()
@@ -79,7 +80,8 @@ private:
CProgressBarCtrl progressBar;
void populateOutputFormats();
- LRESULT OnOutFormatChange( UINT, INT, HWND, BOOL& bHandled );
+ LRESULT onOutFormatChange( UINT, INT, HWND, BOOL& bHandled );
+ LRESULT onInputChange( UINT, INT, HWND, BOOL& );
void onInputFolderCheck();
void onBrowseMedia();
void onBrowseOutput();
@@ -125,6 +127,8 @@ private:
HRESULT progressCallback( double p ) noexcept;
void onWmClose();
- void setOutputPath();
+ // Populate output path based on the provided input media path
void setOutputPath( const CString& input );
+ // Populate output path based on the input media path in the edit box
+ void setOutputPath();
}; \ No newline at end of file