mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
fdb736c1e1
commit
d34965135a
3 changed files with 18 additions and 13 deletions
|
@ -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.
|
||||
|
|
|
@ -67,10 +67,10 @@ public:
|
|||
void showError(QString message);
|
||||
void setTitle(enum MainWindowTitleFormat format);
|
||||
|
||||
// The 'Change DC Shortcuts' should only be enabled
|
||||
// when the profile's visible.
|
||||
void disableDcShortcuts();
|
||||
void enableDcShortcuts();
|
||||
// Some shortcuts like "change DC" or "copy/paste dive components"
|
||||
// should only be enabled when the profile's visible.
|
||||
void disableShortcuts(bool disablePaste = true);
|
||||
void enableShortcuts();
|
||||
void loadFiles(const QStringList files);
|
||||
void importFiles(const QStringList importFiles);
|
||||
void importTxtFiles(const QStringList fileNames);
|
||||
|
|
|
@ -916,7 +916,7 @@ void ProfileWidget2::setProfileState()
|
|||
/* show the same stuff that the profile shows. */
|
||||
|
||||
//TODO: Move the DC handling to another method.
|
||||
MainWindow::instance()->enableDcShortcuts();
|
||||
MainWindow::instance()->enableShortcuts();
|
||||
|
||||
currentState = PROFILE;
|
||||
MainWindow::instance()->setEnabledToolbar(true);
|
||||
|
@ -1061,7 +1061,7 @@ void ProfileWidget2::setAddState()
|
|||
mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y()));
|
||||
disconnectTemporaryConnections();
|
||||
//TODO: Move this method to another place, shouldn't be on mainwindow.
|
||||
MainWindow::instance()->disableDcShortcuts();
|
||||
MainWindow::instance()->disableShortcuts(false);
|
||||
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
|
||||
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
|
||||
actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up);
|
||||
|
@ -1094,7 +1094,7 @@ void ProfileWidget2::setPlanState()
|
|||
mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y()));
|
||||
disconnectTemporaryConnections();
|
||||
//TODO: Move this method to another place, shouldn't be on mainwindow.
|
||||
MainWindow::instance()->disableDcShortcuts();
|
||||
MainWindow::instance()->disableShortcuts();
|
||||
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
|
||||
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
|
||||
actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up);
|
||||
|
|
Loading…
Reference in a new issue