From f8527b9a032f9154669f1b5416b0257f83931dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 12 Mar 2018 21:43:24 +0100 Subject: [PATCH] Add a new type of "look" to the import widget. It is going to be used as the "upgrading..." view while a library is being upgraded. --- YACReaderLibrary/import_widget.cpp | 31 +++++++++++++++++++++++++----- YACReaderLibrary/import_widget.h | 15 +++++---------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/YACReaderLibrary/import_widget.cpp b/YACReaderLibrary/import_widget.cpp index 35fca0f4..c7c0602d 100644 --- a/YACReaderLibrary/import_widget.cpp +++ b/YACReaderLibrary/import_widget.cpp @@ -42,8 +42,6 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget * par normal->setPixmap(line); glow->setPixmap(glowLine); - - QHBoxLayout * layout = new QHBoxLayout(); layout->addWidget(normal,0,Qt::AlignVCenter); @@ -155,6 +153,7 @@ ImportWidget::ImportWidget(QWidget *parent) : QPushButton * stop = new QPushButton(tr("stop")); stop->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); + stopButton = stop; QVBoxLayout * layout = new QVBoxLayout(this); QHBoxLayout * buttonLayout = new QHBoxLayout(); @@ -192,7 +191,7 @@ ImportWidget::ImportWidget(QWidget *parent) : layout->addLayout(buttonLayout,0); layout->addSpacing(10); layout->addStretch(); - portadasLabel = new QLabel(""+tr("Some of the comics being added...")+""); + coversLabel = new QLabel(""+tr("Some of the comics being added...")+""); hideButton = new QToolButton(this); hideButton->setFixedSize(25,18); @@ -202,7 +201,7 @@ ImportWidget::ImportWidget(QWidget *parent) : connect(hideButton,SIGNAL(toggled(bool)),this,SLOT(showCovers(bool))); - layout->addWidget(portadasLabel,0,Qt::AlignHCenter); + layout->addWidget(coversLabel,0,Qt::AlignHCenter); layout->addWidget(coversViewContainer); //layout->addStretch(); layout->addWidget(currentComicLabel,0,Qt::AlignHCenter); @@ -346,6 +345,11 @@ void ImportWidget::setImportLook() iconLabel->setPixmap(QPixmap(":/images/importingIcon.png")); text->setText(""+tr("Importing comics")+""); textDescription->setText(""+tr("

YACReaderLibrary is now creating a new library.

Create a library could take several minutes. You can stop the process and update the library later for completing the task.

")+"
"); + + stopButton->setVisible(true); + coversLabel->setVisible(true); + coversViewContainer->setVisible(true); + hideButton->setVisible(true); } void ImportWidget::setUpdateLook() @@ -353,6 +357,23 @@ void ImportWidget::setUpdateLook() iconLabel->setPixmap(QPixmap(":/images/updatingIcon.png")); text->setText(""+tr("Updating the library")+""); textDescription->setText(""+tr("

The current library is being updated. For faster updates, please, update your libraries frequently.

You can stop the process and continue updating this library later.

")+"
"); + + stopButton->setVisible(true); + coversLabel->setVisible(true); + coversViewContainer->setVisible(true); + hideButton->setVisible(true); +} + +void ImportWidget::setUpgradeLook() +{ + iconLabel->setPixmap(QPixmap(":/images/updatingIcon.png")); + text->setText(""+tr("Upgrading the library")+""); + textDescription->setText(""+tr("

The current library is being upgraded, please wait.

")+"
"); + + stopButton->setVisible(false); + coversLabel->setVisible(false); + coversViewContainer->setVisible(false); + hideButton->setVisible(false); } void ImportWidget::clearScene() @@ -363,7 +384,7 @@ void ImportWidget::clearScene() void ImportWidget::showCovers(bool hide) { - portadasLabel->setHidden(hide); + coversLabel->setHidden(hide); coversViewContainer->setHidden(hide); } diff --git a/YACReaderLibrary/import_widget.h b/YACReaderLibrary/import_widget.h index e38f4d9c..f7dbe314 100644 --- a/YACReaderLibrary/import_widget.h +++ b/YACReaderLibrary/import_widget.h @@ -1,16 +1,9 @@ #ifndef IMPORT_WIDGET_H #define IMPORT_WIDGET_H -#include -class QLabel; -class QGraphicsView; -class QGraphicsScene; -class QElapsedTimer; -class QVBoxLayout; -class QToolButton; -class QResizeEvent; -class QPropertyAnimation; +#include + class ImportWidget : public QWidget { @@ -28,11 +21,12 @@ public slots: void clearScene(); void setImportLook(); void setUpdateLook(); + void setUpgradeLook(); void showCovers(bool hide); private: QLabel * currentComicLabel; - QLabel * portadasLabel; + QLabel * coversLabel; QLabel * iconLabel; QLabel * text; QLabel * textDescription; @@ -40,6 +34,7 @@ private: QGraphicsView * coversView; QGraphicsScene * coversScene; QPropertyAnimation * scrollAnimation; + QPushButton * stopButton; int previousWidth; bool updatingCovers;