void DownloadFromDCWidget::checkLogFile(int state) { ui.chooseLogFile->setEnabled(state == Qt::Checked); data.libdc_log = (state == Qt::Checked); if (state == Qt::Checked && logFile.isEmpty()) { pickLogFile(); } }
void DownloadFromDCWidget::checkLogFile(int state) { ui.chooseLogFile->setEnabled(state == Qt::Checked); // TODO: Verify the Thread. if (state == Qt::Checked) { pickLogFile(); } }
DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f), thread(0), downloading(false), previousLast(0), vendorModel(0), productModel(0), timer(new QTimer(this)), dumpWarningShown(false), currentState(INITIAL) { ui.setupUi(this); ui.progressBar->hide(); ui.progressBar->setMinimum(0); ui.progressBar->setMaximum(100); progress_bar_text = ""; fill_device_list(); fill_computer_list(); ui.chooseDumpFile->setEnabled(ui.dumpToFile->isChecked()); connect(ui.chooseDumpFile, SIGNAL(clicked()), this, SLOT(pickDumpFile())); connect(ui.dumpToFile, SIGNAL(stateChanged(int)), this, SLOT(checkDumpFile(int))); ui.chooseLogFile->setEnabled(ui.logToFile->isChecked()); connect(ui.chooseLogFile, SIGNAL(clicked()), this, SLOT(pickLogFile())); connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); vendorModel = new QStringListModel(vendorList); ui.vendor->setModel(vendorModel); if (default_dive_computer_vendor) { ui.vendor->setCurrentIndex(ui.vendor->findText(default_dive_computer_vendor)); productModel = new QStringListModel(productList[default_dive_computer_vendor]); ui.product->setModel(productModel); if (default_dive_computer_product) ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product)); } connect(ui.product, SIGNAL(currentIndexChanged(int)), this, SLOT(on_product_currentIndexChanged()), Qt::UniqueConnection); if (default_dive_computer_device) ui.device->setEditText(default_dive_computer_device); timer->setInterval(200); connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); updateState(INITIAL); memset(&data, 0, sizeof(data)); }
DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), thread(0), downloading(false), previousLast(0), vendorModel(0), productModel(0), timer(new QTimer(this)), dumpWarningShown(false), ostcFirmwareCheck(0), currentState(INITIAL) { clear_table(&downloadTable); ui.setupUi(this); ui.progressBar->hide(); ui.progressBar->setMinimum(0); ui.progressBar->setMaximum(100); diveImportedModel = new DiveImportedModel(this); ui.downloadedView->setModel(diveImportedModel); ui.downloadedView->setSelectionBehavior(QAbstractItemView::SelectRows); ui.downloadedView->setSelectionMode(QAbstractItemView::SingleSelection); int startingWidth = defaultModelFont().pointSize(); ui.downloadedView->setColumnWidth(0, startingWidth * 20); ui.downloadedView->setColumnWidth(1, startingWidth * 10); ui.downloadedView->setColumnWidth(2, startingWidth * 10); connect(ui.downloadedView, SIGNAL(clicked(QModelIndex)), diveImportedModel, SLOT(changeSelected(QModelIndex))); progress_bar_text = ""; fill_computer_list(); ui.chooseDumpFile->setEnabled(ui.dumpToFile->isChecked()); connect(ui.chooseDumpFile, SIGNAL(clicked()), this, SLOT(pickDumpFile())); connect(ui.dumpToFile, SIGNAL(stateChanged(int)), this, SLOT(checkDumpFile(int))); ui.chooseLogFile->setEnabled(ui.logToFile->isChecked()); connect(ui.chooseLogFile, SIGNAL(clicked()), this, SLOT(pickLogFile())); connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); ui.selectAllButton->setEnabled(false); ui.unselectAllButton->setEnabled(false); connect(ui.selectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectAll())); connect(ui.unselectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectNone())); vendorModel = new QStringListModel(vendorList); ui.vendor->setModel(vendorModel); auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; if (!dc->dc_vendor().isEmpty()) { ui.vendor->setCurrentIndex(ui.vendor->findText(dc->dc_vendor())); productModel = new QStringListModel(productList[dc->dc_vendor()]); ui.product->setModel(productModel); if (!dc->dc_product().isEmpty()) ui.product->setCurrentIndex(ui.product->findText(dc->dc_product())); } if (!dc->dc_device().isEmpty()) ui.device->setEditText(dc->dc_device()); timer->setInterval(200); connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); updateState(INITIAL); memset(&data, 0, sizeof(data)); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(close, SIGNAL(activated()), this, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quit, SIGNAL(activated()), parent, SLOT(close())); ui.ok->setEnabled(false); ui.downloadCancelRetryButton->setEnabled(true); ui.downloadCancelRetryButton->setText(tr("Download")); #if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_SERIAL) ui.bluetoothMode->setText(tr("Choose Bluetooth download mode")); ui.bluetoothMode->setChecked(dc->downloadMode() == DC_TRANSPORT_BLUETOOTH); 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())); #else ui.bluetoothMode->hide(); ui.chooseBluetoothDevice->hide(); #endif }
DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), downloading(false), previousLast(0), timer(new QTimer(this)), dumpWarningShown(false), ostcFirmwareCheck(0), currentState(INITIAL) { diveImportedModel = new DiveImportedModel(this); diveImportedModel->setDiveTable(&downloadTable); vendorModel.setStringList(vendorList); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); int startingWidth = defaultModelFont().pointSize(); clear_table(&downloadTable); ui.setupUi(this); ui.progressBar->hide(); ui.progressBar->setMinimum(0); ui.progressBar->setMaximum(100); ui.downloadedView->setModel(diveImportedModel); ui.downloadedView->setSelectionBehavior(QAbstractItemView::SelectRows); ui.downloadedView->setSelectionMode(QAbstractItemView::SingleSelection); ui.downloadedView->setColumnWidth(0, startingWidth * 20); ui.downloadedView->setColumnWidth(1, startingWidth * 10); ui.downloadedView->setColumnWidth(2, startingWidth * 10); ui.chooseDumpFile->setEnabled(ui.dumpToFile->isChecked()); ui.chooseLogFile->setEnabled(ui.logToFile->isChecked()); ui.selectAllButton->setEnabled(false); ui.unselectAllButton->setEnabled(false); ui.vendor->setModel(&vendorModel); ui.product->setModel(&productModel); progress_bar_text = ""; timer->setInterval(200); connect(ui.downloadedView, SIGNAL(clicked(QModelIndex)), diveImportedModel, SLOT(changeSelected(QModelIndex))); connect(ui.chooseDumpFile, SIGNAL(clicked()), this, SLOT(pickDumpFile())); connect(ui.dumpToFile, SIGNAL(stateChanged(int)), this, SLOT(checkDumpFile(int))); connect(ui.chooseLogFile, SIGNAL(clicked()), this, SLOT(pickLogFile())); connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); connect(ui.selectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectAll())); connect(ui.unselectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectNone())); connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); connect(close, SIGNAL(activated()), this, SLOT(close())); connect(quit, SIGNAL(activated()), parent, SLOT(close())); connect(&thread, SIGNAL(finished()), this, SLOT(onDownloadThreadFinished()), Qt::QueuedConnection); //TODO: Don't call mainwindow. MainWindow *w = MainWindow::instance(); connect(&thread, SIGNAL(finished()), w, SLOT(refreshDisplay())); if (!qPrefDiveComputer::vendor().isEmpty()) { ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor())); productModel.setStringList(productList[qPrefDiveComputer::vendor()]); if (!qPrefDiveComputer::product().isEmpty()) ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product())); } updateState(INITIAL); ui.ok->setEnabled(false); ui.downloadCancelRetryButton->setEnabled(true); ui.downloadCancelRetryButton->setText(tr("Download")); QString deviceText = qPrefDiveComputer::device(); #if defined(BT_SUPPORT) ui.bluetoothMode->setText(tr("Choose Bluetooth download mode")); ui.bluetoothMode->setChecked(qPrefDiveComputer::download_mode() == DC_TRANSPORT_BLUETOOTH); btDeviceSelectionDialog = 0; connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int))); connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice())); ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked()); if (ui.bluetoothMode->isChecked()) deviceText = BtDeviceSelectionDialog::formatDeviceText(qPrefDiveComputer::device(), qPrefDiveComputer::device_name()); #else ui.bluetoothMode->hide(); ui.chooseBluetoothDevice->hide(); #endif if (!deviceText.isEmpty()) ui.device->setEditText(deviceText); }