mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Initialize OmniBar again
+ cleanup of the OmniBar class
This commit is contained in:
parent
dd39666654
commit
a9b5f40702
@ -247,9 +247,6 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) :
|
|||||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
//setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
//setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
||||||
|
|
||||||
// Set omnibar completer for flags
|
|
||||||
this->omnibar->setupCompleter();
|
|
||||||
|
|
||||||
// Set console output context menu
|
// Set console output context menu
|
||||||
ui->consoleOutputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->consoleOutputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->consoleOutputTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
connect(ui->consoleOutputTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||||
@ -336,6 +333,11 @@ void MainWindow::toggleSideBarTheme()
|
|||||||
sideBar->themesButtonToggle();
|
sideBar->themesButtonToggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::refreshOmniBar(const QStringList &flags)
|
||||||
|
{
|
||||||
|
omnibar->refresh(flags);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setFilename(QString fn)
|
void MainWindow::setFilename(QString fn)
|
||||||
{
|
{
|
||||||
// Add file name to window title
|
// Add file name to window title
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
void setWebServerState(bool start);
|
void setWebServerState(bool start);
|
||||||
void raiseMemoryDock();
|
void raiseMemoryDock();
|
||||||
void toggleSideBarTheme();
|
void toggleSideBarTheme();
|
||||||
|
void refreshOmniBar(const QStringList &flags);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -76,13 +76,13 @@ void FlagsWidget::refreshFlagspaces()
|
|||||||
void FlagsWidget::refreshFlags()
|
void FlagsWidget::refreshFlags()
|
||||||
{
|
{
|
||||||
QString flagspace = ui->flagspaceCombo->currentText();
|
QString flagspace = ui->flagspaceCombo->currentText();
|
||||||
// TODO: Do this in Omnibar
|
|
||||||
//this->omnibar->clearFlags();
|
|
||||||
if (flagspace == "(all)")
|
if (flagspace == "(all)")
|
||||||
flagspace = "";
|
flagspace = "";
|
||||||
|
|
||||||
ui->flagsTreeWidget->clear();
|
ui->flagsTreeWidget->clear();
|
||||||
|
|
||||||
|
QStringList flags;
|
||||||
|
|
||||||
for (auto i : main->core->getList("flags", flagspace))
|
for (auto i : main->core->getList("flags", flagspace))
|
||||||
{
|
{
|
||||||
QStringList a = i.split(",");
|
QStringList a = i.split(",");
|
||||||
@ -96,12 +96,12 @@ void FlagsWidget::refreshFlags()
|
|||||||
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], "");
|
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], "");
|
||||||
//this->omnibar->fillFlags(a[0]);
|
//this->omnibar->fillFlags(a[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags.append(a[0]);
|
||||||
}
|
}
|
||||||
qhelpers::adjustColumns(ui->flagsTreeWidget);
|
qhelpers::adjustColumns(ui->flagsTreeWidget);
|
||||||
// Set omnibar completer for flags and commands
|
|
||||||
//this->omnibar->setupCompleter();
|
|
||||||
|
|
||||||
emit flagsRefreshed();
|
main->refreshOmniBar(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlagsWidget::setScrollMode()
|
void FlagsWidget::setScrollMode()
|
||||||
|
@ -25,8 +25,6 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
signals:
|
|
||||||
void flagsRefreshed();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
void on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
|
@ -6,11 +6,24 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
|
Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
|
||||||
QLineEdit(parent)
|
QLineEdit(parent),
|
||||||
|
main(main),
|
||||||
|
commands({": Comments toggle",
|
||||||
|
": Dashboard toggle",
|
||||||
|
": Flags toggle",
|
||||||
|
": Functions toggle",
|
||||||
|
": Imports toggle",
|
||||||
|
": Notepad toggle",
|
||||||
|
": Relocs toggle",
|
||||||
|
": Run Script",
|
||||||
|
": Sections toggle",
|
||||||
|
": Strings toggle",
|
||||||
|
": Symbols toggle",
|
||||||
|
": Tabs up/down",
|
||||||
|
": Theme switch",
|
||||||
|
": Lock/Unlock interface",
|
||||||
|
": Web server start/stop"})
|
||||||
{
|
{
|
||||||
// Radare core found in:
|
|
||||||
this->main = main;
|
|
||||||
|
|
||||||
// QLineEdit basic features
|
// QLineEdit basic features
|
||||||
this->setMinimumHeight(16);
|
this->setMinimumHeight(16);
|
||||||
this->setMaximumHeight(16);
|
this->setMaximumHeight(16);
|
||||||
@ -20,47 +33,34 @@ Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
|
|||||||
this->setTextMargins(10, 0, 0, 0);
|
this->setTextMargins(10, 0, 0, 0);
|
||||||
this->setClearButtonEnabled(true);
|
this->setClearButtonEnabled(true);
|
||||||
|
|
||||||
this->commands << ": Comments toggle"
|
|
||||||
<< ": Dashboard toggle"
|
|
||||||
<< ": Flags toggle"
|
|
||||||
<< ": Functions toggle"
|
|
||||||
<< ": Imports toggle"
|
|
||||||
<< ": Notepad toggle"
|
|
||||||
<< ": Relocs toggle"
|
|
||||||
<< ": Run Script"
|
|
||||||
<< ": Sections toggle"
|
|
||||||
<< ": Strings toggle"
|
|
||||||
<< ": Symbols toggle"
|
|
||||||
<< ": Tabs up/down"
|
|
||||||
<< ": Theme switch"
|
|
||||||
<< ": Lock/Unlock interface"
|
|
||||||
<< ": Web server start/stop";
|
|
||||||
|
|
||||||
connect(this, SIGNAL(returnPressed()), this, SLOT(on_gotoEntry_returnPressed()));
|
connect(this, SIGNAL(returnPressed()), this, SLOT(on_gotoEntry_returnPressed()));
|
||||||
|
|
||||||
// Esc clears omnibar
|
// Esc clears omnibar
|
||||||
QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||||
connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clearContents()));
|
connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clear()));
|
||||||
clear_shortcut->setContext(Qt::WidgetShortcut);
|
clear_shortcut->setContext(Qt::WidgetShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Omnibar::setupCompleter()
|
void Omnibar::setupCompleter()
|
||||||
{
|
{
|
||||||
// Set gotoEntry completer for jump history
|
// Set gotoEntry completer for jump history
|
||||||
QStringList flagsList = this->getFlags();
|
QCompleter *completer = new QCompleter(flags + commands, this);
|
||||||
QCompleter *completer = new QCompleter(flagsList, this);
|
|
||||||
completer->setMaxVisibleItems(20);
|
completer->setMaxVisibleItems(20);
|
||||||
completer->setCompletionMode(QCompleter::PopupCompletion);
|
completer->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
|
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
|
||||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
completer->setFilterMode(Qt::MatchContains);
|
completer->setFilterMode(Qt::MatchContains);
|
||||||
|
|
||||||
QStringListModel *completerModel = (QStringListModel *)(completer->model());
|
|
||||||
completerModel->setStringList(completerModel->stringList() << this->commands);
|
|
||||||
|
|
||||||
this->setCompleter(completer);
|
this->setCompleter(completer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Omnibar::refresh(const QStringList &flagList)
|
||||||
|
{
|
||||||
|
flags = flagList;
|
||||||
|
|
||||||
|
setupCompleter();
|
||||||
|
}
|
||||||
|
|
||||||
void Omnibar::restoreCompleter()
|
void Omnibar::restoreCompleter()
|
||||||
{
|
{
|
||||||
QCompleter *completer = this->completer();
|
QCompleter *completer = this->completer();
|
||||||
@ -84,14 +84,6 @@ void Omnibar::showCommands()
|
|||||||
completer->complete();
|
completer->complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Omnibar::clearContents()
|
|
||||||
{
|
|
||||||
this->setText("");
|
|
||||||
// Necessary hack to make it work properly
|
|
||||||
this->clearFocus();
|
|
||||||
this->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Omnibar::on_gotoEntry_returnPressed()
|
void Omnibar::on_gotoEntry_returnPressed()
|
||||||
{
|
{
|
||||||
QString str = this->text();
|
QString str = this->text();
|
||||||
@ -170,18 +162,3 @@ void Omnibar::on_gotoEntry_returnPressed()
|
|||||||
this->clearFocus();
|
this->clearFocus();
|
||||||
this->restoreCompleter();
|
this->restoreCompleter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Omnibar::fillFlags(QString flag)
|
|
||||||
{
|
|
||||||
this->flags << flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Omnibar::clearFlags()
|
|
||||||
{
|
|
||||||
this->flags.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Omnibar::getFlags()
|
|
||||||
{
|
|
||||||
return this->flags;
|
|
||||||
}
|
|
||||||
|
@ -11,10 +11,7 @@ class Omnibar : public QLineEdit
|
|||||||
public:
|
public:
|
||||||
explicit Omnibar(MainWindow *main, QWidget *parent = 0);
|
explicit Omnibar(MainWindow *main, QWidget *parent = 0);
|
||||||
|
|
||||||
void fillFlags(QString flag);
|
void refresh(const QStringList &flagList);
|
||||||
void clearFlags();
|
|
||||||
QStringList getFlags();
|
|
||||||
void setupCompleter();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_gotoEntry_returnPressed();
|
void on_gotoEntry_returnPressed();
|
||||||
@ -23,11 +20,12 @@ private slots:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showCommands();
|
void showCommands();
|
||||||
void clearContents();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupCompleter();
|
||||||
|
|
||||||
MainWindow *main;
|
MainWindow *main;
|
||||||
QStringList commands;
|
const QStringList commands;
|
||||||
QStringList flags;
|
QStringList flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user