mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-08 00:27:39 +03:00
changed range of wpms, moved time left before pages in chapter, always shows minutes now (not hours)
This commit is contained in:
parent
993a52a639
commit
58985119f1
@ -27,21 +27,8 @@ std::string formatMinutes(const float minutes) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const int totalMinutes = static_cast<int>(std::ceil(minutes));
|
const int totalMinutes = static_cast<int>(std::floor(minutes));
|
||||||
if (totalMinutes < 60) {
|
return std::to_string(totalMinutes) + "m";
|
||||||
return std::to_string(totalMinutes) + "m";
|
|
||||||
}
|
|
||||||
|
|
||||||
const int hours = totalMinutes / 60;
|
|
||||||
const int mins = totalMinutes % 60;
|
|
||||||
|
|
||||||
char buffer[12];
|
|
||||||
if (mins == 0) {
|
|
||||||
std::snprintf(buffer, sizeof(buffer), "%dh", hours);
|
|
||||||
} else {
|
|
||||||
std::snprintf(buffer, sizeof(buffer), "%dh %02dm", hours, mins);
|
|
||||||
}
|
|
||||||
return std::string(buffer);
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -453,6 +440,8 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
// Calculate progress in book
|
// Calculate progress in book
|
||||||
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
|
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
|
||||||
std::string timeLeftText;
|
std::string timeLeftText;
|
||||||
|
const uint8_t bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg);
|
||||||
|
|
||||||
if (SETTINGS.showTimeLeftInChapter && SETTINGS.readingSpeedWpm > 0) {
|
if (SETTINGS.showTimeLeftInChapter && SETTINGS.readingSpeedWpm > 0) {
|
||||||
const uint32_t wordsLeft = section->getWordsLeftFrom(section->currentPage);
|
const uint32_t wordsLeft = section->getWordsLeftFrom(section->currentPage);
|
||||||
if (wordsLeft > 0) {
|
if (wordsLeft > 0) {
|
||||||
@ -461,12 +450,10 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
|
|||||||
timeLeftText = formatMinutes(minutesLeft);
|
timeLeftText = formatMinutes(minutesLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const uint8_t bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg);
|
|
||||||
|
|
||||||
// Right aligned text for progress counter
|
// Right aligned text for progress counter
|
||||||
const std::string progress = std::to_string(section->currentPage + 1) + "/" + std::to_string(section->pageCount) +
|
const std::string progress = (timeLeftText.empty() ? std::string() : timeLeftText + " ") +
|
||||||
" " + std::to_string(bookProgress) + "%" +
|
std::to_string(section->currentPage + 1) + "/" + std::to_string(section->pageCount) +
|
||||||
(timeLeftText.empty() ? std::string() : " " + timeLeftText + " left");
|
" " + std::to_string(bookProgress) + "%";
|
||||||
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progress.c_str());
|
progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progress.c_str());
|
||||||
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
renderer.drawText(SMALL_FONT_ID, renderer.getScreenWidth() - orientedMarginRight - progressTextWidth, textY,
|
||||||
progress.c_str());
|
progress.c_str());
|
||||||
|
|||||||
@ -35,8 +35,8 @@ const SettingInfo settingsList[settingsCount] = {
|
|||||||
SettingInfo::Value("Reader Screen Margin", &CrossPointSettings::screenMargin, {5, 40, 5}),
|
SettingInfo::Value("Reader Screen Margin", &CrossPointSettings::screenMargin, {5, 40, 5}),
|
||||||
SettingInfo::Enum("Reader Paragraph Alignment", &CrossPointSettings::paragraphAlignment,
|
SettingInfo::Enum("Reader Paragraph Alignment", &CrossPointSettings::paragraphAlignment,
|
||||||
{"Justify", "Left", "Center", "Right"}),
|
{"Justify", "Left", "Center", "Right"}),
|
||||||
SettingInfo::Value("Reading Speed (WPM)", &CrossPointSettings::readingSpeedWpm, {80, 300, 10}),
|
SettingInfo::Value("Reading Speed (WPM)", &CrossPointSettings::readingSpeedWpm, {150, 300, 5}),
|
||||||
SettingInfo::Toggle("Show Time Left", &CrossPointSettings::showTimeLeftInChapter),
|
SettingInfo::Toggle("Show Time Left In Chapter", &CrossPointSettings::showTimeLeftInChapter),
|
||||||
SettingInfo::Enum("Time to Sleep", &CrossPointSettings::sleepTimeout,
|
SettingInfo::Enum("Time to Sleep", &CrossPointSettings::sleepTimeout,
|
||||||
{"1 min", "5 min", "10 min", "15 min", "30 min"}),
|
{"1 min", "5 min", "10 min", "15 min", "30 min"}),
|
||||||
SettingInfo::Enum("Refresh Frequency", &CrossPointSettings::refreshFrequency,
|
SettingInfo::Enum("Refresh Frequency", &CrossPointSettings::refreshFrequency,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user