Skip to content

Commit 51da2cd

Browse files
committed
ai_processing_page: add auto format selector
add jpg and png for transcoder_page Signed-off-by: Jack Lau <[email protected]>
1 parent 053b31d commit 51da2cd

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

src/builder/include/ai_processing_page.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private slots:
5656
void OnInputFileSelected(const QString &filePath);
5757
void OnOutputFileSelected(const QString &filePath);
5858
void OnAlgorithmChanged(int index);
59+
void OnFormatChanged(int index);
5960
void OnProcessClicked();
6061
void OnProcessFinished(bool success);
6162

@@ -103,6 +104,11 @@ private slots:
103104
QLabel *audioBitrateLabel;
104105
BitrateWidget *audioBitrateWidget;
105106

107+
// Format section
108+
QGroupBox *formatGroupBox;
109+
QLabel *formatLabel;
110+
QComboBox *formatComboBox;
111+
106112
// Progress section
107113
ProgressWidget *progressWidget;
108114

src/builder/src/ai_processing_page.cpp

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ void AIProcessingPage::OnPageActivated() {
8484
}
8585

8686
void 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

95102
void AIProcessingPage::OnPageDeactivated() {
96103
BasePage::OnPageDeactivated();
104+
HandleSharedDataUpdate(inputFileSelector->GetLineEdit(), outputFileSelector->GetLineEdit(),
105+
formatComboBox->currentText());
97106
}
98107

99108
void 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+
279319
void 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
}

src/builder/src/transcode_page.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void TranscodePage::SetupUI() {
7272
tr("Input File"),
7373
FileSelectorWidget::InputFile,
7474
tr("Select a media file or click Batch for multiple files..."),
75-
tr("Media Files (*.mp4 *.avi *.mkv *.mov *.flv *.wmv *.webm *.ts *.m4v);;All Files (*.*)"),
75+
tr("All Files (*.*)"),
7676
tr("Select Media File"),
7777
this
7878
);
@@ -159,7 +159,7 @@ void TranscodePage::SetupUI() {
159159

160160
formatLabel = new QLabel(tr("Format:"), formatGroupBox);
161161
formatComboBox = new QComboBox(formatGroupBox);
162-
formatComboBox->addItems({"mp4", "mkv", "avi", "mov", "flv", "webm", "ts"});
162+
formatComboBox->addItems({"mp4", "mkv", "avi", "mov", "flv", "webm", "ts", "jpg", "png"});
163163
formatComboBox->setCurrentText("mp4");
164164
connect(formatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
165165
this, &TranscodePage::OnFormatChanged);

0 commit comments

Comments
 (0)