From cc7a6533c066e8273b0b6c28211243d0a25a1207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 26 Nov 2017 22:54:44 +0100 Subject: [PATCH] Use config font in ConsoleWidget and Hexdump parse --- src/utils/Helpers.cpp | 20 -------------------- src/utils/Helpers.h | 3 --- src/widgets/ConsoleWidget.cpp | 22 ++++++++++++---------- src/widgets/ConsoleWidget.h | 2 ++ src/widgets/ConsoleWidget.ui | 18 ++++++++---------- src/widgets/HexdumpWidget.cpp | 2 ++ 6 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/utils/Helpers.cpp b/src/utils/Helpers.cpp index 05effc2d..82b9d72d 100644 --- a/src/utils/Helpers.cpp +++ b/src/utils/Helpers.cpp @@ -21,26 +21,6 @@ static QAbstractItemView::ScrollMode scrollMode() namespace qhelpers { - // TODO: wouldn't it be enough to setFont on the QWidget? - - void normalizeFont(QPlainTextEdit *edit) - { -#ifdef Q_OS_LINUX - QFont anonFont("Inconsolata", 12); - QTextDocument *out_doc = edit->document(); - out_doc->setDefaultFont(anonFont); -#endif - } - - void normalizeEditFont(QTextEdit *edit) - { -#ifdef Q_OS_LINUX - QFont anonFont("Inconsolata", 12); - QTextDocument *out_doc = edit->document(); - out_doc->setDefaultFont(anonFont); -#endif - } - void adjustColumns(QTreeWidget *tw, int columnCount, int padding) { const int count = columnCount == 0 ? tw->columnCount() : columnCount; diff --git a/src/utils/Helpers.h b/src/utils/Helpers.h index 84174ef4..77c669cd 100644 --- a/src/utils/Helpers.h +++ b/src/utils/Helpers.h @@ -15,9 +15,6 @@ class QWidget; namespace qhelpers { - void normalizeFont(QPlainTextEdit *edit); - void normalizeEditFont(QTextEdit *edit); - void adjustColumns(QTreeWidget *tw, int columnCount = 0, int padding = 0); QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(), diff --git a/src/widgets/ConsoleWidget.cpp b/src/widgets/ConsoleWidget.cpp index 160ebcdd..b8a23233 100644 --- a/src/widgets/ConsoleWidget.cpp +++ b/src/widgets/ConsoleWidget.cpp @@ -68,6 +68,7 @@ static const int invalidHistoryPos = -1; static bool isForbidden(const QString &input) { + return false; static const QRegExp delimiters("[;&]"); @@ -102,20 +103,13 @@ ConsoleWidget::ConsoleWidget(QWidget *parent) : // Adjust console lineedit ui->inputLineEdit->setTextMargins(10, 0, 0, 0); - /* - ui->consoleOutputTextEdit->setFont(QFont("Monospace", 8)); - ui->consoleOutputTextEdit->setStyleSheet("background-color:black;color:gray;"); - ui->consoleInputLineEdit->setStyleSheet("background-color:black;color:gray;"); - */ + setupFont(); // Adjust text margins of consoleOutputTextEdit QTextDocument *console_docu = ui->outputTextEdit->document(); console_docu->setDocumentMargin(10); - // Fix output panel font - qhelpers::normalizeFont(ui->outputTextEdit); - - QAction *action = new QAction(tr("Clear ouput"), ui->outputTextEdit); + QAction *action = new QAction(tr("Clear Output"), ui->outputTextEdit); connect(action, SIGNAL(triggered(bool)), ui->outputTextEdit, SLOT(clear())); actions.append(action); @@ -145,10 +139,17 @@ ConsoleWidget::ConsoleWidget(QWidget *parent) : QShortcut *historyOnDown = new QShortcut(QKeySequence(Qt::Key_Down), ui->inputLineEdit); connect(historyOnDown, SIGNAL(activated()), this, SLOT(historyNext())); historyOnDown->setContext(Qt::WidgetShortcut); + + connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(setupFont())); } ConsoleWidget::~ConsoleWidget() {} +void ConsoleWidget::setupFont() +{ + ui->outputTextEdit->setFont(Config()->getFont()); +} + void ConsoleWidget::addOutput(const QString &msg) { ui->outputTextEdit->appendPlainText(msg); @@ -177,7 +178,8 @@ void ConsoleWidget::on_inputLineEdit_returnPressed() if (!isForbidden(input)) { QString res = CutterCore::getInstance()->cmd(input); - ui->outputTextEdit->appendPlainText(res); + QString cmd_line = "[" + RAddressString(Core()->getOffset()) + "]> " + input + "\n"; + ui->outputTextEdit->appendPlainText(cmd_line + res); scrollOutputToEnd(); historyAdd(input); } diff --git a/src/widgets/ConsoleWidget.h b/src/widgets/ConsoleWidget.h index 292cd87f..e472cd02 100644 --- a/src/widgets/ConsoleWidget.h +++ b/src/widgets/ConsoleWidget.h @@ -30,6 +30,8 @@ public slots: void focusInputLineEdit(); private slots: + void setupFont(); + void on_inputLineEdit_returnPressed(); void on_execButton_clicked(); diff --git a/src/widgets/ConsoleWidget.ui b/src/widgets/ConsoleWidget.ui index 0499ddf3..67d05e85 100644 --- a/src/widgets/ConsoleWidget.ui +++ b/src/widgets/ConsoleWidget.ui @@ -43,9 +43,6 @@ 11 - - /*QPlainTextEdit { background: rgb(226, 230, 235) }*/ - QFrame::NoFrame @@ -66,7 +63,7 @@ - 0 + 4 5 @@ -82,13 +79,8 @@ - - - 12 - - - /*border-top: 1px solid rgb(255, 255, 255);*/ + border: 2px solid palette(base); false @@ -103,6 +95,12 @@ + + + 0 + 0 + + Execute command diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 43165377..0c04ed38 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -714,6 +714,8 @@ void HexdumpWidget::setupFonts() ui->offsetHeaderLabel->setFont(font); ui->hexHeaderLabel->setFont(font); ui->asciiHeaderLabel->setFont(font); + + ui->hexDisasTextEdit->setFont(font); } void HexdumpWidget::fontsUpdated()