From f45badd026b3fe8cdecd09e99cb5e108950f1a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 18 Apr 2019 18:42:27 +0200 Subject: [PATCH] Add Option to toggle Line Wrap in Console (#1466) --- src/widgets/ConsoleWidget.cpp | 11 +++++++++++ src/widgets/ConsoleWidget.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/widgets/ConsoleWidget.cpp b/src/widgets/ConsoleWidget.cpp index 02462356..3cd10d46 100644 --- a/src/widgets/ConsoleWidget.cpp +++ b/src/widgets/ConsoleWidget.cpp @@ -88,6 +88,13 @@ ConsoleWidget::ConsoleWidget(MainWindow *main, QAction *action) : connect(actionClear, SIGNAL(triggered(bool)), ui->outputTextEdit, SLOT(clear())); actions.append(actionClear); + actionWrapLines = new QAction(tr("Wrap Lines"), ui->outputTextEdit); + actionWrapLines->setCheckable(true); + connect(actionWrapLines, &QAction::triggered, this, [this] (bool checked) { + ui->outputTextEdit->setLineWrapMode(checked ? QPlainTextEdit::WidgetWidth: QPlainTextEdit::NoWrap); + }); + actions.append(actionWrapLines); + // Completion QCompleter *completer = new QCompleter(radareArgs, this); completer->setMaxVisibleItems(20); @@ -96,6 +103,8 @@ ConsoleWidget::ConsoleWidget(MainWindow *main, QAction *action) : ui->inputLineEdit->setCompleter(completer); + ui->outputTextEdit->setLineWrapMode(QPlainTextEdit::WidgetWidth); + // Set console output context menu ui->outputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->outputTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)), @@ -213,6 +222,8 @@ void ConsoleWidget::on_execButton_clicked() void ConsoleWidget::showCustomContextMenu(const QPoint &pt) { + actionWrapLines->setChecked(ui->outputTextEdit->lineWrapMode() == QPlainTextEdit::WidgetWidth); + QMenu *menu = new QMenu(ui->outputTextEdit); menu->addActions(actions); menu->exec(ui->outputTextEdit->mapToGlobal(pt)); diff --git a/src/widgets/ConsoleWidget.h b/src/widgets/ConsoleWidget.h index 853f36c7..baa19bcb 100644 --- a/src/widgets/ConsoleWidget.h +++ b/src/widgets/ConsoleWidget.h @@ -60,6 +60,7 @@ private: QSharedPointer commandTask; std::unique_ptr ui; + QAction *actionWrapLines; QList actions; bool debugOutputEnabled; int maxHistoryEntries;