summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Henrik Brautaset Aronsen <subsurface@henrik.synth.no>2013-12-03 21:44:48 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-03 13:01:16 -0800
commitb1febf17b1bfd8f0582b4cb9922ba13ae989cb33 (patch)
treeb5fa546e1774fd7dac79386f7f1bdd9587d24a77
parent9b51901f3566b568d6e80d1b5eca985d42e55fcf (diff)
downloadsubsurface-b1febf17b1bfd8f0582b4cb9922ba13ae989cb33.tar.gz
Make sure the save/cancel message is always shown
An addition to the "Move dive notes edit message above the scrollable widget" commit: Make sure the save/cancel message is always displayed on top, regardless of which tab is selected. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/maintab.cpp67
-rw-r--r--qt-ui/maintab.h4
-rw-r--r--qt-ui/maintab.ui12
3 files changed, 58 insertions, 25 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 3950f17f0..dad1e8ec6 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -32,20 +32,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.setupUi(this);
ui.cylinders->setModel(cylindersModel);
ui.weights->setModel(weightModel);
- ui.diveNotesMessage->hide();
- ui.diveEquipmentMessage->hide();
- ui.diveNotesMessage->setCloseButtonVisible(false);
- ui.diveEquipmentMessage->setCloseButtonVisible(false);
+ closeMessage();
QAction *action = new QAction(tr("Save"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
- ui.diveEquipmentMessage->addAction(action);
- ui.diveNotesMessage->addAction(action);
+ addMessageAction(action);
action = new QAction(tr("Cancel"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
- ui.diveEquipmentMessage->addAction(action);
- ui.diveNotesMessage->addAction(action);
+ addMessageAction(action);
if (qApp->style()->objectName() == "oxygen")
setDocumentMode(true);
@@ -164,6 +159,43 @@ void MainTab::addDiveStarted()
editMode = ADD;
}
+void MainTab::addMessageAction(QAction* action)
+{
+ ui.diveEquipmentMessage->addAction(action);
+ ui.diveNotesMessage->addAction(action);
+ ui.diveInfoMessage->addAction(action);
+ ui.diveStatisticsMessage->addAction(action);
+}
+
+void MainTab::hideMessage()
+{
+ ui.diveNotesMessage->animatedHide();
+ ui.diveEquipmentMessage->animatedHide();
+ ui.diveInfoMessage->animatedHide();
+ ui.diveStatisticsMessage->animatedHide();
+}
+
+void MainTab::closeMessage()
+{
+ hideMessage();
+ ui.diveNotesMessage->setCloseButtonVisible(false);
+ ui.diveEquipmentMessage->setCloseButtonVisible(false);
+ ui.diveInfoMessage->setCloseButtonVisible(false);
+ ui.diveStatisticsMessage->setCloseButtonVisible(false);
+}
+
+void MainTab::displayMessage(QString str)
+{
+ ui.diveNotesMessage->setText(str);
+ ui.diveNotesMessage->animatedShow();
+ ui.diveEquipmentMessage->setText(str);
+ ui.diveEquipmentMessage->animatedShow();
+ ui.diveInfoMessage->setText(str);
+ ui.diveInfoMessage->animatedShow();
+ ui.diveStatisticsMessage->setText(str);
+ ui.diveStatisticsMessage->animatedShow();
+}
+
void MainTab::enableEdition(EditMode newEditMode)
{
if (selected_dive < 0 || editMode != NONE)
@@ -175,23 +207,16 @@ void MainTab::enableEdition(EditMode newEditMode)
notesBackup.clear();
if (mainWindow() && mainWindow()->dive_list()->selectedTrips().count() == 1) {
// we are editing trip location and notes
- ui.diveNotesMessage->setText(tr("This trip is being edited."));
- ui.diveNotesMessage->animatedShow();
- ui.diveEquipmentMessage->setText(tr("This trip is being edited."));
- ui.diveEquipmentMessage->animatedShow();
+ displayMessage(tr("This trip is being edited."));
notesBackup[NULL].notes = ui.notes->toPlainText();
notesBackup[NULL].location = ui.location->text();
editMode = TRIP;
} else {
if (amount_selected > 1) {
- ui.diveNotesMessage->setText(tr("Multiple dives are being edited."));
- ui.diveEquipmentMessage->setText(tr("Multiple dives are being edited."));
+ displayMessage(tr("Multiple dives are being edited."));
} else {
- ui.diveNotesMessage->setText(tr("This dive is being edited."));
- ui.diveEquipmentMessage->setText(tr("This dive is being edited."));
+ displayMessage(tr("This dive is being edited."));
}
- ui.diveNotesMessage->animatedShow();
- ui.diveEquipmentMessage->animatedShow();
// We may be editing one or more dives here. backup everything.
struct dive *mydive;
@@ -513,8 +538,7 @@ void MainTab::acceptChanges()
mainWindow()->dive_list()->setEnabled(true);
tabBar()->setTabIcon(0, QIcon()); // Notes
tabBar()->setTabIcon(1, QIcon()); // Equipment
- ui.diveNotesMessage->animatedHide();
- ui.diveEquipmentMessage->animatedHide();
+ hideMessage();
/* now figure out if things have changed */
if (mainWindow() && mainWindow()->dive_list()->selectedTrips().count() == 1) {
if (notesBackup[NULL].notes != ui.notes->toPlainText() ||
@@ -712,8 +736,7 @@ void MainTab::rejectChanges()
}
}
- ui.diveNotesMessage->animatedHide();
- ui.diveEquipmentMessage->animatedHide();
+ hideMessage();
mainWindow()->dive_list()->setEnabled(true);
notesBackup.clear();
resetPallete();
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 5750fb378..aed8f9e70 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -82,6 +82,10 @@ public slots:
void editCylinderWidget(const QModelIndex& index);
void editWeightWidget(const QModelIndex& index);
void addDiveStarted();
+ void addMessageAction(QAction* action);
+ void hideMessage();
+ void closeMessage();
+ void displayMessage(QString str);
void enableEdition(EditMode newEditMode = NONE);
void toggleTriggeredColumn();
private:
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 5848f0efe..7dec3aa8f 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -263,6 +263,9 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
+ <widget class="KMessageWidget" name="diveEquipmentMessage" native="true"/>
+ </item>
+ <item row="1" column="0">
<widget class="QScrollArea" name="scrollArea_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@@ -298,9 +301,6 @@
<property name="spacing">
<number>2</number>
</property>
- <item row="0" column="0">
- <widget class="KMessageWidget" name="diveEquipmentMessage" native="true"/>
- </item>
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
@@ -343,6 +343,9 @@
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
+ <widget class="KMessageWidget" name="diveInfoMessage" native="true"/>
+ </item>
+ <item row="1" column="0">
<widget class="QScrollArea" name="scrollArea_3">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@@ -650,6 +653,9 @@
</attribute>
<layout class="QGridLayout" name="gridLayout1">
<item row="0" column="1">
+ <widget class="KMessageWidget" name="diveStatisticsMessage" native="true"/>
+ </item>
+ <item row="1" column="1">
<widget class="QScrollArea" name="scrollArea_4">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>