feat: Support all current timezones for GPS (#3406)
* Support all current timezones. * Fix function name and calculation for timezone offset. * Allow setting any time offset value from -12 to +14 in 15 minutes increments. * Alternate timezone editor in Companion (from elecpower). * Fix compiler warning. * chore: Add the T20
This commit is contained in:
@@ -182,6 +182,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["hapticMode"] = rhs.hapticMode;
|
||||
node["stickMode"] = rhs.stickMode;
|
||||
node["timezone"] = rhs.timezone;
|
||||
node["timezoneMinutes"] = rhs.timezoneMinutes;
|
||||
node["adjustRTC"] = (int)rhs.adjustRTC;
|
||||
node["inactivityTimer"] = rhs.inactivityTimer;
|
||||
|
||||
@@ -390,6 +391,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["hapticMode"] >> rhs.hapticMode;
|
||||
node["stickMode"] >> rhs.stickMode;
|
||||
node["timezone"] >> rhs.timezone;
|
||||
node["timezoneMinutes"] >> rhs.timezoneMinutes;
|
||||
node["adjustRTC"] >> rhs.adjustRTC;
|
||||
node["inactivityTimer"] >> rhs.inactivityTimer;
|
||||
|
||||
|
||||
@@ -212,6 +212,7 @@ class GeneralSettings {
|
||||
BeeperMode hapticMode;
|
||||
unsigned int stickMode; // TODO enum
|
||||
int timezone;
|
||||
int timezoneMinutes;
|
||||
bool adjustRTC;
|
||||
bool optrexDisplay;
|
||||
unsigned int inactivityTimer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(generaledit_NAMES
|
||||
generaledit
|
||||
@@ -10,6 +10,7 @@ set(generaledit_SRCS
|
||||
hardware.cpp
|
||||
trainer.cpp
|
||||
generaloptions.cpp
|
||||
timezoneedit.cpp
|
||||
)
|
||||
|
||||
set(generaledit_HDRS
|
||||
@@ -17,6 +18,7 @@ set(generaledit_HDRS
|
||||
hardware.h
|
||||
trainer.h
|
||||
generaloptions.h
|
||||
timezoneedit.h
|
||||
)
|
||||
|
||||
set(generaledit_UIS
|
||||
|
||||
@@ -150,7 +150,8 @@ ui(new Ui::GeneralSetup)
|
||||
}
|
||||
|
||||
ui->gpsFormatCB->setCurrentIndex(generalSettings.gpsFormat);
|
||||
ui->timezoneSB->setValue(generalSettings.timezone);
|
||||
|
||||
ui->timezoneLE->setTime((generalSettings.timezone * 3600) + (generalSettings.timezoneMinutes/*quarter hours*/ * 15 * 60));
|
||||
|
||||
if (IS_HORUS_OR_TARANIS(firmware->getBoard())) {
|
||||
ui->adjustRTC->setChecked(generalSettings.adjustRTC);
|
||||
@@ -328,6 +329,16 @@ GeneralSetupPanel::~GeneralSetupPanel()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text)
|
||||
{
|
||||
if (!lock) {
|
||||
int secs = ui->timezoneLE->timeInSeconds();
|
||||
generalSettings.timezone = secs / 3600;
|
||||
generalSettings.timezoneMinutes = (secs % 3600) / (15 * 60); // timezoneMinutes in quarter hours
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::populateBacklightCB()
|
||||
{
|
||||
QComboBox * b = ui->backlightswCB;
|
||||
@@ -693,12 +704,6 @@ void GeneralSetupPanel::on_switchesDelay_valueChanged(int)
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_timezoneSB_editingFinished()
|
||||
{
|
||||
generalSettings.timezone = ui->timezoneSB->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GeneralSetupPanel::on_adjustRTC_stateChanged(int)
|
||||
{
|
||||
generalSettings.adjustRTC = ui->adjustRTC->isChecked();
|
||||
|
||||
@@ -50,7 +50,7 @@ class GeneralSetupPanel : public GeneralPanel
|
||||
void on_faimode_CB_stateChanged(int );
|
||||
void on_rotEncMode_CB_currentIndexChanged(int index);
|
||||
void on_speakerPitchSB_editingFinished();
|
||||
void on_timezoneSB_editingFinished();
|
||||
void on_timezoneLE_textEdited(const QString &text);
|
||||
void on_adjustRTC_stateChanged(int);
|
||||
void on_hapticStrength_valueChanged();
|
||||
void on_soundModeCB_currentIndexChanged(int index);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>810</width>
|
||||
<width>858</width>
|
||||
<height>880</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -927,17 +927,7 @@
|
||||
<item row="18" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="timezoneSB">
|
||||
<property name="minimum">
|
||||
<number>-14</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TimezoneEdit" name="timezoneLE"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="adjustRTC">
|
||||
@@ -2501,6 +2491,13 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TimezoneEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>timezoneedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "timezoneedit.h"
|
||||
|
||||
TimezoneEdit::TimezoneEdit(QWidget * parent) :
|
||||
TimerEdit(parent)
|
||||
{
|
||||
setShowSeconds(false);
|
||||
setMinimumTime(-12 * 60 * 60);
|
||||
setMaximumTime(14 * 60 * 60);
|
||||
setSingleStep(15 * 60);
|
||||
setPageStep(60 * 60);
|
||||
}
|
||||
|
||||
void TimezoneEdit::setupFormat()
|
||||
{
|
||||
QString inputRe = "^(?<pol>-|\\+|\\s)?(?<hrs>[0-9]*[0-9]):(?<mins>00|15|30|45)";
|
||||
m_validator->setRegularExpression(QRegularExpression(inputRe));
|
||||
|
||||
setInputMask("#99:99");
|
||||
setValidator(m_validator);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <TimerEdit>
|
||||
|
||||
class TimezoneEdit : public TimerEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimezoneEdit(QWidget * parent = Q_NULLPTR);
|
||||
virtual ~TimezoneEdit() {}
|
||||
|
||||
protected:
|
||||
void setupFormat() override;
|
||||
};
|
||||
@@ -86,7 +86,7 @@ class TimerEdit : public QLineEdit
|
||||
|
||||
protected:
|
||||
void textEditedHandler();
|
||||
void setupFormat();
|
||||
virtual void setupFormat();
|
||||
void emitValueChanged();
|
||||
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
|
||||
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
Reference in New Issue
Block a user