Skip to content

Commit

Permalink
Save layout of the Decompiler Widgets (#2410)
Browse files Browse the repository at this point in the history
* Create decompiler widgets when loading a layout
* Do not translate the dock widget names used for saving layout.
  • Loading branch information
NirmalManoj committed Aug 30, 2020
1 parent 691de14 commit d7ef6e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/core/MainWindow.cpp
Expand Up @@ -157,6 +157,8 @@ void MainWindow::initUI()
widgetTypeToConstructorMap.insert(DisassemblyWidget::getWidgetType(),
getNewInstance<DisassemblyWidget>);
widgetTypeToConstructorMap.insert(HexdumpWidget::getWidgetType(), getNewInstance<HexdumpWidget>);
widgetTypeToConstructorMap.insert(DecompilerWidget::getWidgetType(),
getNewInstance<DecompilerWidget>);

initToolBar();
initDocks();
Expand Down Expand Up @@ -654,7 +656,12 @@ void MainWindow::finalizeOpen()
auto disasmWidget = qobject_cast<DisassemblyWidget *>(dockWidget);
if (disasmWidget && dockWidget->isVisibleToUser()) {
disasmWidget->raiseMemoryWidget();
// continue looping in case there is a graph wiget
// continue looping in case there is a graph widget
}
auto decompilerWidget = qobject_cast<DecompilerWidget *>(dockWidget);
if (decompilerWidget && dockWidget->isVisibleToUser()) {
decompilerWidget->raiseMemoryWidget();
// continue looping in case there is a graph widget
}
}
}
Expand Down Expand Up @@ -885,7 +892,8 @@ bool MainWindow::isExtraMemoryWidget(QDockWidget *dock) const
{
return qobject_cast<GraphWidget*>(dock) ||
qobject_cast<HexdumpWidget*>(dock) ||
qobject_cast<DisassemblyWidget*>(dock);
qobject_cast<DisassemblyWidget*>(dock) ||
qobject_cast<DecompilerWidget*>(dock);
}

MemoryWidgetType MainWindow::getMemoryWidgetTypeToRestore()
Expand Down Expand Up @@ -1341,7 +1349,8 @@ void MainWindow::setViewLayout(const CutterLayout &layout)
docksToCreate = QStringList {
DisassemblyWidget::getWidgetType(),
GraphWidget::getWidgetType(),
HexdumpWidget::getWidgetType()
HexdumpWidget::getWidgetType(),
DecompilerWidget::getWidgetType()
};
} else {
docksToCreate = layout.viewProperties.keys();
Expand Down
9 changes: 7 additions & 2 deletions src/widgets/DecompilerWidget.cpp
Expand Up @@ -34,8 +34,8 @@ DecompilerWidget::DecompilerWidget(MainWindow *main) :
{
ui->setupUi(this);
setObjectName(main
? main->getUniqueObjectName(tr("Decompiler"))
: tr("Decompiler"));
? main->getUniqueObjectName(getWidgetType())
: getWidgetType());
updateWindowTitle();

syntaxHighlighter = Config()->createSyntaxHighlighter(ui->textEdit->document());
Expand Down Expand Up @@ -108,6 +108,11 @@ DecompilerWidget::DecompilerWidget(MainWindow *main) :

DecompilerWidget::~DecompilerWidget() = default;

QString DecompilerWidget::getWidgetType()
{
return "Decompiler";
}

Decompiler *DecompilerWidget::getCurrentDecompiler()
{
return Core()->getDecompilerById(ui->decompilerComboBox->currentData().toString());
Expand Down
1 change: 1 addition & 0 deletions src/widgets/DecompilerWidget.h
Expand Up @@ -27,6 +27,7 @@ class DecompilerWidget : public MemoryDockWidget
public:
explicit DecompilerWidget(MainWindow *main);
~DecompilerWidget();
static QString getWidgetType();
public slots:
void showDecompilerContextMenu(const QPoint &pt);

Expand Down

0 comments on commit d7ef6e9

Please sign in to comment.