[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 }
]
// 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 {
MenuItem {
//% "Back to library"
@ -202,7 +212,6 @@ SilicaFlickable {
opacity: _loading ? 1 : 0
visible: opacity > 0
Behavior on opacity { FadeAnimation {} }
//% "Loading..."
text: qsTrId("book-view-loading")
text: bookModel ? _loadingTextLabel[bookModel.resetReason] : ""
}
}

View file

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

View file

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

View file

@ -11,6 +11,14 @@
<source>Loading...</source>
<translation>Latautuu...</translation>
</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">
<source>Deleting all books</source>
<translation>Poistetaan kaikki kirjat</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source>
<translation>Загрузка...</translation>
</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">
<source>Deleting all books</source>
<translation>Удаляем все книги</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source>
<translation>Läser in...</translation>
</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">
<source>Deleting all books</source>
<translation>Tar bort alla böcker</translation>

View file

@ -11,6 +11,14 @@
<source>Loading...</source>
<translation>Loading...</translation>
</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">
<source>Deleting all books</source>
<translation>Deleting all books</translation>