Save layout of the Decompiler Widgets (#2410)

* Create decompiler widgets when loading a layout
* Do not translate the dock widget names used for saving layout.
This commit is contained in:
NIRMAL MANOJ C 2020-08-30 16:56:56 +05:30 committed by GitHub
parent 691de14853
commit d7ef6e9e91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View File

@ -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();
@ -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
}
}
}
@ -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()
@ -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();

View File

@ -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());
@ -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());

View File

@ -27,6 +27,7 @@ protected:
public:
explicit DecompilerWidget(MainWindow *main);
~DecompilerWidget();
static QString getWidgetType();
public slots:
void showDecompilerContextMenu(const QPoint &pt);