2017-03-29 10:18:37 +00:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h" // only needed for ut64
|
2018-02-10 18:04:31 +00:00
|
|
|
#include "dialogs/NewFileDialog.h"
|
2019-01-19 20:54:02 +00:00
|
|
|
#include "dialogs/WelcomeDialog.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Configuration.h"
|
|
|
|
#include "common/InitialOptions.h"
|
2019-07-19 19:21:12 +00:00
|
|
|
#include "MemoryDockWidget.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-03-14 09:28:42 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-10-22 10:21:44 +00:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QList>
|
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
class CutterCore;
|
2017-04-13 15:36:20 +00:00
|
|
|
class Omnibar;
|
2018-06-24 19:12:02 +00:00
|
|
|
class ProgressIndicator;
|
2017-10-12 19:55:15 +00:00
|
|
|
class PreviewWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class Highlighter;
|
|
|
|
class AsciiHighlighter;
|
2017-12-08 15:00:52 +00:00
|
|
|
class VisualNavbar;
|
2017-04-13 15:36:20 +00:00
|
|
|
class FunctionsWidget;
|
|
|
|
class ImportsWidget;
|
2017-05-19 07:45:26 +00:00
|
|
|
class ExportsWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class SymbolsWidget;
|
|
|
|
class RelocsWidget;
|
|
|
|
class CommentsWidget;
|
|
|
|
class StringsWidget;
|
|
|
|
class FlagsWidget;
|
|
|
|
class Dashboard;
|
|
|
|
class QLineEdit;
|
2019-02-13 06:38:47 +00:00
|
|
|
class SdbWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class QAction;
|
2018-05-03 07:52:30 +00:00
|
|
|
class SectionsWidget;
|
2018-10-20 18:20:06 +00:00
|
|
|
class SegmentsWidget;
|
2017-04-26 23:00:20 +00:00
|
|
|
class ConsoleWidget;
|
2017-07-13 18:49:12 +00:00
|
|
|
class EntrypointWidget;
|
2017-10-22 10:21:44 +00:00
|
|
|
class DisassemblerGraphView;
|
2017-12-23 16:42:42 +00:00
|
|
|
class ClassesWidget;
|
2018-02-04 14:32:18 +00:00
|
|
|
class ResourcesWidget;
|
2018-02-26 22:26:18 +00:00
|
|
|
class VTablesWidget;
|
2018-03-06 17:21:48 +00:00
|
|
|
class TypesWidget;
|
2018-05-21 17:34:41 +00:00
|
|
|
class HeadersWidget;
|
2018-05-24 15:37:37 +00:00
|
|
|
class ZignaturesWidget;
|
2018-03-08 12:24:15 +00:00
|
|
|
class SearchWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class QDockWidget;
|
2019-03-14 09:28:42 +00:00
|
|
|
class DisassemblyWidget;
|
|
|
|
class GraphWidget;
|
|
|
|
class HexdumpWidget;
|
2019-09-06 05:40:20 +00:00
|
|
|
class DecompilerWidget;
|
2019-03-14 09:28:42 +00:00
|
|
|
class OverviewWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool responsive;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
2018-09-30 20:00:44 +00:00
|
|
|
~MainWindow() override;
|
2017-04-01 01:56:35 +00:00
|
|
|
|
2019-05-17 11:40:50 +00:00
|
|
|
void openNewFile(InitialOptions &options, bool skipOptionsDialog = false);
|
2018-02-06 18:23:01 +00:00
|
|
|
void displayNewFileDialog();
|
2019-01-19 20:54:02 +00:00
|
|
|
void displayWelcomeDialog();
|
2018-02-10 18:04:31 +00:00
|
|
|
void closeNewFileDialog();
|
2017-11-03 17:22:54 +00:00
|
|
|
void openProject(const QString &project_name);
|
2017-10-21 19:20:10 +00:00
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2017-10-21 19:20:10 +00:00
|
|
|
* @param quit whether to show destructive button in dialog
|
|
|
|
* @return if quit is true, false if the application should not close
|
|
|
|
*/
|
|
|
|
bool saveProject(bool quit = false);
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2017-10-21 19:20:10 +00:00
|
|
|
* @param quit whether to show destructive button in dialog
|
2018-10-12 07:08:04 +00:00
|
|
|
* @return false if the application should not close
|
2017-10-21 19:20:10 +00:00
|
|
|
*/
|
2017-11-03 17:22:54 +00:00
|
|
|
bool saveProjectAs(bool quit = false);
|
2017-05-13 18:09:36 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2019-03-18 06:44:14 +00:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
void readSettingsOrDefault();
|
2017-12-17 13:49:03 +00:00
|
|
|
void saveSettings();
|
2018-07-23 23:12:36 +00:00
|
|
|
void readDebugSettings();
|
|
|
|
void saveDebugSettings();
|
2017-04-28 13:38:01 +00:00
|
|
|
void setFilename(const QString &fn);
|
2017-04-27 18:59:27 +00:00
|
|
|
void refreshOmniBar(const QStringList &flags);
|
2017-04-01 01:56:35 +00:00
|
|
|
|
2019-06-18 18:22:26 +00:00
|
|
|
void addWidget(QDockWidget *widget);
|
2019-07-19 19:21:12 +00:00
|
|
|
void addMemoryDockWidget(MemoryDockWidget *widget);
|
2019-06-18 18:22:26 +00:00
|
|
|
void removeWidget(QDockWidget *widget);
|
2019-04-27 09:46:29 +00:00
|
|
|
void addExtraWidget(CutterDockWidget *extraDock);
|
2019-07-19 19:21:12 +00:00
|
|
|
MemoryDockWidget *addNewMemoryWidget(MemoryWidgetType type, RVA address, bool synchronized = true);
|
|
|
|
|
2018-05-25 14:30:59 +00:00
|
|
|
|
2019-02-07 16:19:05 +00:00
|
|
|
void addPluginDockWidget(QDockWidget *dockWidget, QAction *action);
|
2019-04-03 07:50:25 +00:00
|
|
|
enum class MenuType { File, Edit, View, Windows, Debug, Help, Plugins };
|
|
|
|
QMenu *getMenuByType(MenuType type);
|
2019-02-11 19:05:53 +00:00
|
|
|
void addMenuFileAction(QAction *action);
|
2019-02-07 16:19:05 +00:00
|
|
|
|
2018-10-16 06:25:09 +00:00
|
|
|
void updateDockActionChecked(QAction * action);
|
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
QString getFilename() const
|
|
|
|
{
|
|
|
|
return filename;
|
|
|
|
}
|
2019-02-11 19:05:53 +00:00
|
|
|
void messageBoxWarning(QString title, QString message);
|
2018-03-16 21:46:57 +00:00
|
|
|
|
2019-06-18 17:57:07 +00:00
|
|
|
QString getUniqueObjectName(const QString &widgetType) const;
|
2019-07-19 19:21:12 +00:00
|
|
|
void showMemoryWidget();
|
|
|
|
void showMemoryWidget(MemoryWidgetType type);
|
|
|
|
|
|
|
|
QMenu *createShowInMenu(QWidget *parent, RVA address);
|
|
|
|
void setCurrentMemoryWidget(MemoryDockWidget* memoryWidget);
|
2019-09-02 07:34:41 +00:00
|
|
|
MemoryDockWidget* getLastMemoryWidget();
|
2019-06-18 17:57:07 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
public slots:
|
2018-05-27 16:03:29 +00:00
|
|
|
void finalizeOpen();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
void refreshAll();
|
2019-05-30 08:41:14 +00:00
|
|
|
void seekToFunctionLastInstruction();
|
|
|
|
void seekToFunctionStart();
|
2017-12-17 13:49:03 +00:00
|
|
|
void setPanelLock();
|
|
|
|
void setTabLocation();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void on_actionLock_triggered();
|
|
|
|
|
|
|
|
void on_actionLockUnlock_triggered();
|
|
|
|
|
|
|
|
void on_actionTabs_triggered();
|
|
|
|
|
|
|
|
void lockUnlock_Docks(bool what);
|
|
|
|
|
|
|
|
void on_actionRun_Script_triggered();
|
|
|
|
|
|
|
|
void toggleResponsive(bool maybe);
|
|
|
|
|
2018-05-08 20:44:53 +00:00
|
|
|
void openNewFileFailed();
|
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
void toggleOverview(bool visibility, GraphWidget *targetGraph);
|
2017-03-29 10:18:37 +00:00
|
|
|
private slots:
|
|
|
|
void on_actionAbout_triggered();
|
2019-02-07 10:52:08 +00:00
|
|
|
void on_actionIssue_triggered();
|
2019-06-18 13:02:41 +00:00
|
|
|
void addExtraGraph();
|
|
|
|
void addExtraHexdump();
|
|
|
|
void addExtraDisassembly();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionRefresh_Panels_triggered();
|
|
|
|
|
|
|
|
void on_actionDisasAdd_comment_triggered();
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void on_actionDefault_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionFunctionsRename_triggered();
|
|
|
|
|
|
|
|
void on_actionNew_triggered();
|
|
|
|
|
|
|
|
void on_actionSave_triggered();
|
2017-11-03 17:22:54 +00:00
|
|
|
void on_actionSaveAs_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-08 09:11:19 +00:00
|
|
|
void on_actionBackward_triggered();
|
|
|
|
void on_actionForward_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void on_actionOpen_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionTabs_on_Top_triggered();
|
|
|
|
|
|
|
|
void on_actionReset_settings_triggered();
|
|
|
|
|
2017-03-31 21:54:06 +00:00
|
|
|
void on_actionQuit_triggered();
|
|
|
|
|
2017-05-26 08:52:17 +00:00
|
|
|
void on_actionRefresh_contents_triggered();
|
2017-04-12 21:04:39 +00:00
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void on_actionPreferences_triggered();
|
2017-09-02 08:17:48 +00:00
|
|
|
|
2018-01-27 10:40:26 +00:00
|
|
|
void on_actionAnalyze_triggered();
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void on_actionImportPDB_triggered();
|
|
|
|
|
2018-08-24 22:36:15 +00:00
|
|
|
void on_actionExport_as_code_triggered();
|
|
|
|
|
2019-05-08 11:38:25 +00:00
|
|
|
void on_actionGrouped_dock_dragging_triggered(bool checked);
|
|
|
|
|
2018-11-02 06:48:17 +00:00
|
|
|
void projectSaved(bool successfully, const QString &name);
|
2017-10-21 19:20:10 +00:00
|
|
|
|
2018-06-22 18:34:25 +00:00
|
|
|
void updateTasksIndicator();
|
|
|
|
|
2018-05-13 07:50:01 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2018-09-30 20:00:44 +00:00
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
2019-12-13 17:30:55 +00:00
|
|
|
void toggleDebugView();
|
2019-04-27 17:58:44 +00:00
|
|
|
void chooseThemeIcons();
|
2018-05-13 07:50:01 +00:00
|
|
|
|
2019-10-12 05:50:10 +00:00
|
|
|
void onZoomIn();
|
|
|
|
void onZoomOut();
|
|
|
|
void onZoomReset();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-02-04 14:32:18 +00:00
|
|
|
CutterCore *core;
|
2017-12-13 17:36:00 +00:00
|
|
|
|
2017-12-17 13:49:03 +00:00
|
|
|
bool panelLock;
|
|
|
|
bool tabsOnTop;
|
2017-03-29 10:18:37 +00:00
|
|
|
ut64 hexdumpTopOffset;
|
|
|
|
ut64 hexdumpBottomOffset;
|
|
|
|
QString filename;
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
2018-02-04 14:32:18 +00:00
|
|
|
Highlighter *highlighter;
|
2017-03-29 10:18:37 +00:00
|
|
|
AsciiHighlighter *hex_highlighter;
|
2018-02-04 14:32:18 +00:00
|
|
|
VisualNavbar *visualNavbar;
|
|
|
|
Omnibar *omnibar;
|
2018-06-24 19:12:02 +00:00
|
|
|
ProgressIndicator *tasksProgressIndicator;
|
2019-06-18 13:02:41 +00:00
|
|
|
QByteArray emptyState;
|
2018-06-22 18:34:25 +00:00
|
|
|
|
2018-02-04 14:32:18 +00:00
|
|
|
Configuration *configuration;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
QList<QDockWidget *> dockWidgets;
|
2019-06-18 13:02:41 +00:00
|
|
|
QMultiMap<QAction *, QDockWidget *> dockWidgetsOfAction;
|
2019-09-06 05:40:20 +00:00
|
|
|
DecompilerWidget *decompilerDock = nullptr;
|
2019-02-19 15:56:50 +00:00
|
|
|
OverviewWidget *overviewDock = nullptr;
|
2018-02-04 14:32:18 +00:00
|
|
|
EntrypointWidget *entrypointDock = nullptr;
|
|
|
|
FunctionsWidget *functionsDock = nullptr;
|
|
|
|
ImportsWidget *importsDock = nullptr;
|
|
|
|
ExportsWidget *exportsDock = nullptr;
|
2018-05-21 17:34:41 +00:00
|
|
|
HeadersWidget *headersDock = nullptr;
|
2018-03-06 17:21:48 +00:00
|
|
|
TypesWidget *typesDock = nullptr;
|
2018-05-21 17:34:41 +00:00
|
|
|
SearchWidget *searchDock = nullptr;
|
2018-02-04 14:32:18 +00:00
|
|
|
SymbolsWidget *symbolsDock = nullptr;
|
|
|
|
RelocsWidget *relocsDock = nullptr;
|
|
|
|
CommentsWidget *commentsDock = nullptr;
|
|
|
|
StringsWidget *stringsDock = nullptr;
|
|
|
|
FlagsWidget *flagsDock = nullptr;
|
|
|
|
Dashboard *dashboardDock = nullptr;
|
|
|
|
QLineEdit *gotoEntry = nullptr;
|
2019-02-13 06:38:47 +00:00
|
|
|
SdbWidget *sdbDock = nullptr;
|
2018-05-03 07:52:30 +00:00
|
|
|
SectionsWidget *sectionsDock = nullptr;
|
2018-10-20 18:20:06 +00:00
|
|
|
SegmentsWidget *segmentsDock = nullptr;
|
2018-05-24 15:37:37 +00:00
|
|
|
ZignaturesWidget *zignaturesDock = nullptr;
|
2018-02-04 14:32:18 +00:00
|
|
|
ConsoleWidget *consoleDock = nullptr;
|
|
|
|
ClassesWidget *classesDock = nullptr;
|
|
|
|
ResourcesWidget *resourcesDock = nullptr;
|
2018-02-26 22:26:18 +00:00
|
|
|
VTablesWidget *vTablesDock = nullptr;
|
2018-02-04 14:32:18 +00:00
|
|
|
DisassemblerGraphView *graphView = nullptr;
|
|
|
|
QDockWidget *asmDock = nullptr;
|
|
|
|
QDockWidget *calcDock = nullptr;
|
2018-06-06 11:05:20 +00:00
|
|
|
QDockWidget *stackDock = nullptr;
|
2019-10-22 15:51:56 +00:00
|
|
|
QDockWidget *threadsDock = nullptr;
|
2019-12-09 18:43:42 +00:00
|
|
|
QDockWidget *processesDock = nullptr;
|
2018-06-06 11:05:20 +00:00
|
|
|
QDockWidget *registersDock = nullptr;
|
|
|
|
QDockWidget *backtraceDock = nullptr;
|
2018-06-12 08:43:14 +00:00
|
|
|
QDockWidget *memoryMapDock = nullptr;
|
2017-12-13 17:36:00 +00:00
|
|
|
NewFileDialog *newFileDialog = nullptr;
|
2018-06-22 08:45:00 +00:00
|
|
|
QDockWidget *breakpointDock = nullptr;
|
2018-07-19 14:35:46 +00:00
|
|
|
QDockWidget *registerRefsDock = nullptr;
|
2017-12-21 15:47:36 +00:00
|
|
|
|
2019-11-04 16:40:54 +00:00
|
|
|
void initUI();
|
2019-03-18 06:44:14 +00:00
|
|
|
void initToolBar();
|
|
|
|
void initDocks();
|
|
|
|
void initLayout();
|
2019-06-18 13:02:41 +00:00
|
|
|
void initCorners();
|
2019-12-10 07:34:21 +00:00
|
|
|
void initBackForwardMenu();
|
2018-08-18 16:04:45 +00:00
|
|
|
void displayInitialOptionsDialog(const InitialOptions &options = InitialOptions(), bool skipOptionsDialog = false);
|
|
|
|
|
2017-11-03 17:22:54 +00:00
|
|
|
void resetToDefaultLayout();
|
2018-06-12 15:42:38 +00:00
|
|
|
void resetToDebugLayout();
|
2019-01-14 08:17:10 +00:00
|
|
|
void restoreDebugLayout();
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
void updateMemberPointers();
|
|
|
|
void resetDockWidgetList();
|
2017-11-03 17:22:54 +00:00
|
|
|
void restoreDocks();
|
|
|
|
void hideAllDocks();
|
2018-05-25 14:30:59 +00:00
|
|
|
void showZenDocks();
|
2018-06-12 15:42:38 +00:00
|
|
|
void showDebugDocks();
|
2018-10-22 18:06:30 +00:00
|
|
|
void enableDebugWidgetsMenu(bool enable);
|
2019-12-10 07:34:21 +00:00
|
|
|
/**
|
|
|
|
* @brief Fill menu with seek history entries.
|
|
|
|
* @param menu
|
|
|
|
* @param redo set to false for undo history, true for redo.
|
|
|
|
*/
|
|
|
|
void updateHistoryMenu(QMenu *menu, bool redo = false);
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
void toggleDockWidget(QDockWidget *dock_widget, bool show);
|
|
|
|
|
2018-10-16 06:25:09 +00:00
|
|
|
void updateDockActionsChecked();
|
2019-02-19 15:56:50 +00:00
|
|
|
void setOverviewData();
|
2019-03-12 07:37:10 +00:00
|
|
|
bool isOverviewActive();
|
2019-06-18 13:02:41 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
MemoryWidgetType getMemoryWidgetTypeToRestore();
|
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
/**
|
2019-07-04 18:51:44 +00:00
|
|
|
* @brief Map from a widget type (e.g. DisassemblyWidget::getWidgetType()) to the respective contructor of the widget
|
2019-06-18 13:02:41 +00:00
|
|
|
*/
|
2019-07-04 18:51:44 +00:00
|
|
|
QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap;
|
2019-07-19 19:21:12 +00:00
|
|
|
|
2019-09-02 07:34:41 +00:00
|
|
|
MemoryDockWidget* lastSyncMemoryWidget = nullptr;
|
2019-07-19 19:21:12 +00:00
|
|
|
MemoryDockWidget* lastMemoryWidget = nullptr;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|