Use config font in ConsoleWidget and Hexdump parse

This commit is contained in:
Florian Märkl 2017-11-26 22:54:44 +01:00
parent aa15f0b7ae
commit cc7a6533c0
6 changed files with 24 additions and 43 deletions

View File

@ -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;

View File

@ -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(),

View File

@ -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);
}

View File

@ -30,6 +30,8 @@ public slots:
void focusInputLineEdit();
private slots:
void setupFont();
void on_inputLineEdit_returnPressed();
void on_execButton_clicked();

View File

@ -43,9 +43,6 @@
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">/*QPlainTextEdit { background: rgb(226, 230, 235) }*/</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@ -66,7 +63,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
<number>4</number>
</property>
<property name="leftMargin">
<number>5</number>
@ -82,13 +79,8 @@
</property>
<item>
<widget class="QLineEdit" name="inputLineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">/*border-top: 1px solid rgb(255, 255, 255);*/</string>
<string notr="true">border: 2px solid palette(base);</string>
</property>
<property name="frame">
<bool>false</bool>
@ -103,6 +95,12 @@
</item>
<item>
<widget class="QToolButton" name="execButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Execute command</string>
</property>

View File

@ -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()