mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 23:27:38 +03:00
fix some cppcheck complains
This commit is contained in:
parent
9a8aeee5ae
commit
4f227ec277
@ -498,29 +498,29 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
// Position status bar near the bottom of the logical screen, regardless of orientation
|
// Position status bar near the bottom of the logical screen, regardless of orientation
|
||||||
const auto screenHeight = renderer.getScreenHeight();
|
const auto screenHeight = renderer.getScreenHeight();
|
||||||
const auto textY = screenHeight - orientedMarginBottom - 4;
|
const auto textY = screenHeight - orientedMarginBottom - 4;
|
||||||
int progressTextWidth = 0;
|
|
||||||
|
|
||||||
if (showProgress) {
|
if (showProgress) {
|
||||||
// Calculate progress in book
|
// Calculate progress in book
|
||||||
|
// TODO: use progress values for UI
|
||||||
|
|
||||||
|
// cppcheck-suppress unreadVariable
|
||||||
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
|
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
|
||||||
|
// cppcheck-suppress unreadVariable
|
||||||
const float bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg) * 100;
|
const float bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
// Left aligned battery icon and percentage
|
// Left aligned battery icon and percentage
|
||||||
if (showBattery) {
|
if (showBattery) {
|
||||||
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
|
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showBattery) {
|
|
||||||
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showChapterTitle) {
|
if (showChapterTitle) {
|
||||||
// Centered chatper title text
|
// Centered chatper title text
|
||||||
// Page width minus existing content with 30px padding on each side
|
// Page width minus existing content with 30px padding on each side
|
||||||
const int rendererableScreenWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
|
const int rendererableScreenWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
|
||||||
|
|
||||||
|
int progressTextWidth = 0;
|
||||||
const int batterySize = showBattery ? (showBatteryPercentage ? 50 : 20) : 0;
|
const int batterySize = showBattery ? (showBatteryPercentage ? 50 : 20) : 0;
|
||||||
const int titleMarginLeft = batterySize + 30;
|
const int titleMarginLeft = batterySize + 30;
|
||||||
const int titleMarginRight = progressTextWidth + 30;
|
const int titleMarginRight = progressTextWidth + 30;
|
||||||
@ -630,8 +630,8 @@ void EpubReaderActivity::navigateToHref(const char* href, bool savePosition) {
|
|||||||
|
|
||||||
BookMetadataCache::SpineEntry entry = epub->getSpineItem(i);
|
BookMetadataCache::SpineEntry entry = epub->getSpineItem(i);
|
||||||
std::string spineItem = entry.href;
|
std::string spineItem = entry.href;
|
||||||
size_t lastSlash = spineItem.find_last_of('/');
|
size_t lastslash = spineItem.find_last_of('/');
|
||||||
std::string spineFilename = (lastSlash != std::string::npos) ? spineItem.substr(lastSlash + 1) : spineItem;
|
std::string spineFilename = (lastslash != std::string::npos) ? spineItem.substr(lastslash + 1) : spineItem;
|
||||||
|
|
||||||
if (spineFilename == filename) {
|
if (spineFilename == filename) {
|
||||||
targetSpineIndex = i;
|
targetSpineIndex = i;
|
||||||
|
|||||||
@ -14,23 +14,7 @@ constexpr int SKIP_PAGE_MS = 700;
|
|||||||
|
|
||||||
bool EpubReaderChapterSelectionActivity::hasSyncOption() const { return KOREADER_STORE.hasCredentials(); }
|
bool EpubReaderChapterSelectionActivity::hasSyncOption() const { return KOREADER_STORE.hasCredentials(); }
|
||||||
|
|
||||||
int EpubReaderChapterSelectionActivity::getTotalItems() const {
|
|
||||||
// Add 2 for sync options (top and bottom) if credentials are configured
|
|
||||||
const int syncCount = hasSyncOption() ? 2 : 0;
|
|
||||||
return epub->getTocItemsCount() + syncCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EpubReaderChapterSelectionActivity::isSyncItem(int index) const {
|
|
||||||
if (!hasSyncOption()) return false;
|
|
||||||
// First item and last item are sync options
|
|
||||||
return index == 0 || index == getTotalItems() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EpubReaderChapterSelectionActivity::tocIndexFromItemIndex(int itemIndex) const {
|
|
||||||
// Account for the sync option at the top
|
|
||||||
const int offset = hasSyncOption() ? 1 : 0;
|
|
||||||
return itemIndex - offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EpubReaderChapterSelectionActivity::getPageItems() const {
|
int EpubReaderChapterSelectionActivity::getPageItems() const {
|
||||||
// Layout constants used in renderScreen
|
// Layout constants used in renderScreen
|
||||||
|
|||||||
@ -27,18 +27,10 @@ class EpubReaderChapterSelectionActivity final : public ActivityWithSubactivity
|
|||||||
// This adapts automatically when switching between portrait and landscape.
|
// This adapts automatically when switching between portrait and landscape.
|
||||||
int getPageItems() const;
|
int getPageItems() const;
|
||||||
|
|
||||||
// Total items including sync options (top and bottom)
|
|
||||||
int getTotalItems() const;
|
|
||||||
|
|
||||||
// Check if sync option is available (credentials configured)
|
// Check if sync option is available (credentials configured)
|
||||||
bool hasSyncOption() const;
|
bool hasSyncOption() const;
|
||||||
|
|
||||||
// Check if given item index is a sync option (first or last)
|
|
||||||
bool isSyncItem(int index) const;
|
|
||||||
|
|
||||||
// Convert item index to TOC index (accounting for top sync option offset)
|
|
||||||
int tocIndexFromItemIndex(int itemIndex) const;
|
|
||||||
|
|
||||||
// Filtered list of spine indices (excluding footnote pages)
|
// Filtered list of spine indices (excluding footnote pages)
|
||||||
std::vector<int> filteredSpineIndices;
|
std::vector<int> filteredSpineIndices;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user