Mercurial > hg > sonic-visualiser
changeset 163:652b22dcd4ed
* Add mouse actions to key and mouse reference dialog
* Use QDialogButtonBox in all dialogs, for proper button ordering across
platforms (requires Qt 4.2)
* Fix #1733610 program does not exit if preferences dialog visible on close
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2007 11:07:01 +0000 (2007-07-05) |
parents | 9c9bce6440f5 |
children | 75cafe7a9246 |
files | main/MainWindow.cpp main/PreferencesDialog.cpp main/PreferencesDialog.h sv.pch |
diffstat | 4 files changed, 85 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Wed Jul 04 17:22:12 2007 +0000 +++ b/main/MainWindow.cpp Thu Jul 05 11:07:01 2007 +0000 @@ -331,6 +331,7 @@ delete m_viewManager; delete m_oscQueue; delete m_keyReference; + delete m_preferencesDialog; Profiles::getInstance()->dump(); } @@ -691,7 +692,7 @@ action = new QAction(tr("Insert Instants at Selection &Boundaries"), this); action->setShortcut(tr("Shift+Enter")); - action->setStatusTip(tr("Insert new time instants at the start and end of the current selection, in a new layer if necessary")); + action->setStatusTip(tr("Insert new time instants at the start and end of the current selected regions, in a new layer if necessary")); connect(action, SIGNAL(triggered()), this, SLOT(insertInstantsAtBoundaries())); connect(this, SIGNAL(canInsertInstantsAtBoundaries(bool)), action, SLOT(setEnabled(bool))); m_keyReference->registerShortcut(action); @@ -1127,7 +1128,6 @@ action = new QAction(icon, actionText, this); if (!model || model == getMainModel()) { action->setShortcut(shortcutText); - m_keyReference->registerShortcut(action); } } else { action = new QAction(actionText, this); @@ -1193,14 +1193,13 @@ m_rightButtonLayerMenu->addSeparator(); menu->addSeparator(); - action = new QAction(tr("&Rename Layer..."), this); - action->setShortcut(tr("R")); - action->setStatusTip(tr("Rename the currently active layer")); - connect(action, SIGNAL(triggered()), this, SLOT(renameCurrentLayer())); - connect(this, SIGNAL(canRenameLayer(bool)), action, SLOT(setEnabled(bool))); - m_keyReference->registerShortcut(action); - menu->addAction(action); - m_rightButtonLayerMenu->addAction(action); + QAction *raction = new QAction(tr("&Rename Layer..."), this); + raction->setShortcut(tr("R")); + raction->setStatusTip(tr("Rename the currently active layer")); + connect(raction, SIGNAL(triggered()), this, SLOT(renameCurrentLayer())); + connect(this, SIGNAL(canRenameLayer(bool)), raction, SLOT(setEnabled(bool))); + menu->addAction(raction); + m_rightButtonLayerMenu->addAction(raction); action = new QAction(QIcon(":/icons/editdelete.png"), tr("&Delete Layer"), this); action->setShortcut(tr("Ctrl+D")); @@ -1210,6 +1209,8 @@ m_keyReference->registerShortcut(action); menu->addAction(action); m_rightButtonLayerMenu->addAction(action); + + m_keyReference->registerShortcut(raction); // rename after delete, so delete layer goes next to delete pane } void @@ -1436,7 +1437,7 @@ connect(action, SIGNAL(triggered()), this, SLOT(website())); menu->addAction(action); - action = new QAction(tr("&Key Reference"), this); + action = new QAction(tr("&Key and Mouse Reference"), this); action->setShortcut(tr("F2")); action->setStatusTip(tr("Open a window showing the keystrokes you can use in Sonic Visualiser")); connect(action, SIGNAL(triggered()), this, SLOT(keyReference())); @@ -1460,7 +1461,9 @@ if (i == 0) { action->setShortcut(tr("Ctrl+R")); m_keyReference->registerShortcut - (action, tr("Re-open the most recently opened file")); + (tr("Re-open"), + action->shortcut(), + tr("Re-open the current or most recently opened file")); } m_recentFilesMenu->addAction(action); } @@ -1483,9 +1486,9 @@ if (i == 0) { ti->second->setShortcut(tr("Ctrl+T")); m_keyReference->registerShortcut - (tr("Re-run the most recently run transform"), + (tr("Repeat Transform"), ti->second->shortcut(), - ""); + tr("Re-select the most recently run transform")); } m_recentTransformsMenu->addAction(ti->second); } @@ -1591,6 +1594,7 @@ QAction *m_rwdAction = toolbar->addAction(QIcon(":/icons/rewind.png"), tr("Rewind")); m_rwdAction->setShortcut(tr("PgUp")); + m_rwdAction->setStatusTip(tr("Rewind to the previous time instant or time ruler notch")); connect(m_rwdAction, SIGNAL(triggered()), this, SLOT(rewind())); connect(this, SIGNAL(canRewind(bool)), m_rwdAction, SLOT(setEnabled(bool))); @@ -1607,6 +1611,7 @@ m_ffwdAction = toolbar->addAction(QIcon(":/icons/ffwd.png"), tr("Fast Forward")); m_ffwdAction->setShortcut(tr("PgDown")); + m_ffwdAction->setStatusTip(tr("Fast-forward to the next time instant or time ruler notch")); connect(m_ffwdAction, SIGNAL(triggered()), this, SLOT(ffwd())); connect(this, SIGNAL(canFfwd(bool)), m_ffwdAction, SLOT(setEnabled(bool))); @@ -1624,7 +1629,7 @@ psAction->setCheckable(true); psAction->setChecked(m_viewManager->getPlaySelectionMode()); psAction->setShortcut(tr("s")); - psAction->setStatusTip(tr("Constrain playback to the selected area")); + psAction->setStatusTip(tr("Constrain playback to the selected regions")); connect(m_viewManager, SIGNAL(playSelectionModeChanged(bool)), psAction, SLOT(setChecked(bool))); connect(psAction, SIGNAL(triggered()), this, SLOT(playSelectionToggled())); @@ -1673,16 +1678,19 @@ QAction *fastAction = menu->addAction(tr("Speed Up")); fastAction->setShortcut(tr("Ctrl+PgUp")); + fastAction->setStatusTip(tr("Time-stretch playback to speed it up without changing pitch")); connect(fastAction, SIGNAL(triggered()), this, SLOT(speedUpPlayback())); connect(this, SIGNAL(canSpeedUpPlayback(bool)), fastAction, SLOT(setEnabled(bool))); QAction *slowAction = menu->addAction(tr("Slow Down")); slowAction->setShortcut(tr("Ctrl+PgDown")); + slowAction->setStatusTip(tr("Time-stretch playback to slow it down without changing pitch")); connect(slowAction, SIGNAL(triggered()), this, SLOT(slowDownPlayback())); connect(this, SIGNAL(canSlowDownPlayback(bool)), slowAction, SLOT(setEnabled(bool))); QAction *normalAction = menu->addAction(tr("Restore Normal Speed")); normalAction->setShortcut(tr("Ctrl+Home")); + normalAction->setStatusTip(tr("Restore non-time-stretched playback")); connect(normalAction, SIGNAL(triggered()), this, SLOT(restoreNormalPlayback())); connect(this, SIGNAL(canChangePlaybackSpeed(bool)), normalAction, SLOT(setEnabled(bool))); @@ -1764,6 +1772,8 @@ // m_toolActions[ViewManager::TextMode] = action; toolNavigateSelected(); + + Pane::registerShortcuts(*m_keyReference); } void @@ -3123,6 +3133,15 @@ settings.setValue("position", pos()); settings.endGroup(); + delete m_keyReference; + m_keyReference = 0; + + closeSession(); + if (m_preferencesDialog && + m_preferencesDialog->isVisible()) { + m_preferencesDialog->applicationClosing(false); + } + e->accept(); return; } @@ -3131,8 +3150,19 @@ MainWindow::commitData(bool mayAskUser) { if (mayAskUser) { - return checkSaveModified(); + bool rv = checkSaveModified(); + if (rv) { + if (m_preferencesDialog && + m_preferencesDialog->isVisible()) { + m_preferencesDialog->applicationClosing(false); + } + } + return rv; } else { + if (m_preferencesDialog && + m_preferencesDialog->isVisible()) { + m_preferencesDialog->applicationClosing(true); + } if (!m_documentModified) return true; // If we can't check with the user first, then we can't save
--- a/main/PreferencesDialog.cpp Wed Jul 04 17:22:12 2007 +0000 +++ b/main/PreferencesDialog.cpp Thu Jul 05 11:07:01 2007 +0000 @@ -24,6 +24,8 @@ #include <QPushButton> #include <QHBoxLayout> #include <QString> +#include <QDialogButtonBox> +#include <QMessageBox> #include "widgets/WindowTypeSelector.h" #include "base/Preferences.h" @@ -31,7 +33,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags) { - setWindowTitle(tr("Application Preferences")); + setWindowTitle(tr("Sonic Visualiser: Application Preferences")); Preferences *prefs = Preferences::getInstance(); @@ -39,7 +41,7 @@ setLayout(grid); QGroupBox *groupBox = new QGroupBox; - groupBox->setTitle(tr("Sonic Visualiser Application Preferences")); + groupBox->setTitle(tr("Application Preferences")); grid->addWidget(groupBox, 0, 0); QGridLayout *subgrid = new QGridLayout; @@ -144,15 +146,14 @@ subgrid->setRowStretch(row, 10); row++; - QHBoxLayout *hbox = new QHBoxLayout; - grid->addLayout(hbox, 1, 0); + QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal); + grid->addWidget(bb, 1, 0); QPushButton *ok = new QPushButton(tr("OK")); QPushButton *cancel = new QPushButton(tr("Cancel")); - hbox->addStretch(10); - hbox->addWidget(ok); - hbox->addWidget(m_applyButton); - hbox->addWidget(cancel); + bb->addButton(ok, QDialogButtonBox::AcceptRole); + bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole); + bb->addButton(cancel, QDialogButtonBox::RejectRole); connect(ok, SIGNAL(clicked()), this, SLOT(okClicked())); connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked())); connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); @@ -227,3 +228,29 @@ reject(); } +void +PreferencesDialog::applicationClosing(bool quickly) +{ + if (quickly) { + reject(); + return; + } + + if (m_applyButton->isEnabled()) { + int rv = QMessageBox::warning + (this, tr("Preferences Changed"), + tr("Some preferences have been changed but not applied.\n" + "Apply them before closing?"), + QMessageBox::Apply | QMessageBox::Discard, + QMessageBox::Discard); + if (rv == QMessageBox::Apply) { + applyClicked(); + accept(); + } else { + reject(); + } + } else { + accept(); + } +} +
--- a/main/PreferencesDialog.h Wed Jul 04 17:22:12 2007 +0000 +++ b/main/PreferencesDialog.h Thu Jul 05 11:07:01 2007 +0000 @@ -31,6 +31,9 @@ PreferencesDialog(QWidget *parent = 0, Qt::WFlags flags = 0); virtual ~PreferencesDialog(); +public slots: + void applicationClosing(bool quickly); + protected slots: void windowTypeChanged(WindowType type); void spectrogramSmoothingChanged(int state);