[app] Tell the user when we are applying new fonts

"Loading..." message may be misleading as the book is already loaded.
This commit is contained in:
Slava Monich 2015-08-24 13:23:24 +03:00
parent 4dbe01fed0
commit a56349fe11
7 changed files with 74 additions and 8 deletions

View file

@ -50,6 +50,16 @@ SilicaFlickable {
{ pager: true, page: true, title: true, tools: true } { pager: true, page: true, title: true, tools: true }
] ]
// NOTE: These have to match ResetReason in BooksBookModel
readonly property var _loadingTextLabel: [
//% "Loading..."
qsTrId("book-view-loading"),
//% "Applying larger fonts..."
qsTrId("book-view-applying-larger-fonts"),
//% "Applying smaller fonts..."
qsTrId("book-view-applying-smaller-fonts")
]
PullDownMenu { PullDownMenu {
MenuItem { MenuItem {
//% "Back to library" //% "Back to library"
@ -202,7 +212,6 @@ SilicaFlickable {
opacity: _loading ? 1 : 0 opacity: _loading ? 1 : 0
visible: opacity > 0 visible: opacity > 0
Behavior on opacity { FadeAnimation {} } Behavior on opacity { FadeAnimation {} }
//% "Loading..." text: bookModel ? _loadingTextLabel[bookModel.resetReason] : ""
text: qsTrId("book-view-loading")
} }
} }

View file

@ -202,6 +202,7 @@ enum BooksBookModelRole {
BooksBookModel::BooksBookModel(QObject* aParent) : BooksBookModel::BooksBookModel(QObject* aParent) :
QAbstractListModel(aParent), QAbstractListModel(aParent),
iResetReason(ReasonUnknown),
iCurrentPage(-1), iCurrentPage(-1),
iProgress(0), iProgress(0),
iBook(NULL), iBook(NULL),
@ -432,10 +433,10 @@ void BooksBookModel::setSize(QSize aSize)
Q_EMIT pageMarksChanged(); Q_EMIT pageMarksChanged();
Q_EMIT jumpToPage(iData->pickPage(page1, page2, oldPageCount)); Q_EMIT jumpToPage(iData->pickPage(page1, page2, oldPageCount));
} else { } else {
startReset(false); startReset(ReasonUnknown, false);
} }
} else { } else {
startReset(false); startReset(ReasonUnknown, false);
} }
Q_EMIT sizeChanged(); Q_EMIT sizeChanged();
} }
@ -444,11 +445,18 @@ void BooksBookModel::setSize(QSize aSize)
void BooksBookModel::onTextStyleChanged() void BooksBookModel::onTextStyleChanged()
{ {
HDEBUG(iTitle); HDEBUG(iTitle);
iTextStyle = iSettings->textStyle(); shared_ptr<ZLTextStyle> newStyle = iSettings->textStyle();
startReset(); const int newFontSize = newStyle->fontSize();
const int oldFontSize = iTextStyle->fontSize();
const ResetReason reason =
(newFontSize > oldFontSize) ? ReasonIncreasingFontSize :
(newFontSize < oldFontSize) ? ReasonDecreasingFontSize :
ReasonUnknown;
iTextStyle = newStyle;
startReset(reason);
} }
void BooksBookModel::startReset(bool aFullReset) void BooksBookModel::startReset(ResetReason aResetReason, bool aFullReset)
{ {
BooksLoadingSignalBlocker block(this); BooksLoadingSignalBlocker block(this);
const BooksPos thisPage = pageMark(iCurrentPage); const BooksPos thisPage = pageMark(iCurrentPage);
@ -494,6 +502,11 @@ void BooksBookModel::startReset(bool aFullReset)
iProgress = 0; iProgress = 0;
Q_EMIT progressChanged(); Q_EMIT progressChanged();
} }
if (iResetReason != aResetReason) {
iResetReason = aResetReason;
Q_EMIT resetReasonChanged();
}
} }
void BooksBookModel::onResetProgress(int aProgress) void BooksBookModel::onResetProgress(int aProgress)

View file

