mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +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
667e4d954c
commit
092fcafd19
@ -23,7 +23,7 @@ class Container : public UIElement {
|
||||
int borderRadius = 0; // Corner radius (for future rounded rect support)
|
||||
|
||||
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() {
|
||||
for (auto child : children) delete child;
|
||||
}
|
||||
@ -145,7 +145,7 @@ class Rectangle : public UIElement {
|
||||
Expression colorExpr;
|
||||
|
||||
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; }
|
||||
|
||||
void setFill(bool f) {
|
||||
@ -199,7 +199,7 @@ class Label : public UIElement {
|
||||
bool ellipsis = true; // Truncate with ... if too long
|
||||
|
||||
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; }
|
||||
|
||||
void setText(const std::string& expr) {
|
||||
@ -367,7 +367,7 @@ class BitmapElement : public UIElement {
|
||||
int borderRadius = 0;
|
||||
|
||||
public:
|
||||
BitmapElement(const std::string& id) : UIElement(id) {
|
||||
explicit BitmapElement(const std::string& id) : UIElement(id) {
|
||||
cacheable = true; // Bitmaps benefit from caching
|
||||
}
|
||||
ElementType getType() const override { return ElementType::Bitmap; }
|
||||
@ -407,12 +407,13 @@ class ProgressBar : public UIElement {
|
||||
int borderWidth = 1;
|
||||
|
||||
public:
|
||||
ProgressBar(const std::string& id) : UIElement(id) {
|
||||
valueExpr = Expression::parse("0");
|
||||
maxExpr = Expression::parse("100");
|
||||
fgColorExpr = Expression::parse("0x00"); // Black fill
|
||||
bgColorExpr = Expression::parse("0xFF"); // White background
|
||||
}
|
||||
explicit ProgressBar(const std::string& id)
|
||||
: UIElement(id),
|
||||
valueExpr(Expression::parse("0")),
|
||||
maxExpr(Expression::parse("100")),
|
||||
fgColorExpr(Expression::parse("0x00")), // Black fill
|
||||
bgColorExpr(Expression::parse("0xFF")) // White background
|
||||
{}
|
||||
|
||||
ElementType getType() const override { return ElementType::ProgressBar; }
|
||||
|
||||
@ -480,7 +481,7 @@ class Divider : public UIElement {
|
||||
int thickness = 1;
|
||||
|
||||
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; }
|
||||
|
||||
@ -524,9 +525,9 @@ class BatteryIcon : public UIElement {
|
||||
Expression colorExpr;
|
||||
|
||||
public:
|
||||
BatteryIcon(const std::string& id) : UIElement(id) {
|
||||
valueExpr = Expression::parse("0");
|
||||
colorExpr = Expression::parse("0x00"); // Black by default
|
||||
explicit BatteryIcon(const std::string& id)
|
||||
: UIElement(id), valueExpr(Expression::parse("0")), colorExpr(Expression::parse("0x00")) {
|
||||
// Black by default
|
||||
}
|
||||
|
||||
ElementType getType() const override { return ElementType::BatteryIcon; }
|
||||
|
||||
@ -83,7 +83,7 @@ class ThemeContext {
|
||||
}
|
||||
|
||||
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 setInt(const std::string& key, int value) { ints[key] = value; }
|
||||
|
||||
@ -34,7 +34,7 @@ struct Dimension {
|
||||
struct Color {
|
||||
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) {}
|
||||
|
||||
static Color parse(const std::string& str) {
|
||||
|
||||
@ -45,7 +45,7 @@ class UIElement {
|
||||
}
|
||||
|
||||
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() {
|
||||
if (cachedRender) {
|
||||
|
||||
@ -232,20 +232,7 @@ bool HomeActivity::storeCoverBuffer() {
|
||||
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() {
|
||||
if (coverBuffer) {
|
||||
|
||||
@ -47,7 +47,7 @@ class HomeActivity final : public Activity {
|
||||
void render();
|
||||
int getMenuItemCount() const;
|
||||
bool storeCoverBuffer(); // Store frame buffer for cover image
|
||||
bool restoreCoverBuffer(); // Restore frame buffer from stored cover
|
||||
|
||||
void freeCoverBuffer(); // Free the stored cover buffer
|
||||
void loadRecentBooksData(); // Load and cache recent books data
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user