a?adido nuevo widget para gestionar las importacione y actualizaciones

En OSX se ha desactivado el uso de QGraphicsOpacityEffect debido a un bug en Qt
This commit is contained in:
Luis Ángel San Martín 2013-05-11 23:27:31 +02:00
parent 97bd2ee0ab
commit 882dd0c435
16 changed files with 452 additions and 20 deletions

View File

@ -42,10 +42,10 @@ NotificationsLabelWidget::NotificationsLabelWidget(QWidget * parent)
textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
textLabel->setGeometry(imgLabel->geometry());
#ifndef Q_WS_MAC
imgLabel->setGraphicsEffect(effect);
textLabel->setGraphicsEffect(effect2);
#endif
resize(p.size());
updatePosition();

View File

@ -73,7 +73,8 @@ HEADERS += comic_flow.h \
../common/yacreader_flow_gl.h \
../common/yacreader_global.h \
../common/onstart_flow_selection_dialog.h \
no_libraries_widget.h
no_libraries_widget.h \
import_widget.h
SOURCES += comic_flow.cpp \
create_library_dialog.cpp \
@ -108,7 +109,8 @@ SOURCES += comic_flow.cpp \
../common/qnaturalsorting.cpp \
../common/yacreader_flow_gl.cpp \
../common/onstart_flow_selection_dialog.cpp \
no_libraries_widget.cpp
no_libraries_widget.cpp \
import_widget.cpp
include(./server/server.pri)

View File

@ -105,6 +105,7 @@ void CreateLibraryDialog::create()
this->adjustSize();
accept->setEnabled(false);
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
close();
}
else
QMessageBox::critical(NULL,tr("Path not found"),tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));

View File

