[app] Show book title on top of default cover image
This commit is contained in:
parent
74b666ec5e
commit
b12d1be404
3 changed files with 41 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2015-2021 Jolla Ltd.
|
Copyright (C) 2015-2022 Jolla Ltd.
|
||||||
Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
|
Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
|
|
||||||
You may use this file under the terms of the BSD license as follows:
|
You may use this file under the terms of the BSD license as follows:
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ CoverBackground {
|
||||||
id: root
|
id: root
|
||||||
transparent: !_haveBook || grid.count < 6
|
transparent: !_haveBook || grid.count < 6
|
||||||
|
|
||||||
property variant book
|
property var book
|
||||||
property variant shelf
|
property var shelf
|
||||||
|
|
||||||
property bool _haveBook: book ? true : false
|
readonly property bool _haveBook: book ? true : false
|
||||||
|
|
||||||
CoverModel {
|
CoverModel {
|
||||||
id: coverModel
|
id: coverModel
|
||||||
|
@ -105,7 +105,7 @@ CoverBackground {
|
||||||
fill: parent
|
fill: parent
|
||||||
}
|
}
|
||||||
text: book ? book.title : ""
|
text: book ? book.title : ""
|
||||||
visible: bookCover.empty
|
visible: book && !book.hasCover
|
||||||
color: "#FFE898"
|
color: "#ffe898" // Derived from the default cover image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
* Copyright (C) 2015-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of the BSD license as follows:
|
* You may use this file under the terms of the BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -71,9 +71,9 @@ class BooksBook::CoverPaintContext : public BooksPaintContext {
|
||||||
public:
|
public:
|
||||||
CoverPaintContext();
|
CoverPaintContext();
|
||||||
|
|
||||||
void drawImage(int x, int y, const ZLImageData& image);
|
void drawImage(int, int, const ZLImageData&) Q_DECL_OVERRIDE;
|
||||||
void drawImage(int x, int y, const ZLImageData& image, int width, int height, ScalingType type);
|
void drawImage(int, int, const ZLImageData&, int, int, ScalingType) Q_DECL_OVERRIDE;
|
||||||
void handleImage(const ZLImageData& image);
|
void handleImage(const ZLImageData&);
|
||||||
bool gotIt() const;
|
bool gotIt() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -532,11 +532,15 @@ bool BooksBook::hasCoverImage() const
|
||||||
return iCoverImage.width() > 0 && iCoverImage.height() > 0;
|
return iCoverImage.width() > 0 && iCoverImage.height() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BooksBook::setCoverImage(QImage aImage)
|
void BooksBook::setCoverImage(const QImage aImage)
|
||||||
{
|
{
|
||||||
if (iCoverImage != aImage) {
|
if (iCoverImage != aImage) {
|
||||||
|
const bool hadCover = hasCoverImage();
|
||||||
iCoverImage = aImage;
|
iCoverImage = aImage;
|
||||||
Q_EMIT coverImageChanged();
|
Q_EMIT coverImageChanged();
|
||||||
|
if (hadCover != hasCoverImage()) {
|
||||||
|
Q_EMIT hasCoverChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,8 +572,7 @@ bool BooksBook::coverTaskDone()
|
||||||
HDEBUG(iTitle << iCoverTask->hasImage());
|
HDEBUG(iTitle << iCoverTask->hasImage());
|
||||||
const bool gotCover = iCoverTask->hasImage();
|
const bool gotCover = iCoverTask->hasImage();
|
||||||
if (gotCover) {
|
if (gotCover) {
|
||||||
iCoverImage = iCoverTask->iCoverImage;
|
setCoverImage(iCoverTask->iCoverImage);
|
||||||
Q_EMIT coverImageChanged();
|
|
||||||
}
|
}
|
||||||
iCoverTask->release(this);
|
iCoverTask->release(this);
|
||||||
iCoverTask = NULL;
|
iCoverTask = NULL;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2021 Jolla Ltd.
|
* Copyright (C) 2015-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2015-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of the BSD license as follows:
|
* You may use this file under the terms of the BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -47,7 +47,9 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
|
||||||
class BooksBook : public QObject, public BooksItem
|
class BooksBook :
|
||||||
|
public QObject,
|
||||||
|
public BooksItem
|
||||||
{
|
{
|
||||||
class HashTask;
|
class HashTask;
|
||||||
class CoverTask;
|
class CoverTask;
|
||||||
|
@ -63,6 +65,7 @@ class BooksBook : public QObject, public BooksItem
|
||||||
Q_PROPERTY(BooksBook* book READ book CONSTANT)
|
Q_PROPERTY(BooksBook* book READ book CONSTANT)
|
||||||
Q_PROPERTY(bool accessible READ accessible NOTIFY accessibleChanged)
|
Q_PROPERTY(bool accessible READ accessible NOTIFY accessibleChanged)
|
||||||
Q_PROPERTY(bool loadingCover READ loadingCover NOTIFY loadingCoverChanged)
|
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 copyingOut READ copyingOut NOTIFY copyingOutChanged)
|
||||||
Q_PROPERTY(bool fontSizeAdjust READ fontSizeAdjust WRITE setFontSizeAdjust NOTIFY fontSizeAdjustChanged)
|
Q_PROPERTY(bool fontSizeAdjust READ fontSizeAdjust WRITE setFontSizeAdjust NOTIFY fontSizeAdjustChanged)
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ public:
|
||||||
QString authors() const;
|
QString authors() const;
|
||||||
QByteArray hash() const;
|
QByteArray hash() const;
|
||||||
int fontSizeAdjust() const;
|
int fontSizeAdjust() const;
|
||||||
bool setFontSizeAdjust(int aFontSizeAdjust);
|
bool setFontSizeAdjust(int);
|
||||||
int pageStackPos() const;
|
int pageStackPos() const;
|
||||||
BooksPos::List pageStack() const;
|
BooksPos::List pageStack() const;
|
||||||
void setPageStack(BooksPos::List aStack, int aStackPos);
|
void setPageStack(BooksPos::List aStack, int aStackPos);
|
||||||
|
@ -92,25 +95,25 @@ public:
|
||||||
bool hasCoverImage() const;
|
bool hasCoverImage() const;
|
||||||
bool requestCoverImage();
|
bool requestCoverImage();
|
||||||
void cancelCoverRequest();
|
void cancelCoverRequest();
|
||||||
void setCoverImage(QImage aImage);
|
void setCoverImage(const QImage);
|
||||||
QImage coverImage() const;
|
QImage coverImage() const;
|
||||||
void setCopyingOut(bool aValue);
|
void setCopyingOut(bool);
|
||||||
|
|
||||||
// BooksItem
|
// BooksItem
|
||||||
virtual BooksItem* retain();
|
BooksItem* retain() Q_DECL_OVERRIDE;
|
||||||
virtual void release();
|
void release() Q_DECL_OVERRIDE;
|
||||||
virtual QObject* object();
|
QObject* object() Q_DECL_OVERRIDE;
|
||||||
virtual BooksShelf* shelf();
|
BooksShelf* shelf() Q_DECL_OVERRIDE;
|
||||||
virtual BooksBook* book();
|
BooksBook* book() Q_DECL_OVERRIDE;
|
||||||
virtual QString name() const;
|
QString name() const Q_DECL_OVERRIDE;
|
||||||
virtual QString fileName() const;
|
QString fileName() const Q_DECL_OVERRIDE;
|
||||||
virtual QString path() const;
|
QString path() const Q_DECL_OVERRIDE;
|
||||||
virtual bool accessible() const;
|
bool accessible() const Q_DECL_OVERRIDE;
|
||||||
virtual void deleteFiles();
|
void deleteFiles() Q_DECL_OVERRIDE;
|
||||||
virtual BooksItem* copyTo(const BooksStorage& aStorage, QString aRelPath,
|
BooksItem* copyTo(const BooksStorage&, QString, CopyOperation*) Q_DECL_OVERRIDE;
|
||||||
CopyOperation* aObserver);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void hasCoverChanged();
|
||||||
void coverImageChanged();
|
void coverImageChanged();
|
||||||
void loadingCoverChanged();
|
void loadingCoverChanged();
|
||||||
void accessibleChanged();
|
void accessibleChanged();
|
||||||
|
@ -128,10 +131,10 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
bool coverTaskDone();
|
bool coverTaskDone();
|
||||||
bool makeLink(QString aDestPath);
|
bool makeLink(QString);
|
||||||
void requestSave();
|
void requestSave();
|
||||||
QString cachedImagePath() const;
|
QString cachedImagePath() const;
|
||||||
static bool isCanceled(CopyOperation* aOperation);
|
static bool isCanceled(CopyOperation*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAtomicInt iRef;
|
QAtomicInt iRef;
|
||||||
|
|
Loading…
Reference in a new issue