* 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();
tabsOnTop = settings.value("tabsOnTop").toBool();
setTabLocation();
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
resize(size);
move(pos);
updateDockActionsChecked();
}
@ -481,6 +485,29 @@ void MainWindow::saveSettings()
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()
{
if (panelLock) {
@ -705,22 +732,12 @@ void MainWindow::resetToZenLayout()
void MainWindow::resetToDebugLayout()
{
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
hideAllDocks();
restoreDocks();
showDebugDocks();
disassemblyDock->raise();
// 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);
readDebugSettings();
Core()->raisePrioritizedMemoryWidget(memType);
}
void MainWindow::addOutput(const QString &msg)
@ -939,11 +956,12 @@ void MainWindow::changeDebugView()
void MainWindow::changeDefinedView()
{
resetToDefaultLayout();
saveDebugSettings();
CutterCore::MemoryWidgetType memType = Core()->getMemoryWidgetPriority();
hideAllDocks();
restoreDocks();
readSettings();
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
Core()->raisePrioritizedMemoryWidget(memType);
}
void MainWindow::mousePressEvent(QMouseEvent *event)

View File

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