Add Option to toggle Line Wrap in Console (#1466)

This commit is contained in:
Florian Märkl 2019-04-18 18:42:27 +02:00 committed by GitHub
parent f3a246985a
commit f45badd026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

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

View File

@ -60,6 +60,7 @@ private:
QSharedPointer<CommandTask> commandTask;
std::unique_ptr<Ui::ConsoleWidget> ui;
QAction *actionWrapLines;
QList<QAction *> actions;
bool debugOutputEnabled;
int maxHistoryEntries;