mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Update Windows Menu and make Actions checkable
This commit is contained in:
parent
7d84fbfc1d
commit
9bd57776f6
@ -181,21 +181,21 @@ void MainWindow::initUI()
|
||||
*/
|
||||
dockWidgets.reserve(14);
|
||||
|
||||
// Add disassembly view (dockable)
|
||||
this->disassemblyDock = new DisassemblyWidget(tr("Disassembly"), this);
|
||||
dockWidgets.push_back(disassemblyDock);
|
||||
|
||||
sidebarDock = new SidebarWidget(tr("Sidebar"), this);
|
||||
dockWidgets.push_back(sidebarDock);
|
||||
|
||||
hexdumpDock = new HexdumpWidget(tr("Hexdump"), this);
|
||||
dockWidgets.push_back(hexdumpDock);
|
||||
|
||||
pseudocodeDock = new PseudocodeWidget(tr("Pseudocode"), this);
|
||||
dockWidgets.push_back(pseudocodeDock);
|
||||
|
||||
consoleDock = new ConsoleWidget(tr("Console"), this);
|
||||
dockWidgets.push_back(consoleDock);
|
||||
#define ADD_DOCK(cls, dockMember, action) \
|
||||
{ \
|
||||
(dockMember) = new cls(this); \
|
||||
dockWidgets.push_back(dockMember); \
|
||||
connect((action), &QAction::triggered, this, [this](bool checked) \
|
||||
{ \
|
||||
toggleDockWidget((dockMember), checked); \
|
||||
}); \
|
||||
dockWidgetActions[action] = (dockMember); \
|
||||
}
|
||||
ADD_DOCK(DisassemblyWidget, disassemblyDock, ui->actionDisassembly);
|
||||
ADD_DOCK(SidebarWidget, sidebarDock, ui->actionSidebar);
|
||||
ADD_DOCK(HexdumpWidget, hexdumpDock, ui->actionHexdump);
|
||||
ADD_DOCK(PseudocodeWidget, pseudocodeDock, ui->actionPseudocode);
|
||||
ADD_DOCK(ConsoleWidget, consoleDock, ui->actionConsole);
|
||||
|
||||
// Add graph view as dockable
|
||||
graphDock = new QDockWidget(tr("Graph"), this);
|
||||
@ -223,54 +223,25 @@ void MainWindow::initUI()
|
||||
}
|
||||
});
|
||||
dockWidgets.push_back(graphDock);
|
||||
connect(ui->actionGraph, &QAction::triggered, this, [this](bool checked)
|
||||
{
|
||||
toggleDockWidget(graphDock, checked);
|
||||
});
|
||||
|
||||
// Add Sections dock panel
|
||||
this->sectionsDock = new SectionsDock(this);
|
||||
dockWidgets.push_back(sectionsDock);
|
||||
|
||||
// Add entrypoint DockWidget
|
||||
this->entrypointDock = new EntrypointWidget(this);
|
||||
dockWidgets.push_back(entrypointDock);
|
||||
|
||||
// Add functions DockWidget
|
||||
this->functionsDock = new FunctionsWidget(this);
|
||||
dockWidgets.push_back(functionsDock);
|
||||
|
||||
// Add imports DockWidget
|
||||
this->importsDock = new ImportsWidget(this);
|
||||
dockWidgets.push_back(importsDock);
|
||||
|
||||
// Add exports DockWidget
|
||||
this->exportsDock = new ExportsWidget(this);
|
||||
dockWidgets.push_back(exportsDock);
|
||||
|
||||
// Add symbols DockWidget
|
||||
this->symbolsDock = new SymbolsWidget(this);
|
||||
dockWidgets.push_back(symbolsDock);
|
||||
|
||||
// Add relocs DockWidget
|
||||
this->relocsDock = new RelocsWidget(this);
|
||||
dockWidgets.push_back(relocsDock);
|
||||
|
||||
// Add comments DockWidget
|
||||
this->commentsDock = new CommentsWidget(this);
|
||||
dockWidgets.push_back(commentsDock);
|
||||
|
||||
// Add strings DockWidget
|
||||
this->stringsDock = new StringsWidget(this);
|
||||
dockWidgets.push_back(stringsDock);
|
||||
|
||||
// Add flags DockWidget
|
||||
this->flagsDock = new FlagsWidget(this);
|
||||
dockWidgets.push_back(flagsDock);
|
||||
|
||||
// Add Notepad Dock panel
|
||||
this->notepadDock = new Notepad(this);
|
||||
dockWidgets.push_back(notepadDock);
|
||||
|
||||
//Add Dashboard Dock panel
|
||||
this->dashboardDock = new Dashboard(this);
|
||||
dockWidgets.push_back(dashboardDock);
|
||||
ADD_DOCK(SectionsDock, sectionsDock, ui->actionSections);
|
||||
ADD_DOCK(EntrypointWidget, entrypointDock, ui->actionEntrypoints);
|
||||
ADD_DOCK(FunctionsWidget, functionsDock, ui->actionFunctions);
|
||||
ADD_DOCK(ImportsWidget, importsDock, ui->actionImports);
|
||||
ADD_DOCK(ExportsWidget, exportsDock, ui->actionExports);
|
||||
ADD_DOCK(SymbolsWidget, symbolsDock, ui->actionSymbols);
|
||||
ADD_DOCK(RelocsWidget, relocsDock, ui->actionRelocs);
|
||||
ADD_DOCK(CommentsWidget, commentsDock, ui->actionComments);
|
||||
ADD_DOCK(StringsWidget, stringsDock, ui->actionStrings);
|
||||
ADD_DOCK(FlagsWidget, flagsDock, ui->actionFlags);
|
||||
ADD_DOCK(Notepad, notepadDock, ui->actionNotepad);
|
||||
ADD_DOCK(Dashboard, dashboardDock, ui->actionDashboard);
|
||||
ADD_DOCK(SdbDock, sdbDock, ui->actionSDBBrowser);
|
||||
#undef ADD_DOCK
|
||||
|
||||
// Set up dock widgets default layout
|
||||
resetToDefaultLayout();
|
||||
@ -462,6 +433,7 @@ void MainWindow::readSettings()
|
||||
setPanelLock();
|
||||
tabsOnTop = settings.value("tabsOnTop").toBool();
|
||||
setTabLocation();
|
||||
updateDockActionsChecked();
|
||||
}
|
||||
|
||||
void MainWindow::saveSettings()
|
||||
@ -580,61 +552,6 @@ void MainWindow::on_actionTabs_triggered()
|
||||
setTabLocation();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEntry_points_triggered()
|
||||
{
|
||||
toggleDockWidget(entrypointDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFunctions_triggered()
|
||||
{
|
||||
toggleDockWidget(functionsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionImports_triggered()
|
||||
{
|
||||
toggleDockWidget(importsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExports_triggered()
|
||||
{
|
||||
toggleDockWidget(exportsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSymbols_triggered()
|
||||
{
|
||||
toggleDockWidget(symbolsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionReloc_triggered()
|
||||
{
|
||||
toggleDockWidget(relocsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStrings_triggered()
|
||||
{
|
||||
toggleDockWidget(stringsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSections_triggered()
|
||||
{
|
||||
toggleDockWidget(sectionsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFlags_triggered()
|
||||
{
|
||||
toggleDockWidget(flagsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionComents_triggered()
|
||||
{
|
||||
toggleDockWidget(commentsDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNotepad_triggered()
|
||||
{
|
||||
toggleDockWidget(notepadDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
AboutDialog *a = new AboutDialog(this);
|
||||
@ -646,9 +563,9 @@ void MainWindow::on_actionRefresh_Panels_triggered()
|
||||
this->refreshAll();
|
||||
}
|
||||
|
||||
void MainWindow::toggleDockWidget(QDockWidget *dock_widget)
|
||||
void MainWindow::toggleDockWidget(QDockWidget *dock_widget, bool show)
|
||||
{
|
||||
if (dock_widget->isVisible())
|
||||
if (!show)
|
||||
{
|
||||
dock_widget->close();
|
||||
}
|
||||
@ -707,6 +624,8 @@ void MainWindow::restoreDocks()
|
||||
tabifyDockWidget(dashboardDock, notepadDock);
|
||||
|
||||
dashboardDock->raise();
|
||||
|
||||
updateDockActionsChecked();
|
||||
}
|
||||
|
||||
|
||||
@ -716,6 +635,16 @@ void MainWindow::hideAllDocks()
|
||||
{
|
||||
w->hide();
|
||||
}
|
||||
|
||||
updateDockActionsChecked();
|
||||
}
|
||||
|
||||
void MainWindow::updateDockActionsChecked()
|
||||
{
|
||||
for(auto i=dockWidgetActions.constBegin(); i!=dockWidgetActions.constEnd(); i++)
|
||||
{
|
||||
i.key()->setChecked(!i.value()->isHidden());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showDefaultDocks()
|
||||
@ -744,6 +673,8 @@ void MainWindow::showDefaultDocks()
|
||||
w->show();
|
||||
}
|
||||
}
|
||||
|
||||
updateDockActionsChecked();
|
||||
}
|
||||
|
||||
void MainWindow::resetToDefaultLayout()
|
||||
@ -845,14 +776,6 @@ void MainWindow::on_actionWhite_Theme_triggered()
|
||||
this->setDefaultTheme();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSDBBrowser_triggered()
|
||||
{
|
||||
this->sdbDock = new SdbDock(this);
|
||||
//this->tabifyDockWidget(this->previewDock, this->sdbDock);
|
||||
this->sdbDock->setFloating(true);
|
||||
this->sdbDock->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLoad_triggered()
|
||||
{
|
||||
QProcess process(this);
|
||||
@ -860,19 +783,6 @@ void MainWindow::on_actionLoad_triggered()
|
||||
process.startDetached(qApp->applicationFilePath());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDashboard_triggered()
|
||||
{
|
||||
if (this->dashboardDock->isVisible())
|
||||
{
|
||||
this->dashboardDock->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dashboardDock->show();
|
||||
this->dashboardDock->raise();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleResponsive(bool maybe)
|
||||
{
|
||||
this->responsive = maybe;
|
||||
|
@ -93,18 +93,6 @@ public slots:
|
||||
void setDarkTheme();
|
||||
void setDefaultTheme();
|
||||
|
||||
void on_actionEntry_points_triggered();
|
||||
void on_actionFunctions_triggered();
|
||||
void on_actionImports_triggered();
|
||||
void on_actionExports_triggered();
|
||||
void on_actionSymbols_triggered();
|
||||
void on_actionReloc_triggered();
|
||||
void on_actionStrings_triggered();
|
||||
void on_actionSections_triggered();
|
||||
void on_actionFlags_triggered();
|
||||
void on_actionComents_triggered();
|
||||
void on_actionNotepad_triggered();
|
||||
|
||||
void on_actionLock_triggered();
|
||||
|
||||
void on_actionLockUnlock_triggered();
|
||||
@ -113,8 +101,6 @@ public slots:
|
||||
|
||||
void lockUnlock_Docks(bool what);
|
||||
|
||||
void on_actionDashboard_triggered();
|
||||
|
||||
void on_actionDark_Theme_triggered();
|
||||
|
||||
void on_actionRun_Script_triggered();
|
||||
@ -124,7 +110,6 @@ public slots:
|
||||
void backButton_clicked();
|
||||
|
||||
private slots:
|
||||
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
void on_actionRefresh_Panels_triggered();
|
||||
@ -145,8 +130,6 @@ private slots:
|
||||
|
||||
void on_actionWhite_Theme_triggered();
|
||||
|
||||
void on_actionSDBBrowser_triggered();
|
||||
|
||||
void on_actionLoad_triggered();
|
||||
|
||||
void on_actionForward_triggered();
|
||||
@ -183,7 +166,6 @@ private:
|
||||
ut64 hexdumpTopOffset;
|
||||
ut64 hexdumpBottomOffset;
|
||||
QString filename;
|
||||
QList<QDockWidget *> dockWidgets;
|
||||
std::unique_ptr<Ui::MainWindow> ui;
|
||||
Highlighter *highlighter;
|
||||
AsciiHighlighter *hex_highlighter;
|
||||
@ -204,13 +186,17 @@ private:
|
||||
SectionsDock *sectionsDock;
|
||||
ConsoleWidget *consoleDock;
|
||||
|
||||
void toggleDockWidget(QDockWidget *dock_widget);
|
||||
QList<QDockWidget *> dockWidgets;
|
||||
QMap<QAction *, QDockWidget *> dockWidgetActions;
|
||||
|
||||
void toggleDockWidget(QDockWidget *dock_widget, bool show);
|
||||
|
||||
void resetToDefaultLayout();
|
||||
|
||||
void restoreDocks();
|
||||
void hideAllDocks();
|
||||
void showDefaultDocks();
|
||||
void updateDockActionsChecked();
|
||||
|
||||
public:
|
||||
QString getFilename() const { return filename; }
|
||||
|
@ -166,7 +166,7 @@ border-top: 0px;
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1013</width>
|
||||
<height>22</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="defaultUp">
|
||||
@ -180,8 +180,8 @@ border-top: 0px;
|
||||
<rect>
|
||||
<x>273</x>
|
||||
<y>133</y>
|
||||
<width>173</width>
|
||||
<height>206</height>
|
||||
<width>140</width>
|
||||
<height>239</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -233,20 +233,27 @@ border-top: 0px;
|
||||
</property>
|
||||
<addaction name="actionDashboard"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEntry_points"/>
|
||||
<addaction name="actionDisassembly"/>
|
||||
<addaction name="actionGraph"/>
|
||||
<addaction name="actionHexdump"/>
|
||||
<addaction name="actionPseudocode"/>
|
||||
<addaction name="actionSidebar"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEntrypoints"/>
|
||||
<addaction name="actionFunctions"/>
|
||||
<addaction name="actionImports"/>
|
||||
<addaction name="actionExports"/>
|
||||
<addaction name="actionSymbols"/>
|
||||
<addaction name="actionSDBBrowser"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReloc"/>
|
||||
<addaction name="actionRelocs"/>
|
||||
<addaction name="actionStrings"/>
|
||||
<addaction name="actionFlags"/>
|
||||
<addaction name="actionSections"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionComents"/>
|
||||
<addaction name="actionComments"/>
|
||||
<addaction name="actionNotepad"/>
|
||||
<addaction name="actionConsole"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
@ -473,7 +480,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionStrings">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Strings</string>
|
||||
@ -484,7 +491,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionSections">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sections</string>
|
||||
@ -495,7 +502,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionFunctions">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Functions</string>
|
||||
@ -506,7 +513,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionImports">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Imports</string>
|
||||
@ -517,7 +524,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionSymbols">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Symbols</string>
|
||||
@ -526,9 +533,9 @@ QToolButton:pressed {
|
||||
<string>Show/Hide Symbols panel</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReloc">
|
||||
<action name="actionRelocs">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Relocs</string>
|
||||
@ -539,7 +546,7 @@ QToolButton:pressed {
|
||||
</action>
|
||||
<action name="actionFlags">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Flags</string>
|
||||
@ -598,9 +605,9 @@ QToolButton:pressed {
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionComents">
|
||||
<action name="actionComments">
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comments</string>
|
||||
@ -643,11 +650,6 @@ QToolButton:pressed {
|
||||
<string>Bindiff</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGraph">
|
||||
<property name="text">
|
||||
<string>Graph</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSearch">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
@ -853,11 +855,17 @@ QToolButton:pressed {
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNotepad">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Notepad</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSDBBrowser">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SDB Browser</string>
|
||||
</property>
|
||||
@ -868,6 +876,9 @@ QToolButton:pressed {
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDashboard">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dashboard</string>
|
||||
</property>
|
||||
@ -892,6 +903,9 @@ QToolButton:pressed {
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExports">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exports</string>
|
||||
</property>
|
||||
@ -923,7 +937,10 @@ QToolButton:pressed {
|
||||
<string>Show pseudocode rather than assembly</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntry_points">
|
||||
<action name="actionEntrypoints">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Entry Points</string>
|
||||
</property>
|
||||
@ -954,6 +971,54 @@ QToolButton:pressed {
|
||||
<string>Tmp</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisassembly">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disassembly</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGraph">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Graph</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPseudocode">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pseudocode</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHexdump">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hexdump</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSidebar">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sidebar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionConsole">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Console</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
@ -47,6 +47,8 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent)
|
||||
cursorLineOffset = 0;
|
||||
seekFromCursor = false;
|
||||
|
||||
setWindowTitle(tr("Disassembly"));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addWidget(mDisasTextEdit);
|
||||
layout->setMargin(0);
|
||||
@ -153,12 +155,6 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent)
|
||||
#undef ADD_SHORTCUT
|
||||
}
|
||||
|
||||
DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :
|
||||
DisassemblyWidget(parent)
|
||||
{
|
||||
this->setWindowTitle(title);
|
||||
}
|
||||
|
||||
QWidget* DisassemblyWidget::getTextWidget()
|
||||
{
|
||||
return mDisasTextEdit;
|
||||
|
@ -17,7 +17,6 @@ class DisassemblyWidget : public QDockWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DisassemblyWidget(QWidget *parent = nullptr);
|
||||
explicit DisassemblyWidget(const QString &title, QWidget *parent = nullptr);
|
||||
QWidget* getTextWidget();
|
||||
|
||||
public slots:
|
||||
|
Loading…
Reference in New Issue
Block a user