cutter/src/core/MainWindow.h

281 lines
7.7 KiB
C
Raw Normal View History

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "core/Cutter.h" // only needed for ut64
#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-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;
class Omnibar;
2018-06-24 19:12:02 +00:00
class ProgressIndicator;
class PreviewWidget;
class Highlighter;
class AsciiHighlighter;
class VisualNavbar;
class FunctionsWidget;
class ImportsWidget;
class ExportsWidget;
class SymbolsWidget;
class RelocsWidget;
class CommentsWidget;
class StringsWidget;
class FlagsWidget;
class Dashboard;
class QLineEdit;
class SdbWidget;
class QAction;
class SectionsWidget;
class SegmentsWidget;
class ConsoleWidget;
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;
class SearchWidget;
class QDockWidget;
2019-03-14 09:28:42 +00:00
class DisassemblyWidget;
class GraphWidget;
class HexdumpWidget;
class PseudocodeWidget;
class OverviewWidget;
2018-03-21 20:32:32 +00:00
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
bool responsive;
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
2019-05-17 11:40:50 +00:00
void openNewFile(InitialOptions &options, bool skipOptionsDialog = false);
void displayNewFileDialog();
2019-01-19 20:54:02 +00:00
void displayWelcomeDialog();
void closeNewFileDialog();
void openProject(const QString &project_name);
void initUI();
2019-03-06 20:30:39 +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
/**
* @param quit whether to show destructive button in dialog
* @return false if the application should not close
*/
bool saveProjectAs(bool quit = false);
void closeEvent(QCloseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void readSettingsOrDefault();
void saveSettings();
void readDebugSettings();
void saveDebugSettings();
void setFilename(const QString &fn);
void refreshOmniBar(const QStringList &flags);
void addWidget(QDockWidget *widget);
void removeWidget(QDockWidget *widget);
2019-04-27 09:46:29 +00:00
void addExtraWidget(CutterDockWidget *extraDock);
void addPluginDockWidget(QDockWidget *dockWidget, QAction *action);
enum class MenuType { File, Edit, View, Windows, Debug, Help, Plugins };
QMenu *getMenuByType(MenuType type);
void addMenuFileAction(QAction *action);
void updateDockActionChecked(QAction * action);
QString getFilename() const
{
return filename;
}
void messageBoxWarning(QString title, QString message);
QString getUniqueObjectName(const QString &widgetType) const;
public slots:
void finalizeOpen();
void refreshAll();
void seekToFunctionLastInstruction();
void seekToFunctionStart();
void setPanelLock();
void setTabLocation();
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);
void openNewFileFailed();
void toggleOverview(bool visibility, GraphWidget *targetGraph);
private slots:
void on_actionAbout_triggered();
void on_actionIssue_triggered();
void addExtraGraph();
void addExtraHexdump();
void addExtraDisassembly();
void on_actionRefresh_Panels_triggered();
void on_actionDisasAdd_comment_triggered();
2018-01-16 14:09:51 +00:00
void on_actionDefault_triggered();
void on_actionFunctionsRename_triggered();
void on_actionNew_triggered();
void on_actionSave_triggered();
void on_actionSaveAs_triggered();
2018-03-08 09:11:19 +00:00
void on_actionBackward_triggered();
void on_actionForward_triggered();
2017-11-27 17:28:44 +00:00
void on_actionUndoSeek_triggered();
void on_actionRedoSeek_triggered();
2018-01-16 14:09:51 +00:00
void on_actionOpen_triggered();
void on_actionTabs_on_Top_triggered();
void on_actionReset_settings_triggered();
void on_actionQuit_triggered();
void on_actionRefresh_contents_triggered();
void on_actionPreferences_triggered();
2017-09-02 08:17:48 +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();
void on_actionGrouped_dock_dragging_triggered(bool checked);
void projectSaved(bool successfully, const QString &name);
void updateTasksIndicator();
void mousePressEvent(QMouseEvent *event) override;
bool eventFilter(QObject *object, QEvent *event) override;
void changeDebugView();
void changeDefinedView();
void chooseThemeIcons();
private:
2018-02-04 14:32:18 +00:00
CutterCore *core;
2017-12-13 17:36:00 +00:00
bool panelLock;
bool tabsOnTop;
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;
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;
QByteArray emptyState;
2018-02-04 14:32:18 +00:00
Configuration *configuration;
QList<QDockWidget *> dockWidgets;
QMultiMap<QAction *, QDockWidget *> dockWidgetsOfAction;
2018-02-04 14:32:18 +00:00
PseudocodeWidget *pseudocodeDock = nullptr;
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;
SdbWidget *sdbDock = nullptr;
SectionsWidget *sectionsDock = nullptr;
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;
QDockWidget *stackDock = nullptr;
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;
QDockWidget *breakpointDock = nullptr;
2018-07-19 14:35:46 +00:00
QDockWidget *registerRefsDock = nullptr;
void initToolBar();
void initDocks();
void initLayout();
void initCorners();
void displayInitialOptionsDialog(const InitialOptions &options = InitialOptions(), bool skipOptionsDialog = false);
void resetToDefaultLayout();
void resetToDebugLayout();
2019-01-14 08:17:10 +00:00
void restoreDebugLayout();
void updateMemberPointers();
void resetDockWidgetList();
void restoreDocks();
void hideAllDocks();
void showZenDocks();
void showDebugDocks();
void enableDebugWidgetsMenu(bool enable);
void toggleDockWidget(QDockWidget *dock_widget, bool show);
void updateDockActionsChecked();
void setOverviewData();
bool isOverviewActive();
/**
* @brief Map from a widget type (e.g. DisassemblyWidget::getWidgetType()) to the respective contructor of the widget
*/
QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap;
};
#endif // MAINWINDOW_H