@ -57,8 +57,12 @@
<file>../images/comicRar.png</file>
<file>../images/comicTar.png</file>
<file>../images/comic7z.png</file>
<file>../images/serverConfigBackground.png</file>
<file>../images/serverConfigBackground.png</file>
<file>../images/noLibrariesIcon.png</file>
<file>../images/noLibrariesLine.png</file>
<file>../images/importingIcon.png</file>
<file>../images/importTopCoversDecoration.png</file>
<file>../images/importBottomCoversDecoration.png</file>
<file>../images/glowLine.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,338 @@
#include "import_widget.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QScrollBar>
#include <QGraphicsItemAnimation>
#include <QTimeLine>
#include <QGLWidget>
#include <QTimer>
#include <QElapsedTimer>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
class YACReaderActivityIndicatorWidget : public QWidget
{
public:
YACReaderActivityIndicatorWidget(QWidget * parent = 0);
public slots:
private:
QLabel * normal;
QLabel * glow;
};
YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget * parent)
:QWidget(parent)
{
QPixmap line(":/images/noLibrariesLine.png");
QPixmap glowLine(":/images/glowLine.png");
normal = new QLabel(this);
glow = new QLabel(this);
normal->setPixmap(line);
glow->setPixmap(glowLine);
QHBoxLayout * layout = new QHBoxLayout();
layout->addWidget(normal,0,Qt::AlignVCenter);
setLayout(layout);
layout->setMargin(4);
layout->setSpacing(0);
//setFixedHeight(3);
//resize(579,3);
glow->setGeometry(4,4,glowLine.width(),glowLine.height());
//normal->setGeometry(0,1,579,1);
QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect();
//effect->setOpacity(1.0);
QPropertyAnimation * animation = new QPropertyAnimation(effect,"opacity");
animation->setDuration(1000);
animation->setStartValue(1);
animation->setEndValue(0);
//animation->setEasingCurve(QEasingCurve::InQuint);
QPropertyAnimation * animation2 = new QPropertyAnimation(effect,"opacity");
animation2->setDuration(1000);
animation2->setStartValue(0);
animation2->setEndValue(1);
//animation2->setEasingCurve(QEasingCurve::InQuint);
#ifndef Q_WS_MAC
glow->setGraphicsEffect(effect);
#endif
connect(animation,SIGNAL(finished()),animation2,SLOT(start()));
connect(animation2,SIGNAL(finished()),animation,SLOT(start()));
animation->start();
}
ImportWidget::ImportWidget(QWidget *parent) :
QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QPalette p(palette());
p.setColor(QPalette::Background, QColor(250,250,250));
setAutoFillBackground(true);
setPalette(p);
QPixmap icon(":/images/importingIcon.png");
QLabel * iconLabel = new QLabel();
iconLabel->setPixmap(icon);
/*QPixmap line(":/images/noLibrariesLine.png");
QLabel * lineLabel = new QLabel();
lineLabel->setPixmap(line);*/
YACReaderActivityIndicatorWidget * activityIndicator = new YACReaderActivityIndicatorWidget();
QLabel * text = new QLabel("<font color=\"#495252\">"+tr("Importing comics")+"</font>");
text->setStyleSheet("QLabel {font-size:25px;font-weight:bold;}");
QLabel * textDescription = new QLabel("<font color=\"#565959\">"+tr("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")+"</font>");
textDescription->setWordWrap(true);
textDescription->setMaximumWidth(330);
currentComicLabel = new QLabel("<font color=\"#565959\">...</font>");
QVBoxLayout * coversViewLayout = new QVBoxLayout;
coversView = new QGraphicsView();
//coversView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
coversView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
coversView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
coversView->setMaximumHeight(300);
coversView->setStyleSheet("QGraphicsView {background-color: #E6E6E6;border:none;}");
coversScene = new QGraphicsScene();
coversScene->setSceneRect(0,0,coversView->width(),coversView->height());
coversView->setAlignment(Qt::AlignLeft);
coversView->setScene(coversScene);
QLabel * topDecorator = new QLabel();
QLabel * bottomDecorator = new QLabel();
QPixmap top(":/images/importTopCoversDecoration.png");
QPixmap bottom(":/images/importBottomCoversDecoration.png");
topDecorator->setPixmap(top);
bottomDecorator->setPixmap(bottom);
topDecorator->setScaledContents(true);
bottomDecorator->setScaledContents(true);
topDecorator->setFixedHeight(top.height());
bottomDecorator->setFixedHeight(bottom.height());
coversViewLayout->addWidget(topDecorator,0);
coversViewLayout->addWidget(coversView,1);
coversViewLayout->addWidget(bottomDecorator,0);
coversViewLayout->setMargin(0);
coversViewLayout->setSpacing(0);
QPushButton * stop = new QPushButton(tr("stop"));
stop->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
stop->setMaximumWidth(100);
QVBoxLayout * layout = new QVBoxLayout(this);
QHBoxLayout * buttonLayout = new QHBoxLayout();
QHBoxLayout * topLayout = new QHBoxLayout();
QVBoxLayout * textLayout = new QVBoxLayout();
QWidget * topWidget = new QWidget();
topWidget->setFixedSize(650,180);
textLayout->addSpacing(12);
textLayout->addWidget(text);
textLayout->addSpacing(12);
textLayout->addWidget(textDescription);
textLayout->addStretch();
topLayout->addStretch();
topLayout->addWidget(iconLabel,0,Qt::AlignVCenter);
topLayout->addSpacing(30);
topLayout->addLayout(textLayout,1);
topLayout->addStretch();
topLayout->setMargin(0);
topWidget->setLayout(topLayout);
layout->setAlignment(Qt::AlignHCenter);
buttonLayout->addSpacing(250);
buttonLayout->addWidget(stop);
buttonLayout->addSpacing(250);
layout->addSpacing(50);
layout->addWidget(topWidget,0,Qt::AlignHCenter);
layout->addSpacing(20);
layout->addWidget(activityIndicator,0,Qt::AlignHCenter);
layout->addSpacing(10);
layout->addLayout(buttonLayout,0);
layout->addSpacing(10);
layout->addStretch();
portadasLabel = new QLabel("<font color=\"#565959\">"+tr("Some of the comics being added...")+"</font>");
layout->addWidget(portadasLabel,0,Qt::AlignHCenter);
layout->addLayout(coversViewLayout);
//layout->addStretch();
layout->addWidget(currentComicLabel,0,Qt::AlignHCenter);
layout->setContentsMargins(0,layout->contentsMargins().top(),0,layout->contentsMargins().bottom());
connect(stop,SIGNAL(clicked()),this,SIGNAL(stop()));
//connect(stop,SIGNAL(clicked()),this,SLOT(addCoverTest()));
previousWidth = 10;
updatingCovers = false;
elapsedTimer = new QElapsedTimer();
}
void ImportWidget::newComic(const QString & path, const QString & coverPath)
{
currentComicLabel->setText("<font color=\"#565959\">"+path+"</font>");
if(((elapsedTimer->elapsed()>=1000) || ((previousWidth < coversView->width()) && (elapsedTimer->elapsed()>=500))) && !updatingCovers)//todo elapsed time
{
QPixmap p(coverPath);
p = p.scaledToHeight(300,Qt::SmoothTransformation);
QGraphicsPixmapItem * item = new QGraphicsPixmapItem(p);
item->setPos(previousWidth,0);
item->setZValue(i/10000.0);
previousWidth += 10 + p.width();
coversScene->addItem(item);
elapsedTimer->start();
if(previousWidth >= coversView->width()+200 && !updatingCovers)
{
updatingCovers = true;
QGraphicsItem * last = coversScene->items().last();
int width = p.width();
if(previousWidth > 3000)
{
coversScene->removeItem(last);
delete last;
}
foreach(QGraphicsItem * itemToMove, coversScene->items())
{
QTimeLine *timer = new QTimeLine(400);
timer->setFrameRange(0, 24);
timer->setUpdateInterval(17);
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
animation->setItem(itemToMove);
animation->setTimeLine(timer);
QPointF point = itemToMove->scenePos();
float step = (width+10)/24.0;
for (int i = 0; i < 24; ++i)
animation->setPosAt(i / 24.0, QPointF(point.x()-((i+1)*step), point.y()));
timer->start();
connect(timer,SIGNAL(finished()),timer,SLOT(deleteLater()));
connect(timer,SIGNAL(finished()),animation,SLOT(deleteLater()));
}
QTimer::singleShot(400,this,SLOT(finishedUpdatingCover()));
previousWidth -= 10+width;
}
}
}
void ImportWidget::finishedUpdatingCover()
{
updatingCovers = false;
}
void ImportWidget::newCover(const QPixmap & image)
{
}
static int i = 1;
static int previousWidth = 10;
static int j = 0;
void ImportWidget::addCoverTest()
{
QPixmap p(QString("c:/temp/%1.jpg").arg(i));
p = p.scaledToHeight(300,Qt::SmoothTransformation);
QGraphicsPixmapItem * item = new QGraphicsPixmapItem(p);
item->setPos(previousWidth,0);
item->setZValue(i/10000.0);
previousWidth += 10 + p.width();
coversScene->addItem(item);
if(previousWidth >= coversView->width())
{
QGraphicsItem * last = coversScene->items().last();
int width = p.width();
if(j>=1)
{
coversScene->removeItem(last);
delete last;
}
else
j++;
foreach(QGraphicsItem * itemToMove, coversScene->items())
{
QTimeLine *timer = new QTimeLine(/*350*/1000);
timer->setFrameRange(0, 60);
QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
animation->setItem(itemToMove);
animation->setTimeLine(timer);
QPointF point = itemToMove->scenePos();
float step = (width+10)/60.0;
for (int i = 0; i < 60; ++i)
animation->setPosAt(i / 60.0, QPointF(point.x()-((i+1)*step), point.y()));
timer->start();
}
previousWidth -= 10+width;
}
i++;
}
void ImportWidget::clear()
{
previousWidth = 10;
//nos aseguramos de que las animaciones han finalizado antes de borrar
QList<QGraphicsItem*> all = coversScene->items();
for (int i = 0; i < all.size(); i++)
{
QGraphicsItem *gi = all[i];
if(gi->parentItem()==NULL)
delete gi;
}
coversScene->clear();
updatingCovers = false;
currentComicLabel->setText("<font color=\"#565959\">...</font>");
i = 0;
}
void ImportWidget::clearScene()
{
}

