diff --git a/companion/src/companion9x.qrc b/companion/src/companion9x.qrc index 103a05dee..2000e4e15 100644 --- a/companion/src/companion9x.qrc +++ b/companion/src/companion9x.qrc @@ -64,6 +64,7 @@ images/duplicate.png images/fuses.png images/list.png + images/maps.png images/play.png images/stop.png images/read_eeprom_file.png diff --git a/companion/src/images/maps.png b/companion/src/images/maps.png new file mode 100644 index 000000000..852742cb8 Binary files /dev/null and b/companion/src/images/maps.png differ diff --git a/companion/src/logsdialog.cpp b/companion/src/logsdialog.cpp index 0eed00b23..5ad0327dd 100644 --- a/companion/src/logsdialog.cpp +++ b/companion/src/logsdialog.cpp @@ -1,6 +1,11 @@ #include "logsdialog.h" #include "ui_logsdialog.h" #include "qcustomplot.h" +#if defined WIN32 || !defined __GNUC__ +#include +#else +#include +#endif logsDialog::logsDialog(QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), @@ -33,6 +38,11 @@ logsDialog::logsDialog(QWidget *parent) : ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setVisible(false); + QSettings settings("companion9x", "companion9x"); + QString Path=settings.value("gePath", "").toString(); + if (Path.isEmpty() || !QFile(Path).exists()) { + ui->mapsButton->hide(); + } // connect slot that ties some axis selections together (especially opposite axes): connect(ui->customPlot, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged())); @@ -165,6 +175,79 @@ void logsDialog::selectionChanged() } } +void logsDialog::on_mapsButton_clicked() { + int n = csvlog.count(); // number of points in graph + if (n==0) return; + int latcol=0, longcol=0, altcol=0, coursecol=0, speedcol=0; + int itemSelected=0.; + bool rangeSelected=false; + QSettings settings("companion9x", "companion9x"); + QString gePath=settings.value("gePath", "").toString(); + if (gePath.isEmpty() || !QFile(gePath).exists()) { + return; + } + for (int i=1; ilogTable->item(i-1,1)->isSelected()) { + rangeSelected=true; + itemSelected++; + } + } + if (itemSelected==0) { + itemSelected=n-1; + } + QString geFilename = QDir::tempPath() + "/flight.kml"; + if (QFile::exists(geFilename)) { + unlink(geFilename.toAscii()); + } + QFile geFile(geFilename); + if (!geFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + QMessageBox::warning(this, tr("Error"), + tr("Cannot write file %1:\n%2.") + .arg(geFilename) + .arg(geFile.errorString())); + return; + } + + QTextStream outputStream(&geFile); + outputStream << "\n\n"; + outputStream << "\n\tflight.kml\n\tMy Flight\n\t\t\n"; + outputStream << "\t\t\t1\n\t\t\trelativeToGround\n\t\t\t\n\t\t\t\t"; + for (int i=1; ilogTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) { + outputStream << csvlog.at(i).at(longcol) << "," << csvlog.at(i).at(latcol) << "," << csvlog.at(i).at(altcol) << " " ; + } + } + outputStream << "\n\t\t\t\n\t\t\n\t\n\n\n"; + geFile.close(); + + QStringList parameters; + parameters << geFilename; + QProcess *process = new QProcess(this); + process->startDetached(gePath, parameters); +} + + void logsDialog::mousePress() { // if an axis is selected, only allow the direction of that axis to be dragged @@ -293,8 +376,7 @@ void logsDialog::plotValue(int index, int plot, int numplots) } } } - for (int i=1; ilogTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) { double tmp; QString tstamp=csvlog.at(i).at(0)+QString(" ")+csvlog.at(i).at(1); diff --git a/companion/src/logsdialog.h b/companion/src/logsdialog.h index 54142fdab..9901228a7 100644 --- a/companion/src/logsdialog.h +++ b/companion/src/logsdialog.h @@ -34,6 +34,7 @@ private slots: // void graphClicked(QCPAbstractPlottable *plottable); void on_fileOpen_BT_clicked(); void on_sessions_CB_currentIndexChanged(int index); + void on_mapsButton_clicked(); private: QList csvlog; diff --git a/companion/src/logsdialog.ui b/companion/src/logsdialog.ui index c8e417d16..deee92d6b 100644 --- a/companion/src/logsdialog.ui +++ b/companion/src/logsdialog.ui @@ -20,7 +20,7 @@ true - + @@ -46,43 +46,6 @@ - - - - - 0 - 0 - - - - - 120 - 16777215 - - - - 0 - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - 0 - - - true - - - false - - - @@ -195,7 +158,7 @@ - + @@ -238,6 +201,78 @@ + + + + + 0 + 0 + + + + + 120 + 16777215 + + + + 0 + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + 0 + + + true + + + false + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 120 + 57 + + + + + + + + :/images/maps.png:/images/maps.png + + + + 120 + 57 + + + + diff --git a/companion/src/preferencesdialog.cpp b/companion/src/preferencesdialog.cpp index 8ad749686..6afa8ee9a 100644 --- a/companion/src/preferencesdialog.cpp +++ b/companion/src/preferencesdialog.cpp @@ -76,6 +76,9 @@ void preferencesDialog::baseFirmwareChanged() ui->voice_dnld->setEnabled(true); ui->sdPathButton->setEnabled(true); ui->sdPath->setEnabled(true); + ui->ge_label->show(); + ui->ge_lineedit->show(); + ui->ge_pathButton->show(); } else { ui->voiceLabel->hide(); ui->voiceCombo->hide(); @@ -83,6 +86,9 @@ void preferencesDialog::baseFirmwareChanged() ui->sdPathButton->hide(); ui->sdPath->hide(); ui->sdPathLabel->hide(); + ui->ge_label->hide(); + ui->ge_lineedit->hide(); + ui->ge_pathButton->hide(); } populateFirmwareOptions(firmware); int width=firmware->eepromInterface->getCapability(LCDWidth); @@ -268,6 +274,7 @@ void preferencesDialog::writeValues() settings.setValue("backLight", ui->backLightColor->currentIndex()); settings.setValue("libraryPath", ui->libraryPath->text()); settings.setValue("sdPath", ui->sdPath->text()); + settings.setValue("gePath", ui->ge_lineedit->text()); settings.setValue("embedded_splashes", ui->splashincludeCB->currentIndex()); if (!ui->SplashFileName->text().isEmpty()) { QImage Image = ui->imageLabel->pixmap()->toImage(); @@ -342,6 +349,9 @@ void preferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) ui->sdPathButton->show(); ui->sdPath->show(); ui->sdPathLabel->show(); + ui->ge_label->show(); + ui->ge_lineedit->show(); + ui->ge_pathButton->show(); if (current_firmware_variant.id.contains(opt.name) ||firmware->voice) { ui->voiceLabel->setEnabled(true); ui->voiceCombo->setEnabled(true); @@ -408,6 +418,10 @@ void preferencesDialog::initSettings() if (QDir(Path).exists()) { ui->sdPath->setText(Path); } + Path=settings.value("gePath", "").toString(); + if (QFile(Path).exists()) { + ui->ge_lineedit->setText(Path); + } Path=settings.value("backupPath", "").toString(); if (!Path.isEmpty()) { if (QDir(Path).exists()) { @@ -519,7 +533,7 @@ void preferencesDialog::on_fw_dnld_clicked() void preferencesDialog::on_voice_dnld_clicked() { ui->ProfSave_PB->setEnabled(true); - QString url="http://93.51.182.154/voices/"; + QString url="http://fw.opentx.it/voices/"; FirmwareVariant variant = getFirmwareVariant(); url.append(QString("%1/%2/").arg(variant.firmware->id).arg(ui->voiceCombo->currentText())); QDesktopServices::openUrl(url); @@ -574,6 +588,15 @@ void preferencesDialog::on_backupPathButton_clicked() ui->backupEnable->setEnabled(true); } +void preferencesDialog::on_ge_pathButton_clicked() +{ + QSettings settings("companion9x", "companion9x"); + QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text()); + if (!fileName.isEmpty()) { + ui->ge_lineedit->setText(fileName); + } +} + void preferencesDialog::on_splashLibraryButton_clicked() { QString fileName; @@ -655,6 +678,7 @@ void preferencesDialog::on_ProfSave_PB_clicked() settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); settings.setValue("sdPath", ui->sdPath->text()); settings.setValue("SplashFileName", ui->SplashFileName->text()); + settings.setValue("gePath", ui->ge_lineedit->text()); if (ui->imageLabel->pixmap()) { QImage Image = ui->imageLabel->pixmap()->toImage(); settings.setValue("SplashImage", image2qstring(Image)); diff --git a/companion/src/preferencesdialog.h b/companion/src/preferencesdialog.h index 101b610ed..9a31ea8fd 100644 --- a/companion/src/preferencesdialog.h +++ b/companion/src/preferencesdialog.h @@ -48,6 +48,7 @@ private slots: void on_snapshotPathButton_clicked(); void on_snapshotClipboardCKB_clicked(); void on_backupPathButton_clicked(); + void on_ge_pathButton_clicked(); void on_sdPathButton_clicked(); void on_splashLibraryButton_clicked(); void on_checkFWUpdates_clicked(); diff --git a/companion/src/preferencesdialog.ui b/companion/src/preferencesdialog.ui index f3e5bf005..b52060211 100644 --- a/companion/src/preferencesdialog.ui +++ b/companion/src/preferencesdialog.ui @@ -39,6 +39,19 @@ 4 + + + + + 0 + 0 + + + + Show Splash Screen + + + @@ -261,253 +274,7 @@ - - - - - 0 - 0 - - - - Show Splash Screen - - - - - - - - 0 - 0 - - - - Custom TX splash screen - - - - - - - - - Enable - - - - - - - - 0 - 0 - - - - - - - - Calibrate - - - - - - - - - 1 - - - - - Open Folder - - - - - - - true - - - true - - - - - - - - - - - - 0 - 0 - - - - FwInfo - - - - - - - Check for updates - - - - - - - - - - 0 - 0 - - - - Personal splash library - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 0 - 0 - - - - Ask for flashing after Download - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - Export Profile - - - - - - - Save Profile - - - - - - - 1 - - - 10 - - - - - - - Import Profile - - - - - - - - - - Profile Name - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - 0 - 0 - - - - Language (requires restart) - - - - + @@ -651,7 +418,271 @@ This is used by the templated to determine which channel goes to what number out - + + + + + 0 + 0 + + + + Custom TX splash screen + + + + + + + + + Enable + + + + + + + + 0 + 0 + + + + + + + + Calibrate + + + + + + + + + 1 + + + + + Open Folder + + + + + + + true + + + true + + + + + + + + + + + + 0 + 0 + + + + FwInfo + + + + + + + Check for updates + + + + + + + + + + 0 + 0 + + + + Personal splash library + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + Ask for flashing after Download + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + Export Profile + + + + + + + Save Profile + + + + + + + 1 + + + 10 + + + + + + + Import Profile + + + + + + + + + + Profile Name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 0 + 0 + + + + Language (requires restart) + + + + + + + 1 + + + + + Open Folder + + + + + + + true + + + true + + + + + + + Use clipboard only + + + + + + @@ -664,7 +695,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -680,7 +711,7 @@ This is used by the templated to determine which channel goes to what number out - + Mode selection: @@ -728,7 +759,7 @@ Mode 4: - + @@ -777,7 +808,7 @@ Mode 4: - + Profile slot @@ -816,7 +847,7 @@ Mode 4: - + Qt::Vertical @@ -832,7 +863,7 @@ Mode 4: - + @@ -859,7 +890,7 @@ Mode 4: - + QLayout::SetMaximumSize @@ -950,7 +981,7 @@ May be different from firmware language - + @@ -997,37 +1028,6 @@ May be different from firmware language - - - - 1 - - - - - Open Folder - - - - - - - true - - - true - - - - - - - Use clipboard only - - - - - @@ -1048,7 +1048,7 @@ May be different from firmware language - + QLayout::SetMaximumSize @@ -1601,6 +1601,31 @@ May be different from firmware language + + + + + + true + + + + + + + Find Executable + + + + + + + + + Google Earth Executable + + +