mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Save and restore Dive Planner Settings
This patch adds the code that saves and restores the dive planner settings. Fixes #608 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									a502958a66
								
							
						
					
					
						commit
						887f9e63c3
					
				
					 3 changed files with 28 additions and 3 deletions
				
			
		|  | @ -364,6 +364,18 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) | ||||||
| { | { | ||||||
| 	ui.setupUi(this); | 	ui.setupUi(this); | ||||||
| 
 | 
 | ||||||
|  | 	QSettings s; | ||||||
|  | 	s.beginGroup("Planner"); | ||||||
|  | 	prefs.ascrate75 = s.value("ascrate75", 9).toInt(); | ||||||
|  | 	prefs.ascrate50 = s.value("ascrate50", 6).toInt(); | ||||||
|  | 	prefs.ascratestops = s.value("ascratestops", 6).toInt(); | ||||||
|  | 	prefs.ascratelast6m = s.value("ascratelast6m", 1).toInt(); | ||||||
|  | 	prefs.descrate = s.value("descrate", 18).toInt(); | ||||||
|  | 	prefs.bottompo2 = s.value("bottompo2", 1400).toInt(); | ||||||
|  | 	prefs.decopo2 = s.value("decopo2",1600).toInt(); | ||||||
|  | 	prefs.doo2breaks = s.value("doo2breaks", false).toBool(); | ||||||
|  | 	s.endGroup(); | ||||||
|  | 
 | ||||||
| 	ui.ascRate75->setValue(prefs.ascrate75 / UNIT_FACTOR); | 	ui.ascRate75->setValue(prefs.ascrate75 / UNIT_FACTOR); | ||||||
| 	ui.ascRate50->setValue(prefs.ascrate50 / UNIT_FACTOR); | 	ui.ascRate50->setValue(prefs.ascrate50 / UNIT_FACTOR); | ||||||
| 	ui.ascRateStops->setValue(prefs.ascratestops / UNIT_FACTOR); | 	ui.ascRateStops->setValue(prefs.ascratestops / UNIT_FACTOR); | ||||||
|  | @ -373,7 +385,6 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) | ||||||
| 	ui.decopo2->setValue(prefs.decopo2 / 1000.0); | 	ui.decopo2->setValue(prefs.decopo2 / 1000.0); | ||||||
| 	ui.backgasBreaks->setChecked(prefs.doo2breaks); | 	ui.backgasBreaks->setChecked(prefs.doo2breaks); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); | 	connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); | ||||||
| 	connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); | 	connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); | ||||||
| 	connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool))); | 	connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool))); | ||||||
|  | @ -407,6 +418,21 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) | ||||||
| 	setMinimumHeight(0); | 	setMinimumHeight(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | PlannerSettingsWidget::~PlannerSettingsWidget() | ||||||
|  | { | ||||||
|  | 	QSettings s; | ||||||
|  | 	s.beginGroup("Planner"); | ||||||
|  | 	s.setValue("ascrate75", prefs.ascrate75); | ||||||
|  | 	s.setValue("ascrate50", prefs.ascrate50); | ||||||
|  | 	s.setValue("ascratestops", prefs.ascratestops); | ||||||
|  | 	s.setValue("ascratelast6m", prefs.ascratelast6m); | ||||||
|  | 	s.setValue("descrate", prefs.descrate); | ||||||
|  | 	s.setValue("bottompo2", prefs.bottompo2); | ||||||
|  | 	s.setValue("decopo2", prefs.decopo2); | ||||||
|  | 	s.setValue("doo2breaks", prefs.doo2breaks); | ||||||
|  | 	s.endGroup(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void PlannerSettingsWidget::settingsChanged() | void PlannerSettingsWidget::settingsChanged() | ||||||
| { | { | ||||||
| 	if (get_units()->length == units::FEET) { | 	if (get_units()->length == units::FEET) { | ||||||
|  |  | ||||||
|  | @ -150,7 +150,7 @@ class PlannerSettingsWidget : public QWidget { | ||||||
| 	Q_OBJECT | 	Q_OBJECT | ||||||
| public: | public: | ||||||
| 	explicit PlannerSettingsWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); | 	explicit PlannerSettingsWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); | ||||||
| 
 | 	virtual ~PlannerSettingsWidget(); | ||||||
| public | public | ||||||
| slots: | slots: | ||||||
| 	void settingsChanged(); | 	void settingsChanged(); | ||||||
|  |  | ||||||
|  | @ -797,7 +797,6 @@ void MainWindow::readSettings() | ||||||
| 	default_dive_computer_product = getSetting(s, "dive_computer_product"); | 	default_dive_computer_product = getSetting(s, "dive_computer_product"); | ||||||
| 	default_dive_computer_device = getSetting(s, "dive_computer_device"); | 	default_dive_computer_device = getSetting(s, "dive_computer_device"); | ||||||
| 	s.endGroup(); | 	s.endGroup(); | ||||||
| 
 |  | ||||||
| 	QNetworkProxy proxy; | 	QNetworkProxy proxy; | ||||||
| 	proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type)); | 	proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type)); | ||||||
| 	proxy.setHostName(prefs.proxy_host); | 	proxy.setHostName(prefs.proxy_host); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue