mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Added show/hide shortcut to functions filter
This commit is contained in:
parent
1cf395d7b9
commit
f662360524
@ -12,6 +12,7 @@
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QResource>
|
||||
#include <QShortcut>
|
||||
|
||||
FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, MainWindow *main, QObject *parent)
|
||||
: QAbstractItemModel(parent),
|
||||
@ -329,6 +330,19 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
|
||||
// leave the filter visible by default so users know it exists
|
||||
//ui->filterLineEdit->setVisible(false);
|
||||
|
||||
// Ctrl-F to show/hide the filter entry
|
||||
QShortcut *search_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this);
|
||||
connect(search_shortcut, SIGNAL(activated()), this, SLOT(toggle_visibility()));
|
||||
search_shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
|
||||
// Esc to clear the filter entry
|
||||
QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clear_filter()));
|
||||
clear_shortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||
|
||||
QFontInfo font_info = ui->functionsTreeView->fontInfo();
|
||||
QFont default_font = QFont(font_info.family(), font_info.pointSize());
|
||||
QFont highlight_font = QFont(font_info.family(), font_info.pointSize(), QFont::Bold);
|
||||
@ -602,3 +616,22 @@ void FunctionsWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->functionsTreeView);
|
||||
}
|
||||
|
||||
void FunctionsWidget::toggle_visibility() {
|
||||
if (ui->filterLineEdit->isVisible()) {
|
||||
ui->filterLineEdit->setVisible(false);
|
||||
ui->functionsTreeView->setFocus();
|
||||
} else {
|
||||
ui->filterLineEdit->setVisible(true);
|
||||
ui->filterLineEdit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionsWidget::clear_filter() {
|
||||
if (ui->filterLineEdit->text() == "") {
|
||||
ui->filterLineEdit->setVisible(false);
|
||||
ui->functionsTreeView->setFocus();
|
||||
} else {
|
||||
ui->filterLineEdit->setText("");
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
private slots:
|
||||
void cursorAddressChanged(RVA addr);
|
||||
void functionRenamed(const QString &prev_name, const QString &new_name);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -104,6 +103,10 @@ private slots:
|
||||
|
||||
void on_actionVertical_triggered();
|
||||
|
||||
void toggle_visibility();
|
||||
|
||||
void clear_filter();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
|
@ -196,6 +196,9 @@ QToolTip {
|
||||
<property name="placeholderText">
|
||||
<string>Quick Filter</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user