Qt touchups (#20465)
* reduce minimum size * clean that up * consistent * feels pretty good * cleanup * less laggy toggle * openpilot Co-authored-by: Comma Device <device@comma.ai>pull/20470/head
parent
55926e762a
commit
7f56991b41
2
cereal
2
cereal
|
@ -1 +1 @@
|
|||
Subproject commit 8203d5570221feb7a14349db65142c600e2545ef
|
||||
Subproject commit 38ecbfe03b4b3cdc984c6358a58df2b471aea968
|
|
@ -374,7 +374,7 @@ void ui_draw(UIState *s) {
|
|||
s->viz_rect.w -= sbr_w;
|
||||
}
|
||||
|
||||
const bool draw_alerts = s->scene.started && s->active_app == cereal::UiLayoutState::App::NONE;
|
||||
const bool draw_alerts = s->scene.started;
|
||||
const bool draw_vision = draw_alerts && s->vipc_client->connected;
|
||||
|
||||
// GL drawing functions
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
#include "common/params.h"
|
||||
#include "common/util.h"
|
||||
|
||||
#include <QSslSocket>
|
||||
|
||||
#if defined(QCOM) || defined(QCOM2)
|
||||
const std::string private_key_path = "/persist/comma/id_rsa";
|
||||
#else
|
||||
|
@ -95,18 +93,11 @@ RequestRepeater::RequestRepeater(QWidget* parent, QString requestURL, int period
|
|||
}
|
||||
|
||||
void RequestRepeater::sendRequest(QString requestURL, QVector<QPair<QString, QJsonValue>> payloads){
|
||||
// No network calls onroad
|
||||
if(GLWindow::ui_state.scene.started){
|
||||
return;
|
||||
}
|
||||
if (!active || (!GLWindow::ui_state.awake && disableWithScreen)) {
|
||||
return;
|
||||
}
|
||||
if(reply != NULL){
|
||||
if (GLWindow::ui_state.scene.started || !active || reply != NULL ||
|
||||
(!GLWindow::ui_state.awake && disableWithScreen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
aborted = false;
|
||||
QString token = CommaApi::create_jwt(payloads);
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(requestURL));
|
||||
|
@ -126,13 +117,12 @@ void RequestRepeater::sendRequest(QString requestURL, QVector<QPair<QString, QJs
|
|||
}
|
||||
|
||||
void RequestRepeater::requestTimeout(){
|
||||
aborted = true;
|
||||
reply->abort();
|
||||
}
|
||||
|
||||
// This function should always emit something
|
||||
void RequestRepeater::requestFinished(){
|
||||
if (!aborted) {
|
||||
if (reply->error() != QNetworkReply::OperationCanceledError) {
|
||||
networkTimer->stop();
|
||||
QString response = reply->readAll();
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
|
|
|
@ -41,7 +41,6 @@ private:
|
|||
QNetworkReply* reply;
|
||||
QNetworkAccessManager* networkAccessManager;
|
||||
QTimer* networkTimer;
|
||||
std::atomic<bool> aborted = false; // Not 100% sure we need atomic
|
||||
void sendRequest(QString requestURL, QVector<QPair<QString, QJsonValue>> payloads);
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -221,7 +221,7 @@ void WifiManager::connect(QByteArray ssid, QString username, QString password, S
|
|||
Connection connection;
|
||||
connection["connection"]["type"] = "802-11-wireless";
|
||||
connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}');
|
||||
connection["connection"]["id"] = "OpenPilot connection "+QString::fromStdString(ssid.toStdString());
|
||||
connection["connection"]["id"] = "openpilot connection "+QString::fromStdString(ssid.toStdString());
|
||||
connection["connection"]["autoconnect-retries"] = 0;
|
||||
|
||||
connection["802-11-wireless"]["ssid"] = ssid;
|
||||
|
|
|
@ -16,6 +16,7 @@ QFrame *horizontal_line(QWidget *parent) {
|
|||
|
||||
AbstractControl::AbstractControl(const QString &title, const QString &desc, const QString &icon, QWidget *parent) : QFrame(parent) {
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
vlayout->setMargin(0);
|
||||
|
||||
hlayout = new QHBoxLayout;
|
||||
hlayout->setMargin(0);
|
||||
|
|
|
@ -19,7 +19,7 @@ protected:
|
|||
|
||||
QSize minimumSizeHint() const override {
|
||||
QSize size = QFrame::minimumSizeHint();
|
||||
size.setHeight(150);
|
||||
size.setHeight(120);
|
||||
return size;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ SshControl::SshControl() : AbstractControl("SSH Keys", "Warning: This grants SSH
|
|||
btn.setStyleSheet(R"(
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-size: 35px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
|
|
|
@ -9,7 +9,7 @@ public:
|
|||
Toggle(QWidget* parent = nullptr);
|
||||
void togglePosition();
|
||||
bool on;
|
||||
int animation_duration = 250;
|
||||
int animation_duration = 150;
|
||||
int immediateOffset = 0;
|
||||
int offset_circle() const {
|
||||
return _x_circle;
|
||||
|
|
|
@ -16,13 +16,11 @@ static void draw_background(UIState *s) {
|
|||
}
|
||||
|
||||
static void draw_settings_button(UIState *s) {
|
||||
const float alpha = s->active_app == cereal::UiLayoutState::App::SETTINGS ? 1.0f : 0.65f;
|
||||
ui_draw_image(s, settings_btn, "button_settings", alpha);
|
||||
ui_draw_image(s, settings_btn, "button_settings", 0.65f);
|
||||
}
|
||||
|
||||
static void draw_home_button(UIState *s) {
|
||||
const float alpha = s->active_app == cereal::UiLayoutState::App::HOME ? 1.0f : 0.65f;
|
||||
ui_draw_image(s, home_btn, "button_home", alpha);
|
||||
ui_draw_image(s, home_btn, "button_home", 1.0f);
|
||||
}
|
||||
|
||||
static void draw_network_strength(UIState *s) {
|
||||
|
@ -36,14 +34,6 @@ static void draw_network_strength(UIState *s) {
|
|||
ui_draw_image(s, {58, 196, 176, 27}, util::string_format("network_%d", img_idx).c_str(), 1.0f);
|
||||
}
|
||||
|
||||
static void draw_battery_icon(UIState *s) {
|
||||
const char *battery_img = s->scene.deviceState.getBatteryStatus() == "Charging" ? "battery_charging" : "battery";
|
||||
const Rect rect = {160, 255, 76, 36};
|
||||
ui_fill_rect(s->vg, {rect.x + 6, rect.y + 5,
|
||||
int((rect.w - 19) * s->scene.deviceState.getBatteryPercent() * 0.01), rect.h - 11}, COLOR_WHITE);
|
||||
ui_draw_image(s, rect, battery_img, 1.0f);
|
||||
}
|
||||
|
||||
static void draw_network_type(UIState *s) {
|
||||
static std::map<cereal::DeviceState::NetworkType, const char *> network_type_map = {
|
||||
{cereal::DeviceState::NetworkType::NONE, "--"},
|
||||
|
@ -150,7 +140,6 @@ void ui_draw_sidebar(UIState *s) {
|
|||
draw_settings_button(s);
|
||||
draw_home_button(s);
|
||||
draw_network_strength(s);
|
||||
draw_battery_icon(s);
|
||||
draw_network_type(s);
|
||||
draw_temp_metric(s);
|
||||
draw_panda_metric(s);
|
||||
|
|
|
@ -55,7 +55,7 @@ static void ui_init_vision(UIState *s) {
|
|||
|
||||
void ui_init(UIState *s) {
|
||||
s->sm = new SubMaster({
|
||||
"modelV2", "controlsState", "uiLayoutState", "liveCalibration", "radarState", "deviceState", "liveLocationKalman",
|
||||
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "liveLocationKalman",
|
||||
"pandaState", "carParams", "driverState", "driverMonitoringState", "sensorEvents", "carState", "ubloxGnss",
|
||||
#ifdef QCOM2
|
||||
"roadCameraState",
|
||||
|
@ -178,11 +178,6 @@ static void update_sockets(UIState *s) {
|
|||
if (sm.updated("modelV2")) {
|
||||
update_model(s, sm["modelV2"].getModelV2());
|
||||
}
|
||||
if (sm.updated("uiLayoutState")) {
|
||||
auto data = sm["uiLayoutState"].getUiLayoutState();
|
||||
s->active_app = data.getActiveApp();
|
||||
s->sidebar_collapsed = data.getSidebarCollapsed();
|
||||
}
|
||||
if (sm.updated("deviceState")) {
|
||||
scene.deviceState = sm["deviceState"].getDeviceState();
|
||||
}
|
||||
|
@ -341,13 +336,11 @@ static void update_status(UIState *s) {
|
|||
|
||||
read_param(&s->scene.is_rhd, "IsRHD");
|
||||
read_param(&s->scene.end_to_end, "EndToEndToggle");
|
||||
s->active_app = cereal::UiLayoutState::App::NONE;
|
||||
s->sidebar_collapsed = true;
|
||||
s->scene.alert_size = cereal::ControlsState::AlertSize::NONE;
|
||||
s->vipc_client = s->scene.driver_view ? s->vipc_client_front : s->vipc_client_rear;
|
||||
} else {
|
||||
s->status = STATUS_OFFROAD;
|
||||
s->active_app = cereal::UiLayoutState::App::HOME;
|
||||
s->sidebar_collapsed = false;
|
||||
s->sound->stop();
|
||||
s->vipc_client->connected = false;
|
||||
|
|
|
@ -157,7 +157,6 @@ typedef struct UIState {
|
|||
Sound *sound;
|
||||
UIStatus status;
|
||||
UIScene scene;
|
||||
cereal::UiLayoutState::App active_app;
|
||||
|
||||
// graphics
|
||||
std::unique_ptr<GLShader> gl_shader;
|
||||
|
|
Loading…
Reference in New Issue