diff --git a/build_num b/build_num index b908dd6a5..c4a0a3e6a 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 1370 +#define BUILD_NUM 1372 diff --git a/src/gui/instDialog.cpp b/src/gui/instDialog.cpp index 5df5195a0..b8b12fc51 100644 --- a/src/gui/instDialog.cpp +++ b/src/gui/instDialog.cpp @@ -105,6 +105,14 @@ instDialog::instDialog(QWidget* p, rejectDialogFlag = false; currentLog = m_dialog->procLogDisplay; + QTextCursor cursor(currentLog->textCursor()); + normal_format = cursor.charFormat(); + error_format = normal_format; + error_format.setForeground(QBrush(Qt::red)); + error_format.setProperty(QTextFormat::FontWeight, 100); + highlight_format = normal_format; + highlight_format.setProperty(QTextFormat::FontWeight, 100); + currentSaveButton = m_dialog->saveMCLogButton; currentSaveButton->setEnabled(true); currentStopButton = m_dialog->controlMCButton; diff --git a/src/gui/instDialog.h b/src/gui/instDialog.h index 9597be998..1e7b94571 100644 --- a/src/gui/instDialog.h +++ b/src/gui/instDialog.h @@ -55,6 +55,7 @@ class QCheckListItem; class QPushButton; class QProgressBar; class QStringList; +class QTextCharFormat; //class QCheckTableItem; namespace libfwbuilder @@ -116,6 +117,10 @@ class instDialog : public QDialog, public FakeWizard bool showSelectedFlag; QTextEdit *currentLog; + QTextCharFormat normal_format; + QTextCharFormat error_format; + QTextCharFormat highlight_format; + QPushButton *currentSaveButton; QPushButton *currentStopButton; QProgressBar *currentProgressBar; diff --git a/src/gui/instDialog_ui_ops.cpp b/src/gui/instDialog_ui_ops.cpp index 6ff597732..4de0589f6 100644 --- a/src/gui/instDialog_ui_ops.cpp +++ b/src/gui/instDialog_ui_ops.cpp @@ -58,6 +58,9 @@ #include #include #include +#include +#include +#include #include "fwbuilder/Resources.h" #include "fwbuilder/FWObjectDatabase.h" @@ -223,36 +226,35 @@ void instDialog::storeInstallerOptions() void instDialog::summary() { - addToLog( "
" + QObject::tr("Summary:\n") ); - addToLog( QObject::tr("* firewall name : %1\n") - .arg(QString::fromUtf8(cnf.fwobj->getName().c_str())) ); - addToLog( QObject::tr("* user name : %1\n") - .arg(cnf.user)); - addToLog( QObject::tr("* management address : %1\n").arg(cnf.maddr) ); - addToLog( QObject::tr("* platform : %1\n") - .arg(cnf.fwobj->getStr("platform").c_str()) ); - addToLog( QObject::tr("* host OS : %1\n") - .arg(cnf.fwobj->getStr("host_OS").c_str()) ); - addToLog( QObject::tr("* Loading configuration from file %1\n") + QStringList str; + + str.append(QObject::tr("Summary:")); + str.append(QObject::tr("* firewall name : %1") + .arg(QString::fromUtf8(cnf.fwobj->getName().c_str()))); + str.append(QObject::tr("* user name : %1").arg(cnf.user)); + str.append(QObject::tr("* management address : %1").arg(cnf.maddr)); + str.append(QObject::tr("* platform : %1") + .arg(cnf.fwobj->getStr("platform").c_str())); + str.append( QObject::tr("* host OS : %1") + .arg(cnf.fwobj->getStr("host_OS").c_str())); + str.append( QObject::tr("* Loading configuration from file %1") .arg(cnf.fwbfile)); if (cnf.incremental) - { - addToLog( QObject::tr("* Incremental install\n")); - } + str.append(QObject::tr("* Incremental install")); + if (cnf.save_diff && cnf.incremental) - { - addToLog( - QObject::tr("* Configuration diff will be saved in file %1\n"). - arg(cnf.diff_file)); - } + str.append(QObject::tr("* Configuration diff will be saved in file %1"). + arg(cnf.diff_file)); + if (cnf.dry_run) - { - addToLog( - QObject::tr( - "* Commands will not be executed on the firewall\n")); - } - addToLog("
\n"); + str.append(QObject::tr("* Commands will not be executed on the firewall")); + + str.append(""); + + QTextCursor cursor = currentLog->textCursor(); + cursor.insertBlock(); + cursor.insertText(str.join("\n"), highlight_format); } void instDialog::fillCompileSelectList() @@ -465,37 +467,39 @@ void instDialog::saveLog() */ void instDialog::addToLog(const QString &line) { - if (fwbdebug) qDebug("instDialog::addToLog"); + if (fwbdebug) + qDebug("instDialog::addToLog: '%s'", line.toLatin1().constData()); + if (line.isEmpty()) return; if (currentLog) { - QString txt = line; - txt.replace(QRegExp("(Error(:| )[^\n]*)"), - QString("\\1")); - txt.replace(QRegExp("(Abnormal[^\n]*)"), - QString("\\1")); + QString txt = line.trimmed(); + QRegExp err1("(Error(:| )[^\n]*)"); + QRegExp err2("(Abnormal[^\n]*)"); + QRegExp err3("(fwb_[a-z]{1,}: \\S*\\.cpp:\\d{1,}: .*: Assertion .* failed.)"); - // the following regex matches assertion errors - txt.replace(QRegExp("(fwb_[a-z]{1,}: \\S*\\.cpp:\\d{1,}: .*: Assertion .* failed.)"), - QString("\\1")); + QTextCharFormat format; - txt.replace('\r', ""); - txt.replace('\n', ""); + if (err1.indexIn(txt) != -1 || + err2.indexIn(txt) != -1 || + err3.indexIn(txt) != -1) format = error_format; + else format = normal_format; /* See sourceforge bug https://sourceforge.net/tracker/?func=detail&aid=2847263&group_id=5314&atid=1070394 * - * insertHtml() becomes incrementally slow as the amount of text - * already in the QTextEditor increases. Compiling ~10 firewalls with - * few dozen rules each slows the output to a crawl on Windows. - * QTextEditor::append() seems to be much faster. + * QTextEditor::insertHtml() becomes incrementally slow as the + * amount of text already in the QTextEditor + * increases. Compiling ~10 firewalls with few dozen rules + * each slows the output to a crawl on Windows. Keeping each + * line in a separate block makes it much faster. */ - currentLog->append(txt); -// currentLog->insertHtml(txt); -// currentLog->ensureCursorVisible(); - if (fwbdebug) - qDebug("instDialog::addToLog: '%s'", txt.toLatin1().constData()); + QTextCursor cursor = currentLog->textCursor(); + cursor.insertBlock(); + cursor.insertText(txt, format); + + currentLog->ensureCursorVisible(); qApp->processEvents(); }