View File

@ -0,0 +1,38 @@
#ifndef IMPORT_WIDGET_H
#define IMPORT_WIDGET_H
#include <QWidget>
class QLabel;
class QGraphicsView;
class QGraphicsScene;
class QElapsedTimer;
class ImportWidget : public QWidget
{
Q_OBJECT
public:
explicit ImportWidget(QWidget *parent = 0);
signals:
void stop();
public slots:
void newComic(const QString & path, const QString & coverPath);
void newCover(const QPixmap & image);
void clear();
void addCoverTest();
void finishedUpdatingCover();
void clearScene();
private:
QLabel * currentComicLabel;
QLabel * portadasLabel;
QGraphicsView * coversView;
QGraphicsScene * coversScene;
int previousWidth;
bool updatingCovers;
QElapsedTimer * elapsedTimer;
quint64 i;
};
#endif // IMPORT_WIDGET_H

View File

@ -233,6 +233,8 @@ void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo &
//ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+fileInfo.fileName()+".jpg");
tc.create();
numPages = tc.getNumPages();
emit(comicAdded(relativePath,_target+"/covers/"+hash+".jpg"));
}
comic.info.setNumPages(numPages);
comic.insert(_database);

View File

@ -52,6 +52,7 @@
void finished();
void coverExtracted(QString);
void folderUpdated(QString);
void comicAdded(QString,QString);
void updated();
void created();
};

