summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-02-11 13:58:23 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-11 16:34:02 -0800
commit68691c9d6d05ba28c8e0e8c837dcd32bb2eec42c (patch)
tree309705eb75fa69d3730b372ecbee4b4bb7bfae38 /qt-ui
parent7d66dcd12d42db7c9e3f18be21615204588a66e3 (diff)
downloadsubsurface-68691c9d6d05ba28c8e0e8c837dcd32bb2eec42c.tar.gz
Accept / Cancel location edit
Make it possible to cancel or accept the location edit and get back to the mainwindow default state. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp3
-rw-r--r--qt-ui/mainwindow.cpp5
-rw-r--r--qt-ui/mainwindow.h1
-rw-r--r--qt-ui/simplewidgets.cpp30
-rw-r--r--qt-ui/simplewidgets.h9
5 files changed, 45 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 385b0e2e2..2f39c17db 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -57,12 +57,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
action = new QAction(tr("Discard changes"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
+ addMessageAction(action);
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected()));
- addMessageAction(action);
-
if (qApp->style()->objectName() == "oxygen")
setDocumentMode(true);
else
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index c3226c0d0..51b0353be 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -112,6 +112,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
connect(mainTab, SIGNAL(requestDiveSiteEdit()), this, SLOT(enableDiveSiteEdit()));
+ connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
#ifdef NO_PRINTING
ui.printPlan->hide();
ui.menuFile->removeAction(ui.actionPrint);
@@ -217,6 +218,10 @@ void MainWindow::enableDiveSiteEdit() {
setApplicationState("EditDiveSite");
}
+void MainWindow::setDefaultState() {
+ setApplicationState("Default");
+}
+
void MainWindow::setLoadedWithFiles(bool f)
{
filesAsArguments = f;
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 69ee44217..300748371 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -160,6 +160,7 @@ slots:
void on_actionFilterTags_triggered();
void on_actionConfigure_Dive_Computer_triggered();
void enableDiveSiteEdit();
+ void setDefaultState();
protected:
void closeEvent(QCloseEvent *);
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 98d9bcf9f..63ec4b4fa 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -6,6 +6,7 @@
#include <QShortcut>
#include <QCalendarWidget>
#include <QKeyEvent>
+#include <QAction>
#include "file.h"
#include "mainwindow.h"
@@ -646,7 +647,34 @@ void MultiFilter::closeFilter()
MultiFilterSortModel::instance()->clearFilter();
hide();
}
+#include <QDebug>
+#include <QShowEvent>
-LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent) {
+LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent)
+{
ui.setupUi(this);
+ ui.diveSiteMessage->setText("You are editing the Dive Site");
+ ui.diveSiteMessage->setCloseButtonVisible(false);
+
+ QAction *action = new QAction(tr("Apply changes"), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
+ ui.diveSiteMessage->addAction(action);
+
+ action = new QAction(tr("Discard changes"), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
+ ui.diveSiteMessage->addAction(action);
+}
+
+void LocationInformationWidget::acceptChanges()
+{
+ emit informationManagementEnded();
+}
+
+void LocationInformationWidget::rejectChanges()
+{
+ emit informationManagementEnded();
+}
+
+void LocationInformationWidget::showEvent(QShowEvent *ev) {
+ ui.diveSiteMessage->setCloseButtonVisible(false);
}
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index cfa9e0423..16ed0478c 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -221,6 +221,15 @@ class LocationInformationWidget : public QGroupBox {
Q_OBJECT
public:
LocationInformationWidget(QWidget *parent = 0);
+
+public slots:
+ void acceptChanges();
+ void rejectChanges();
+
+ void showEvent(QShowEvent *);
+signals:
+ void informationManagementEnded();
+
private:
Ui::LocationInformation ui;
};