mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-30 08:45:25 +00:00
Add Core()->message() (#658)
* Add Core()->message() * Remove MainWindows::addOutput * Use qDebug() for debug messages * Add message() to PythonApi * MainWindow: Replace Core() calls
This commit is contained in:
parent
6d1bc87453
commit
f5edf6f213
@ -585,6 +585,18 @@ void CutterCore::triggerGraphOptionsChanged()
|
|||||||
emit graphOptionsChanged();
|
emit graphOptionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CutterCore::message(const QString &msg, bool debug)
|
||||||
|
{
|
||||||
|
if (msg.isEmpty())
|
||||||
|
return;
|
||||||
|
if (debug) {
|
||||||
|
qDebug() << msg;
|
||||||
|
emit newDebugMessage(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit newMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
QString CutterCore::getConfig(const QString &k)
|
QString CutterCore::getConfig(const QString &k)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
|
@ -598,6 +598,8 @@ public:
|
|||||||
void triggerAsmOptionsChanged();
|
void triggerAsmOptionsChanged();
|
||||||
void triggerGraphOptionsChanged();
|
void triggerGraphOptionsChanged();
|
||||||
|
|
||||||
|
void message(const QString &msg, bool debug = false);
|
||||||
|
|
||||||
void setCutterPlugins(QList<CutterPlugin*> plugins);
|
void setCutterPlugins(QList<CutterPlugin*> plugins);
|
||||||
QList<CutterPlugin*> getCutterPlugins();
|
QList<CutterPlugin*> getCutterPlugins();
|
||||||
|
|
||||||
@ -640,6 +642,9 @@ signals:
|
|||||||
void changeDefinedView();
|
void changeDefinedView();
|
||||||
void changeDebugView();
|
void changeDebugView();
|
||||||
|
|
||||||
|
void newMessage(const QString &msg);
|
||||||
|
void newDebugMessage(const QString &msg);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -263,12 +263,17 @@ void MainWindow::initUI()
|
|||||||
connect(core, &CutterCore::changeDebugView, this, &MainWindow::changeDebugView);
|
connect(core, &CutterCore::changeDebugView, this, &MainWindow::changeDebugView);
|
||||||
connect(core, &CutterCore::changeDefinedView, this, &MainWindow::changeDefinedView);
|
connect(core, &CutterCore::changeDefinedView, this, &MainWindow::changeDefinedView);
|
||||||
|
|
||||||
|
connect(core, SIGNAL(newMessage(const QString &)),
|
||||||
|
this->consoleDock, SLOT(addOutput(const QString &)));
|
||||||
|
connect(core, SIGNAL(newDebugMessage(const QString &)),
|
||||||
|
this->consoleDock, SLOT(addDebugOutput(const QString &)));
|
||||||
|
|
||||||
updateTasksIndicator();
|
updateTasksIndicator();
|
||||||
connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this,
|
connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this,
|
||||||
&MainWindow::updateTasksIndicator);
|
&MainWindow::updateTasksIndicator);
|
||||||
|
|
||||||
/* Load plugins */
|
/* Load plugins */
|
||||||
QList<CutterPlugin *> plugins = Core()->getCutterPlugins();
|
QList<CutterPlugin *> plugins = core->getCutterPlugins();
|
||||||
for (auto plugin : plugins) {
|
for (auto plugin : plugins) {
|
||||||
CutterDockWidget *pluginDock = plugin->setupInterface(this);
|
CutterDockWidget *pluginDock = plugin->setupInterface(this);
|
||||||
tabifyDockWidget(dashboardDock, pluginDock);
|
tabifyDockWidget(dashboardDock, pluginDock);
|
||||||
@ -277,7 +282,7 @@ void MainWindow::initUI()
|
|||||||
|
|
||||||
void MainWindow::updateTasksIndicator()
|
void MainWindow::updateTasksIndicator()
|
||||||
{
|
{
|
||||||
bool running = Core()->getAsyncTaskManager()->getTasksRunning();
|
bool running = core->getAsyncTaskManager()->getTasksRunning();
|
||||||
tasksProgressIndicator->setProgressIndicatorVisible(running);
|
tasksProgressIndicator->setProgressIndicatorVisible(running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,12 +392,12 @@ void MainWindow::finalizeOpen()
|
|||||||
// Override any incorrect setting saved in the project
|
// Override any incorrect setting saved in the project
|
||||||
core->setSettings();
|
core->setSettings();
|
||||||
|
|
||||||
addOutput(tr(" > Populating UI"));
|
core->message(tr(" > Populating UI"));
|
||||||
refreshAll();
|
refreshAll();
|
||||||
|
|
||||||
addOutput(tr(" > Finished, happy reversing :)"));
|
core->message(tr(" > Finished, happy reversing :)"));
|
||||||
// Add fortune message
|
// Add fortune message
|
||||||
addOutput("\n" + core->cmd("fo"));
|
core->message("\n" + core->cmd("fo"));
|
||||||
showMaximized();
|
showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,17 +438,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
tr("Do you really want to exit?\nSave your project before closing!"),
|
tr("Do you really want to exit?\nSave your project before closing!"),
|
||||||
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
|
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
|
||||||
if (ret == QMessageBox::Save) {
|
if (ret == QMessageBox::Save) {
|
||||||
if (saveProject(true) && !Core()->currentlyDebugging) {
|
if (saveProject(true) && !core->currentlyDebugging) {
|
||||||
saveSettings();
|
saveSettings();
|
||||||
} else if (Core()->currentlyDebugging) {
|
} else if (core->currentlyDebugging) {
|
||||||
Core()->stopDebug();
|
core->stopDebug();
|
||||||
}
|
}
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
} else if (ret == QMessageBox::Discard) {
|
} else if (ret == QMessageBox::Discard) {
|
||||||
if (!Core()->currentlyDebugging) {
|
if (!core->currentlyDebugging) {
|
||||||
saveSettings();
|
saveSettings();
|
||||||
} else if (Core()->currentlyDebugging) {
|
} else if (core->currentlyDebugging) {
|
||||||
Core()->stopDebug();
|
core->stopDebug();
|
||||||
}
|
}
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
} else {
|
} else {
|
||||||
@ -534,7 +539,7 @@ void MainWindow::setTabLocation()
|
|||||||
|
|
||||||
void MainWindow::refreshAll()
|
void MainWindow::refreshAll()
|
||||||
{
|
{
|
||||||
Core()->triggerRefreshAll();
|
core->triggerRefreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::lockUnlock_Docks(bool what)
|
void MainWindow::lockUnlock_Docks(bool what)
|
||||||
@ -705,7 +710,7 @@ void MainWindow::resetToDefaultLayout()
|
|||||||
restoreFunctionDock.restoreWidth(functionsDock->widget());
|
restoreFunctionDock.restoreWidth(functionsDock->widget());
|
||||||
restoreSidebarDock.restoreWidth(sidebarDock->widget());
|
restoreSidebarDock.restoreWidth(sidebarDock->widget());
|
||||||
|
|
||||||
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
core->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::resetToZenLayout()
|
void MainWindow::resetToZenLayout()
|
||||||
@ -723,18 +728,18 @@ void MainWindow::resetToZenLayout()
|
|||||||
|
|
||||||
restoreFunctionDock.restoreWidth(functionsDock->widget());
|
restoreFunctionDock.restoreWidth(functionsDock->widget());
|
||||||
|
|
||||||
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
core->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::resetToDebugLayout()
|
void MainWindow::resetToDebugLayout()
|
||||||
{
|
{
|
||||||
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
|
CutterCore::MemoryWidgetType memType = core->getMemoryWidgetPriority();
|
||||||
bool isMaxim = isMaximized();
|
bool isMaxim = isMaximized();
|
||||||
hideAllDocks();
|
hideAllDocks();
|
||||||
restoreDocks();
|
restoreDocks();
|
||||||
showDebugDocks();
|
showDebugDocks();
|
||||||
readDebugSettings();
|
readDebugSettings();
|
||||||
Core()->raisePrioritizedMemoryWidget(memType);
|
core->raisePrioritizedMemoryWidget(memType);
|
||||||
if (isMaxim) {
|
if (isMaxim) {
|
||||||
showMaximized();
|
showMaximized();
|
||||||
} else {
|
} else {
|
||||||
@ -742,17 +747,6 @@ void MainWindow::resetToDebugLayout()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addOutput(const QString &msg)
|
|
||||||
{
|
|
||||||
consoleDock->addOutput(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::addDebugOutput(const QString &msg)
|
|
||||||
{
|
|
||||||
printf("debug output: %s\n", msg.toLocal8Bit().constData());
|
|
||||||
consoleDock->addDebugOutput(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionLock_triggered()
|
void MainWindow::on_actionLock_triggered()
|
||||||
{
|
{
|
||||||
panelLock = !panelLock;
|
panelLock = !panelLock;
|
||||||
@ -825,7 +819,7 @@ void MainWindow::on_actionRun_Script_triggered()
|
|||||||
fileName = dialog.getOpenFileName(this, tr("Select radare2 script"));
|
fileName = dialog.getOpenFileName(this, tr("Select radare2 script"));
|
||||||
if (!fileName.length()) // Cancel was pressed
|
if (!fileName.length()) // Cancel was pressed
|
||||||
return;
|
return;
|
||||||
Core()->loadScript(fileName);
|
core->loadScript(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -869,22 +863,22 @@ void MainWindow::on_actionQuit_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionBackward_triggered()
|
void MainWindow::on_actionBackward_triggered()
|
||||||
{
|
{
|
||||||
Core()->seekPrev();
|
core->seekPrev();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionForward_triggered()
|
void MainWindow::on_actionForward_triggered()
|
||||||
{
|
{
|
||||||
Core()->seekNext();
|
core->seekNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionUndoSeek_triggered()
|
void MainWindow::on_actionUndoSeek_triggered()
|
||||||
{
|
{
|
||||||
Core()->seekPrev();
|
core->seekPrev();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRedoSeek_triggered()
|
void MainWindow::on_actionRedoSeek_triggered()
|
||||||
{
|
{
|
||||||
Core()->seekNext();
|
core->seekNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionDisasAdd_comment_triggered()
|
void MainWindow::on_actionDisasAdd_comment_triggered()
|
||||||
@ -940,8 +934,8 @@ void MainWindow::on_actionImportPDB_triggered()
|
|||||||
QString pdbFile = dialog.selectedFiles().first();
|
QString pdbFile = dialog.selectedFiles().first();
|
||||||
|
|
||||||
if (!pdbFile.isEmpty()) {
|
if (!pdbFile.isEmpty()) {
|
||||||
Core()->loadPDB(pdbFile);
|
core->loadPDB(pdbFile);
|
||||||
addOutput(tr("%1 loaded.").arg(pdbFile));
|
core->message(tr("%1 loaded.").arg(pdbFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,7 +993,7 @@ void MainWindow::on_actionExport_as_code_triggered()
|
|||||||
|
|
||||||
void MainWindow::projectSaved(const QString &name)
|
void MainWindow::projectSaved(const QString &name)
|
||||||
{
|
{
|
||||||
addOutput(tr("Project saved: ") + name);
|
core->message(tr("Project saved: ") + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::changeDebugView()
|
void MainWindow::changeDebugView()
|
||||||
@ -1011,21 +1005,21 @@ void MainWindow::changeDebugView()
|
|||||||
void MainWindow::changeDefinedView()
|
void MainWindow::changeDefinedView()
|
||||||
{
|
{
|
||||||
saveDebugSettings();
|
saveDebugSettings();
|
||||||
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
|
CutterCore::MemoryWidgetType memType = core->getMemoryWidgetPriority();
|
||||||
hideAllDocks();
|
hideAllDocks();
|
||||||
restoreDocks();
|
restoreDocks();
|
||||||
readSettings();
|
readSettings();
|
||||||
Core()->raisePrioritizedMemoryWidget(memType);
|
core->raisePrioritizedMemoryWidget(memType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::mousePressEvent(QMouseEvent *event)
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->button()) {
|
switch (event->button()) {
|
||||||
case Qt::BackButton:
|
case Qt::BackButton:
|
||||||
Core()->seekPrev();
|
core->seekPrev();
|
||||||
break;
|
break;
|
||||||
case Qt::ForwardButton:
|
case Qt::ForwardButton:
|
||||||
Core()->seekNext();
|
core->seekNext();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -93,8 +93,6 @@ public:
|
|||||||
void readDebugSettings();
|
void readDebugSettings();
|
||||||
void saveDebugSettings();
|
void saveDebugSettings();
|
||||||
void setFilename(const QString &fn);
|
void setFilename(const QString &fn);
|
||||||
void addOutput(const QString &msg);
|
|
||||||
void addDebugOutput(const QString &msg);
|
|
||||||
void refreshOmniBar(const QStringList &flags);
|
void refreshOmniBar(const QStringList &flags);
|
||||||
|
|
||||||
void addToDockWidgetList(QDockWidget *dockWidget);
|
void addToDockWidgetList(QDockWidget *dockWidget);
|
||||||
|
@ -62,6 +62,22 @@ PyObject *api_refresh(PyObject *self, PyObject *args)
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject *api_message(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
{
|
||||||
|
Q_UNUSED(self);
|
||||||
|
char *message;
|
||||||
|
int debug = 0;
|
||||||
|
static const char *kwlist[] = { "", "debug", NULL };
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i",
|
||||||
|
const_cast<char**>(kwlist),
|
||||||
|
&message, &debug)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
Core()->message(QString(message), debug);
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
PyMethodDef CutterMethods[] = {
|
PyMethodDef CutterMethods[] = {
|
||||||
{
|
{
|
||||||
"version", api_version, METH_NOARGS,
|
"version", api_version, METH_NOARGS,
|
||||||
@ -79,6 +95,10 @@ PyMethodDef CutterMethods[] = {
|
|||||||
"refresh", api_refresh, METH_NOARGS,
|
"refresh", api_refresh, METH_NOARGS,
|
||||||
"Refresh Cutter widgets"
|
"Refresh Cutter widgets"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"message", (PyCFunction) api_message, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Print message"
|
||||||
|
},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ public:
|
|||||||
|
|
||||||
~ConsoleWidget();
|
~ConsoleWidget();
|
||||||
|
|
||||||
void addOutput(const QString &msg);
|
|
||||||
void addDebugOutput(const QString &msg);
|
|
||||||
|
|
||||||
void setDebugOutputEnabled(bool enabled)
|
void setDebugOutputEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
debugOutputEnabled = enabled;
|
debugOutputEnabled = enabled;
|
||||||
@ -36,6 +33,9 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void focusInputLineEdit();
|
void focusInputLineEdit();
|
||||||
|
|
||||||
|
void addOutput(const QString &msg);
|
||||||
|
void addDebugOutput(const QString &msg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupFont();
|
void setupFont();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user