[app] Show book title on top of default cover image

This commit is contained in:
Slava Monich 2022-10-31 17:52:02 +02:00
parent 74b666ec5e
commit b12d1be404
3 changed files with 41 additions and 35 deletions

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2015-2021 Jolla Ltd.
Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
Copyright (C) 2015-2022 Jolla Ltd.
Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of the BSD license as follows:
@ -38,10 +38,10 @@ CoverBackground {
id: root
transparent: !_haveBook || grid.count < 6
property variant book
property variant shelf
property var book
property var shelf
property bool _haveBook: book ? true : false
readonly property bool _haveBook: book ? true : false
CoverModel {
id: coverModel
@ -105,7 +105,7 @@ CoverBackground {
fill: parent
}
text: book ? book.title : ""
visible: bookCover.empty
color: "#FFE898"
visible: book && !book.hasCover
color: "#ffe898" // Derived from the default cover image
}
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2021 Jolla Ltd.
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2022 Jolla Ltd.
* Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@ -71,9 +71,9 @@ class BooksBook::CoverPaintContext : public BooksPaintContext {
public:
CoverPaintContext();
void drawImage(int x, int y, const ZLImageData& image);
void drawImage(int x, int y, const ZLImageData& image, int width, int height, ScalingType type);
void handleImage(const ZLImageData& image);
void drawImage(int, int, const ZLImageData&) Q_DECL_OVERRIDE;
void drawImage(int, int, const ZLImageData&, int, int, ScalingType) Q_DECL_OVERRIDE;
void handleImage(const ZLImageData&);
bool gotIt() const;
public:
@ -532,11 +532,15 @@ bool BooksBook::hasCoverImage() const
return iCoverImage.width() > 0 && iCoverImage.height() > 0;
}
void BooksBook::setCoverImage(QImage aImage)
void BooksBook::setCoverImage(const QImage aImage)
{
if (iCoverImage != aImage) {
const bool hadCover = hasCoverImage();
iCoverImage = aImage;
Q_EMIT coverImageChanged();
if (hadCover != hasCoverImage()) {
Q_EMIT hasCoverChanged();
}
}
}
@ -568,8 +572,7 @@ bool BooksBook::coverTaskDone()
HDEBUG(iTitle << iCoverTask->hasImage());
const bool gotCover = iCoverTask->hasImage();
if (gotCover) {
iCoverImage = iCoverTask->iCoverImage;
Q_EMIT coverImageChanged();
setCoverImage(iCoverTask->iCoverImage);
}
iCoverTask->release(this);
iCoverTask = NULL;

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2021 Jolla Ltd.
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2022 Jolla Ltd.
* Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@ -47,7 +47,9 @@
#include <QImage>
#include <QtQml>
class BooksBook : public QObject, public BooksItem
class BooksBook :
public QObject,
public BooksItem
{
class HashTask;
class CoverTask;
@ -63,6 +65,7 @@ class BooksBook : public QObject, public BooksItem
Q_PROPERTY(BooksBook* book READ book CONSTANT)
Q_PROPERTY(bool accessible READ accessible NOTIFY accessibleChanged)
Q_PROPERTY(bool loadingCover READ loadingCover NOTIFY loadingCoverChanged)
Q_PROPERTY(bool hasCover READ hasCoverImage NOTIFY hasCoverChanged)
Q_PROPERTY(bool copyingOut READ copyingOut NOTIFY copyingOutChanged)
Q_PROPERTY(bool fontSizeAdjust READ fontSizeAdjust WRITE setFontSizeAdjust NOTIFY fontSizeAdjustChanged)
@ -80,7 +83,7 @@ public:
QString authors() const;
QByteArray hash() const;
int fontSizeAdjust() const;
bool setFontSizeAdjust(int aFontSizeAdjust);
bool setFontSizeAdjust(int);
int pageStackPos() const;
BooksPos::List pageStack() const;
void setPageStack(BooksPos::List aStack, int aStackPos);
@ -92,25 +95,25 @@ public:
bool hasCoverImage() const;
bool requestCoverImage();
void cancelCoverRequest();
void setCoverImage(QImage aImage);
void setCoverImage(const QImage);
QImage coverImage() const;
void setCopyingOut(bool aValue);
void setCopyingOut(bool);
// BooksItem
virtual BooksItem* retain();
virtual void release();
virtual QObject* object();
virtual BooksShelf* shelf();
virtual BooksBook* book();
virtual QString name() const;
virtual QString fileName() const;
virtual QString path() const;
virtual bool accessible() const;
virtual void deleteFiles();
virtual BooksItem* copyTo(const BooksStorage& aStorage, QString aRelPath,
CopyOperation* aObserver);
BooksItem* retain() Q_DECL_OVERRIDE;
void release() Q_DECL_OVERRIDE;
QObject* object() Q_DECL_OVERRIDE;
BooksShelf* shelf() Q_DECL_OVERRIDE;
BooksBook* book() Q_DECL_OVERRIDE;
QString name() const Q_DECL_OVERRIDE;
QString fileName() const Q_DECL_OVERRIDE;
QString path() const Q_DECL_OVERRIDE;
bool accessible() const Q_DECL_OVERRIDE;
void deleteFiles() Q_DECL_OVERRIDE;
BooksItem* copyTo(const BooksStorage&, QString, CopyOperation*) Q_DECL_OVERRIDE;
Q_SIGNALS:
void hasCoverChanged();
void coverImageChanged();
void loadingCoverChanged();
void accessibleChanged();
@ -128,10 +131,10 @@ private Q_SLOTS:
private:
void init();
bool coverTaskDone();
bool makeLink(QString aDestPath);
bool makeLink(QString);
void requestSave();
QString cachedImagePath() const;
static bool isCanceled(CopyOperation* aOperation);
static bool isCanceled(CopyOperation*);
private:
QAtomicInt iRef;