summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-02-27 12:31:00 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-27 10:48:35 -0800
commit8c56b2f45e546048941ba004bce5e5bfd0e6e660 (patch)
treedda271fc80ce1d57df9dd31ea7c0644ae8bd62fc
parent0307f3d5432dfc98cc4be317b0f2ce93e27c336b (diff)
downloadsubsurface-8c56b2f45e546048941ba004bce5e5bfd0e6e660.tar.gz
Store zoomed plot in preferences
This patch makes the 'Zoomed Plot' a preference that can be stored and retrieved, this way if the user sets the plot to be 'zoomed', this information will persist even if they closed or opened subsurface again. Also, added the 'Scale' button on the new profile, but didn't did the glue code yet. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--display.h2
-rw-r--r--pref.h1
-rw-r--r--profile.c5
-rw-r--r--qt-ui/mainwindow.cpp12
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/mainwindow.ui31
-rw-r--r--qt-ui/preferences.cpp1
-rw-r--r--qt-ui/profilegraphics.cpp3
8 files changed, 41 insertions, 16 deletions
diff --git a/display.h b/display.h
index 30fd2067a..64d481eeb 100644
--- a/display.h
+++ b/display.h
@@ -52,7 +52,7 @@ struct options {
int profile_height, notes_height, tanks_height;
};
-extern char zoomed_plot, dc_number;
+extern char dc_number;
extern unsigned int amount_selected;
diff --git a/pref.h b/pref.h
index 415743562..83e88cdcd 100644
--- a/pref.h
+++ b/pref.h
@@ -38,6 +38,7 @@ struct preferences {
struct units units;
short show_sac;
bool display_unused_tanks;
+ bool zoomed_plot;
};
enum unit_system_values { METRIC, IMPERIAL, PERSONALIZE };
diff --git a/profile.c b/profile.c
index 5ab59ce6c..84ba30f97 100644
--- a/profile.c
+++ b/profile.c
@@ -16,7 +16,6 @@
#include "membuffer.h"
int selected_dive = -1; /* careful: 0 is a valid value */
-char zoomed_plot = 0;
char dc_number = 0;
@@ -61,7 +60,7 @@ static void dump_pi (struct plot_info *pi)
int get_maxtime(struct plot_info *pi)
{
int seconds = pi->maxtime;
- if (zoomed_plot) {
+ if (prefs.zoomed_plot) {
/* Rounded up to one minute, with at least 2.5 minutes to
* spare.
* For dive times shorter than 10 minutes, we use seconds/4 to
@@ -86,7 +85,7 @@ int get_maxdepth(struct plot_info *pi)
unsigned mm = pi->maxdepth;
int md;
- if (zoomed_plot) {
+ if (prefs.zoomed_plot) {
/* Rounded up to 10m, with at least 3m to spare */
md = ROUND_UP(mm+3000, 10000);
} else {
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 70415f077..59ebf2f25 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -364,12 +364,6 @@ void MainWindow::on_actionAutoGroup_triggered()
mark_divelist_changed(true);
}
-void MainWindow::on_actionToggleZoom_triggered()
-{
- zoomed_plot = !zoomed_plot;
- ui.ProfileWidget->refresh();
-}
-
void MainWindow::on_actionYearlyStatistics_triggered()
{
QTreeView *view = new QTreeView();
@@ -1066,4 +1060,10 @@ void MainWindow::on_profSAC_clicked(bool triggered)
TOOLBOX_PREF_PROFILE(show_sac);
}
+void MainWindow::on_profScaled_clicked(bool triggered)
+{
+ prefs.zoomed_plot = triggered;
+ TOOLBOX_PREF_PROFILE(zoomed_plot);
+}
+
#undef TOOLBOX_PREF_PROFILE
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 24d3d701f..a9c2d4701 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -81,7 +81,6 @@ private slots:
void on_actionAddDive_triggered();
void on_actionRenumber_triggered();
void on_actionAutoGroup_triggered();
- void on_actionToggleZoom_triggered();
void on_actionYearlyStatistics_triggered();
/* view menu actions */
@@ -123,6 +122,7 @@ private slots:
void on_profPn2_clicked(bool triggered);
void on_profRuler_clicked(bool triggered);
void on_profSAC_clicked(bool triggered);
+ void on_profScaled_clicked(bool triggered);
protected:
void closeEvent(QCloseEvent *);
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index 6e1489eca..e6adb5ba2 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>763</width>
- <height>667</height>
+ <width>1418</width>
+ <height>1084</height>
</rect>
</property>
<widget class="QWidget" name="centralwidget">
@@ -454,7 +454,7 @@
<string>...</string>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../subsurface.qrc">
<normaloff>:/flag</normaloff>:/flag</iconset>
</property>
<property name="iconSize">
@@ -472,6 +472,29 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="profScaled">
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../subsurface.qrc">
+ <normaloff>:/scale</normaloff>:/scale</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -564,7 +587,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>763</width>
+ <width>1418</width>
<height>25</height>
</rect>
</property>
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index c1c03e829..4d3816feb 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -264,6 +264,7 @@ void PreferencesDialog::loadSettings()
GET_INT("gflow", gflow);
GET_INT("gfhigh", gfhigh);
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
+ GET_BOOL("zoomed_plot", zoomed_plot);
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
GET_BOOL("show_sac", show_sac);
GET_BOOL("display_unused_tanks", display_unused_tanks);
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index c63f7159d..2ec903950 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1453,9 +1453,10 @@ void ProfileGraphicsView::on_rulerAction()
void ProfileGraphicsView::on_scaleAction()
{
- zoomed_plot = !zoomed_plot;
+ prefs.zoomed_plot = !prefs.zoomed_plot;
refresh();
}
+
QColor EventItem::getColor(const color_indice_t i)
{
return profile_color[i].at((isGrayscale) ? 1 : 0);