Skip to content

Commit f6495de

Browse files
committed
fix decoder
1 parent 5c1cd23 commit f6495de

File tree

8 files changed

+457
-200
lines changed

8 files changed

+457
-200
lines changed

src/apps/HubertFA/gui/MainWindow.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ namespace HFA {
7575
}
7676

7777
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
78+
// 初始化错误文本格式为红色
79+
m_errorFormat.setForeground(Qt::red);
80+
7881
auto rmProvider = ExecutionProvider::CPU;
7982
int device_id = -1;
8083
if (isDmlAvailable(device_id)) {
@@ -394,7 +397,7 @@ namespace HFA {
394397
m_failIndex.append(filename + ": " + msg);
395398
progressBar->setValue(m_workFinished);
396399

397-
out->appendPlainText(filename + ": " + msg);
400+
appendErrorMessage(filename + ": " + msg);
398401

399402
if (m_workFinished == m_workTotal) {
400403
slot_threadFinished();
@@ -405,9 +408,6 @@ namespace HFA {
405408
m_workFinished++;
406409
progressBar->setValue(m_workFinished);
407410

408-
if (!msg.isEmpty())
409-
out->appendPlainText(filename + ": " + msg);
410-
411411
if (m_workFinished == m_workTotal) {
412412
slot_threadFinished();
413413
}
@@ -418,17 +418,18 @@ namespace HFA {
418418
.arg(m_workTotal - m_workError)
419419
.arg(m_workError)
420420
.arg(m_workTotal);
421-
if (m_workError > 0) {
422-
QString failSummary = "Failed tasks:\n";
423-
for (const QString &fileMsg : m_failIndex) {
424-
failSummary += " " + fileMsg + "\n";
425-
}
426-
out->appendPlainText(failSummary);
427-
m_failIndex.clear();
428-
}
421+
429422
QMessageBox::information(this, QApplication::applicationName(), msg);
423+
430424
m_workFinished = 0;
431425
m_workError = 0;
432426
m_workTotal = 0;
433427
}
428+
429+
void MainWindow::appendErrorMessage(const QString &message) const {
430+
QTextCursor cursor = out->textCursor();
431+
cursor.movePosition(QTextCursor::End);
432+
cursor.insertText(message + "\n", m_errorFormat);
433+
out->ensureCursorVisible();
434+
}
434435
}

src/apps/HubertFA/gui/MainWindow.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <QPluginLoader>
1414
#include <QProgressBar>
1515
#include <QPushButton>
16+
#include <QTextCharFormat> // 添加这行
1617
#include <QThreadPool>
1718

1819
#include "../util/Hfa.h"
@@ -74,6 +75,8 @@ namespace HFA {
7475
QStringList m_failIndex;
7576
QThreadPool *m_threadpool;
7677

78+
QTextCharFormat m_errorFormat;
79+
7780
void slot_outTgPath();
7881

7982
void slot_removeListItem() const;
@@ -86,6 +89,8 @@ namespace HFA {
8689

8790
void _q_fileMenuTriggered(const QAction *action);
8891
void _q_helpMenuTriggered(const QAction *action);
92+
93+
void appendErrorMessage(const QString &message) const;
8994
};
9095
}
91-
#endif // MAINWINDOW_H
96+
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)