30 #include <QStringList>
33 #include <QVBoxLayout>
34 #include <QPushButton>
37 #include <QFileDialog>
38 #include <QMessageBox>
45 m_config =
new Ui_Form();
46 m_config->setupUi(
this);
49 connect(m_config->saveToFile, &QAbstractButton::clicked,
this, &DebugGadgetWidget::saveLog);
50 connect(m_config->clearLog, &QAbstractButton::clicked,
this, &DebugGadgetWidget::clearLog);
58 void DebugGadgetWidget::saveLog()
60 QString fileName = QFileDialog::getSaveFileName(
61 this, tr(
"Save log File As"),
62 QString(
"gcs-debug-log-%0.html")
63 .arg(QDateTime::currentDateTime().toString(
"yyyyMMdd-hhmmss")),
65 if (fileName.isEmpty())
69 if (
file.open(QIODevice::WriteOnly)
70 && (
file.write(m_config->plainTextEdit->toHtml().toLatin1()) != -1)) {
73 QMessageBox::critical(
this, tr(
"Log Save"), tr(
"Unable to save log: ") + fileName,
79 void DebugGadgetWidget::clearLog()
81 m_config->plainTextEdit->clear();
85 const int line,
const QString &
function)
113 #ifdef QT_DEBUG // only display this extended info to devs
114 source = QString(
"[%0:%1 %2]").arg(file).arg(line).arg(
function);
121 m_config->plainTextEdit->setTextColor(color);
122 m_config->plainTextEdit->append(
123 QString(
"%0[%1]%2 %3").arg(QTime::currentTime().toString()).arg(type).arg(source).arg(msg));
125 QScrollBar *sb = m_config->plainTextEdit->verticalScrollBar();
126 sb->setValue(sb->maximum());
void message(DebugEngine::Level level, const QString &msg, const QString &file="", const int line=0, const QString &function="")
DebugGadgetWidget(QWidget *parent=nullptr)
static DebugEngine * getInstance()