"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.10.3/src/core/MainWindow.h" (8 May 2020, 9680 Bytes) of package /linux/privat/cutter-1.10.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MainWindow.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.10.2_vs_1.10.3.

    1 #ifndef MAINWINDOW_H
    2 #define MAINWINDOW_H
    3 
    4 #include "core/Cutter.h" // only needed for ut64
    5 #include "dialogs/NewFileDialog.h"
    6 #include "dialogs/WelcomeDialog.h"
    7 #include "common/Configuration.h"
    8 #include "common/InitialOptions.h"
    9 #include "MemoryDockWidget.h"
   10 
   11 #include <memory>
   12 
   13 #include <QMainWindow>
   14 #include <QList>
   15 
   16 class CutterCore;
   17 class Omnibar;
   18 class ProgressIndicator;
   19 class PreviewWidget;
   20 class Highlighter;
   21 class AsciiHighlighter;
   22 class VisualNavbar;
   23 class FunctionsWidget;
   24 class ImportsWidget;
   25 class ExportsWidget;
   26 class SymbolsWidget;
   27 class RelocsWidget;
   28 class CommentsWidget;
   29 class StringsWidget;
   30 class FlagsWidget;
   31 class Dashboard;
   32 class QLineEdit;
   33 class SdbWidget;
   34 class QAction;
   35 class SectionsWidget;
   36 class SegmentsWidget;
   37 class ConsoleWidget;
   38 class EntrypointWidget;
   39 class DisassemblerGraphView;
   40 class ClassesWidget;
   41 class ResourcesWidget;
   42 class VTablesWidget;
   43 class TypesWidget;
   44 class HeadersWidget;
   45 class ZignaturesWidget;
   46 class SearchWidget;
   47 class QDockWidget;
   48 class DisassemblyWidget;
   49 class GraphWidget;
   50 class HexdumpWidget;
   51 class DecompilerWidget;
   52 class OverviewWidget;
   53 
   54 namespace Ui {
   55 class MainWindow;
   56 }
   57 
   58 class MainWindow : public QMainWindow
   59 {
   60     Q_OBJECT
   61 
   62 public:
   63     bool responsive;
   64 
   65     explicit MainWindow(QWidget *parent = nullptr);
   66     ~MainWindow() override;
   67 
   68     void openNewFile(InitialOptions &options, bool skipOptionsDialog = false);
   69     void displayNewFileDialog();
   70     void displayWelcomeDialog();
   71     void closeNewFileDialog();
   72     void openProject(const QString &project_name);
   73 
   74     /**
   75      * @param quit whether to show destructive button in dialog
   76      * @return if quit is true, false if the application should not close
   77      */
   78     bool saveProject(bool quit = false);
   79 
   80     /**
   81      * @param quit whether to show destructive button in dialog
   82      * @return false if the application should not close
   83      */
   84     bool saveProjectAs(bool quit = false);
   85 
   86     void closeEvent(QCloseEvent *event) override;
   87     void paintEvent(QPaintEvent *event) override;
   88     void readSettingsOrDefault();
   89     void saveSettings();
   90     void readDebugSettings();
   91     void saveDebugSettings();
   92     void setFilename(const QString &fn);
   93     void refreshOmniBar(const QStringList &flags);
   94 
   95     void addWidget(QDockWidget *widget);
   96     void addMemoryDockWidget(MemoryDockWidget *widget);
   97     void removeWidget(QDockWidget *widget);
   98     void addExtraWidget(CutterDockWidget *extraDock);
   99     MemoryDockWidget *addNewMemoryWidget(MemoryWidgetType type, RVA address, bool synchronized = true);
  100 
  101 
  102     void addPluginDockWidget(QDockWidget *dockWidget, QAction *action);
  103     enum class MenuType { File, Edit, View, Windows, Debug, Help, Plugins };
  104     /**
  105      * @brief Getter for MainWindow's different menus
  106      * @param type The type which represents the desired menu
  107      * @return The requested menu or nullptr if "type" is invalid
  108      */
  109     QMenu *getMenuByType(MenuType type);
  110     void addMenuFileAction(QAction *action);
  111 
  112     void updateDockActionChecked(QAction * action);
  113 
  114     QString getFilename() const
  115     {
  116         return filename;
  117     }
  118     void messageBoxWarning(QString title, QString message);
  119 
  120     QString getUniqueObjectName(const QString &widgetType) const;
  121     void showMemoryWidget();
  122     void showMemoryWidget(MemoryWidgetType type);
  123 
  124     QMenu *createShowInMenu(QWidget *parent, RVA address);
  125     void setCurrentMemoryWidget(MemoryDockWidget* memoryWidget);
  126     MemoryDockWidget* getLastMemoryWidget();
  127 
  128     /* Context menu plugins */
  129     enum class ContextMenuType { Disassembly, Addressable };
  130     /**
  131      * @brief Fetches the pointer to a context menu extension of type
  132      * @param type - the type of the context menu
  133      * @return plugins submenu of the selected context menu
  134      */
  135     QMenu *getContextMenuExtensions(ContextMenuType type);
  136 
  137 public slots:
  138     void finalizeOpen();
  139 
  140     void refreshAll();
  141     void seekToFunctionLastInstruction();
  142     void seekToFunctionStart();
  143     void setPanelLock();
  144     void setTabLocation();
  145 
  146     void on_actionLock_triggered();
  147 
  148     void on_actionLockUnlock_triggered();
  149 
  150     void on_actionTabs_triggered();
  151 
  152     void lockUnlock_Docks(bool what);
  153 
  154     void on_actionRun_Script_triggered();
  155 
  156     void toggleResponsive(bool maybe);
  157 
  158     void openNewFileFailed();
  159 
  160     void toggleOverview(bool visibility, GraphWidget *targetGraph);
  161 private slots:
  162     void on_actionAbout_triggered();
  163     void on_actionIssue_triggered();
  164     void addExtraGraph();
  165     void addExtraHexdump();
  166     void addExtraDisassembly();
  167 
  168     void on_actionRefresh_Panels_triggered();
  169 
  170     void on_actionDisasAdd_comment_triggered();
  171 
  172     void on_actionDefault_triggered();
  173 
  174     void on_actionFunctionsRename_triggered();
  175 
  176     void on_actionNew_triggered();
  177 
  178     void on_actionSave_triggered();
  179     void on_actionSaveAs_triggered();
  180 
  181     void on_actionBackward_triggered();
  182     void on_actionForward_triggered();
  183 
  184     void on_actionMap_triggered();
  185 
  186     void on_actionTabs_on_Top_triggered();
  187 
  188     void on_actionReset_settings_triggered();
  189 
  190     void on_actionQuit_triggered();
  191 
  192     void on_actionRefresh_contents_triggered();
  193 
  194     void on_actionPreferences_triggered();
  195 
  196     void on_actionAnalyze_triggered();
  197 
  198     void on_actionImportPDB_triggered();
  199 
  200     void on_actionExport_as_code_triggered();
  201 
  202     void on_actionGrouped_dock_dragging_triggered(bool checked);
  203 
  204     void projectSaved(bool successfully, const QString &name);
  205 
  206     void updateTasksIndicator();
  207 
  208     void mousePressEvent(QMouseEvent *event) override;
  209     bool eventFilter(QObject *object, QEvent *event) override;
  210     bool event(QEvent *event) override;
  211     void toggleDebugView();
  212     void chooseThemeIcons();
  213 
  214     void onZoomIn();
  215     void onZoomOut();
  216     void onZoomReset();
  217 
  218 private:
  219     CutterCore *core;
  220 
  221     bool panelLock;
  222     bool tabsOnTop;
  223     ut64 hexdumpTopOffset;
  224     ut64 hexdumpBottomOffset;
  225     QString filename;
  226     std::unique_ptr<Ui::MainWindow> ui;
  227     Highlighter *highlighter;
  228     AsciiHighlighter *hex_highlighter;
  229     VisualNavbar *visualNavbar;
  230     Omnibar *omnibar;
  231     ProgressIndicator *tasksProgressIndicator;
  232     QByteArray emptyState;
  233 
  234     Configuration *configuration;
  235 
  236     QList<QDockWidget *> dockWidgets;
  237     QMultiMap<QAction *, QDockWidget *> dockWidgetsOfAction;
  238     DecompilerWidget   *decompilerDock = nullptr;
  239     OverviewWidget     *overviewDock = nullptr;
  240     EntrypointWidget   *entrypointDock = nullptr;
  241     FunctionsWidget    *functionsDock = nullptr;
  242     ImportsWidget      *importsDock = nullptr;
  243     ExportsWidget      *exportsDock = nullptr;
  244     HeadersWidget      *headersDock = nullptr;
  245     TypesWidget        *typesDock = nullptr;
  246     SearchWidget       *searchDock = nullptr;
  247     SymbolsWidget      *symbolsDock = nullptr;
  248     RelocsWidget       *relocsDock = nullptr;
  249     CommentsWidget     *commentsDock = nullptr;
  250     StringsWidget      *stringsDock = nullptr;
  251     FlagsWidget        *flagsDock = nullptr;
  252     Dashboard          *dashboardDock = nullptr;
  253     QLineEdit          *gotoEntry = nullptr;
  254     SdbWidget          *sdbDock = nullptr;
  255     SectionsWidget     *sectionsDock = nullptr;
  256     SegmentsWidget     *segmentsDock = nullptr;
  257     ZignaturesWidget   *zignaturesDock = nullptr;
  258     ConsoleWidget      *consoleDock = nullptr;
  259     ClassesWidget      *classesDock = nullptr;
  260     ResourcesWidget    *resourcesDock = nullptr;
  261     VTablesWidget      *vTablesDock = nullptr;
  262     DisassemblerGraphView *graphView = nullptr;
  263     QDockWidget        *asmDock = nullptr;
  264     QDockWidget        *calcDock = nullptr;
  265     QDockWidget        *stackDock = nullptr;
  266     QDockWidget        *threadsDock = nullptr;
  267     QDockWidget        *processesDock = nullptr;
  268     QDockWidget        *registersDock = nullptr;
  269     QDockWidget        *backtraceDock = nullptr;
  270     QDockWidget        *memoryMapDock = nullptr;
  271     NewFileDialog      *newFileDialog = nullptr;
  272     QDockWidget        *breakpointDock = nullptr;
  273     QDockWidget        *registerRefsDock = nullptr;
  274 
  275     QMenu *disassemblyContextMenuExtensions = nullptr;
  276     QMenu *addressableContextMenuExtensions = nullptr;
  277 
  278     void initUI();
  279     void initToolBar();
  280     void initDocks();
  281     void initLayout();
  282     void initCorners();
  283     void initBackForwardMenu();
  284     void displayInitialOptionsDialog(const InitialOptions &options = InitialOptions(), bool skipOptionsDialog = false);
  285 
  286     void resetToDefaultLayout();
  287     void resetToDebugLayout();
  288     void restoreDebugLayout();
  289 
  290     void updateMemberPointers();
  291     void resetDockWidgetList();
  292     void restoreDocks();
  293     void hideAllDocks();
  294     void showZenDocks();
  295     void showDebugDocks();
  296     void enableDebugWidgetsMenu(bool enable);
  297     /**
  298      * @brief Fill menu with seek history entries.
  299      * @param menu
  300      * @param redo set to false for undo history, true for redo.
  301      */
  302     void updateHistoryMenu(QMenu *menu, bool redo = false);
  303 
  304     void toggleDockWidget(QDockWidget *dock_widget, bool show);
  305 
  306     void updateDockActionsChecked();
  307     void setOverviewData();
  308     bool isOverviewActive();
  309     /**
  310      * @brief Check if a widget is one of debug specific dock widgets.
  311      * @param dock
  312      * @return true for debug specific widgets, false for all other including common dock widgets.
  313      */
  314     bool isDebugWidget(QDockWidget *dock) const;
  315 
  316     MemoryWidgetType getMemoryWidgetTypeToRestore();
  317 
  318     /**
  319      * @brief Map from a widget type (e.g. DisassemblyWidget::getWidgetType()) to the respective contructor of the widget
  320      */
  321     QMap<QString, std::function<CutterDockWidget*(MainWindow*, QAction*)>> widgetTypeToConstructorMap;
  322 
  323     MemoryDockWidget* lastSyncMemoryWidget = nullptr;
  324     MemoryDockWidget* lastMemoryWidget = nullptr;
  325 };
  326 
  327 #endif // MAINWINDOW_H