@ -57,6 +57,7 @@
class BooksBookModel: public QAbstractListModel, private BooksLoadingProperty class BooksBookModel: public QAbstractListModel, private BooksLoadingProperty
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(ResetReason)
Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
@ -69,8 +70,16 @@ class BooksBookModel: public QAbstractListModel, private BooksLoadingProperty
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
Q_PROPERTY(BooksBook* book READ book WRITE setBook NOTIFY bookChanged) Q_PROPERTY(BooksBook* book READ book WRITE setBook NOTIFY bookChanged)
Q_PROPERTY(BooksSettings* settings READ settings WRITE setSettings NOTIFY settingsChanged) Q_PROPERTY(BooksSettings* settings READ settings WRITE setSettings NOTIFY settingsChanged)
Q_PROPERTY(ResetReason resetReason READ resetReason NOTIFY resetReasonChanged)
public: public:
// NOTE: These have to match the labels in BooksBookView.qml
enum ResetReason {
ReasonUnknown,
ReasonIncreasingFontSize,
ReasonDecreasingFontSize
};
explicit BooksBookModel(QObject* aParent = NULL); explicit BooksBookModel(QObject* aParent = NULL);
~BooksBookModel(); ~BooksBookModel();
@ -80,6 +89,7 @@ public:
QString title() const { return iTitle; } QString title() const { return iTitle; }
int width() const { return iSize.width(); } int width() const { return iSize.width(); }
int height() const { return iSize.height(); } int height() const { return iSize.height(); }
ResetReason resetReason() const { return iResetReason; }
QSize size() const { return iSize; } QSize size() const { return iSize; }
void setSize(QSize aSize); void setSize(QSize aSize);
@ -120,7 +130,7 @@ public:
private: private:
void updateSize(); void updateSize();
void updateModel(int aPrevPageCount); void updateModel(int aPrevPageCount);
void startReset(bool aFullReset = true); void startReset(ResetReason aReason = ReasonUnknown, bool aFull = true);
private Q_SLOTS: private Q_SLOTS:
void onResetProgress(int aProgress); void onResetProgress(int aProgress);
@ -142,12 +152,14 @@ Q_SIGNALS:
void rightMarginChanged(); void rightMarginChanged();
void topMarginChanged(); void topMarginChanged();
void bottomMarginChanged(); void bottomMarginChanged();
void resetReasonChanged();
void jumpToPage(int index); void jumpToPage(int index);
private: private:
class Data; class Data;
class Task; class Task;
ResetReason iResetReason;
int iCurrentPage; int iCurrentPage;
int iProgress; int iProgress;
QSize iSize; QSize iSize;

View file

@ -11,6 +11,14 @@
<source>Loading...</source> <source>Loading...</source>
<translation>Latautuu...</translation> <translation>Latautuu...</translation>
</message> </message>
<message id="book-view-applying-larger-fonts">
<source>Applying larger fonts...</source>
<translation>Vaihdetaan isompiin fontteihin...</translation>
</message>
<message id="book-view-applying-smaller-fonts">
<source>Applying smaller fonts...</source>
<translation>Vaihdetaan pienempiin fontteihin...</translation>
</message>
<message id="shelf-view-about-to-delete-all"> <message id="shelf-view-about-to-delete-all">
<source>Deleting all books</source> <source>Deleting all books</source>
<translation>Poistetaan kaikki kirjat</translation> <translation>Poistetaan kaikki kirjat</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source> <source>Loading...</source>
<translation>Загрузка...</translation> <translation>Загрузка...</translation>
</message> </message>
<message id="book-view-applying-larger-fonts">
<source>Applying larger fonts...</source>
<translation>Увеличиваем шрифты...</translation>
</message>
<message id="book-view-applying-smaller-fonts">
<source>Applying smaller fonts...</source>
<translation>Уменьшаем шрифты...</translation>
</message>
<message id="shelf-view-about-to-delete-all"> <message id="shelf-view-about-to-delete-all">
<source>Deleting all books</source> <source>Deleting all books</source>
<translation>Удаляем все книги</translation> <translation>Удаляем все книги</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source> <source>Loading...</source>
<translation>Läser in...</translation> <translation>Läser in...</translation>
</message> </message>
<message id="book-view-applying-larger-fonts">
<source>Applying larger fonts...</source>
<translation type="unfinished">Tillämpa större typsnitt...</translation>
</message>
<message id="book-view-applying-smaller-fonts">
<source>Applying smaller fonts...</source>
<translation type="unfinished">Tillämpa mindre typsnitt...</translation>
</message>
<message id="shelf-view-about-to-delete-all"> <message id="shelf-view-about-to-delete-all">
<source>Deleting all books</source> <source>Deleting all books</source>
<translation>Tar bort alla böcker</translation> <translation>Tar bort alla böcker</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source> <source>Loading...</source>
<translation>Loading...</translation> <translation>Loading...</translation>
</message> </message>
<message id="book-view-applying-larger-fonts">
<source>Applying larger fonts...</source>
<translation>Applying larger fonts...</translation>
</message>
<message id="book-view-applying-smaller-fonts">
<source>Applying smaller fonts...</source>
<translation>Applying smaller fonts...</translation>
</message>
<message id="shelf-view-about-to-delete-all"> <message id="shelf-view-about-to-delete-all">
<source>Deleting all books</source> <source>Deleting all books</source>
<translation>Deleting all books</translation> <translation>Deleting all books</translation>