summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-03 07:30:08 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-03 07:36:09 -0800
commitd34965135a3b3f8fd887bb1d2a6083fb2f181fb0 (patch)
treebbff5d2b7ffbadf581902f710aad8a0b33d3b9f8 /qt-ui/mainwindow.cpp
parentfdb736c1e1ae6ba637061fe967fb8ef3ff571084 (diff)
downloadsubsurface-d34965135a3b3f8fd887bb1d2a6083fb2f181fb0.tar.gz
Disable dive component copy/paste shortcuts when no profile show
Instead of inventing another way to do this (and inevitably forgetting a path where this should be re-enabled) I renamed the DcShortcup related function and made them enable/disable the copy and paste shortcuts as well. Of course there now is one exception (isn't there always?): in "ADD" state we don't want to be able to switch DCs, but we do want to be able to paste. Fixes #825 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 3b7333619..df87eeef0 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -268,7 +268,7 @@ void MainWindow::cleanUpEmpty()
ui.globe->reload();
if (!existing_filename)
setTitle(MWTF_DEFAULT);
- disableDcShortcuts();
+ disableShortcuts();
}
bool MainWindow::okToClose(QString message)
@@ -342,21 +342,26 @@ void MainWindow::on_actionPrint_triggered()
#endif
}
-void MainWindow::disableDcShortcuts()
+void MainWindow::disableShortcuts(bool disablePaste)
{
ui.actionPreviousDC->setShortcut(QKeySequence());
ui.actionNextDC->setShortcut(QKeySequence());
+ ui.copy->setShortcut(QKeySequence());
+ if (disablePaste)
+ ui.paste->setShortcut(QKeySequence());
}
-void MainWindow::enableDcShortcuts()
+void MainWindow::enableShortcuts()
{
ui.actionPreviousDC->setShortcut(Qt::Key_Left);
ui.actionNextDC->setShortcut(Qt::Key_Right);
+ ui.copy->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
+ ui.paste->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
}
void MainWindow::showProfile()
{
- enableDcShortcuts();
+ enableShortcuts();
ui.newProfile->setProfileState();
ui.infoPane->setCurrentIndex(MAINTAB);
}
@@ -1359,14 +1364,14 @@ void MainWindow::editCurrentDive()
QString defaultDC(d->dc.model);
DivePlannerPointsModel::instance()->clear();
if (defaultDC == "manually added dive") {
- disableDcShortcuts();
+ disableShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
ui.newProfile->setAddState();
ui.infoPane->setCurrentIndex(MAINTAB);
DivePlannerPointsModel::instance()->loadFromDive(d);
ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
} else if (defaultDC == "planned dive") {
- disableDcShortcuts();
+ disableShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
//TODO: I BROKE THIS BY COMMENTING THE LINE BELOW
// and I'm sleepy now, so I think I should not try to fix right away.