[PATCH 1/4] Profile2: provide means to disable the tool buttons
Lubomir I. Ivanov
neolit123 at gmail.com
Tue Mar 11 09:30:58 PDT 2014
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
Once the poster is displayed when there are no dives in the list,
we may also want to disable the QToolButtons (PO2, SAC, etc..),
until a new dive is loaded and the profile is redrawn.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
not particulary fond of the solution as it adds a public
method in MainWindow and yet these buttons are profile related only,
but technically part of mainwindow.ui.
perhaps it would be best to put the buttons in some sort of a
container and manipulate them from there - e.g. ProfileToolBar or
in Profile2, this however means more source files.
---
qt-ui/mainwindow.cpp | 17 +++++++++++++++++
qt-ui/mainwindow.h | 1 +
qt-ui/profile/profilewidget2.cpp | 2 ++
3 files changed, 20 insertions(+)
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 20f463c..b43f8a8 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -166,6 +166,23 @@ void MainWindow::cleanUpEmpty()
setTitle(MWTF_DEFAULT);
}
+void MainWindow::setToolButtonsEnabled(bool enabled)
+{
+ ui.profPO2->setEnabled(enabled);
+ ui.profPn2->setEnabled(enabled);
+ ui.profPhe->setEnabled(enabled);
+ ui.profDcCeiling->setEnabled(enabled);
+ ui.profCalcCeiling->setEnabled(enabled);
+ ui.profCalcAllTissues->setEnabled(enabled);
+ ui.profIncrement3m->setEnabled(enabled);
+ ui.profMod->setEnabled(enabled);
+ ui.profEad->setEnabled(enabled);
+ ui.profNdl_tts->setEnabled(enabled);
+ ui.profSAC->setEnabled(enabled);
+ ui.profRuler->setEnabled(enabled);
+ ui.profScaled->setEnabled(enabled);
+}
+
void MainWindow::on_actionClose_triggered()
{
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 40f22dd..70b9793 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -76,6 +76,7 @@ public:
void loadFiles(const QStringList files);
void importFiles(const QStringList importFiles);
void cleanUpEmpty();
+ void setToolButtonsEnabled(bool enabled);
ProfileWidget2 *graphics() const;
private
slots:
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 822f1bc..d03d0dc 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -544,6 +544,7 @@ void ProfileWidget2::setEmptyState()
dataModel->clear();
currentState = EMPTY;
+ MainWindow::instance()->setToolButtonsEnabled(false);
backgroundFile = QString(":poster");
fixBackgroundPos();
@@ -577,6 +578,7 @@ void ProfileWidget2::setProfileState()
return;
currentState = PROFILE;
+ MainWindow::instance()->setToolButtonsEnabled(true);
toolTipItem->readPos();
setBackgroundBrush(getColor(::BACKGROUND));
--
1.7.11.msysgit.0
More information about the subsurface
mailing list