View File

@ -22,6 +22,7 @@
#include "yacreader_global.h"
#include "onstart_flow_selection_dialog.h"
#include "no_libraries_widget.h"
#include "import_widget.h"
//
@ -37,7 +38,7 @@ LibraryWindow::LibraryWindow()
}
else
{
hideNoLibrariesWidget();
showRootWidget();
}
}
@ -228,6 +229,9 @@ void LibraryWindow::doLayout()
noLibrariesWidget = new NoLibrariesWidget();
mainWidget->addWidget(noLibrariesWidget);
importWidget = new ImportWidget();
mainWidget->addWidget(importWidget);
connect(noLibrariesWidget,SIGNAL(createNewLibrary()),this,SLOT(createLibrary()));
connect(noLibrariesWidget,SIGNAL(addExistingLibrary()),this,SLOT(showAddLibrary()));
}
@ -595,12 +599,19 @@ void LibraryWindow::createConnections()
//libraryCreator connections
connect(createLibraryDialog,SIGNAL(createLibrary(QString,QString,QString)),this,SLOT(create(QString,QString,QString)));
connect(importComicsInfoDialog,SIGNAL(finished(int)),this,SLOT(reloadCurrentLibrary()));
connect(libraryCreator,SIGNAL(coverExtracted(QString)),createLibraryDialog,SLOT(showCurrentFile(QString)));
connect(libraryCreator,SIGNAL(finished()),createLibraryDialog,SLOT(close()));
connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString)));
connect(libraryCreator,SIGNAL(finished()),updateLibraryDialog,SLOT(close()));
connect(libraryCreator,SIGNAL(finished()),this,SLOT(showRootWidget()));
connect(libraryCreator,SIGNAL(updated()),this,SLOT(reloadCurrentLibrary()));
connect(libraryCreator,SIGNAL(created()),this,SLOT(openLastCreated()));
//new import widget
connect(libraryCreator,SIGNAL(comicAdded(QString,QString)),importWidget,SLOT(newComic(QString,QString)));
//connect(libraryCreator,SIGNAL(finished()),importWidget,SLOT(clear()));
//connect(importWidget,SIGNAL(stop()),this,SLOT(cancelCreating()));
connect(importWidget,SIGNAL(stop()),this,SLOT(stopLibraryCreator()));
//packageManager connections
connect(exportLibraryDialog,SIGNAL(exportPath(QString)),this,SLOT(exportLibrary(QString)));
@ -694,7 +705,7 @@ void LibraryWindow::loadLibrary(const QString & name)
{
if(libraries.size()>0) //si hay bibliotecas...
{
hideNoLibrariesWidget();
showRootWidget();
QString path=libraries.value(name)+"/.yacreaderlibrary";
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
QString dbVersion;
@ -1008,6 +1019,8 @@ void LibraryWindow::create(QString source, QString dest, QString name)
_lastAdded = name;
_sourceLastAdded = source;
showImportingWidget();
}
void LibraryWindow::reloadCurrentLibrary()
@ -1101,7 +1114,9 @@ void LibraryWindow::saveLibraries()
void LibraryWindow::updateLibrary()
{
updateLibraryDialog->show();
//updateLibraryDialog->show();
showImportingWidget();
QString currentLibrary = selectedLibrary->currentText();
QString path = libraries.value(currentLibrary);
_lastAdded = currentLibrary;
@ -1539,7 +1554,16 @@ void LibraryWindow::showNoLibrariesWidget()
{
mainWidget->setCurrentIndex(1);
}
void LibraryWindow::hideNoLibrariesWidget()
void LibraryWindow::showRootWidget()
{
libraryToolBar->setDisabled(false);
mainWidget->setCurrentIndex(0);
}
void LibraryWindow::showImportingWidget()
{
importWidget->clear();
libraryToolBar->setDisabled(true);
mainWidget->setCurrentIndex(2);
}

View File

@ -13,6 +13,7 @@
#include <QFileInfoList>
#include <QStackedWidget>
//TODO cambiar por class XXXXX
#include "create_library_dialog.h"
#include "add_library_dialog.h"
#include "library_creator.h"
@ -32,6 +33,7 @@
#include "treeitem.h"
#include "server_config_dialog.h"
#include "no_libraries_widget.h"
#include "import_widget.h"
class LibraryWindow : public QMainWindow
{
@ -83,6 +85,7 @@ private:
QStackedWidget * mainWidget;
NoLibrariesWidget * noLibrariesWidget;
ImportWidget * importWidget;
bool fetching;
@ -217,7 +220,8 @@ public:
void showImportComicsInfo();
void asignNumbers();
void showNoLibrariesWidget();
void hideNoLibrariesWidget();
void showRootWidget();
void showImportingWidget();
//server interface
QMap<QString,QString> getLibraries(){return libraries;};

View File

@ -1,6 +1,6 @@
#include "no_libraries_widget.h"
#include <QLabel>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
@ -23,8 +23,11 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent) :
QLabel * lineLabel = new QLabel();
lineLabel->setPixmap(line);
QLabel * text = new QLabel(tr("<font color=\"#565959\">You don't have any librarires yet</font>"));
QLabel * text = new QLabel("<font color=\"#495252\">"+tr("You don't have any librarires yet")+"</font>");
text->setStyleSheet("QLabel {font-size:25px;font-weight:bold;}");
QLabel * textDescription = new QLabel("<font color=\"#565959\">"+tr("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")+"</font>");
textDescription->setWordWrap(true);
textDescription->setMaximumWidth(330);
QPushButton * createButton = new QPushButton(tr("create your first library"));
createButton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
@ -33,22 +36,37 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent) :
QVBoxLayout * layout = new QVBoxLayout(this);
QHBoxLayout * buttonLayout = new QHBoxLayout();
//QHBoxLayout * topLayout = new QHBoxLayout();
//QVBoxLayout * textLayout = new QVBoxLayout();
QHBoxLayout * topLayout = new QHBoxLayout();
QVBoxLayout * textLayout = new QVBoxLayout();
QWidget * topWidget = new QWidget();
topWidget->setFixedSize(650,160);
textLayout->addSpacing(12);
textLayout->addWidget(text);
textLayout->addSpacing(12);
textLayout->addWidget(textDescription);
textLayout->addStretch();
topLayout->addStretch();
topLayout->addWidget(iconLabel,0,Qt::AlignVCenter);
topLayout->addSpacing(30);
topLayout->addLayout(textLayout,1);
topLayout->addStretch();
topLayout->setMargin(0);
topWidget->setLayout(topLayout);
layout->setAlignment(Qt::AlignHCenter);
buttonLayout->addSpacing(100);
buttonLayout->addSpacing(125);
buttonLayout->addWidget(createButton);
layout->addSpacing(25);
buttonLayout->addWidget(addButton);
buttonLayout->addSpacing(100);
buttonLayout->addSpacing(125);
layout->addStretch();
layout->addWidget(iconLabel,0,Qt::AlignHCenter);
layout->addSpacing(10);
layout->addWidget(text,0,Qt::AlignHCenter);
layout->addSpacing(10);
layout->addWidget(topWidget);
layout->addSpacing(20);
layout->addWidget(lineLabel,0,Qt::AlignHCenter);
layout->addSpacing(10);
layout->addLayout(buttonLayout,0);

BIN
images/glowLine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

BIN
images/importingIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB