diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/configuredivecomputerdialog.cpp | 34 | ||||
-rw-r--r-- | qt-ui/configuredivecomputerdialog.h | 8 | ||||
-rw-r--r-- | qt-ui/configuredivecomputerdialog.ui | 5 |
3 files changed, 43 insertions, 4 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 537b23121..acebcfa33 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -115,7 +115,8 @@ void GasTypeComboBoxItemDelegate::setModelData(QWidget *editor, QAbstractItemMod ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), config(0), - deviceDetails(0) + deviceDetails(0), + btDeviceSelectionDialog(0) { ui.setupUi(this); @@ -133,6 +134,11 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(dc_open())); connect(ui.disconnectButton, SIGNAL(clicked()), this, SLOT(dc_close())); +#if BT_SUPPORT + connect(ui.bluetoothMode, SIGNAL(clicked(bool)), this, SLOT(selectRemoteBluetoothDevice())); +#else + ui.bluetoothMode->setVisible(false); +#endif memset(&device_data, 0, sizeof(device_data)); fill_computer_list(); @@ -1173,6 +1179,30 @@ void ConfigureDiveComputerDialog::pickLogFile() } } +#ifdef BT_SUPPORT +void ConfigureDiveComputerDialog::selectRemoteBluetoothDevice() +{ + if (!btDeviceSelectionDialog) { + btDeviceSelectionDialog = new BtDeviceSelectionDialog(this); + connect(btDeviceSelectionDialog, SIGNAL(finished(int)), + this, SLOT(bluetoothSelectionDialogIsFinished(int))); + } + + btDeviceSelectionDialog->show(); +} + +void ConfigureDiveComputerDialog::bluetoothSelectionDialogIsFinished(int result) +{ + if (result == QDialog::Accepted) { + ui.device->setCurrentText(btDeviceSelectionDialog->getSelectedDeviceAddress()); + device_data.bluetooth_mode = true; + + ui.progressBar->setFormat("Connecting to device..."); + dc_open(); + } +} +#endif + void ConfigureDiveComputerDialog::dc_open() { getDeviceData(); @@ -1188,6 +1218,7 @@ void ConfigureDiveComputerDialog::dc_open() ui.disconnectButton->setEnabled(true); ui.restoreBackupButton->setEnabled(true); ui.connectButton->setEnabled(false); + ui.bluetoothMode->setEnabled(false); ui.DiveComputerList->setEnabled(false); ui.logToFile->setEnabled(false); if (fw_upgrade_possible) @@ -1204,6 +1235,7 @@ void ConfigureDiveComputerDialog::dc_close() ui.updateFirmwareButton->setEnabled(false); ui.disconnectButton->setEnabled(false); ui.connectButton->setEnabled(true); + ui.bluetoothMode->setEnabled(true); ui.backupButton->setEnabled(false); ui.saveSettingsPushButton->setEnabled(false); ui.restoreBackupButton->setEnabled(false); diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index d11726873..7092e9708 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -8,6 +8,7 @@ #include "configuredivecomputer.h" #include <QStyledItemDelegate> #include <QNetworkAccessManager> +#include "btdeviceselectiondialog.h" class GasSpinBoxItemDelegate : public QStyledItemDelegate { Q_OBJECT @@ -84,6 +85,11 @@ slots: void dc_open(); void dc_close(); +#if BT_SUPPORT + void bluetoothSelectionDialogIsFinished(int result); + void selectRemoteBluetoothDevice(); +#endif + private: Ui::ConfigureDiveComputerDialog ui; @@ -112,6 +118,8 @@ private: QString selected_vendor; QString selected_product; bool fw_upgrade_possible; + + BtDeviceSelectionDialog *btDeviceSelectionDialog; }; class OstcFirmwareCheck : QObject { diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index edc24e29e..bdfe8473c 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -42,9 +42,9 @@ </widget> </item> <item> - <widget class="QToolButton" name="search"> + <widget class="QPushButton" name="bluetoothMode"> <property name="text"> - <string>...</string> + <string>Connect via bluetooth</string> </property> </widget> </item> @@ -2602,7 +2602,6 @@ </widget> <tabstops> <tabstop>device</tabstop> - <tabstop>search</tabstop> <tabstop>retrieveDetails</tabstop> <tabstop>saveSettingsPushButton</tabstop> <tabstop>backupButton</tabstop> |