mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06: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::BottomRightCorner, Qt::RightDockWidgetArea );
|
||||
|
||||
// Set omnibar completer for flags
|
||||
this->omnibar->setupCompleter();
|
||||
|
||||
// Set console output context menu
|
||||
ui->consoleOutputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->consoleOutputTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
@ -336,6 +333,11 @@ void MainWindow::toggleSideBarTheme()
|
||||
sideBar->themesButtonToggle();
|
||||
}
|
||||
|
||||
void MainWindow::refreshOmniBar(const QStringList &flags)
|
||||
{
|
||||
omnibar->refresh(flags);
|
||||
}
|
||||
|
||||
void MainWindow::setFilename(QString fn)
|
||||
{
|
||||
// Add file name to window title
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
void setWebServerState(bool start);
|
||||
void raiseMemoryDock();
|
||||
void toggleSideBarTheme();
|
||||
void refreshOmniBar(const QStringList &flags);
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -76,13 +76,13 @@ void FlagsWidget::refreshFlagspaces()
|
||||
void FlagsWidget::refreshFlags()
|
||||
{
|
||||
QString flagspace = ui->flagspaceCombo->currentText();
|
||||
// TODO: Do this in Omnibar
|
||||
//this->omnibar->clearFlags();
|
||||
if (flagspace == "(all)")
|
||||
flagspace = "";
|
||||
|
||||
ui->flagsTreeWidget->clear();
|
||||
|
||||
QStringList flags;
|
||||
|
||||
for (auto i : main->core->getList("flags", flagspace))
|
||||
{
|
||||
QStringList a = i.split(",");
|
||||
@ -96,12 +96,12 @@ void FlagsWidget::refreshFlags()
|
||||
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], "");
|
||||
//this->omnibar->fillFlags(a[0]);
|
||||
}
|
||||
|
||||
flags.append(a[0]);
|
||||
}
|
||||
qhelpers::adjustColumns(ui->flagsTreeWidget);
|
||||
// Set omnibar completer for flags and commands
|
||||
//this->omnibar->setupCompleter();
|
||||
|
||||
emit flagsRefreshed();
|
||||
main->refreshOmniBar(flags);
|
||||
}
|
||||
|
||||
void FlagsWidget::setScrollMode()
|
||||
|
@ -25,8 +25,6 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void flagsRefreshed();
|
||||
|
||||
private slots:
|
||||
void on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
@ -6,11 +6,24 @@
|
||||
#include <QShortcut>
|
||||
|
||||
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
|
||||
this->setMinimumHeight(16);
|
||||
this->setMaximumHeight(16);
|
||||
@ -20,47 +33,34 @@ Omnibar::Omnibar(MainWindow *main, QWidget *parent) :
|
||||
this->setTextMargins(10, 0, 0, 0);
|
||||
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()));
|
||||
|
||||
// Esc clears omnibar
|
||||
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);
|
||||
}
|
||||
|
||||
void Omnibar::setupCompleter()
|
||||
{
|
||||
// Set gotoEntry completer for jump history
|
||||
QStringList flagsList = this->getFlags();
|
||||
QCompleter *completer = new QCompleter(flagsList, this);
|
||||
QCompleter *completer = new QCompleter(flags + commands, this);
|
||||
completer->setMaxVisibleItems(20);
|
||||
completer->setCompletionMode(QCompleter::PopupCompletion);
|
||||
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completer->setFilterMode(Qt::MatchContains);
|
||||
|
||||
QStringListModel *completerModel = (QStringListModel *)(completer->model());
|
||||
completerModel->setStringList(completerModel->stringList() << this->commands);
|
||||
|
||||
this->setCompleter(completer);
|
||||
}
|
||||
|
||||
void Omnibar::refresh(const QStringList &flagList)
|
||||
{
|
||||
flags = flagList;
|
||||
|
||||
setupCompleter();
|
||||
}
|
||||
|
||||
void Omnibar::restoreCompleter()
|
||||
{
|
||||
QCompleter *completer = this->completer();
|
||||
@ -84,14 +84,6 @@ void Omnibar::showCommands()
|
||||
completer->complete();
|
||||
}
|
||||
|
||||
void Omnibar::clearContents()
|
||||
{
|
||||
this->setText("");
|
||||
// Necessary hack to make it work properly
|
||||
this->clearFocus();
|
||||
this->setFocus();
|
||||
}
|
||||
|
||||
void Omnibar::on_gotoEntry_returnPressed()
|
||||
{
|
||||
QString str = this->text();
|
||||
@ -170,18 +162,3 @@ void Omnibar::on_gotoEntry_returnPressed()
|
||||
this->clearFocus();
|
||||
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:
|
||||
explicit Omnibar(MainWindow *main, QWidget *parent = 0);
|
||||
|
||||
void fillFlags(QString flag);
|
||||
void clearFlags();
|
||||
QStringList getFlags();
|
||||
void setupCompleter();
|
||||
void refresh(const QStringList &flagList);
|
||||
|
||||
private slots:
|
||||
void on_gotoEntry_returnPressed();
|
||||
@ -23,12 +20,13 @@ private slots:
|
||||
|
||||
public slots:
|
||||
void showCommands();
|
||||
void clearContents();
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
QStringList commands;
|
||||
QStringList flags;
|
||||
void setupCompleter();
|
||||
|
||||
MainWindow *main;
|
||||
const QStringList commands;
|
||||
QStringList flags;
|
||||
};
|
||||
|
||||
#endif // OMNIBAR_H
|
||||
|
Loading…
Reference in New Issue
Block a user