Skip to content

Commit

Permalink
Visuals - Custom Themes - Icon Pack
Browse files Browse the repository at this point in the history
Switch out the standard openpilot icons with a set of themed icons.

Want to submit your own icon pack? Post it in the 'feature-request' channel in the FrogPilot Discord!
  • Loading branch information
FrogAi committed Aug 6, 2024
1 parent 2740c83 commit 100f604
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions selfdrive/ui/qt/sidebar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(
{3, {"stalin_theme", {QColor(255, 0, 0)}}}
};

for (auto &[key, themeData] : themeConfiguration) {
QString &themeName = themeData.first;
QString base = themeName == "stock" ? "../assets/images" : QString("../frogpilot/assets/custom_themes/%1/images").arg(themeName);
std::vector<QString> paths = {base + "/button_home.png", base + "/button_flag.png", base + "/button_settings.png"};

home_imgs[key] = loadPixmap(paths[0], home_btn.size());
flag_imgs[key] = loadPixmap(paths[1], home_btn.size());
settings_imgs[key] = loadPixmap(paths[2], settings_btn.size(), Qt::IgnoreAspectRatio);
}

home_img = home_imgs[scene.custom_icons];
flag_img = flag_imgs[scene.custom_icons];
settings_img = settings_imgs[scene.custom_icons];
currentColors = themeConfiguration[scene.custom_colors].second;
}

Expand Down Expand Up @@ -95,6 +108,10 @@ void Sidebar::updateState(const UIState &s) {
// FrogPilot properties
const UIScene &scene = s.scene;

home_img = home_imgs[scene.custom_icons];
flag_img = flag_imgs[scene.custom_icons];
settings_img = settings_imgs[scene.custom_icons];

currentColors = themeConfiguration[scene.custom_colors].second;

auto frogpilotDeviceState = sm["frogpilotDeviceState"].getFrogpilotDeviceState();
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/qt/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public slots:
Params params;

std::unordered_map<int, std::pair<QString, std::vector<QColor>>> themeConfiguration;
std::unordered_map<int, QPixmap> flag_imgs;
std::unordered_map<int, QPixmap> home_imgs;
std::unordered_map<int, QPixmap> settings_imgs;

std::vector<QColor> currentColors;
};
1 change: 1 addition & 0 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void ui_update_frogpilot_params(UIState *s, Params &params) {

bool custom_theme = params.getBool("CustomTheme");
scene.custom_colors = custom_theme ? params.getInt("CustomColors") : 0;
scene.custom_icons = custom_theme ? params.getInt("CustomIcons") : 0;

scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing");
scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing");
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ typedef struct UIScene {
int conditional_speed_lead;
int conditional_status;
int custom_colors;
int custom_icons;
int model_length;
int steering_angle_deg;
int tethering_config;
Expand Down

0 comments on commit 100f604

Please sign in to comment.