* Debug geometry is now customizable

* Preserve open widget when switching to and from debug mode
 * Fix wonky widgets when using readSettings
This commit is contained in:
mandlebro 2018-07-24 00:12:36 +01:00 committed by xarkes
parent 4314add765
commit 94c0f2b5c2
2 changed files with 37 additions and 17 deletions

View File

@ -467,6 +467,10 @@ void MainWindow::readSettings()
setPanelLock(); setPanelLock();
tabsOnTop = settings.value("tabsOnTop").toBool(); tabsOnTop = settings.value("tabsOnTop").toBool();
setTabLocation(); setTabLocation();
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
resize(size);
move(pos);
updateDockActionsChecked(); updateDockActionsChecked();
} }
@ -481,6 +485,29 @@ void MainWindow::saveSettings()
settings.setValue("tabsOnTop", tabsOnTop); settings.setValue("tabsOnTop", tabsOnTop);
} }
void MainWindow::readDebugSettings()
{
QSettings settings;
QByteArray geo = settings.value("debug.geometry", QByteArray()).toByteArray();
restoreGeometry(geo);
QByteArray state = settings.value("debug.state", QByteArray()).toByteArray();
restoreState(state);
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
resize(size);
move(pos);
updateDockActionsChecked();
}
void MainWindow::saveDebugSettings()
{
QSettings settings;
settings.setValue("debug.geometry", saveGeometry());
settings.setValue("debug.state", saveState());
settings.setValue("size", size());
settings.setValue("pos", pos());
}
void MainWindow::setPanelLock() void MainWindow::setPanelLock()
{ {
if (panelLock) { if (panelLock) {
@ -705,22 +732,12 @@ void MainWindow::resetToZenLayout()
void MainWindow::resetToDebugLayout() void MainWindow::resetToDebugLayout()
{ {
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
hideAllDocks(); hideAllDocks();
restoreDocks(); restoreDocks();
showDebugDocks(); showDebugDocks();
disassemblyDock->raise(); readDebugSettings();
Core()->raisePrioritizedMemoryWidget(memType);
// ugly workaround to set the default widths of functions/stack
// if anyone finds a way to do this cleaner that also works, feel free to change it!
auto restoreFunctionDock = qhelpers::forceWidth(functionsDock->widget(), 150);
auto restoreStackDock = qhelpers::forceWidth(stackDock->widget(), 350);
qApp->processEvents();
restoreFunctionDock.restoreWidth(functionsDock->widget());
restoreStackDock.restoreWidth(stackDock->widget());
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
} }
void MainWindow::addOutput(const QString &msg) void MainWindow::addOutput(const QString &msg)
@ -939,11 +956,12 @@ void MainWindow::changeDebugView()
void MainWindow::changeDefinedView() void MainWindow::changeDefinedView()
{ {
resetToDefaultLayout(); saveDebugSettings();
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
hideAllDocks();
restoreDocks();
readSettings(); readSettings();
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); Core()->raisePrioritizedMemoryWidget(memType);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
} }
void MainWindow::mousePressEvent(QMouseEvent *event) void MainWindow::mousePressEvent(QMouseEvent *event)

View File

@ -91,6 +91,8 @@ public:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void readSettings(); void readSettings();
void saveSettings(); void saveSettings();
void readDebugSettings();
void saveDebugSettings();
void setFilename(const QString &fn); void setFilename(const QString &fn);
void addOutput(const QString &msg); void addOutput(const QString &msg);
void addDebugOutput(const QString &msg); void addDebugOutput(const QString &msg);