summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 21:03:58 +0000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 22:15:33 +0000
commit76c44dd6a30065e8d6aa9427aaae14f10cebb4a5 (patch)
tree0c2a2d2182aa6bc7655c85e571bbfbfda0f03dc1 /qt-ui
parent984876082107f9272ad671e7ff3d5a45dec00588 (diff)
downloadsubsurface-76c44dd6a30065e8d6aa9427aaae14f10cebb4a5.tar.gz
Don't offer to add a gas change if there is ony one gas
In the context menu of the profile it makes no sense to offer the ability to switch gases unless there is a gas to switch to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 6ca3d81ad..d49c9525c 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1096,16 +1096,19 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
}
}
// create the profile context menu
- QMenu *gasChange = m.addMenu(tr("Add gas change"));
GasSelectionModel *model = GasSelectionModel::instance();
model->repopulate();
int rowCount = model->rowCount();
- for (int i = 0; i < rowCount; i++) {
- QAction *action = new QAction(&m);
- action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString() + QString(tr(" (Tank %1)")).arg(i + 1));
- connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
- action->setData(event->globalPos());
- gasChange->addAction(action);
+ if (rowCount > 1) {
+ // if we have more than one gas, offer to switch to another one
+ QMenu *gasChange = m.addMenu(tr("Add gas change"));
+ for (int i = 0; i < rowCount; i++) {
+ QAction *action = new QAction(&m);
+ action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString() + QString(tr(" (Tank %1)")).arg(i + 1));
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
+ action->setData(event->globalPos());
+ gasChange->addAction(action);
+ }
}
QAction *action = m.addAction(tr("Add bookmark"), this, SLOT(addBookmark()));
action->setData(event->globalPos());