summaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-07-06 16:35:13 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-06 08:36:42 -0700
commitdff4e5f33eee0ba112ddd2265410a5e858d6c98f (patch)
tree87c3e50d860999dc6372bb2a1b25f84f962bbbea /qt-ui/downloadfromdivecomputer.cpp
parentb4c4d95ea4d19d63492a5de4abdab31673ab9725 (diff)
downloadsubsurface-dff4e5f33eee0ba112ddd2265410a5e858d6c98f.tar.gz
Add a dialog for remote Bluetooth devices selection
Implement a dialog which can be used for remote Bluetooth devices selection and to control the local Bluetooth device. Functionalities of the widget: - expose information about the local BT device - scan for remote BT devices - pair/unpair with a remote BT device - turn on/off the local BT device - logging - save the selected BT device The selection dialog is created when the bluetoothMode checkbox is enabled. Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index f1bb05823..276e4047c 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -99,6 +99,8 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
ui.ok->setEnabled(false);
ui.downloadCancelRetryButton->setEnabled(true);
ui.downloadCancelRetryButton->setText(tr("Download"));
+
+ btDeviceSelectionDialog = 0;
ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice()));
@@ -311,7 +313,11 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
data.vendor = strdup(ui.vendor->currentText().toUtf8().data());
data.product = strdup(ui.product->currentText().toUtf8().data());
- if (same_string(data.vendor, "Uemis")) {
+ data.bluetooth_mode = ui.bluetoothMode->isChecked();
+ if (data.bluetooth_mode) {
+ // Get the selected device address
+ data.devname = strdup(btDeviceSelectionDialog->getSelectedDeviceAddress().toUtf8().data());
+ } else if (same_string(data.vendor, "Uemis")) {
char *colon;
char *devname = strdup(ui.device->currentText().toUtf8().data());
@@ -523,7 +529,24 @@ void DownloadFromDCWidget::markChildrenAsEnabled()
void DownloadFromDCWidget::selectRemoteBluetoothDevice()
{
- //TODO add implementation
+ if (!btDeviceSelectionDialog) {
+ btDeviceSelectionDialog = new BtDeviceSelectionDialog(this);
+ connect(btDeviceSelectionDialog, SIGNAL(finished(int)),
+ this, SLOT(bluetoothSelectionDialogIsFinished(int)));
+ }
+
+ btDeviceSelectionDialog->show();
+}
+
+void DownloadFromDCWidget::bluetoothSelectionDialogIsFinished(int result)
+{
+ if (result == QDialog::Accepted) {
+ /* Make the selected Bluetooth device default */
+ ui.device->setCurrentText(btDeviceSelectionDialog->getSelectedDeviceName());
+ } else if (result == QDialog::Rejected){
+ /* Disable Bluetooth download mode */
+ ui.bluetoothMode->setChecked(false);
+ }
}
void DownloadFromDCWidget::enableBluetoothMode(int state)