mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-23 08:53:44 +08:00
Remove "Driving Model" label and adjust item management
Eliminated the "Driving Model" label from SoftwarePanel and refactored item management to improve code clarity and functionality. Updated macro naming and added new list widget functions for better handling of UI elements.
This commit is contained in:
@@ -112,7 +112,6 @@ protected:
|
||||
bool is_onroad = false;
|
||||
|
||||
QLabel *onroadLbl;
|
||||
LabelControl *currentModelLbl;
|
||||
LabelControl *versionLbl;
|
||||
ButtonControl *installBtn;
|
||||
ButtonControl *downloadBtn;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "common/params.h"
|
||||
#include "common/util.h"
|
||||
#include "common/model.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
@@ -22,9 +21,6 @@ void SoftwarePanel::checkForUpdates() {
|
||||
}
|
||||
|
||||
SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
|
||||
currentModelLbl = new LabelControl(tr("Driving Model"), CURRENT_MODEL);
|
||||
addItem(currentModelLbl);
|
||||
|
||||
onroadLbl = new QLabel(tr("Updates are only downloaded while the car is off."));
|
||||
onroadLbl->setStyleSheet("font-size: 50px; font-weight: 400; text-align: left; padding-top: 30px; padding-bottom: 30px;");
|
||||
addItem(onroadLbl);
|
||||
@@ -74,7 +70,9 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
|
||||
checkForUpdates();
|
||||
}
|
||||
});
|
||||
addItem(targetBranchBtn);
|
||||
if (!params.getBool("IsTestedBranch")) {
|
||||
addItem(targetBranchBtn);
|
||||
}
|
||||
|
||||
// uninstall button
|
||||
auto uninstallBtn = new ButtonControl(tr("Uninstall %1").arg(getBrand()), tr("UNINSTALL"));
|
||||
@@ -155,4 +153,4 @@ void SoftwarePanel::updateLabels() {
|
||||
installBtn->setDescription(QString::fromStdString(params.get("UpdaterNewReleaseNotes")));
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -295,10 +295,12 @@ class ListWidget : public QWidget {
|
||||
inline void addItem(QLayout *layout) { inner_layout.addLayout(layout); }
|
||||
inline void setSpacing(int spacing) { inner_layout.setSpacing(spacing); }
|
||||
|
||||
// TODO: move this out of the macros before going public. Looks phishy, and it's harder to debug it...
|
||||
#ifdef SUNNYPILOT
|
||||
LIST_WIDGET_FUNCTION_1
|
||||
LIST_WIDGET_FUNCTION_2
|
||||
LIST_WIDGET_FUCNTION_3
|
||||
LIST_WIDGET_FUNCTION_3
|
||||
LIST_WIDGET_FUNCTION_4
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -63,7 +63,7 @@ SoftwarePanelSP::SoftwarePanelSP(QWidget *parent) : SoftwarePanel(parent) {
|
||||
// Connect click event from currentModelLblBtn to local slot
|
||||
connect(currentModelLblBtn, &ButtonControl::clicked, this, &SoftwarePanelSP::handleCurrentModelLblBtnClicked);
|
||||
|
||||
ReplaceOrAddWidget(currentModelLbl, currentModelLblBtn);
|
||||
addItem(currentModelLblBtn, 0);
|
||||
}
|
||||
|
||||
void SoftwarePanelSP::handleDownloadFailed(const QString &modelType) {
|
||||
|
||||
@@ -35,12 +35,16 @@
|
||||
} \
|
||||
} \
|
||||
|
||||
#define LIST_WIDGET_FUCNTION_3 \
|
||||
#define LIST_WIDGET_FUNCTION_3 \
|
||||
inline void addItem(QWidget *w, int index) { inner_layout.insertWidget(index, w); } \
|
||||
|
||||
#define LIST_WIDGET_FUNCTION_4 \
|
||||
inline void ReplaceOrAddWidget(QWidget *old_widget, QWidget *new_widget) { \
|
||||
if (const int index = inner_layout.indexOf(old_widget); index != -1) { \
|
||||
RemoveWidgetAt(index); \
|
||||
AddWidgetAt(index, new_widget); \
|
||||
} else { \
|
||||
addItem(new_widget); \
|
||||
addItem(new_widget, 0); \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
Reference in New Issue
Block a user