mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
build Qt UI with clazy (#19537)
* clazy, level0 * level1 old-commit-hash: 069189fd7fd9dc677b29725f92fd3b4b80911d8a
This commit is contained in:
@@ -17,6 +17,10 @@ AddOption('--asan',
|
||||
action='store_true',
|
||||
help='turn on ASAN')
|
||||
|
||||
AddOption('--clazy',
|
||||
action='store_true',
|
||||
help='build with clazy')
|
||||
|
||||
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
||||
if platform.system() == "Darwin":
|
||||
arch = "Darwin"
|
||||
|
||||
@@ -44,6 +44,17 @@ if arch in ["x86_64", "Darwin", "larch64"]:
|
||||
qt_env['CXXFLAGS'] += qt_flags
|
||||
qt_env['LIBPATH'] += ['#selfdrive/ui']
|
||||
|
||||
if GetOption("clazy"):
|
||||
checks = [
|
||||
"level0",
|
||||
"level1",
|
||||
"no-range-loop",
|
||||
"no-non-pod-global-static",
|
||||
]
|
||||
qt_env['CXX'] = 'clazy'
|
||||
qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0]
|
||||
qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks)
|
||||
|
||||
|
||||
src = ['ui.cc', 'paint.cc', 'sidebar.cc', '#phonelibs/nanovg/nanovg.c']
|
||||
libs = [common, 'zmq', 'capnp', 'kj', 'm', cereal, messaging, gpucommon, visionipc]
|
||||
|
||||
@@ -103,7 +103,7 @@ QString WifiManager::get_ipv4_address(){
|
||||
return "";
|
||||
}
|
||||
QVector<QDBusObjectPath> conns = get_active_connections();
|
||||
for (auto p : conns){
|
||||
for (auto &p : conns){
|
||||
QString active_connection = p.path();
|
||||
QDBusInterface nm(nm_service, active_connection, props_iface, bus);
|
||||
QDBusObjectPath pth = get_response<QDBusObjectPath>(nm.call("Get", connection_iface, "Ip4Config"));
|
||||
@@ -261,14 +261,13 @@ void WifiManager::clear_connections(QString ssid) {
|
||||
|
||||
const QDBusArgument &dbusArg = response.arguments().at(0).value<QDBusArgument>();
|
||||
|
||||
QMap<QString,QMap<QString,QVariant> > map;
|
||||
QMap<QString, QMap<QString,QVariant>> map;
|
||||
dbusArg >> map;
|
||||
for (QString outer_key : map.keys()) {
|
||||
QMap<QString,QVariant> innerMap = map.value(outer_key);
|
||||
for (QString inner_key : innerMap.keys()) {
|
||||
if (inner_key == "ssid") {
|
||||
QString value = innerMap.value(inner_key).value<QString>();
|
||||
if (value == ssid) {
|
||||
for (auto &inner : map) {
|
||||
for (auto &val : inner) {
|
||||
QString key = inner.key(val);
|
||||
if (key == "ssid") {
|
||||
if (val == ssid) {
|
||||
nm2.call("Delete");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ void OffroadAlert::refresh() {
|
||||
} else {
|
||||
vlayout->addSpacing(60);
|
||||
|
||||
for (auto alert : alerts) {
|
||||
for (const auto &alert : alerts) {
|
||||
QLabel *l = new QLabel(alert.text);
|
||||
l->setWordWrap(true);
|
||||
l->setMargin(60);
|
||||
@@ -136,7 +136,7 @@ void OffroadAlert::parse_alerts() {
|
||||
}
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
for (const QString& key : json.keys()) {
|
||||
for (const QString &key : json.keys()) {
|
||||
std::vector<char> bytes = Params().read_db_bytes(key.toStdString().c_str());
|
||||
|
||||
if (bytes.size()) {
|
||||
|
||||
@@ -19,14 +19,14 @@ void Toggle::paintEvent(QPaintEvent *e) {
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
// Draw toggle background left
|
||||
p.setBrush(QColor("#33ab4c"));
|
||||
p.setBrush(QColor(0x33ab4c));
|
||||
p.drawRoundedRect(QRect(0, _y_rect, _x_circle + _radius, _height_rect), _height_rect/2, _height_rect/2);
|
||||
// Draw toggle background right
|
||||
p.setBrush(QColor("#0a1a26"));
|
||||
p.setBrush(QColor(0x0a1a26));
|
||||
p.drawRoundedRect(QRect(_x_circle - _radius, _y_rect, width() -(_x_circle - _radius), _height_rect), _height_rect/2, _height_rect/2);
|
||||
|
||||
// Draw toggle circle
|
||||
p.setBrush(QColor("#fafafa"));
|
||||
p.setBrush(QColor(0xfafafa));
|
||||
p.drawEllipse(QRectF(_x_circle - _radius, _y_circle - _radius, 2 * _radius, 2 * _radius));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
class Toggle : public QAbstractButton {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle)
|
||||
Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle CONSTANT)
|
||||
|
||||
public:
|
||||
Toggle(QWidget* parent = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user