From 86868764980ff9eb2c2a9570fa4d118d6b1ad26b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 15 Mar 2017 18:25:21 +0000 Subject: [PATCH] Do not use menu shortcut that hides shortcut key used in widgets Ctrl+M (Cmd+M) was being used as a menu shortcut and in key press event handlers which leads to inconsistent behaviour on some platforms. Removed menu action shortcut. Also tidied up handling of the hide controls menu action by making it a checkable action and using its checked state to store the control hiding state. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7608 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 35 +++++++++++++++-------------------- mainwindow.h | 3 +-- mainwindow.ui | 6 +++--- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 0d97cacf5..534f28b5b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -878,8 +878,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, connect (&splashTimer, &QTimer::timeout, this, &MainWindow::splash_done); splashTimer.setSingleShot (true); splashTimer.start (20 * 1000); - m_bHideControls = !m_bHideControls; // we're not toggling here so we start in opposite state - on_actionHide_Controls_triggered(); // this must be the last statement of constructor if (!m_valid) throw std::runtime_error {"Fatal initialization exception"}; @@ -944,7 +942,7 @@ void MainWindow::writeSettings() m_settings->setValue ("AstroDisplayed", m_astroWidget && m_astroWidget->isVisible()); m_settings->setValue ("MsgAvgDisplayed", m_msgAvgWidget && m_msgAvgWidget->isVisible()); m_settings->setValue ("FreeText", ui->freeTextMsg->currentText ()); - m_settings->setValue ("HideControls", m_bHideControls); + m_settings->setValue ("HideControls", ui->actionHide_Controls->isChecked ()); m_settings->endGroup(); m_settings->beginGroup("Common"); @@ -998,9 +996,7 @@ void MainWindow::writeSettings() void MainWindow::readSettings() { m_settings->beginGroup("MainWindow"); - m_bHideControls = m_settings->value("HideControls", false).toBool (); - m_bHideControls = !m_bHideControls; // we're not toggling here so we start in opposite state - on_actionHide_Controls_triggered(); + ui->actionHide_Controls->setChecked (m_settings->value("HideControls", false).toBool ()); restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); m_geometryNoControls = m_settings->value ("geometryNoControls",saveGeometry()).toByteArray(); restoreState (m_settings->value ("state", saveState ()).toByteArray ()); @@ -1649,9 +1645,9 @@ void MainWindow::keyPressEvent (QKeyEvent * e) } break; case Qt::Key_M: - if(e->modifiers() & Qt::ControlModifier) { - on_actionHide_Controls_triggered(); - return; + if(e->modifiers() & Qt::ControlModifier) { + ui->actionHide_Controls->toggle (); + return; } break; case Qt::Key_F4: @@ -2037,12 +2033,11 @@ void MainWindow::on_actionFast_Graph_triggered() // This allows the window to shrink by removing certain things // and reducing space used by controls -void MainWindow::on_actionHide_Controls_triggered() +void MainWindow::on_actionHide_Controls_toggled (bool checked) { - m_bHideControls = !m_bHideControls; - int spacing = m_bHideControls ? 1 : 6; + int spacing = checked ? 1 : 6; - if (m_bHideControls) { + if (checked) { statusBar ()->removeWidget (&auto_tx_label); minimumSize().setHeight(450); minimumSize().setWidth(700); @@ -2056,15 +2051,15 @@ void MainWindow::on_actionHide_Controls_triggered() minimumSize().setHeight(520); minimumSize().setWidth(770); } - ui->menuBar->setVisible(!m_bHideControls); + ui->menuBar->setVisible(!checked); if(m_mode!="FreqCal") { - ui->label_6->setVisible(!m_bHideControls); - ui->label_7->setVisible(!m_bHideControls); - ui->decodedTextLabel2->setVisible(!m_bHideControls); - ui->line_2->setVisible(!m_bHideControls); + ui->label_6->setVisible(!checked); + ui->label_7->setVisible(!checked); + ui->decodedTextLabel2->setVisible(!checked); + ui->line_2->setVisible(!checked); } - ui->line->setVisible(!m_bHideControls); - ui->decodedTextLabel->setVisible(!m_bHideControls); + ui->line->setVisible(!checked); + ui->decodedTextLabel->setVisible(!checked); ui->gridLayout_5->layout()->setSpacing(spacing); ui->horizontalLayout->layout()->setSpacing(spacing); ui->horizontalLayout_2->layout()->setSpacing(spacing); diff --git a/mainwindow.h b/mainwindow.h index e08f00742..bc55069a4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -248,7 +248,7 @@ private slots: void on_actionEcho_triggered(); void on_actionISCAT_triggered(); void on_actionFast_Graph_triggered(); - void on_actionHide_Controls_triggered(); + void on_actionHide_Controls_toggled (bool chaecked); void fast_decode_done(); void on_actionMeasure_reference_spectrum_triggered(); void on_actionErase_reference_spectrum_triggered(); @@ -437,7 +437,6 @@ private: bool m_bNoMoreFiles; bool m_bQRAsyncWarned; bool m_bDoubleClicked; - bool m_bHideControls; int m_ihsym; int m_nzap; diff --git a/mainwindow.ui b/mainwindow.ui index 86aaede57..510a64777 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -2934,15 +2934,15 @@ QPushButton[state="ok"] { + + true + Hide menus and labels Reduces window size by removing controls and some spacing - - Ctrl+M -