Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: use toggle in main window triggered action #106

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/gui/mainwindow/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@
</property>
</action>
<action name="actionCsrShow">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>C&amp;ontrol and Status Registers</string>
</property>
Expand Down
19 changes: 18 additions & 1 deletion src/gui/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -546,6 +549,20 @@ void MainWindow::show_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area,
}
}

void MainWindow::toggle_dockwidget(QDockWidget *dw, Qt::DockWidgetArea area,
bool defaultVisible, bool resetState) {
if (dw == nullptr) { return; }
if (dw->isHidden()) {
dw->show();
addDockWidget(area, dw);
} else {
dw->hide();
if (dw->isFloating()) {
dw->setFloating(false);
}
}
}

void MainWindow::machine_status(enum machine::Machine::Status st) {
QString status;
switch (st) {
Expand Down
13 changes: 13 additions & 0 deletions src/gui/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ExtProcess> build_process;
bool ignore_unsaved = false;
};
Expand Down