Fix initial objectName for Memory Widgets

This commit is contained in:
Florian Märkl 2019-06-18 19:57:07 +02:00
parent 0c3b7e7f07
commit ede98df6ac
5 changed files with 11 additions and 11 deletions

View File

@ -312,7 +312,7 @@ void MainWindow::initDocks()
vTablesDock = new VTablesWidget(this, ui->actionVTables);
QSettings s;
QStringList docks = s.value("docks").toStringList();
QStringList docks = s.value("docks", QStringList { GraphWidget::getWidgetType() }).toStringList();
// Restore all extra widgets
QString className;
@ -373,21 +373,18 @@ void MainWindow::updateTasksIndicator()
void MainWindow::addExtraGraph()
{
auto *extraDock = new GraphWidget(this, ui->actionGraph);
extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType()));
addExtraWidget(extraDock);
}
void MainWindow::addExtraHexdump()
{
auto *extraDock = new HexdumpWidget(this, ui->actionHexdump);
extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType()));
addExtraWidget(extraDock);
}
void MainWindow::addExtraDisassembly()
{
auto *extraDock = new DisassemblyWidget(this, ui->actionDisassembly);
extraDock->setObjectName(getUniqueObjectName(extraDock->getWidgetType()));
addExtraWidget(extraDock);
}
@ -857,14 +854,14 @@ void MainWindow::updateDockActionsChecked()
}
}
QString MainWindow::getUniqueObjectName(const QString& widgetType) const
QString MainWindow::getUniqueObjectName(const QString &widgetType) const
{
QStringList docks;
docks.reserve(dockWidgets.size());
QString name;
for (const auto &it : dockWidgets) {
name = it->objectName();
if (name.split(';').at(0) == widgetType && name != "Graph Overview") {
if (name.split(';').at(0) == widgetType) {
docks.push_back(name);
}
}

View File

@ -110,6 +110,8 @@ public:
}
void messageBoxWarning(QString title, QString message);
QString getUniqueObjectName(const QString &widgetType) const;
public slots:
void finalizeOpen();
@ -276,8 +278,6 @@ private:
* pointer to class constructor and action that passed to this constructor.
*/
QMap<QString, std::pair<std::function<CutterDockWidget*(MainWindow*, QAction*)>, QAction*>> classNameToConstructorAndActionMap;
QString getUniqueObjectName(const QString &widgetType) const;
};
#endif // MAINWINDOW_H

View File

@ -3,6 +3,7 @@
#include "common/Configuration.h"
#include "common/Helpers.h"
#include "common/TempConfig.h"
#include "core/MainWindow.h"
#include <QScrollBar>
#include <QJsonArray>
@ -39,7 +40,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
, mDisasScrollArea(new DisassemblyScrollArea(this))
, mDisasTextEdit(new DisassemblyTextEdit(this))
{
setObjectName(getWidgetType());
setObjectName(main->getUniqueObjectName(getWidgetType()));
topOffset = bottomOffset = RVA_INVALID;
cursorLineOffset = 0;

View File

@ -6,7 +6,8 @@
GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
MemoryDockWidget(CutterCore::MemoryWidgetType::Graph, main, action)
{
setObjectName(getWidgetType());
setObjectName(main->getUniqueObjectName(getWidgetType()));
setAllowedAreas(Qt::AllDockWidgetAreas);
graphView = new DisassemblerGraphView(this, seekable);
setWidget(graphView);

View File

@ -4,6 +4,7 @@
#include "common/Helpers.h"
#include "common/Configuration.h"
#include "common/TempConfig.h"
#include "core/MainWindow.h"
#include <QJsonObject>
#include <QJsonArray>
@ -21,7 +22,7 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
{
ui->setupUi(this);
setObjectName(getWidgetType());
setObjectName(main->getUniqueObjectName(getWidgetType()));
ui->copyMD5->setIcon(QIcon(":/img/icons/copy.svg"));
ui->copySHA1->setIcon(QIcon(":/img/icons/copy.svg"));