#include "debugconsole.h"#include "ui_debugconsole.h"#include "iconmanager.h"#include <QPushButton>DebugConsole::DebugConsole(QWidget *parent) :QDialog(parent),ui(new Ui::DebugConsole){ui->setupUi(this);ui->textEdit->setReadOnly(true);QPushButton* resetBtn = ui->buttonBox->button(QDialogButtonBox::Reset);connect(resetBtn, SIGNAL(clicked()), this, SLOT(reset()));initFormats();}DebugConsole::~DebugConsole(){delete ui;}void DebugConsole::debug(const QString &msg){message(msg, dbgFormat);}void DebugConsole::warning(const QString &msg){message(msg, wrnFormat);}void DebugConsole::critical(const QString &msg){message(msg, criFormat);}void DebugConsole::fatal(const QString &msg){message(msg, fatFormat);}void DebugConsole::initFormats(){dbgFormat.setForeground(Qt::blue);wrnFormat.setForeground(Qt::darkRed);criFormat.setForeground(Qt::red);criFormat.setFontUnderline(true);fatFormat.setForeground(Qt::red);fatFormat.setFontUnderline(true);QFontMetrics fm(ui->textEdit->font());int indent = fm.width(QString("X").repeated(25));ui->textEdit->document()->setIndentWidth(indent);blockFormat.setIndent(1);blockFormat.setTextIndent(-indent);}void DebugConsole::message(const QString &msg, const QTextCharFormat &format){ui->textEdit->setCurrentCharFormat(format);QTextCursor cur = ui->textEdit->textCursor();cur.insertText(msg);cur.mergeBlockFormat(blockFormat);cur.insertBlock(blockFormat);}void DebugConsole::reset(){ui->textEdit->clear();}void DebugConsole::showEvent(QShowEvent*){setWindowIcon(ICONS.SQLITESTUDIO_APP);}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。