hide chapters for formats that doesn't support it

This commit is contained in:
Agel committed 2026-03-19 22:34:34 +01:00
1 parent 353c82f6d6
commit cf1721f916
4 files changed
+45 -3

No files matched your search

+5
View File
@@ -44,6 +44,11 @@ int ReadingModel::totalChapters() const
return m_totalChapters;
}
bool ReadingModel::hasChapters() const
{
return m_totalChapters > 1;
}
double ReadingModel::progress() const
{
if (m_totalChapters == 0)
+2
View File
@@ -13,6 +13,7 @@ class ReadingModel : public QAbstractListModel {
Q_PROPERTY(int currentChapter READ currentChapter NOTIFY chapterChanged)
Q_PROPERTY(int totalChapters READ totalChapters NOTIFY totalChaptersChanged)
Q_PROPERTY(double progress READ progress NOTIFY chapterChanged)
Q_PROPERTY(bool hasChapters READ hasChapters NOTIFY totalChaptersChanged)
public:
enum Roles {
@@ -30,6 +31,7 @@ public:
int currentChapter() const;
int totalChapters() const;
double progress() const;
bool hasChapters() const;
void setReader(FormatReader *reader);
Q_INVOKABLE void nextChapter();
+3 -3
View File
@@ -15,7 +15,7 @@ Rectangle {
Text {
anchors.verticalCenter: parent.verticalCenter
x: parent.width * 0.5
text: bookController.hasBook
text: bookController.hasBook && readingModel.hasChapters
? "Chapter " + (readingModel.currentChapter + 1) + " / " + readingModel.totalChapters
: ""
font.pixelSize: 11
@@ -27,8 +27,8 @@ Rectangle {
anchors.right: parent.right
anchors.rightMargin: 16
anchors.verticalCenter: parent.verticalCenter
visible: bookController.hasBook
text: bookController.hasBook
visible: bookController.hasBook && readingModel.hasChapters
text: bookController.hasBook && readingModel.hasChapters
? (readingModel.currentChapter + 1) + "/" + readingModel.totalChapters
: ""
font.pixelSize: 11