summaryrefslogtreecommitdiffstats
path: root/Examples
diff options
context:
space:
mode:
authorKonstantin <const@const.me>2023-01-20 20:02:26 +0100
committerKonstantin <const@const.me>2023-01-20 20:02:26 +0100
commit9c30dd0f95a11cb24f97b7eabd8eebb7ebdd5134 (patch)
tree3922d39035523f9a2855e699d847af3dae4dbd61 /Examples
parentb188f58777d42884747bc6419e8b01adc8d4b339 (diff)
UX improvement, populate output path
Diffstat (limited to 'Examples')
-rw-r--r--Examples/WhisperDesktop/Resource.h5
-rw-r--r--Examples/WhisperDesktop/TranscribeDlg.cpp56
-rw-r--r--Examples/WhisperDesktop/TranscribeDlg.h6
-rw-r--r--Examples/WhisperDesktop/Utils/miscUtils.h7
-rw-r--r--Examples/WhisperDesktop/WhisperDesktop.rcbin20076 -> 20384 bytes
5 files changed, 67 insertions, 7 deletions
diff --git a/Examples/WhisperDesktop/Resource.h b/Examples/WhisperDesktop/Resource.h
index a4ccf94..530d222 100644
--- a/Examples/WhisperDesktop/Resource.h
+++ b/Examples/WhisperDesktop/Resource.h
@@ -49,8 +49,9 @@
#define IDC_TRANSLATE 1026
#define IDC_MODEL_ADV 1027
#define IDC_WAVE 1028
-#define IDC_WAVE2 1029
#define IDC_RESHAPED_MAT_MUL 1029
+#define IDC_CHECK2 1029
+#define IDC_USE_INPUT_FOLDER 1029
#define IDC_STATIC -1
// Next default values for new objects
@@ -60,7 +61,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32771
-#define _APS_NEXT_CONTROL_VALUE 1029
+#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
diff --git a/Examples/WhisperDesktop/TranscribeDlg.cpp b/Examples/WhisperDesktop/TranscribeDlg.cpp
index b99e98a..bfdb6f1 100644
--- a/Examples/WhisperDesktop/TranscribeDlg.cpp
+++ b/Examples/WhisperDesktop/TranscribeDlg.cpp
@@ -37,7 +37,7 @@ LRESULT TranscribeDlg::OnInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam
{
languageSelector, GetDlgItem( IDC_TRANSLATE ),
sourceMediaPath, GetDlgItem( IDC_BROWSE_MEDIA ),
- transcribeOutFormat,
+ transcribeOutFormat, useInputFolder,
transcribeOutputPath, GetDlgItem( IDC_BROWSE_RESULT ),
GetDlgItem( IDC_TRANSCRIBE ),
GetDlgItem( IDCANCEL ),
@@ -120,9 +120,17 @@ enum struct TranscribeDlg::eOutputFormat : uint8_t
LRESULT TranscribeDlg::OnOutFormatChange( UINT, INT, HWND, BOOL& bHandled )
{
- const BOOL enabled = transcribeOutFormat.GetCurSel() != 0;
+ BOOL enabled = transcribeOutFormat.GetCurSel() != 0;
+ useInputFolder.EnableWindow( enabled );
+
+ if( isChecked( useInputFolder ) && enabled )
+ {
+ enabled = FALSE;
+ setOutputPath();
+ }
transcribeOutputPath.EnableWindow( enabled );
transcribeOutputBrowse.EnableWindow( enabled );
+
return 0;
}
@@ -133,8 +141,11 @@ void TranscribeDlg::onBrowseMedia()
CString path;
sourceMediaPath.GetWindowText( path );
- if( getOpenFileName( m_hWnd, title, filters, path ) )
- sourceMediaPath.SetWindowText( path );
+ if( !getOpenFileName( m_hWnd, title, filters, path ) )
+ return;
+ sourceMediaPath.SetWindowText( path );
+ if( useInputFolder.IsWindowEnabled() && useInputFolder.GetCheck() == BST_CHECKED )
+ setOutputPath( path );
}
static const LPCTSTR outputFilters = L"Text files (*.txt)\0*.txt\0SubRip subtitles (*.srt)\0*.srt\0WebVTT subtitles (*.vtt)\0*.vtt\0\0";
@@ -143,6 +154,43 @@ static const std::array<LPCTSTR, 3> outputExtensions =
L".txt", L".srt", L".vtt"
};
+void TranscribeDlg::setOutputPath( const CString& input )
+{
+ const int format = transcribeOutFormat.GetCurSel() - 1;
+ if( format < 0 || format >= outputExtensions.size() )
+ return;
+ const LPCTSTR ext = outputExtensions[ format ];
+ CString path = input;
+ const bool renamed = PathRenameExtension( path.GetBufferSetLength( path.GetLength() + 4 ), ext );
+ path.ReleaseBuffer();
+ if( !renamed )
+ return;
+ transcribeOutputPath.SetWindowText( path );
+}
+
+void TranscribeDlg::setOutputPath()
+{
+ CString path;
+ if( !sourceMediaPath.GetWindowText( path ) )
+ return;
+ if( path.GetLength() <= 0 )
+ return;
+ setOutputPath( path );
+}
+
+void TranscribeDlg::onInputFolderCheck()
+{
+ const bool checked = isChecked( useInputFolder );
+
+ BOOL enableOutput = checked ? FALSE : TRUE;
+ transcribeOutputPath.EnableWindow( enableOutput );
+ transcribeOutputBrowse.EnableWindow( enableOutput );
+
+ if( !checked )
+ return;
+ setOutputPath();
+}
+
void TranscribeDlg::onBrowseOutput()
{
const DWORD origFilterIndex = (DWORD)transcribeOutFormat.GetCurSel() - 1;
diff --git a/Examples/WhisperDesktop/TranscribeDlg.h b/Examples/WhisperDesktop/TranscribeDlg.h
index 354e002..9a90510 100644
--- a/Examples/WhisperDesktop/TranscribeDlg.h
+++ b/Examples/WhisperDesktop/TranscribeDlg.h
@@ -28,6 +28,7 @@ public:
ON_BUTTON_CLICK( IDC_CONSOLE, cbConsole.click )
ON_BUTTON_CLICK( IDCANCEL, onClose )
ON_BUTTON_CLICK( IDC_BACK, onBack )
+ ON_BUTTON_CLICK( IDC_USE_INPUT_FOLDER, onInputFolderCheck )
ON_BUTTON_CLICK( IDC_BROWSE_MEDIA, onBrowseMedia )
ON_BUTTON_CLICK( IDC_BROWSE_RESULT, onBrowseOutput )
ON_BUTTON_CLICK( IDC_TRANSCRIBE, onTranscribe )
@@ -41,6 +42,7 @@ public:
DDX_CONTROL_HANDLE( IDC_MODEL_DESC, modelDesc )
DDX_CONTROL_HANDLE( IDC_PATH_MEDIA, sourceMediaPath )
DDX_CONTROL_HANDLE( IDC_OUTPUT_FORMAT, transcribeOutFormat )
+ DDX_CONTROL_HANDLE( IDC_USE_INPUT_FOLDER, useInputFolder )
DDX_CONTROL_HANDLE( IDC_PATH_RESULT, transcribeOutputPath )
DDX_CONTROL_HANDLE( IDC_BROWSE_RESULT, transcribeOutputBrowse );
DDX_CONTROL_HANDLE( IDC_TRANSCRIBE_PROGRESS, progressBar );
@@ -70,6 +72,7 @@ private:
TranslateCheckbox cbTranslate;
CEdit sourceMediaPath;
+ CButton useInputFolder;
CEdit transcribeOutputPath;
CButton transcribeOutputBrowse;
CComboBox transcribeOutFormat;
@@ -77,6 +80,7 @@ private:
void populateOutputFormats();
LRESULT OnOutFormatChange( UINT, INT, HWND, BOOL& bHandled );
+ void onInputFolderCheck();
void onBrowseMedia();
void onBrowseOutput();
void onTranscribe();
@@ -121,4 +125,6 @@ private:
HRESULT progressCallback( double p ) noexcept;
void onWmClose();
+ void setOutputPath();
+ void setOutputPath( const CString& input );
}; \ No newline at end of file
diff --git a/Examples/WhisperDesktop/Utils/miscUtils.h b/Examples/WhisperDesktop/Utils/miscUtils.h
index 8cf8151..1beb7b3 100644
--- a/Examples/WhisperDesktop/Utils/miscUtils.h
+++ b/Examples/WhisperDesktop/Utils/miscUtils.h
@@ -69,4 +69,9 @@ inline uint32_t flipRgb( uint32_t val )
return val >> 8;
}
-bool isInvalidTranslate( HWND owner, uint32_t lang, bool translate ); \ No newline at end of file
+bool isInvalidTranslate( HWND owner, uint32_t lang, bool translate );
+
+inline bool isChecked( CButton& btn )
+{
+ return btn.GetCheck() == BST_CHECKED;
+} \ No newline at end of file
diff --git a/Examples/WhisperDesktop/WhisperDesktop.rc b/Examples/WhisperDesktop/WhisperDesktop.rc
index ecf30cd..de8627b 100644
--- a/Examples/WhisperDesktop/WhisperDesktop.rc
+++ b/Examples/WhisperDesktop/WhisperDesktop.rc
Binary files differ