mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +00:00
* Add shift-F12 shortcut for strings widget. * change strings shortcut to use global map * add Shift-I shortcut for Imports * add Shift-E shortcut for Exports * add Shift-G shortcut for Graph view * add widgets shortcuts map file * update widget checkboxes when using shortcuts
This commit is contained in:
parent
25b4301906
commit
4b454e086e
@ -627,6 +627,11 @@ void MainWindow::updateDockActionsChecked()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateDockActionChecked(QAction * action)
|
||||
{
|
||||
action->setChecked(!dockWidgetActions[action]->isHidden());
|
||||
}
|
||||
|
||||
void MainWindow::showZenDocks()
|
||||
{
|
||||
const QList<QDockWidget *> zenDocks = { functionsDock,
|
||||
|
@ -99,6 +99,8 @@ public:
|
||||
void addDockWidgetAction(QDockWidget *dockWidget, QAction *action);
|
||||
void addExtraWidget(QDockWidget *extraDock);
|
||||
|
||||
void updateDockActionChecked(QAction * action);
|
||||
|
||||
|
||||
public slots:
|
||||
void finalizeOpen();
|
||||
@ -241,10 +243,11 @@ private:
|
||||
void hideAllDocks();
|
||||
void showZenDocks();
|
||||
void showDebugDocks();
|
||||
void updateDockActionsChecked();
|
||||
|
||||
void toggleDockWidget(QDockWidget *dock_widget, bool show);
|
||||
|
||||
void updateDockActionsChecked();
|
||||
|
||||
public:
|
||||
QString getFilename() const
|
||||
{
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "MainWindow.h"
|
||||
#include "utils/Helpers.h"
|
||||
|
||||
#include "WidgetShortcuts.h"
|
||||
|
||||
ExportsModel::ExportsModel(QList<ExportDescription> *exports, QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
exports(exports)
|
||||
@ -126,6 +128,12 @@ ExportsWidget::ExportsWidget(MainWindow *main, QAction *action) :
|
||||
ui->exportsTreeView->setModel(exportsProxyModel);
|
||||
ui->exportsTreeView->sortByColumn(ExportsModel::OffsetColumn, Qt::AscendingOrder);
|
||||
|
||||
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["ExportsWidget"], main);
|
||||
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
|
||||
toggleDockWidget(true);
|
||||
main->updateDockActionChecked(action);
|
||||
} );
|
||||
|
||||
// Ctrl-F to show/hide the filter entry
|
||||
QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "GraphWidget.h"
|
||||
#include "DisassemblerGraphView.h"
|
||||
#include "WidgetShortcuts.h"
|
||||
|
||||
GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
|
||||
CutterDockWidget(main, action)
|
||||
@ -10,6 +11,16 @@ GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
|
||||
this->graphView = new DisassemblerGraphView(this);
|
||||
this->setWidget(graphView);
|
||||
|
||||
// getting the name of the class is implementation defined, and cannot be
|
||||
// used reliably across different compilers.
|
||||
//QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts[typeid(this).name()], main);
|
||||
|
||||
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["GraphWidget"], main);
|
||||
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
|
||||
toggleDockWidget(true);
|
||||
main->updateDockActionChecked(action);
|
||||
} );
|
||||
|
||||
connect(this, &QDockWidget::visibilityChanged, this, [](bool visibility) {
|
||||
if (visibility) {
|
||||
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Graph);
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "MainWindow.h"
|
||||
#include "utils/Helpers.h"
|
||||
|
||||
#include "WidgetShortcuts.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
@ -138,6 +140,12 @@ ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
|
||||
ui->importsTreeView->setModel(importsProxyModel);
|
||||
ui->importsTreeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder);
|
||||
|
||||
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["ImportsWidget"], main);
|
||||
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
|
||||
toggleDockWidget(true);
|
||||
main->updateDockActionChecked(action);
|
||||
} );
|
||||
|
||||
// Ctrl-F to show/hide the filter entry
|
||||
QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "utils/Helpers.h"
|
||||
#include "dialogs/XrefsDialog.h"
|
||||
|
||||
#include "WidgetShortcuts.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QClipboard>
|
||||
|
||||
@ -135,6 +137,13 @@ StringsWidget::StringsWidget(MainWindow *main, QAction *action) :
|
||||
|
||||
qhelpers::setVerticalScrollMode(ui->stringsTreeView);
|
||||
|
||||
// Shift-F12 to toggle strings window
|
||||
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["StringsWidget"], main);
|
||||
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
|
||||
toggleDockWidget(true);
|
||||
main->updateDockActionChecked(action);
|
||||
} );
|
||||
|
||||
// Ctrl-F to show/hide the filter entry
|
||||
QShortcut *search_shortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(search_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
|
||||
|
11
src/widgets/WidgetShortcuts.h
Normal file
11
src/widgets/WidgetShortcuts.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef WIDGETSHORTCUTS_H
|
||||
#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 }
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user