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