mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-19 21:12:07 +08:00
7030dc02ce
Introduced the RETURN_IF_SUNNYPILOT macro to handle conditional returns in the settings code. This ensures that certain blocks of code are bypassed when SUNNYPILOT is defined, improving modularity and reducing preprocessor directives.
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
#include <QDateTime>
|
|
#include <QFileSystemWatcher>
|
|
#include <QPainter>
|
|
#include <QPixmap>
|
|
#include <QSurfaceFormat>
|
|
#include <QWidget>
|
|
|
|
#include "cereal/gen/cpp/car.capnp.h"
|
|
#include "common/params.h"
|
|
|
|
#ifdef SUNNYPILOT
|
|
#define RETURN_IF_SUNNYPILOT return;
|
|
#else
|
|
#define RETURN_IF_SUNNYPILOT // Do nothing
|
|
#endif
|
|
|
|
QString getVersion();
|
|
QString getBrand();
|
|
QString getUserAgent(bool sunnylink = false);
|
|
std::optional<QString> getDongleId();
|
|
std::optional<QString> getSunnylinkDongleId();
|
|
QMap<QString, QString> getSupportedLanguages();
|
|
QMap<QString, QString> getCarNames();
|
|
void setQtSurfaceFormat();
|
|
void sigTermHandler(int s);
|
|
QString timeAgo(const QDateTime &date);
|
|
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
|
void initApp(int argc, char *argv[], bool disable_hidpi = true);
|
|
QWidget* topWidget(QWidget* widget);
|
|
QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
|
|
QPixmap bootstrapPixmap(const QString &id);
|
|
|
|
void drawRoundedRect(QPainter &painter, const QRectF &rect, qreal xRadiusTop, qreal yRadiusTop, qreal xRadiusBottom, qreal yRadiusBottom);
|
|
QColor interpColor(float xv, std::vector<float> xp, std::vector<QColor> fp);
|
|
bool hasLongitudinalControl(const cereal::CarParams::Reader &car_params);
|
|
|
|
struct InterFont : public QFont {
|
|
InterFont(int pixel_size, QFont::Weight weight = QFont::Normal) : QFont("Inter") {
|
|
setPixelSize(pixel_size);
|
|
setWeight(weight);
|
|
}
|
|
};
|
|
|
|
class ParamWatcher : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ParamWatcher(QObject *parent);
|
|
void addParam(const QString ¶m_name);
|
|
|
|
signals:
|
|
void paramChanged(const QString ¶m_name, const QString ¶m_value);
|
|
|
|
private:
|
|
void fileChanged(const QString &path);
|
|
|
|
QFileSystemWatcher *watcher;
|
|
QHash<QString, QString> params_hash;
|
|
Params params;
|
|
};
|