[Companion] Move some single-use functions out of helpers module; cosmetics.
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
class FrSkyAlarmData {
|
class FrSkyAlarmData {
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(FrSkyAlarmData)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrSkyAlarmData() { clear(); }
|
FrSkyAlarmData() { clear(); }
|
||||||
unsigned int level; // 0=none, 1=Yellow, 2=Orange, 3=Red
|
unsigned int level; // 0=none, 1=Yellow, 2=Orange, 3=Red
|
||||||
@@ -33,6 +35,20 @@ class FrSkyAlarmData {
|
|||||||
unsigned int value; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
|
unsigned int value; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc.
|
||||||
|
|
||||||
void clear() { memset(this, 0, sizeof(FrSkyAlarmData)); }
|
void clear() { memset(this, 0, sizeof(FrSkyAlarmData)); }
|
||||||
|
|
||||||
|
static QString alarmLevelName(int alarm)
|
||||||
|
{
|
||||||
|
switch (alarm) {
|
||||||
|
case 1:
|
||||||
|
return tr("Yellow");
|
||||||
|
case 2:
|
||||||
|
return tr("Orange");
|
||||||
|
case 3:
|
||||||
|
return tr("Red");
|
||||||
|
default:
|
||||||
|
return "----";
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FrSkyChannelData {
|
class FrSkyChannelData {
|
||||||
@@ -49,6 +65,16 @@ class FrSkyChannelData {
|
|||||||
float getRatio() const;
|
float getRatio() const;
|
||||||
RawSourceRange getRange() const;
|
RawSourceRange getRange() const;
|
||||||
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
|
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
|
||||||
|
|
||||||
|
static QString unitString(int units)
|
||||||
|
{
|
||||||
|
switch(units) {
|
||||||
|
case 1:
|
||||||
|
return QCoreApplication::translate("FrSkyChannelData", "---");
|
||||||
|
default:
|
||||||
|
return QCoreApplication::translate("FrSkyChannelData", "V");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FrSkyBarData {
|
struct FrSkyBarData {
|
||||||
|
|||||||
+38
-97
@@ -75,6 +75,37 @@ const QColor colors[CPN_MAX_CURVES] = {
|
|||||||
QColor(255,127,0),
|
QColor(255,127,0),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CompanionIcon
|
||||||
|
*/
|
||||||
|
|
||||||
|
static QString iconThemeFolder(int theme_set)
|
||||||
|
{
|
||||||
|
switch(theme_set) {
|
||||||
|
case 0:
|
||||||
|
return QStringLiteral("classic");
|
||||||
|
case 2:
|
||||||
|
return QStringLiteral("monowhite");
|
||||||
|
case 3:
|
||||||
|
return QStringLiteral("monochrome");
|
||||||
|
case 4:
|
||||||
|
return QStringLiteral("monoblue");
|
||||||
|
default:
|
||||||
|
return QStringLiteral("yerico");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompanionIcon::CompanionIcon(const QString &baseimage)
|
||||||
|
{
|
||||||
|
const QString theme = iconThemeFolder(g.theme());
|
||||||
|
addFile(":/themes/"+theme+"/16/"+baseimage, QSize(16,16));
|
||||||
|
addFile(":/themes/"+theme+"/24/"+baseimage, QSize(24,24));
|
||||||
|
addFile(":/themes/"+theme+"/32/"+baseimage, QSize(32,32));
|
||||||
|
addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GVarGroup
|
* GVarGroup
|
||||||
*/
|
*/
|
||||||
@@ -172,6 +203,7 @@ void GVarGroup::setWeight(int val)
|
|||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CurveGroup
|
* CurveGroup
|
||||||
*/
|
*/
|
||||||
@@ -334,6 +366,7 @@ void CurveGroup::valuesChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helpers namespace functions
|
* Helpers namespace functions
|
||||||
*/
|
*/
|
||||||
@@ -390,6 +423,11 @@ void Helpers::populateGvarUseCB(QComboBox * b, unsigned int phase)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
||||||
|
{
|
||||||
|
return s1.toLower() < s2.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
void Helpers::populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current)
|
void Helpers::populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current)
|
||||||
{
|
{
|
||||||
b->clear();
|
b->clear();
|
||||||
@@ -500,98 +538,6 @@ QStandardItemModel * Helpers::getRawSourceItemModel(const GeneralSettings * cons
|
|||||||
return itemModel;
|
return itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString image2qstring(QImage image)
|
|
||||||
{
|
|
||||||
if (image.isNull())
|
|
||||||
return "";
|
|
||||||
QBuffer buffer;
|
|
||||||
image.save(&buffer, "PNG");
|
|
||||||
QString ImageStr;
|
|
||||||
int b=0;
|
|
||||||
int size=buffer.data().size();
|
|
||||||
for (int j = 0; j < size; j++) {
|
|
||||||
b=buffer.data().at(j);
|
|
||||||
ImageStr += QString("%1").arg(b&0xff, 2, 16, QChar('0'));
|
|
||||||
}
|
|
||||||
return ImageStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int findmult(float value, float base)
|
|
||||||
{
|
|
||||||
int vvalue = value*10;
|
|
||||||
int vbase = base*10;
|
|
||||||
vvalue--;
|
|
||||||
|
|
||||||
int mult = 0;
|
|
||||||
for (int i=8; i>=0; i--) {
|
|
||||||
if (vvalue/vbase >= (1<<i)) {
|
|
||||||
mult = i+1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mult;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move to FrSkyAlarmData
|
|
||||||
QString getFrSkyAlarmType(int alarm)
|
|
||||||
{
|
|
||||||
switch (alarm) {
|
|
||||||
case 1:
|
|
||||||
return QCoreApplication::translate("FrSkyAlarmData", "Yellow");
|
|
||||||
case 2:
|
|
||||||
return QCoreApplication::translate("FrSkyAlarmData", "Orange");
|
|
||||||
case 3:
|
|
||||||
return QCoreApplication::translate("FrSkyAlarmData", "Red");
|
|
||||||
default:
|
|
||||||
return "----";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: move to FrSkyChannelData
|
|
||||||
QString getFrSkyUnits(int units)
|
|
||||||
{
|
|
||||||
switch(units) {
|
|
||||||
case 1:
|
|
||||||
return QCoreApplication::translate("FrSkyChannelData", "---");
|
|
||||||
default:
|
|
||||||
return QCoreApplication::translate("FrSkyChannelData", "V");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString getTheme()
|
|
||||||
{
|
|
||||||
int theme_set = g.theme();
|
|
||||||
QString Theme;
|
|
||||||
switch(theme_set) {
|
|
||||||
case 0:
|
|
||||||
Theme="classic";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Theme="monowhite";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
Theme="monochrome";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
Theme="monoblue";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Theme="yerico";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return Theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompanionIcon::CompanionIcon(const QString &baseimage)
|
|
||||||
{
|
|
||||||
static QString theme = getTheme();
|
|
||||||
addFile(":/themes/"+theme+"/16/"+baseimage, QSize(16,16));
|
|
||||||
addFile(":/themes/"+theme+"/24/"+baseimage, QSize(24,24));
|
|
||||||
addFile(":/themes/"+theme+"/32/"+baseimage, QSize(32,32));
|
|
||||||
addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48));
|
|
||||||
}
|
|
||||||
|
|
||||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
{
|
{
|
||||||
QString fwId = SimulatorLoader::findSimulatorByFirmwareName(getCurrentFirmware()->getId());
|
QString fwId = SimulatorLoader::findSimulatorByFirmwareName(getCurrentFirmware()->getId());
|
||||||
@@ -754,11 +700,6 @@ QSet<QString> getFilesSet(const QString &path, const QStringList &filter, int ma
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
|
||||||
{
|
|
||||||
return s1.toLower() < s2.toLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpsGlitchFilter::isGlitch(GpsCoord coord)
|
bool GpsGlitchFilter::isGlitch(GpsCoord coord)
|
||||||
{
|
{
|
||||||
if ((fabs(coord.latitude) < 0.1) && (fabs(coord.longitude) < 0.1)) {
|
if ((fabs(coord.latitude) < 0.1) && (fabs(coord.longitude) < 0.1)) {
|
||||||
|
|||||||
+8
-19
@@ -52,8 +52,6 @@ extern const QColor colors[CPN_MAX_CURVES];
|
|||||||
|
|
||||||
#define TRIM_MODE_NONE 0x1F // 0b11111
|
#define TRIM_MODE_NONE 0x1F // 0b11111
|
||||||
|
|
||||||
QString getTheme();
|
|
||||||
|
|
||||||
class CompanionIcon: public QIcon {
|
class CompanionIcon: public QIcon {
|
||||||
public:
|
public:
|
||||||
CompanionIcon(const QString &baseimage);
|
CompanionIcon(const QString &baseimage);
|
||||||
@@ -146,14 +144,7 @@ namespace Helpers
|
|||||||
void getFileComboBoxValue(QComboBox * b, char * dest, int length);
|
void getFileComboBoxValue(QComboBox * b, char * dest, int length);
|
||||||
} // namespace Helpers
|
} // namespace Helpers
|
||||||
|
|
||||||
// TODO : move to Helpers namespace
|
// TODO : move globals to Helpers namespace
|
||||||
|
|
||||||
QString image2qstring(QImage image);
|
|
||||||
int findmult(float value, float base);
|
|
||||||
|
|
||||||
/* FrSky helpers */
|
|
||||||
QString getFrSkyAlarmType(int alarm);
|
|
||||||
QString getFrSkyUnits(int units);
|
|
||||||
|
|
||||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx);
|
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx);
|
||||||
|
|
||||||
@@ -163,14 +154,6 @@ QPixmap makePixMap(const QImage & image);
|
|||||||
int version2index(const QString & version);
|
int version2index(const QString & version);
|
||||||
const QString index2version(int index);
|
const QString index2version(int index);
|
||||||
|
|
||||||
class QTimeS : public QTime
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QTimeS(int s) { int h = s/3600; s %= 3600; int m = s/60; s %=60; setHMS(h, m, s); }
|
|
||||||
QTimeS(const QTime & q) : QTime(q) {}
|
|
||||||
int seconds() const { return hour()*3600 + minute()*60 + second(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
bool qunlink(const QString & fileName);
|
bool qunlink(const QString & fileName);
|
||||||
|
|
||||||
QString generateProcessUniqueTempFileName(const QString & fileName);
|
QString generateProcessUniqueTempFileName(const QString & fileName);
|
||||||
@@ -179,8 +162,14 @@ bool isTempFileName(const QString & fileName);
|
|||||||
QString getSoundsPath(const GeneralSettings &generalSettings);
|
QString getSoundsPath(const GeneralSettings &generalSettings);
|
||||||
QSet<QString> getFilesSet(const QString &path, const QStringList &filter, int maxLen);
|
QSet<QString> getFilesSet(const QString &path, const QStringList &filter, int maxLen);
|
||||||
|
|
||||||
bool caseInsensitiveLessThan(const QString &s1, const QString &s2);
|
|
||||||
|
|
||||||
|
class QTimeS : public QTime
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QTimeS(int s) { int h = s/3600; s %= 3600; int m = s/60; s %=60; setHMS(h, m, s); }
|
||||||
|
QTimeS(const QTime & q) : QTime(q) {}
|
||||||
|
int seconds() const { return hour()*3600 + minute()*60 + second(); }
|
||||||
|
};
|
||||||
|
|
||||||
class GpsCoord
|
class GpsCoord
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -93,6 +93,23 @@ void TelemetryAnalog::update()
|
|||||||
ui->CalibSB->setValue(mini);
|
ui->CalibSB->setValue(mini);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int findmult(float value, float base)
|
||||||
|
{
|
||||||
|
int vvalue = value*10;
|
||||||
|
int vbase = base*10;
|
||||||
|
vvalue--;
|
||||||
|
|
||||||
|
int mult = 0;
|
||||||
|
for (int i=8; i>=0; i--) {
|
||||||
|
if (vvalue/vbase >= (1<<i)) {
|
||||||
|
mult = i+1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mult;
|
||||||
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
float ratio = analog.getRatio();
|
float ratio = analog.getRatio();
|
||||||
|
|||||||
@@ -752,7 +752,7 @@ QString MultiModelPrinter::printTelemetry()
|
|||||||
columns.appendRowHeader(QStringList() << tr("Analogs") << tr("Unit") << tr("Scale") << tr("Offset"));
|
columns.appendRowHeader(QStringList() << tr("Analogs") << tr("Unit") << tr("Scale") << tr("Offset"));
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
columns.appendRowStart(QString("A%1").arg(i+1), 20);
|
columns.appendRowStart(QString("A%1").arg(i+1), 20);
|
||||||
COMPARECELLWIDTH(getFrSkyUnits(model->frsky.channels[i].type), 20);
|
COMPARECELLWIDTH(FrSkyChannelData::unitString(model->frsky.channels[i].type), 20);
|
||||||
COMPARECELLWIDTH(QString::number((model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ? 10.0 : 1)), 10, (model->frsky.channels[i].type==0 ? 1 : 0)), 20);
|
COMPARECELLWIDTH(QString::number((model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ? 10.0 : 1)), 10, (model->frsky.channels[i].type==0 ? 1 : 0)), 20);
|
||||||
COMPARECELLWIDTH(QString::number((model->frsky.channels[i].offset*(model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ?10.0 : 1)))/255, 10, (model->frsky.channels[i].type==0 ? 1 : 0)), 40);
|
COMPARECELLWIDTH(QString::number((model->frsky.channels[i].offset*(model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ?10.0 : 1)))/255, 10, (model->frsky.channels[i].type==0 ? 1 : 0)), 40);
|
||||||
columns.appendRowEnd();
|
columns.appendRowEnd();
|
||||||
@@ -769,10 +769,10 @@ QString MultiModelPrinter::printTelemetry()
|
|||||||
{
|
{
|
||||||
columns.appendRowStart(tr("RSSI Alarms"), 20);
|
columns.appendRowStart(tr("RSSI Alarms"), 20);
|
||||||
columns.appendCellStart(80);
|
columns.appendCellStart(80);
|
||||||
COMPARESTRING("", (IS_ARM(getCurrentBoard()) ? tr("Low") : getFrSkyAlarmType(model->rssiAlarms.level[0])), false);
|
COMPARESTRING("", (IS_ARM(getCurrentBoard()) ? tr("Low") : FrSkyAlarmData::alarmLevelName(model->rssiAlarms.level[0])), false);
|
||||||
columns.append(": ");
|
columns.append(": ");
|
||||||
COMPARESTRING("", QString("< %1").arg(QString::number(model->rssiAlarms.warning, 10)), true);
|
COMPARESTRING("", QString("< %1").arg(QString::number(model->rssiAlarms.warning, 10)), true);
|
||||||
COMPARESTRING("", (IS_ARM(getCurrentBoard()) ? tr("Critical") : getFrSkyAlarmType(model->rssiAlarms.level[1])), false);
|
COMPARESTRING("", (IS_ARM(getCurrentBoard()) ? tr("Critical") : FrSkyAlarmData::alarmLevelName(model->rssiAlarms.level[1])), false);
|
||||||
columns.append(": ");
|
columns.append(": ");
|
||||||
COMPARESTRING("", QString("< %1").arg(QString::number(model->rssiAlarms.critical, 10)), true);
|
COMPARESTRING("", QString("< %1").arg(QString::number(model->rssiAlarms.critical, 10)), true);
|
||||||
COMPARESTRING(tr("Telemetry audio"), modelPrinter->printRssiAlarmsDisabled(model->rssiAlarms.disabled), false);
|
COMPARESTRING(tr("Telemetry audio"), modelPrinter->printRssiAlarmsDisabled(model->rssiAlarms.disabled), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user