From a977fdeb603bae0c2189007e24947b568ccfe20c Mon Sep 17 00:00:00 2001 From: trdthg Date: Sat, 24 Feb 2024 15:59:17 +0800 Subject: [PATCH 1/3] use toggle in main window triggered action --- src/gui/mainwindow/mainwindow.cpp | 21 +++++++++++++++++++-- src/gui/mainwindow/mainwindow.h | 13 +++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow/mainwindow.cpp b/src/gui/mainwindow/mainwindow.cpp index c904d03a..b283320a 100644 --- a/src/gui/mainwindow/mainwindow.cpp +++ b/src/gui/mainwindow/mainwindow.cpp @@ -160,7 +160,7 @@ MainWindow::MainWindow(QSettings *settings, QWidget *parent) connect(ui->actionPeripherals, &QAction::triggered, this, &MainWindow::show_peripherals); connect(ui->actionTerminal, &QAction::triggered, this, &MainWindow::show_terminal); connect(ui->actionLcdDisplay, &QAction::triggered, this, &MainWindow::show_lcd_display); - connect(ui->actionCsrShow, &QAction::triggered, this, &MainWindow::show_csrdock); + connect(ui->actionCsrShow, &QAction::triggered, this, &MainWindow::toggle_csrdock); connect(ui->actionCore_View_show, &QAction::triggered, this, &MainWindow::show_hide_coreview); connect(ui->actionMessages, &QAction::triggered, this, &MainWindow::show_messages); connect(ui->actionResetWindows, &QAction::triggered, this, &MainWindow::reset_windows); @@ -409,6 +409,9 @@ void MainWindow::print_action() { } \ void MainWindow::reset_state_##NAME() { \ show_dockwidget(&*NAME, DEFAULT_AREA, DEFAULT_VISIBLE, true); \ +} \ +void MainWindow::toggle_##NAME() { \ + toggle_dockwidget(&*NAME, DEFAULT_AREA, DEFAULT_VISIBLE, true); \ } SHOW_HANDLER(registers, Qt::TopDockWidgetArea, true) @@ -538,14 +541,28 @@ void MainWindow::show_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area, dw->hide(); } } else if (dw->isHidden()) { - dw->show(); addDockWidget(area, dw); + dw->show(); } else { dw->raise(); dw->setFocus(); } } +void MainWindow::toggle_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area, + bool defaultVisible, bool resetState) { + if (dw == nullptr) { return; } + if (dw->isHidden()) { + addDockWidget(area, dw); + dw->show(); + } else { + dw->hide(); + if (dw->isFloating()) { + dw->setFloating(false); + } + } +} + void MainWindow::machine_status(enum machine::Machine::Status st) { QString status; switch (st) { diff --git a/src/gui/mainwindow/mainwindow.h b/src/gui/mainwindow/mainwindow.h index d08b0802..90febbc3 100644 --- a/src/gui/mainwindow/mainwindow.h +++ b/src/gui/mainwindow/mainwindow.h @@ -90,6 +90,17 @@ public slots: void show_csrdock(); void show_hide_coreview(bool show); void show_messages(); + void toggle_registers(); + void toggle_program(); + void toggle_memory(); + void toggle_cache_data(); + void toggle_cache_program(); + void toggle_cache_level2(); + void toggle_peripherals(); + void toggle_terminal(); + void toggle_lcd_display(); + void toggle_csrdock(); + void toggle_messages(); void reset_windows(); void show_symbol_dialog(); // Actions - help @@ -142,6 +153,8 @@ public slots: void show_dockwidget(QDockWidget *w, Qt::DockWidgetArea area = Qt::RightDockWidgetArea, bool defaultVisible = false, bool resetState = false); + void toggle_dockwidget(QDockWidget *w, Qt::DockWidgetArea area = Qt::RightDockWidgetArea, + bool defaultVisible = false, bool resetState = false); QPointer build_process; bool ignore_unsaved = false; }; From ad4ec9dc22521d35e273c70711efd455b2a8e56d Mon Sep 17 00:00:00 2001 From: trdthg Date: Sat, 24 Feb 2024 16:51:30 +0800 Subject: [PATCH 2/3] add checkbox box --- src/gui/mainwindow/MainWindow.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/mainwindow/MainWindow.ui b/src/gui/mainwindow/MainWindow.ui index e9240e0d..80eec552 100644 --- a/src/gui/mainwindow/MainWindow.ui +++ b/src/gui/mainwindow/MainWindow.ui @@ -450,6 +450,9 @@ + + true + C&ontrol and Status Registers From d81564d724834eb2b98d6033a72c0c09af243d8a Mon Sep 17 00:00:00 2001 From: trdthg Date: Sat, 24 Feb 2024 18:27:03 +0800 Subject: [PATCH 3/3] fix --- src/gui/mainwindow/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow/mainwindow.cpp b/src/gui/mainwindow/mainwindow.cpp index b283320a..ac265130 100644 --- a/src/gui/mainwindow/mainwindow.cpp +++ b/src/gui/mainwindow/mainwindow.cpp @@ -541,8 +541,8 @@ void MainWindow::show_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area, dw->hide(); } } else if (dw->isHidden()) { - addDockWidget(area, dw); dw->show(); + addDockWidget(area, dw); } else { dw->raise(); dw->setFocus(); @@ -553,8 +553,8 @@ void MainWindow::toggle_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area, bool defaultVisible, bool resetState) { if (dw == nullptr) { return; } if (dw->isHidden()) { - addDockWidget(area, dw); dw->show(); + addDockWidget(area, dw); } else { dw->hide(); if (dw->isFloating()) {