mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
added an animation for the transition between flow and grid comics views
This commit is contained in:
parent
b860d8776a
commit
9f53ae6efc
@ -199,9 +199,11 @@ isEqual(QT_MAJOR_VERSION, 5) {
|
|||||||
#QML/GridView
|
#QML/GridView
|
||||||
QT += quick qml
|
QT += quick qml
|
||||||
|
|
||||||
HEADERS += grid_comics_view.h
|
HEADERS += grid_comics_view.h \
|
||||||
|
comics_view_transition.h
|
||||||
|
|
||||||
SOURCES += grid_comics_view.cpp
|
SOURCES += grid_comics_view.cpp \
|
||||||
|
comics_view_transition.cpp
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc
|
||||||
|
|
||||||
|
74
YACReaderLibrary/comics_view_transition.cpp
Normal file
74
YACReaderLibrary/comics_view_transition.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include "comics_view_transition.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMovie>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
ComicsViewTransition::ComicsViewTransition(QWidget *parent) :
|
||||||
|
QWidget(parent),movie(0)
|
||||||
|
{
|
||||||
|
QVBoxLayout * layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
|
movieLabel = new QLabel("Placeholder");
|
||||||
|
movieLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
QLabel * textLabel = new QLabel("Switching comics view");
|
||||||
|
textLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
textLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||||
|
//movieLabel->setFixedSize(450,350);
|
||||||
|
|
||||||
|
layout->addSpacing(100);
|
||||||
|
layout->addWidget(movieLabel);
|
||||||
|
layout->addSpacing(20);
|
||||||
|
layout->addWidget(textLabel);
|
||||||
|
layout->addStretch();
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
setStyleSheet("QWidget {background:#2A2A2A}");
|
||||||
|
|
||||||
|
//QSizePolicy sp();
|
||||||
|
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
//movieLabel->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize ComicsViewTransition::sizeHint()
|
||||||
|
{
|
||||||
|
return QSize(450,350);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicsViewTransition::startMovie()
|
||||||
|
{
|
||||||
|
if(movie)
|
||||||
|
delete movie;
|
||||||
|
|
||||||
|
if(settings->value(COMICS_VIEW_STATUS) == YACReader::Flow)
|
||||||
|
movie = new QMovie(":/images/flow_to_grid.gif");
|
||||||
|
else
|
||||||
|
movie = new QMovie(":/images/grid_to_flow.gif");
|
||||||
|
|
||||||
|
connect(movie,SIGNAL(finished()),this,SIGNAL(transitionFinished()));
|
||||||
|
//connect(movie,SIGNAL(finished()),movie,SLOT(deleteLater());
|
||||||
|
movie->setSpeed(200);
|
||||||
|
movie->jumpToFrame(0);
|
||||||
|
movieLabel->setMovie(movie);
|
||||||
|
|
||||||
|
QTimer::singleShot(100,movie,SLOT(start()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicsViewTransition::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter (this);
|
||||||
|
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
|
||||||
|
}
|
31
YACReaderLibrary/comics_view_transition.h
Normal file
31
YACReaderLibrary/comics_view_transition.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef COMICS_VIEW_TRANSITION_H
|
||||||
|
#define COMICS_VIEW_TRANSITION_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QMovie;
|
||||||
|
class QSettings;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class ComicsViewTransition : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ComicsViewTransition(QWidget *parent = 0);
|
||||||
|
QSize sizeHint();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void transitionFinished();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void startMovie();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QMovie * movie;
|
||||||
|
QSettings * settings;
|
||||||
|
QLabel * movieLabel;
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMICS_VIEW_TRANSITION_H
|
@ -17,5 +17,7 @@
|
|||||||
<file alias="images/colapse.png">../images/colapse_osx.png</file>
|
<file alias="images/colapse.png">../images/colapse_osx.png</file>
|
||||||
<file alias="images/newLibraryIcon.png">../images/newLibraryIcon_osx.png</file>
|
<file alias="images/newLibraryIcon.png">../images/newLibraryIcon_osx.png</file>
|
||||||
<file alias="images/openLibraryIcon.png">../images/openLibraryIcon_osx.png</file>
|
<file alias="images/openLibraryIcon.png">../images/openLibraryIcon_osx.png</file>
|
||||||
|
<file alias="images/flow_to_grid.gif">../images/flow_to_grid.gif</file>
|
||||||
|
<file alias="images/grid_to_flow.gif">../images/grid_to_flow.gif</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -16,5 +16,7 @@
|
|||||||
<file>../images/openLibraryIcon.png</file>
|
<file>../images/openLibraryIcon.png</file>
|
||||||
<file>../images/main_toolbar/flow.png</file>
|
<file>../images/main_toolbar/flow.png</file>
|
||||||
<file>../images/main_toolbar/grid.png</file>
|
<file>../images/main_toolbar/grid.png</file>
|
||||||
|
<file>../images/flow_to_grid.gif</file>
|
||||||
|
<file>../images/grid_to_flow.gif</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
|
|
||||||
#include "classic_comics_view.h"
|
#include "classic_comics_view.h"
|
||||||
#include "grid_comics_view.h"
|
#include "grid_comics_view.h"
|
||||||
|
#include "comics_view_transition.h"
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
|
|
||||||
@ -189,8 +190,7 @@ void LibraryWindow::doLayout()
|
|||||||
foldersTitle->addAction(colapseAllNodesAction);
|
foldersTitle->addAction(colapseAllNodesAction);
|
||||||
|
|
||||||
//FINAL LAYOUT-------------------------------------------------------------
|
//FINAL LAYOUT-------------------------------------------------------------
|
||||||
comicsViewStack = new QWidget();
|
comicsViewStack = new QStackedWidget();
|
||||||
QHBoxLayout * l = new QHBoxLayout();
|
|
||||||
|
|
||||||
if(!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) {
|
if(!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) {
|
||||||
comicsView = classicComicsView = new ClassicComicsView();
|
comicsView = classicComicsView = new ClassicComicsView();
|
||||||
@ -205,9 +205,8 @@ void LibraryWindow::doLayout()
|
|||||||
doComicsViewConnections();
|
doComicsViewConnections();
|
||||||
|
|
||||||
comicsView->setToolBar(editInfoToolBar);
|
comicsView->setToolBar(editInfoToolBar);
|
||||||
l->addWidget(comicsView);
|
comicsViewStack->addWidget(comicsView);
|
||||||
comicsViewStack->setLayout(l);
|
comicsViewStack->addWidget(comicsViewTransition = new ComicsViewTransition());
|
||||||
l->setContentsMargins(0,0,0,0);
|
|
||||||
|
|
||||||
fullScreenToolTip = new QLabel(comicsView);
|
fullScreenToolTip = new QLabel(comicsView);
|
||||||
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
fullScreenToolTip->setText(tr("<font color='white'> press 'F' to close fullscreen mode </font>"));
|
||||||
@ -886,6 +885,8 @@ void LibraryWindow::createConnections()
|
|||||||
|
|
||||||
//connect(socialAction,SIGNAL(triggered()),this,SLOT(showSocial()));
|
//connect(socialAction,SIGNAL(triggered()),this,SLOT(showSocial()));
|
||||||
|
|
||||||
|
connect(comicsViewTransition,SIGNAL(transitionFinished()),this,SLOT(showComicsView()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::loadLibrary(const QString & name)
|
void LibraryWindow::loadLibrary(const QString & name)
|
||||||
@ -1519,19 +1520,21 @@ void LibraryWindow::switchToComicsView(ComicsView * from, ComicsView * to)
|
|||||||
|
|
||||||
comicsView->setToolBar(editInfoToolBar);
|
comicsView->setToolBar(editInfoToolBar);
|
||||||
|
|
||||||
QHBoxLayout * l = new QHBoxLayout();
|
comicsViewStack->removeWidget(from);
|
||||||
l->addWidget(to);
|
comicsViewStack->insertWidget(0,comicsView);
|
||||||
l->setContentsMargins(0,0,0,0);
|
|
||||||
delete comicsViewStack->layout();
|
|
||||||
comicsViewStack->setLayout(l);
|
|
||||||
|
|
||||||
delete from;
|
delete from;
|
||||||
|
|
||||||
reloadCovers();
|
reloadCovers();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO recover the current comics selection and restore it in the destination
|
void LibraryWindow::showComicsViewTransition()
|
||||||
void LibraryWindow::toggleComicsView()
|
{
|
||||||
|
comicsViewStack->setCurrentIndex(1);
|
||||||
|
comicsViewTransition->startMovie();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::toggleComicsView_delayed()
|
||||||
{
|
{
|
||||||
if(comicsViewStatus == Flow){
|
if(comicsViewStatus == Flow){
|
||||||
QIcon icoViewsButton;
|
QIcon icoViewsButton;
|
||||||
@ -1551,6 +1554,18 @@ void LibraryWindow::toggleComicsView()
|
|||||||
settings->setValue(COMICS_VIEW_STATUS, comicsViewStatus);
|
settings->setValue(COMICS_VIEW_STATUS, comicsViewStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::showComicsView()
|
||||||
|
{
|
||||||
|
comicsViewStack->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO recover the current comics selection and restore it in the destination
|
||||||
|
void LibraryWindow::toggleComicsView()
|
||||||
|
{
|
||||||
|
QTimer::singleShot(0,this,SLOT(showComicsViewTransition()));
|
||||||
|
QTimer::singleShot(32,this,SLOT(toggleComicsView_delayed()));
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryWindow::asignNumbers()
|
void LibraryWindow::asignNumbers()
|
||||||
{
|
{
|
||||||
QModelIndexList indexList = getSelectedComics();
|
QModelIndexList indexList = getSelectedComics();
|
||||||
|
@ -52,6 +52,7 @@ class ComicVineDialog;
|
|||||||
class ComicsView;
|
class ComicsView;
|
||||||
class ClassicComicsView;
|
class ClassicComicsView;
|
||||||
class GridComicsView;
|
class GridComicsView;
|
||||||
|
class ComicsViewTransition;
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
using namespace YACReader;
|
using namespace YACReader;
|
||||||
@ -96,7 +97,8 @@ private:
|
|||||||
ComicsView * comicsView;
|
ComicsView * comicsView;
|
||||||
ClassicComicsView * classicComicsView;
|
ClassicComicsView * classicComicsView;
|
||||||
GridComicsView * gridComicsView;
|
GridComicsView * gridComicsView;
|
||||||
QWidget * comicsViewStack;
|
QStackedWidget * comicsViewStack;
|
||||||
|
ComicsViewTransition * comicsViewTransition;
|
||||||
|
|
||||||
YACReaderTreeView * foldersView;
|
YACReaderTreeView * foldersView;
|
||||||
YACReaderLibraryListWidget * selectedLibrary;
|
YACReaderLibraryListWidget * selectedLibrary;
|
||||||
@ -227,12 +229,6 @@ private:
|
|||||||
|
|
||||||
bool removeError;
|
bool removeError;
|
||||||
|
|
||||||
enum ComicsViewStatus
|
|
||||||
{
|
|
||||||
Flow,
|
|
||||||
Grid
|
|
||||||
};
|
|
||||||
|
|
||||||
ComicsViewStatus comicsViewStatus;
|
ComicsViewStatus comicsViewStatus;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -305,6 +301,9 @@ public:
|
|||||||
void checkRemoveError();
|
void checkRemoveError();
|
||||||
void resetComicRating();
|
void resetComicRating();
|
||||||
void switchToComicsView(ComicsView *from, ComicsView *to);
|
void switchToComicsView(ComicsView *from, ComicsView *to);
|
||||||
|
void showComicsViewTransition();
|
||||||
|
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
||||||
|
void showComicsView();
|
||||||
void toggleComicsView();
|
void toggleComicsView();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,6 +95,12 @@ namespace YACReader
|
|||||||
SevenZNotFound = 700
|
SevenZNotFound = 700
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ComicsViewStatus
|
||||||
|
{
|
||||||
|
Flow,
|
||||||
|
Grid
|
||||||
|
};
|
||||||
|
|
||||||
QString getSettingsPath();
|
QString getSettingsPath();
|
||||||
void addSperator(QWidget * w);
|
void addSperator(QWidget * w);
|
||||||
QAction * createSeparator();
|
QAction * createSeparator();
|
||||||
|
BIN
images/flow_to_grid.gif
Normal file
BIN
images/flow_to_grid.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 121 KiB |
BIN
images/grid_to_flow.gif
Normal file
BIN
images/grid_to_flow.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 127 KiB |
Loading…
Reference in New Issue
Block a user