Preferenced UI: add dive download tab

Add a preferences tab for dive download, allowing resetting the
buttons representing download connections in the Download panel.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
willemferguson 2019-12-08 15:44:14 +02:00 committed by Dirk Hohndel
parent f63f3eb4ae
commit b24caa4e2d
11 changed files with 180 additions and 30 deletions

View file

@ -15,6 +15,7 @@
#include "qPrefUnit.h"
#include "qPrefUpdateManager.h"
#include "qPrefEquipment.h"
#include "qPrefMedia.h"
#include <QtQml>
#include <QQmlContext>
@ -40,6 +41,7 @@ void qPref::loadSync(bool doSync)
qPrefUnits::loadSync(doSync);
qPrefUpdateManager::loadSync(doSync);
qPrefEquipment::loadSync(doSync);
qPrefMedia::loadSync(doSync);
}
Q_DECLARE_METATYPE(deco_mode);
@ -64,6 +66,8 @@ void qPref::registerQML(QQmlEngine *engine)
ct->setContextProperty("PrefUnits", qPrefUnits::instance());
ct->setContextProperty("PrefUpdateManager", qPrefUpdateManager::instance());
ct->setContextProperty("PrefEquipment", qPrefUpdateManager::instance());
ct->setContextProperty("PrefMedia", qPrefUpdateManager::instance());
ct->setContextProperty("PrefClearDc", qPrefUpdateManager::instance());
}
// Register special types

View file

@ -14,6 +14,7 @@ set(SUBSURFACE_PREFERENCES_UI
preferences_language.ui
preferences_media.ui
preferences_equipment.ui
preferences_dc.ui
)
qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI})
@ -23,6 +24,10 @@ source_group("Subsurface Interface Files" FILES ${SUBSURFACE_PREFERENCES_UI})
set(SUBSURFACE_PREFERENCES_LIB_SRCS
abstractpreferenceswidget.cpp
abstractpreferenceswidget.h
preferences_cloud.cpp
preferences_cloud.h
preferences_dc.cpp
preferences_dc.h
preferences_defaults.cpp
preferences_defaults.h
preferences_equipment.cpp
@ -37,8 +42,6 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS
preferences_media.h
preferences_network.cpp
preferences_network.h
preferences_cloud.cpp
preferences_cloud.h
preferences_units.cpp
preferences_units.h
preferencesdialog.cpp

View file

@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-2.0
#include "preferences_dc.h"
#include "ui_preferences_dc.h"
#include "core/dive.h"
#include "core/settings/qPrefDisplay.h"
#include "core/settings/qPrefCloudStorage.h"
#include "core/settings/qPrefDiveComputer.h"
#include <QFileDialog>
#include <QProcess>
#include <QMessageBox>
PreferencesDc::PreferencesDc(): AbstractPreferencesWidget(tr("Dive download"), QIcon(":preferences-dc-icon"), 0 ), ui(new Ui::PreferencesDc())
{
ui->setupUi(this);
const QSize BUTTON_SIZE = QSize(200, 22);
ui->resetRememberedDCs->resize(BUTTON_SIZE);
}
PreferencesDc::~PreferencesDc()
{
delete ui;
}
void PreferencesDc::on_resetRememberedDCs_clicked()
{
qPrefDiveComputer::set_vendor1(QString());
qPrefDiveComputer::set_vendor2(QString());
qPrefDiveComputer::set_vendor3(QString());
qPrefDiveComputer::set_vendor4(QString());
}
void PreferencesDc::refreshSettings()
{
}
void PreferencesDc::syncSettings()
{
}

View file

@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef PREFERENCES_DC_H
#define PREFERENCES_DC_H
#include "abstractpreferenceswidget.h"
#include "core/pref.h"
namespace Ui {
class PreferencesDc;
}
class PreferencesDc : public AbstractPreferencesWidget {
Q_OBJECT
public:
PreferencesDc();
~PreferencesDc();
void refreshSettings() override;
void syncSettings() override;
public slots:
void on_resetRememberedDCs_clicked();
private:
Ui::PreferencesDc *ui;
};
#endif

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesDc</class>
<widget class="QWidget" name="PreferencesDc">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>558</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_help2">
<property name="toolTip">
<string extracomment="Help info 1"/>
</property>
<property name="text">
<string>DIVE COMPUTER</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<layout class="QGridLayout" name="gridlayout">
<item row="0" column="0">
<widget class="QLabel" name="label_help2">
<property name="toolTip">
<string extracomment="Help info 1"/>
</property>
<property name="text">
<string>Delete connections</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_help2">
<property name="toolTip">
<string extracomment="Help info 1"/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>When importing dives from a dive computer (DC), Subsurface remembers the connection(s), showing them as selectable buttons in the Download panel. This is useful for DCs using Bluetooth for communication. In order to clear all this information, click on the button below. After clearing the information the buttons on the Download panel disappear and it is necessary to establish new connection(s) with dive computer(s) before importing dives again.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="resetRememberedDCs">
<property name="text">
<string>Delete all dive computer connections</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_help2">
<property name="text">
<string> </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
</connections>
</ui>

View file

@ -47,14 +47,6 @@ void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle)
ui->chooseFile->setEnabled(toggle);
}
void PreferencesDefaults::on_resetRememberedDCs_clicked()
{
qPrefDiveComputer::set_vendor1(QString());
qPrefDiveComputer::set_vendor2(QString());
qPrefDiveComputer::set_vendor3(QString());
qPrefDiveComputer::set_vendor4(QString());
}
void PreferencesDefaults::on_resetSettings_clicked()
{
// apparently this button was never hooked up?

View file

@ -21,7 +21,6 @@ public slots:
void on_btnUseDefaultFile_toggled(bool toggled);
void on_localDefaultFile_toggled(bool toggled);
void on_resetSettings_clicked();
void on_resetRememberedDCs_clicked();
private:
Ui::PreferencesDefaults *ui;

View file

@ -178,26 +178,10 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Clear settings</string>
<widget class="QPushButton" name="resetSettings">
<property name="text">
<string>Reset all settings to their default value</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="resetRememberedDCs">
<property name="text">
<string>Reset remembered dive computers</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetSettings">
<property name="text">
<string>Reset all settings to their default value</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>

View file

@ -11,6 +11,7 @@
#include "preferences_cloud.h"
#include "preferences_equipment.h"
#include "preferences_media.h"
#include "preferences_dc.h"
#include "core/qthelper.h"
@ -71,6 +72,7 @@ PreferencesDialog::PreferencesDialog()
addPreferencePage(new PreferencesCloud());
addPreferencePage(new PreferencesEquipment());
addPreferencePage(new PreferencesMedia());
addPreferencePage(new PreferencesDc());
refreshPages();

BIN
icons/pref_dc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -15,6 +15,7 @@
<file alias="preferences-cloud-icon">icons/pref_cloud.png</file>
<file alias="preferences-equipment-icon">icons/pref_equipment.png</file>
<file alias="preferences-media-icon">icons/pref_media.png</file>
<file alias="preferences-dc-icon">icons/pref_dc.png</file>
<file alias="scale-graph-icon">icons/graph.png</file>
<file alias="value-minimum-icon">icons/minimum.png</file>
<file alias="value-maximum-icon">icons/maximum.png</file>