mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-29 15:55:04 +00:00
Toggle Console Widget and clear output (#2213)
* Add shortcuts to toggle Console and clear its output * Update the docs Co-authored-by: Kārlis Seņko <karlis3p70l1ij@gmail.com>
This commit is contained in:
parent
b1e79ec6a6
commit
bfec29f825
@ -30,6 +30,10 @@ Widget shortcuts
|
||||
+-----------+---------+
|
||||
| Shift+E | Exports |
|
||||
+-----------+---------+
|
||||
| Ctrl+` | Console |
|
||||
+-----------+---------+
|
||||
| : | Console |
|
||||
+-----------+---------+
|
||||
|
||||
Disassembly view shortcuts
|
||||
--------------------------
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "ui_ConsoleWidget.h"
|
||||
#include "common/Helpers.h"
|
||||
#include "common/SvgIconEngine.h"
|
||||
#include "WidgetShortcuts.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <io.h>
|
||||
@ -59,8 +60,24 @@ ConsoleWidget::ConsoleWidget(MainWindow *main) :
|
||||
QTextDocument *console_docu = ui->outputTextEdit->document();
|
||||
console_docu->setDocumentMargin(10);
|
||||
|
||||
QAction *actionClear = new QAction(tr("Clear Output"), ui->outputTextEdit);
|
||||
connect(actionClear, SIGNAL(triggered(bool)), ui->outputTextEdit, SLOT(clear()));
|
||||
// Ctrl+` and ';' to toggle console widget
|
||||
QAction *toggleConsole = toggleViewAction();
|
||||
QList<QKeySequence> toggleShortcuts;
|
||||
toggleShortcuts << widgetShortcuts["ConsoleWidget"] << widgetShortcuts["ConsoleWidgetAlternative"];
|
||||
toggleConsole->setShortcuts(toggleShortcuts);
|
||||
connect(toggleConsole, &QAction::triggered, this, [this, toggleConsole](){
|
||||
if (toggleConsole->isChecked()) {
|
||||
widgetToFocusOnRaise()->setFocus();
|
||||
}
|
||||
});
|
||||
|
||||
QAction *actionClear = new QAction(tr("Clear Output"), this);
|
||||
connect(actionClear, &QAction::triggered, ui->outputTextEdit, &QPlainTextEdit::clear);
|
||||
addAction(actionClear);
|
||||
|
||||
// Ctrl+l to clear the output
|
||||
actionClear->setShortcut(Qt::CTRL + Qt::Key_L);
|
||||
actionClear->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
actions.append(actionClear);
|
||||
|
||||
actionWrapLines = new QAction(tr("Wrap Lines"), ui->outputTextEdit);
|
||||
@ -157,6 +174,11 @@ bool ConsoleWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *ConsoleWidget::widgetToFocusOnRaise()
|
||||
{
|
||||
return ui->r2InputLineEdit;
|
||||
}
|
||||
|
||||
void ConsoleWidget::setupFont()
|
||||
{
|
||||
ui->outputTextEdit->setFont(Config()->getFont());
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
QWidget* widgetToFocusOnRaise() override;
|
||||
|
||||
public slots:
|
||||
void focusInputLineEdit();
|
||||
|
@ -2,10 +2,12 @@
|
||||
#define WIDGETSHORTCUTS_H
|
||||
|
||||
static const QHash<QString, QKeySequence> widgetShortcuts = {
|
||||
{ "StringsWidget", Qt::SHIFT + Qt::Key_F12 },
|
||||
{ "GraphWidget", Qt::SHIFT + Qt::Key_G },
|
||||
{ "ImportsWidget", Qt::SHIFT + Qt::Key_I },
|
||||
{ "ExportsWidget", Qt::SHIFT + Qt::Key_E }
|
||||
{ "StringsWidget", Qt::SHIFT + Qt::Key_F12 },
|
||||
{ "GraphWidget", Qt::SHIFT + Qt::Key_G },
|
||||
{ "ImportsWidget", Qt::SHIFT + Qt::Key_I },
|
||||
{ "ExportsWidget", Qt::SHIFT + Qt::Key_E },
|
||||
{ "ConsoleWidget", Qt::CTRL + Qt::Key_QuoteLeft },
|
||||
{ "ConsoleWidgetAlternative", Qt::Key_Colon }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user