mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
fix(cppcheck): resolve style and performance issues
- Remove unused HomeActivity::restoreCoverBuffer - Use initialization lists in constructors - Mark single-argument constructors as explicit
This commit is contained in:
parent
75cc861bd0
commit
a4310bf2c3
@ -23,7 +23,7 @@ class Container : public UIElement {
|
|||||||
int borderRadius = 0; // Corner radius (for future rounded rect support)
|
int borderRadius = 0; // Corner radius (for future rounded rect support)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Container(const std::string& id) : UIElement(id) { bgColorExpr = Expression::parse("0xFF"); }
|
explicit Container(const std::string& id) : UIElement(id), bgColorExpr(Expression::parse("0xFF")) {}
|
||||||
virtual ~Container() {
|
virtual ~Container() {
|
||||||
for (auto child : children) delete child;
|
for (auto child : children) delete child;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ class Rectangle : public UIElement {
|
|||||||
Expression colorExpr;
|
Expression colorExpr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rectangle(const std::string& id) : UIElement(id) { colorExpr = Expression::parse("0x00"); }
|
explicit Rectangle(const std::string& id) : UIElement(id), colorExpr(Expression::parse("0x00")) {}
|
||||||
ElementType getType() const override { return ElementType::Rectangle; }
|
ElementType getType() const override { return ElementType::Rectangle; }
|
||||||
|
|
||||||
void setFill(bool f) {
|
void setFill(bool f) {
|
||||||
@ -199,7 +199,7 @@ class Label : public UIElement {
|
|||||||
bool ellipsis = true; // Truncate with ... if too long
|
bool ellipsis = true; // Truncate with ... if too long
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Label(const std::string& id) : UIElement(id) { colorExpr = Expression::parse("0x00"); }
|
explicit Label(const std::string& id) : UIElement(id), colorExpr(Expression::parse("0x00")) {}
|
||||||
ElementType getType() const override { return ElementType::Label; }
|
ElementType getType() const override { return ElementType::Label; }
|
||||||
|
|
||||||
void setText(const std::string& expr) {
|
void setText(const std::string& expr) {
|
||||||
@ -367,7 +367,7 @@ class BitmapElement : public UIElement {
|
|||||||
int borderRadius = 0;
|
int borderRadius = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BitmapElement(const std::string& id) : UIElement(id) {
|
explicit BitmapElement(const std::string& id) : UIElement(id) {
|
||||||
cacheable = true; // Bitmaps benefit from caching
|
cacheable = true; // Bitmaps benefit from caching
|
||||||
}
|
}
|
||||||
ElementType getType() const override { return ElementType::Bitmap; }
|
ElementType getType() const override { return ElementType::Bitmap; }
|
||||||
@ -407,12 +407,13 @@ class ProgressBar : public UIElement {
|
|||||||
int borderWidth = 1;
|
int borderWidth = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProgressBar(const std::string& id) : UIElement(id) {
|
explicit ProgressBar(const std::string& id)
|
||||||
valueExpr = Expression::parse("0");
|
: UIElement(id),
|
||||||
maxExpr = Expression::parse("100");
|
valueExpr(Expression::parse("0")),
|
||||||
fgColorExpr = Expression::parse("0x00"); // Black fill
|
maxExpr(Expression::parse("100")),
|
||||||
bgColorExpr = Expression::parse("0xFF"); // White background
|
fgColorExpr(Expression::parse("0x00")), // Black fill
|
||||||
}
|
bgColorExpr(Expression::parse("0xFF")) // White background
|
||||||
|
{}
|
||||||
|
|
||||||
ElementType getType() const override { return ElementType::ProgressBar; }
|
ElementType getType() const override { return ElementType::ProgressBar; }
|
||||||
|
|
||||||
@ -480,7 +481,7 @@ class Divider : public UIElement {
|
|||||||
int thickness = 1;
|
int thickness = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Divider(const std::string& id) : UIElement(id) { colorExpr = Expression::parse("0x00"); }
|
explicit Divider(const std::string& id) : UIElement(id), colorExpr(Expression::parse("0x00")) {}
|
||||||
|
|
||||||
ElementType getType() const override { return ElementType::Divider; }
|
ElementType getType() const override { return ElementType::Divider; }
|
||||||
|
|
||||||
@ -524,9 +525,9 @@ class BatteryIcon : public UIElement {
|
|||||||
Expression colorExpr;
|
Expression colorExpr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BatteryIcon(const std::string& id) : UIElement(id) {
|
explicit BatteryIcon(const std::string& id)
|
||||||
valueExpr = Expression::parse("0");
|
: UIElement(id), valueExpr(Expression::parse("0")), colorExpr(Expression::parse("0x00")) {
|
||||||
colorExpr = Expression::parse("0x00"); // Black by default
|
// Black by default
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementType getType() const override { return ElementType::BatteryIcon; }
|
ElementType getType() const override { return ElementType::BatteryIcon; }
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class ThemeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThemeContext(const ThemeContext* parent = nullptr) : parent(parent) {}
|
explicit ThemeContext(const ThemeContext* parent = nullptr) : parent(parent) {}
|
||||||
|
|
||||||
void setString(const std::string& key, const std::string& value) { strings[key] = value; }
|
void setString(const std::string& key, const std::string& value) { strings[key] = value; }
|
||||||
void setInt(const std::string& key, int value) { ints[key] = value; }
|
void setInt(const std::string& key, int value) { ints[key] = value; }
|
||||||
|
|||||||
@ -34,7 +34,7 @@ struct Dimension {
|
|||||||
struct Color {
|
struct Color {
|
||||||
uint8_t value; // For E-Ink: 0 (Black) to 255 (White), or simplified palette
|
uint8_t value; // For E-Ink: 0 (Black) to 255 (White), or simplified palette
|
||||||
|
|
||||||
Color(uint8_t v) : value(v) {}
|
explicit Color(uint8_t v) : value(v) {}
|
||||||
Color() : value(0) {}
|
Color() : value(0) {}
|
||||||
|
|
||||||
static Color parse(const std::string& str) {
|
static Color parse(const std::string& str) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class UIElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UIElement(const std::string& id) : id(id) { visibleExpr = Expression::parse("true"); }
|
UIElement(const std::string& id) : id(id), visibleExpr(Expression::parse("true")) {}
|
||||||
|
|
||||||
virtual ~UIElement() {
|
virtual ~UIElement() {
|
||||||
if (cachedRender) {
|
if (cachedRender) {
|
||||||
|
|||||||
@ -229,20 +229,7 @@ bool HomeActivity::storeCoverBuffer() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HomeActivity::restoreCoverBuffer() {
|
|
||||||
if (!coverBuffer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* frameBuffer = renderer.getFrameBuffer();
|
|
||||||
if (!frameBuffer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t bufferSize = GfxRenderer::getBufferSize();
|
|
||||||
memcpy(frameBuffer, coverBuffer, bufferSize);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HomeActivity::freeCoverBuffer() {
|
void HomeActivity::freeCoverBuffer() {
|
||||||
if (coverBuffer) {
|
if (coverBuffer) {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class HomeActivity final : public Activity {
|
|||||||
void render();
|
void render();
|
||||||
int getMenuItemCount() const;
|
int getMenuItemCount() const;
|
||||||
bool storeCoverBuffer(); // Store frame buffer for cover image
|
bool storeCoverBuffer(); // Store frame buffer for cover image
|
||||||
bool restoreCoverBuffer(); // Restore frame buffer from stored cover
|
|
||||||
void freeCoverBuffer(); // Free the stored cover buffer
|
void freeCoverBuffer(); // Free the stored cover buffer
|
||||||
void loadRecentBooksData(); // Load and cache recent books data
|
void loadRecentBooksData(); // Load and cache recent books data
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user