@@ -84,6 +84,13 @@ void AIProcessingPage::OnPageActivated() {
8484}
8585
8686void AIProcessingPage::OnInputFileChanged (const QString &newPath) {
87+ QString ext = GetFileExtension (newPath);
88+ if (!ext.isEmpty ()) {
89+ int index = formatComboBox->findText (ext);
90+ if (index >= 0 ) {
91+ formatComboBox->setCurrentIndex (index);
92+ }
93+ }
8794 // Update output path when input changes
8895 UpdateOutputPath ();
8996}
@@ -94,6 +101,8 @@ void AIProcessingPage::OnOutputPathUpdate() {
94101
95102void AIProcessingPage::OnPageDeactivated () {
96103 BasePage::OnPageDeactivated ();
104+ HandleSharedDataUpdate (inputFileSelector->GetLineEdit (), outputFileSelector->GetLineEdit (),
105+ formatComboBox->currentText ());
97106}
98107
99108void AIProcessingPage::SetupUI () {
@@ -106,7 +115,7 @@ void AIProcessingPage::SetupUI() {
106115 tr (" Input File" ),
107116 FileSelectorWidget::InputFile,
108117 tr (" Select a media file or click Batch for multiple files..." ),
109- tr (" Media Files (*.mp4 *.avi *.mkv *.mov *.flv *.wmv *.webm *.ts *.m4v);; All Files (*.*)" ),
118+ tr (" All Files (*.*)" ),
110119 tr (" Select Media File" ),
111120 this
112121 );
@@ -166,8 +175,8 @@ void AIProcessingPage::SetupUI() {
166175
167176 videoCodecLabel = new QLabel (tr (" Codec:" ), videoGroupBox);
168177 videoCodecComboBox = new QComboBox (videoGroupBox);
169- videoCodecComboBox->addItems ({" libx264" , " libx265" , " libvpx-vp9" , " copy" });
170- videoCodecComboBox->setCurrentText (" libx264 " );
178+ videoCodecComboBox->addItems ({" auto " , " libx264" , " libx265" , " libvpx-vp9" , " copy" });
179+ videoCodecComboBox->setCurrentText (" auto " );
171180
172181 videoBitrateLabel = new QLabel (tr (" Bitrate:" ), videoGroupBox);
173182 videoBitrateWidget = new BitrateWidget (BitrateWidget::Video, videoGroupBox);
@@ -186,8 +195,8 @@ void AIProcessingPage::SetupUI() {
186195
187196 audioCodecLabel = new QLabel (tr (" Codec:" ), audioGroupBox);
188197 audioCodecComboBox = new QComboBox (audioGroupBox);
189- audioCodecComboBox->addItems ({" aac" , " libmp3lame" , " libopus" , " copy" });
190- audioCodecComboBox->setCurrentText (" aac " );
198+ audioCodecComboBox->addItems ({" auto " , " aac" , " libmp3lame" , " libopus" , " copy" });
199+ audioCodecComboBox->setCurrentText (" auto " );
191200
192201 audioBitrateLabel = new QLabel (tr (" Bitrate:" ), audioGroupBox);
193202 audioBitrateWidget = new BitrateWidget (BitrateWidget::Audio, audioGroupBox);
@@ -199,12 +208,29 @@ void AIProcessingPage::SetupUI() {
199208
200209 mainLayout->addWidget (audioGroupBox);
201210
211+ // Format Section
212+ formatGroupBox = new QGroupBox (tr (" File Format" ), this );
213+ QHBoxLayout *formatLayout = new QHBoxLayout (formatGroupBox);
214+
215+ formatLabel = new QLabel (tr (" Format:" ), formatGroupBox);
216+ formatComboBox = new QComboBox (formatGroupBox);
217+ formatComboBox->addItems ({" mp4" , " mkv" , " avi" , " mov" , " flv" , " webm" , " ts" , " jpg" , " png" });
218+ formatComboBox->setCurrentText (" mp4" );
219+ connect (formatComboBox, QOverload<int >::of (&QComboBox::currentIndexChanged),
220+ this , &AIProcessingPage::OnFormatChanged);
221+
222+ formatLayout->addWidget (formatLabel);
223+ formatLayout->addWidget (formatComboBox);
224+ formatLayout->addStretch ();
225+
226+ mainLayout->addWidget (formatGroupBox);
227+
202228 // Output File Selector
203229 outputFileSelector = new FileSelectorWidget (
204230 tr (" Output File" ),
205231 FileSelectorWidget::OutputFile,
206232 tr (" Output file path..." ),
207- tr (" Media Files (*.mp4 *.avi *.mkv *.mov);; All Files (*.*)" ),
233+ tr (" All Files (*.*)" ),
208234 tr (" Select Output File" ),
209235 this
210236 );
@@ -259,6 +285,15 @@ void AIProcessingPage::OnInputFileSelected(const QString &filePath) {
259285 mainWindow->GetSharedData ()->SetInputFilePath (filePath);
260286 }
261287
288+ // Set default format to same as input file
289+ QString ext = GetFileExtension (filePath);
290+ if (!ext.isEmpty ()) {
291+ int index = formatComboBox->findText (ext);
292+ if (index >= 0 ) {
293+ formatComboBox->setCurrentIndex (index);
294+ }
295+ }
296+
262297 // Update output path
263298 UpdateOutputPath ();
264299}
@@ -276,11 +311,17 @@ void AIProcessingPage::OnAlgorithmChanged(int index) {
276311 algoSettingsStack->setCurrentIndex (index);
277312}
278313
314+ void AIProcessingPage::OnFormatChanged (int index) {
315+ Q_UNUSED (index);
316+ UpdateOutputPath ();
317+ }
318+
279319void AIProcessingPage::OnProcessClicked () {
280320 // Check if batch mode is active
281321 if (batchModeHelper->IsBatchMode ()) {
282322 // Batch mode: Add to queue
283- batchModeHelper->AddToQueue (" mp4" ); // Default output format
323+ QString format = formatComboBox->currentText ();
324+ batchModeHelper->AddToQueue (format);
284325 return ;
285326 }
286327
@@ -321,7 +362,8 @@ void AIProcessingPage::UpdateOutputPath() {
321362 if (!inputPath.isEmpty ()) {
322363 OpenConverter *mainWindow = qobject_cast<OpenConverter *>(window ());
323364 if (mainWindow && mainWindow->GetSharedData ()) {
324- QString outputPath = mainWindow->GetSharedData ()->GenerateOutputPath (" mp4" );
365+ QString format = formatComboBox->currentText ();
366+ QString outputPath = mainWindow->GetSharedData ()->GenerateOutputPath (format);
325367 outputFileSelector->SetFilePath (outputPath);
326368 processButton->setEnabled (true );
327369 }
0 commit comments