diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp b/SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp new file mode 100644 index 0000000..033eb1c --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/debugconsole.cpp @@ -0,0 +1,79 @@ +#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); +} |
