a?adido comic flow con opengl a yacreaderlibrary

modificados los paginadores

soporte multidispositivo del servidor a?adido

nuevos templates de la web agregados
This commit is contained in:
Luis Ángel San Martín 2012-10-02 07:58:12 +02:00
parent 0487531bb6
commit 4e43e66df3
26 changed files with 1952 additions and 82 deletions

View File

@ -12,7 +12,7 @@ INCLUDEPATH += ../common \
../YACReader
CONFIG += release
CONFIG -= flat
QT += sql network
QT += sql network opengl
# Input
HEADERS += comic_flow.h \
@ -43,7 +43,9 @@ HEADERS += comic_flow.h \
../common/check_new_version.h \
../YACReader/comic.h \
../YACReader/bookmarks.h \
server_config_dialog.h
server_config_dialog.h \
../common/comic_flow_widget.h \
../common/yacreader_flow_gl.h
SOURCES += comic_flow.cpp \
create_library_dialog.cpp \
@ -74,7 +76,9 @@ SOURCES += comic_flow.cpp \
../common/check_new_version.cpp \
../YACReader/comic.cpp \
../YACReader/bookmarks.cpp \
server_config_dialog.cpp
server_config_dialog.cpp \
../common/comic_flow_widget.cpp \
../common/yacreader_flow_gl.cpp
include(./server/server.pri)

View File

@ -51,7 +51,7 @@ void LibraryWindow::doLayout()
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal); //spliter principal
//TODO: flowType is a global variable
//CONFIG COMIC_FLOW--------------------------------------------------------
comicFlow = new ComicFlow(0,flowType);
comicFlow = new ComicFlowWidgetGL(0);
comicFlow->setFocusPolicy(Qt::StrongFocus);
comicFlow->setShowMarks(true);
QMatrix m;

View File

@ -15,7 +15,8 @@
#include "create_library_dialog.h"
#include "add_library_dialog.h"
#include "library_creator.h"
#include "comic_flow.h"
//#include "comic_flow.h"
#include "comic_flow_widget.h"
#include "custom_widgets.h"
#include "rename_library_dialog.h"
#include "properties_dialog.h"
@ -53,7 +54,7 @@ private:
YACReaderSortComics * proxySort;
PackageManager * packageManager;
ComicFlow * comicFlow;
ComicFlowWidget * comicFlow;
QSize slideSizeW;
QSize slideSizeF;
//search filter

View File

@ -42,7 +42,8 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
{
HttpSession session=Static::sessionStore->getSession(request,response);
QStringList pathElements = ((QString)request.getPath()).split('/');
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
QStringList pathElements = path.split('/');
QString libraryName = pathElements.at(2);
qulonglong comicId = pathElements.at(4).toULongLong();

View File

@ -16,7 +16,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
QMap<QString,QString> libraries = mw->getLibraries();
QString path = request.getPath();
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
QStringList pathElements = path.split('/');
QString libraryName = pathElements.at(2);
QString fileName = pathElements.at(4);

View File

@ -12,6 +12,16 @@ ErrorController::ErrorController(int errorCode)
void ErrorController::service(HttpRequest& request, HttpResponse& response)
{
response.setStatus(300,"redirect");
response.write("<html> <head> <meta http-equiv=\"refresh\" content=\"0; URL=/\"> </head> <body> </body> </html>", true);
switch(error)
{
case 300:
response.setStatus(300,"redirect");
response.write("<html> <head> <meta http-equiv=\"refresh\" content=\"0; URL=/\"> </head> <body> </body> </html>", true);
break;
case 404:
response.setStatus(404,"not found");
response.write("404 not found",true);
break;
}
}

View File

@ -29,25 +29,24 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
QString y = session.get("xxx").toString();
//response.writeText(QString("session xxx : %1 <br/>").arg(y));
Template t=Static::templateLoader->getTemplate("folder",request.getHeader("Accept-Language"));
Template t=Static::templateLoader->getTemplate("folder_"+session.getDeviceType(),request.getHeader("Accept-Language"));
t.enableWarnings();
QString path = request.getPath();
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
QStringList pathElements = path.split('/');
QString libraryName = pathElements.at(2);
qulonglong parentId = pathElements.at(4).toULongLong();
QList<LibraryItem *> folderContent = mw->getFolderContentFromLibrary(libraryName,parentId);
QList<LibraryItem *> folderComics = mw->getFolderComicsFromLibrary(libraryName,parentId);
response.writeText(libraryName);
folderContent.append(folderComics);
qSort(folderContent.begin(),folderContent.end(),LibraryItemSorter());
folderComics.clear();
qulonglong backId = mw->getParentFromComicFolderId(libraryName,parentId);
int page = 0;
QByteArray p = request.getParameter("page");
if(p.length() != 0)
@ -57,11 +56,10 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
//QString currentPath = session.get("currentPath").toString();
//QStringList pathSize = currentPath.split("/").last().toInt;
if(backId == 1 && parentId == 1)
t.setVariable(QString("upurl"),"/?page=0");
else
t.setVariable(QString("upurl"),"/library/" + libraryName + "/folder/" +QString("%1").arg(backId));//.arg(upPage));
t.setVariable(QString("upurl"),"/library/" + QUrl::toPercentEncoding(libraryName) + "/folder/" +QString("%1").arg(backId));//.arg(upPage));
/*if(currentPath.length()>0)
{
@ -115,19 +113,23 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
t.setVariable(QString("element%1.browse").arg(i),QString("<a href=\"%1\">Browse</a>").arg(QString("/library/%1/folder/%2").arg(libraryName).arg(item->id)));
//t.setVariable(QString("element%1.url").arg(i),"/library/"+libraryName+"/folder/"+QString("%1").arg(folderContent.at(i + (page*10))->id));
t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/folder/"+QString("%1/info").arg(folderContent.at(i + (page*elementsPerPage))->id));
//t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/folder/"+QString("%1/info").arg(folderContent.at(i + (page*elementsPerPage))->id));
t.setVariable(QString("element%1.download").arg(i),QString("<a href=\"%1\">Download</a>").arg("/library/"+QUrl::toPercentEncoding(libraryName)+"/folder/"+QString("%1/info").arg(folderContent.at(i + (page*elementsPerPage))->id)));
}
else
{
const ComicDB * comic = (ComicDB *)item;
t.setVariable(QString("element%1.browse").arg(i),"");
t.setVariable(QString("element%1.image.width").arg(i),"80px");
t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/comic/"+QString("%1").arg(comic->id));
//t.setVariable(QString("element%1.image.url").arg(i),"/images/f.png");
if(session.isComicOnDevice(comic->info.hash))
t.setVariable(QString("element%1.image.url").arg(i),"/images/f.png");
//t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/comic/"+QString("%1").arg(comic->id));
if(!session.isComicOnDevice(comic->info.hash))
t.setVariable(QString("element%1.download").arg(i),QString("<a href=\"%1\">Download</a>").arg("/library/"+QUrl::toPercentEncoding(libraryName)+"/comic/"+QString("%1").arg(comic->id)));
else
t.setVariable(QString("element%1.image.url").arg(i),QString("/library/%1/cover/%2.jpg").arg(libraryName).arg(comic->info.hash));
t.setVariable(QString("element%1.download").arg(i),QString(""));
//t.setVariable(QString("element%1.image.url").arg(i),"/images/f.png");
t.setVariable(QString("element%1.image.url").arg(i),QString("/library/%1/cover/%2.jpg").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(comic->info.hash));
}
i++;
}
@ -172,8 +174,8 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
t.setVariable(QString("elementcomic%1.name").arg(j),comic->name);
//else
// t.setVariable(QString("elementcomic%1.name").arg(i),*comic->info.title);
t.setVariable(QString("elementcomic%1.url").arg(j),"/library/"+libraryName+"/comic/"+QString("%1").arg(comic->id));
t.setVariable(QString("elementcomic%1.coverulr").arg(j),"/library/"+libraryName+"/cover/"+QString("%1").arg(comic->info.hash + ".jpg"));
t.setVariable(QString("elementcomic%1.url").arg(j),"/library/"+QUrl::toPercentEncoding(libraryName)+"/comic/"+QString("%1").arg(comic->id));
t.setVariable(QString("elementcomic%1.coverulr").arg(j),"/library/"+QUrl::toPercentEncoding(libraryName)+"/cover/"+QString("%1").arg(comic->info.hash + ".jpg"));
j++;
}
@ -210,7 +212,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
{
//response.writeText(QString("%1 - %2 <br />").arg(*itr).arg(count));
t.setVariable(QString("index%1.indexname").arg(i), *itr);
t.setVariable(QString("index%1.url").arg(i),QString("/library/%1/folder/%2?page=%3").arg(libraryName).arg(parentId).arg(indexPage));
t.setVariable(QString("index%1.url").arg(i),QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg(indexPage));
i++;
count += indexCount.value(*itr);
indexPage = count/elementsPerPage;
@ -222,13 +224,19 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
while(z < numPages)
{
t.setVariable(QString("page%1.url").arg(z),QString("/library/%1/folder/%2?page=%3").arg(libraryName).arg(parentId).arg(z));
t.setVariable(QString("page%1.url").arg(z),QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg(z));
t.setVariable(QString("page%1.number").arg(z),QString("%1").arg(z));
if(page == z)
t.setVariable(QString("page%1.number").arg(z),QString("<strong>%1</strong>").arg(z));
t.setVariable(QString("page%1.current").arg(z),"current");
else
t.setVariable(QString("page%1.number").arg(z),QString("%1").arg(z));
t.setVariable(QString("page%1.current").arg(z),"");
z++;
}
t.setVariable("page.first",QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg(0));
t.setVariable("page.previous",QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg((page==0)?page:page-1));
t.setVariable("page.next",QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg((page==numPages-1)?page:page+1));
t.setVariable("page.last",QString("/library/%1/folder/%2?page=%3").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(parentId).arg(numPages-1));
}
else
{

View File

@ -15,7 +15,7 @@ void FolderInfoController::service(HttpRequest& request, HttpResponse& response)
{
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
QString path = request.getPath();
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
QStringList pathElements = path.split('/');
QString libraryName = pathElements.at(2);
qulonglong parentId = pathElements.at(4).toULongLong();
@ -26,14 +26,14 @@ void FolderInfoController::service(HttpRequest& request, HttpResponse& response)
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
{
currentFolder = (Folder *)(*itr);
response.writeText(QString("/library/%1/folder/%2/info\n").arg(libraryName).arg(currentFolder->id));
response.writeText(QString("/library/%1/folder/%2/info\n").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(currentFolder->id));
}
ComicDB * currentComic;
for(QList<LibraryItem *>::const_iterator itr = folderComics.constBegin();itr!=folderComics.constEnd();itr++)
{
currentComic = (ComicDB *)(*itr);
response.writeText(QString("/library/%1/comic/%2\n").arg(libraryName).arg(currentComic->id));
response.writeText(QString("/library/%1/comic/%2\n").arg(QString(QUrl::toPercentEncoding(libraryName))).arg(currentComic->id));
}
}

View File

@ -13,21 +13,28 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1");
HttpSession session=Static::sessionStore->getSession(request,response);
session.set("xxx","yyy");
session.set("ySession","ok");
QString postData = QString::fromUtf8(request.getBody());
response.writeText(postData);
QList<QString> data = postData.split("\n");
session.setDeviceType(data.at(0).split(":").at(1));
session.setDisplayType(data.at(1).split(":").at(1));
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
foreach(QString hash,comics)
if(data.length() > 2)
{
session.setComicOnDevice(hash);
session.setDeviceType(data.at(0).split(":").at(1));
session.setDisplayType(data.at(1).split(":").at(1));
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
foreach(QString hash,comics)
{
session.setComicOnDevice(hash);
}
}
else //valores por defecto, con propositos de depuración
{
session.setDeviceType("iphone");
session.setDisplayType("retina");
}
Template t=Static::templateLoader->getTemplate("libraries",request.getHeader("Accept-Language"));
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
t.enableWarnings();
QMap<QString,QString> libraries = mw->getLibraries();
@ -36,7 +43,7 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
t.loop("library",names.length());
int i=0;
while (i<names.length()) {
t.setVariable(QString("library%1.name").arg(i),names.at(i));
t.setVariable(QString("library%1.name").arg(i),QUrl::toPercentEncoding(names.at(i)));
t.setVariable(QString("library%1.label").arg(i),names.at(i));
i++;
}

View File

@ -13,7 +13,8 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
{
HttpSession session=Static::sessionStore->getSession(request,response);
QStringList pathElements = ((QString)request.getPath()).split('/');
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
QStringList pathElements = path.split('/');
QString libraryName = pathElements.at(2);
qulonglong comicId = pathElements.at(4).toULongLong();
unsigned int page = pathElements.at(6).toUInt();

View File

@ -7,6 +7,8 @@
#include <QFileInfo>
#include <QDir>
#include <QDateTime>
#include "httpsession.h"
#include "static.h"
StaticFileController::StaticFileController(QSettings* settings, QObject* parent)
:HttpRequestHandler(parent)
@ -61,12 +63,14 @@ void StaticFileController::service(HttpRequest& request, HttpResponse& response)
path+="/index.html";
}
//TODO(DONE) carga sensible a la localización
//TODO(DONE) carga sensible al dispositivo y a la localización
QString stringPath = path;
QStringList paths = QString(path).split('/');
QString fileName = paths.last();
stringPath.remove(fileName);
fileName = getLocalizedFileName(fileName, request.getHeader("Accept-Language"), stringPath);
HttpSession session=Static::sessionStore->getSession(request,response);
QString device = session.getDeviceType();
fileName = getDeviceAwareFileName(fileName, device, request.getHeader("Accept-Language"), stringPath);
QString newPath = stringPath.append(fileName);
//END_TODO
QFile file(docroot+path);
@ -171,3 +175,17 @@ QString StaticFileController::getLocalizedFileName(QString fileName, QString loc
return fileName;
}
QString StaticFileController::getDeviceAwareFileName(QString fileName, QString device, QString locales, QString path) const
{
QFileInfo fi(fileName);
QString baseName = fi.baseName();
QString extension = fi.completeSuffix();
QString completeFileName = getLocalizedFileName(fileName+"_"+device+"."+extension,locales,path);
if(QFile(docroot+"/"+path+completeFileName).exists())
return completeFileName; //existe un archivo específico para este dispositivo y locales
else
return getLocalizedFileName(fileName,locales,path); //no hay archivo específico para el dispositivo, pero puede haberlo para estas locales
}

View File

@ -69,6 +69,7 @@ private:
/** Timeout for each cached file */
int cacheTimeout;
/** Maximum size of files in cache, larger files are not cached */
int maxCachedFileSize;
@ -81,7 +82,8 @@ private:
/** Set a content-type header in the response depending on the ending of the filename */
void setContentType(QString file, HttpResponse& response) const;
QString StaticFileController::getLocalizedFileName(QString fileName, QString locales, QString path) const;
QString getLocalizedFileName(QString fileName, QString locales, QString path) const;
QString getDeviceAwareFileName(QString fileName, QString device, QString locales, QString path) const;
bool exists(QString localizedName, QString path) const;
};

View File

@ -20,6 +20,10 @@
#include "controllers/pagecontroller.h"
#include "controllers/errorcontroller.h"
#include "library_window.h"
extern LibraryWindow * mw;
RequestMapper::RequestMapper(QObject* parent)
:HttpRequestHandler(parent) {}
@ -34,6 +38,10 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
QRegExp cover("/library/.+/cover/[0-9a-f]+.jpg");
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?");
QRegExp library("/library/([^/.]+)/.+");
path = QUrl::fromPercentEncoding(path).toLatin1();
//primera petición, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no está habilitada
if(path == "/")
{
@ -41,42 +49,44 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
}
else
{
//se comprueba que la sesión sea la correcta con el fin de evitar accesos no autorizados
HttpSession session=Static::sessionStore->getSession(request,response);
if(session.contains("xxx"))
if(session.contains("ySession"))
{
//listar el contenido del folder
if(folder.exactMatch(path))
if(library.indexIn(path)!=-1 && mw->getLibraries().contains(library.cap(1)) )
{
FolderController().service(request, response);
}
else if (folderInfo.exactMatch(path))
{
FolderInfoController().service(request, response);
}
else if(cover.exactMatch(path))
{
CoverController().service(request, response);
}
else if(comic.exactMatch(path))
{
ComicController().service(request, response);
}
else if(comicPage.exactMatch(path))
{
PageController().service(request,response);
//listar el contenido del folder
if(folder.exactMatch(path))
{
FolderController().service(request, response);
}
else if (folderInfo.exactMatch(path))
{
FolderInfoController().service(request, response);
}
else if(cover.exactMatch(path))
{
CoverController().service(request, response);
}
else if(comic.exactMatch(path))
{
ComicController().service(request, response);
}
else if(comicPage.exactMatch(path))
{
PageController().service(request,response);
}
}
else
{
response.writeText(library.cap(1));
Static::staticFileController->service(request, response);
}
}
else //acceso no autorizado
else //acceso no autorizado, redirección
{
ErrorController(403).service(request,response);
ErrorController(300).service(request,response);
}
}

View File

@ -5,11 +5,6 @@ HEADERS += \
$$PWD/static.h \
$$PWD/startup.h \
$$PWD/requestmapper.h \
$$PWD/controllers/dumpcontroller.h \
$$PWD/controllers/templatecontroller.h \
$$PWD/controllers/formcontroller.h \
$$PWD/controllers/fileuploadcontroller.h \
$$PWD/controllers/sessioncontroller.h \
$$PWD/controllers/comiccontroller.h \
$$PWD/controllers/errorcontroller.h \
$$PWD/controllers/foldercontroller.h \
@ -23,11 +18,6 @@ SOURCES += \
$$PWD/static.cpp \
$$PWD/startup.cpp \
$$PWD/requestmapper.cpp \
$$PWD/controllers/dumpcontroller.cpp \
$$PWD/controllers/templatecontroller.cpp \
$$PWD/controllers/formcontroller.cpp \
$$PWD/controllers/fileuploadcontroller.cpp \
$$PWD/controllers/sessioncontroller.cpp \
$$PWD/controllers/comiccontroller.cpp \
$$PWD/controllers/errorcontroller.cpp \
$$PWD/controllers/foldercontroller.cpp \

View File

@ -0,0 +1,228 @@
#include "comic_flow_widget.h"
ComicFlowWidget::ComicFlowWidget(QWidget * parent)
:QWidget(parent)
{
}
ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget * parent)
:ComicFlowWidget(parent)
{
flow = new ComicFlow(parent);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
l->addWidget(flow);
setLayout(l);
//TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
}
QSize ComicFlowWidgetSW::minimumSizeHint() const
{
return flow->minimumSizeHint();
}
QSize ComicFlowWidgetSW::sizeHint() const
{
return flow->sizeHint();
}
void ComicFlowWidgetSW::setShowMarks(bool value)
{
flow->setShowMarks(value);
}
void ComicFlowWidgetSW::setMarks(QVector<bool> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetSW::setMarkImage(QImage & image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetSW::markSlide(int index)
{
flow->markSlide(index);
}
void ComicFlowWidgetSW::unmarkSlide(int index)
{
flow->unmarkSlide(index);
}
void ComicFlowWidgetSW::setSlideSize(QSize size)
{
flow->setSlideSize(size);
}
void ComicFlowWidgetSW::clear()
{
flow->clear();
}
void ComicFlowWidgetSW::setImagePaths(QStringList paths)
{
flow->setImagePaths(paths);
}
void ComicFlowWidgetSW::setCenterIndex(int index)
{
flow->setCenterIndex(index);
}
void ComicFlowWidgetSW::showSlide(int index)
{
flow->showSlide(index);
}
int ComicFlowWidgetSW::centerIndex()
{
return flow->centerIndex();
}
void ComicFlowWidgetSW::updateMarks()
{
flow->updateMarks();
}
void ComicFlowWidgetSW::setFlowType(PictureFlow::FlowType flowType)
{
flow->setFlowType(flowType);
}
void ComicFlowWidgetSW::render()
{
flow->render();
}
void ComicFlowWidgetSW::keyPressEvent(QKeyEvent* event)
{
flow->keyPressEvent(event);
}
void ComicFlowWidgetSW::paintEvent(QPaintEvent *event)
{
flow->paintEvent(event);
}
void ComicFlowWidgetSW::mousePressEvent(QMouseEvent* event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetSW::resizeEvent(QResizeEvent* event)
{
flow->resizeEvent(event);
}
void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent* event)
{
flow->mouseDoubleClickEvent(event);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///OpenGL ComicFlow
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent)
:ComicFlowWidget(parent)
{
flow = new YACReaderFlowGL(parent);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
l->addWidget(flow);
setLayout(l);
//TODO eleminar "padding"
QPalette Pal(palette());
// set black background
Pal.setColor(QPalette::Background, Qt::black);
setAutoFillBackground(true);
setPalette(Pal);
}
QSize ComicFlowWidgetGL::minimumSizeHint() const
{
return flow->minimumSizeHint();
}
QSize ComicFlowWidgetGL::sizeHint() const
{
return flow->sizeHint();
}
void ComicFlowWidgetGL::setShowMarks(bool value)
{
flow->setShowMarks(value);
}
void ComicFlowWidgetGL::setMarks(QVector<bool> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetGL::setMarkImage(QImage & image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetGL::markSlide(int index)
{
flow->markSlide(index);
}
void ComicFlowWidgetGL::unmarkSlide(int index)
{
flow->unmarkSlide(index);
}
void ComicFlowWidgetGL::setSlideSize(QSize size)
{
flow->setSlideSize(size);
}
void ComicFlowWidgetGL::clear()
{
flow->clear();
}
void ComicFlowWidgetGL::setImagePaths(QStringList paths)
{
flow->setImagePaths(paths);
}
void ComicFlowWidgetGL::setCenterIndex(int index)
{
flow->setCenterIndex(index);
}
void ComicFlowWidgetGL::showSlide(int index)
{
flow->showSlide(index);
}
int ComicFlowWidgetGL::centerIndex()
{
return flow->centerIndex();
}
void ComicFlowWidgetGL::updateMarks()
{
flow->updateMarks();
}
void ComicFlowWidgetGL::setFlowType(PictureFlow::FlowType flowType)
{
flow->setFlowType(flowType);
}
void ComicFlowWidgetGL::render()
{
flow->render();
}
void ComicFlowWidgetGL::keyPressEvent(QKeyEvent* event)
{
flow->keyPressEvent(event);
}
void ComicFlowWidgetGL::paintEvent(QPaintEvent *event)
{
//flow->paintEvent(event);
}
void ComicFlowWidgetGL::mousePressEvent(QMouseEvent* event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetGL::resizeEvent(QResizeEvent* event)
{
flow->resizeGL(event->size().width(),event->size().height());
}
void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent* event)
{
flow->mouseDoubleClickEvent(event);
}

View File

@ -0,0 +1,98 @@
#pragma once
#include <QWidget>
#include "pictureflow.h"
#include "comic_flow.h"
#include "yacreader_flow_gl.h"
class ComicFlowWidget : public QWidget
{
Q_OBJECT
public:
ComicFlowWidget(QWidget * paret = 0);
public slots:
virtual void setShowMarks(bool value) = 0;
virtual void setMarks(QVector<bool> marks) = 0;
virtual void setMarkImage(QImage & image) = 0;
virtual void markSlide(int index) = 0;
virtual void unmarkSlide(int index) = 0;
virtual void setSlideSize(QSize size) = 0;
virtual void clear() = 0;
virtual void setImagePaths(QStringList paths) = 0;
virtual void setCenterIndex(int index) = 0;
virtual void showSlide(int index) = 0;
virtual int centerIndex() = 0;
virtual void updateMarks() = 0;
virtual void setFlowType(PictureFlow::FlowType flowType) = 0;
virtual void render() = 0;
signals:
void centerIndexChanged(int);
void selected(unsigned int);
};
class ComicFlowWidgetSW : public ComicFlowWidget
{
Q_OBJECT
private:
ComicFlow * flow;
public:
ComicFlowWidgetSW(QWidget * parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setImagePaths(QStringList paths);
void setCenterIndex(int index);
void showSlide(int index);
int centerIndex();
void updateMarks();
void setFlowType(PictureFlow::FlowType flowType);
void render();
protected:
void keyPressEvent(QKeyEvent* event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
class ComicFlowWidgetGL : public ComicFlowWidget
{
Q_OBJECT
private:
YACReaderFlowGL * flow;
public:
ComicFlowWidgetGL(QWidget * parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setImagePaths(QStringList paths);
void setCenterIndex(int index);
void showSlide(int index);
int centerIndex();
void updateMarks();
void setFlowType(PictureFlow::FlowType flowType);
void render();
protected:
void keyPressEvent(QKeyEvent* event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};

View File

@ -66,7 +66,7 @@ class YACReaderFlow : public PictureFlow
Q_OBJECT
public:
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
protected:
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);

View File

@ -204,7 +204,7 @@ public slots:
signals:
void centerIndexChanged(int index);
protected:
public:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);

1095
common/yacreader_flow_gl.cpp Normal file

File diff suppressed because it is too large Load Diff

300
common/yacreader_flow_gl.h Normal file
View File

@ -0,0 +1,300 @@
//OpenGL Coverflow API by J.Roth
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <QtOpenGL>
#include <QGLWidget>
#include <QMutex>
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
class ImageLoaderGL;
class QGLContext;
class WidgetLoader;
//Cover Vector
typedef struct RVect{
float x;
float y;
float z;
float rot;
};
//the cover info struct
typedef struct CFImage{
GLuint img;
char name[256];
float width;
float height;
int index;
RVect current;
RVect animEnd;
};
struct Preset{
/*** Animation Settings ***/
//sets the speed of the animation
float animationStep;
//sets the acceleration of the animation
float animationSpeedUp;
//sets the maximum speed of the animation
float animationStepMax;
//sets the distance of view
float animationFadeOutDist;
//sets the rotation increasion
float preRotation;
//sets the light strenght on rotation
float viewRotateLightStrenght;
//sets the speed of the rotation
float viewRotateAdd;
//sets the speed of reversing the rotation
float viewRotateSub;
//sets the maximum view angle
float viewAngle;
/*** Position Configuration ***/
//the X Position of the Coverflow
float cfX;
//the Y Position of the Coverflow
float cfY;
//the Z Position of the Coverflow
float cfZ;
//the X Rotation of the Coverflow
float cfRX;
//the Y Rotation of the Coverflow
float cfRY;
//the Z Rotation of the Coverflow
float cfRZ;
//sets the rotation of each cover
float rotation;
//sets the distance between the covers
float xDistance;
//sets the distance between the centered and the non centered covers
float centerDistance;
//sets the pushback amount
float zDistance;
//sets the elevation amount
float yDistance;
};
extern struct Preset defaultYACReaderFlowConfig;
extern struct Preset presetYACReaderFlowClassicConfig;
extern struct Preset presetYACReaderFlowStripeConfig;
extern struct Preset presetYACReaderFlowOverlappedStripeConfig;
extern struct Preset pressetYACReaderFlowUpConfig;
extern struct Preset pressetYACReaderFlowDownConfig;
class YACReaderFlowGL : public QGLWidget
{
Q_OBJECT
private:
int timerId;
/*** System variables ***/
CFImage dummy;
int viewRotateActive;
float stepBackup;
GLuint markTexture;
/*functions*/
void calcPos(CFImage *CF,int pos);
void calcRV(RVect *RV,int pos);
void animate(RVect *Current,RVect to);
void drawCover(CFImage *CF);
ImageLoaderGL * worker;
int updateCount;
WidgetLoader * loader;
int fontSize;
protected:
void initializeGL();
void paintGL();
void timerEvent(QTimerEvent *);
public:
//number of Covers
int numObjects;
bool showMarks;
QVector<bool> loaded;
QVector<bool> marks;
QList<QString> paths;
CFImage * cfImages;
/*** Animation Settings ***/
Preset config;
//sets/returns the curent selected cover
int currentSelected;
//defines the position of the centered cover
RVect centerPos;
/*** Style ***/
//sets the amount of shading of the covers in the back (0-1)
float shadingTop;
float shadingBottom;
//sets the reflection strenght (0-1)
float reflectionUp;
float reflectionBottom;
/*** System info ***/
float viewRotate;
/*Constructor*/
YACReaderFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
~YACReaderFlowGL();
//size;
QSize minimumSizeHint() const;
QSize sizeHint() const;
/*functions*/
//if called it moves the coverflow to the left
void showPrevious();
//if called it moves the coverflow to the right
void showNext();
//go to
void setCurrentIndex(int pos);
//must be called whenever the coverflow animation is stopped
void cleanupAnimation();
//Draws the coverflow
void draw();
//updates the coverflow
void updatePositions();
//inserts a new item to the coverflow
//if item is set to a value > -1 it updates a already set value
//otherwise a new entry is set
void insert(char *name, GLuint Tex, float x, float y,int item = -1);
//removes a item
void remove(int item);
//replaces the texture of the item 'item' with Tex
void replace(char *name, GLuint Tex, float x, float y,int item);
//create n covers with the default nu
void populate(int n);
/*Info*/
//retuns the CFImage Struct of the current selected item
//to read title or textures
CFImage getCurrentSelected();
public slots:
void setCF_RX(int value);
//the Y Rotation of the Coverflow
void setCF_RY(int value);
//the Z Rotation of the Coverflow
void setCF_RZ(int value);
//perspective
void setZoom(int zoom);
void setRotation(int angle);
//sets the distance between the covers
void setX_Distance(int distance);
//sets the distance between the centered and the non centered covers
void setCenter_Distance(int distance);
//sets the pushback amount
void setZ_Distance(int distance);
void setCF_Y(int value);
void setY_Distance(int value);
void setPreset(const Preset & p);
void updateImageData();
void reset();
//interface with yacreaderlibrary, compatibility
void setShowMarks(bool value);
void setMarks(QVector<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setImagePaths(QStringList paths);
void setCenterIndex(int index);
void showSlide(int index);
int centerIndex();
void updateMarks();
void setFlowType(PictureFlow::FlowType flowType);
void render();
//void paintEvent(QPaintEvent *event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent * event);
void keyPressEvent(QKeyEvent *event);
void resizeGL(int width, int height);
signals:
void centerIndexChanged(int);
void selected(unsigned int);
};
class WidgetLoader : public QGLWidget
{
Q_OBJECT
public:
WidgetLoader(QWidget *parent, QGLWidget * shared);
YACReaderFlowGL * flow;
public slots:
void loadTexture(int index);
};
class ImageLoaderGL : public QThread
{
public:
ImageLoaderGL(YACReaderFlowGL * flow);
~ImageLoaderGL();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, const QString& fileName);
void reset(){idx = -1;};
int index() const { return idx; };
QImage result();
YACReaderFlowGL * flow;
GLuint resultTexture;
QImage loadImage(const QString& fileName);
protected:
void run();
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool working;
int idx;
QString fileName;
QSize size;
QImage img;
};
//class TextureLoader : public QThread
//{
//public:
// TextureLoader();
// ~TextureLoader();
// // returns FALSE if worker is still busy and can't take the task
//
// YACReaderFlow * flow;
// ImageLoader * worker;
//protected:
// void run();
//
//};

View File

@ -16,7 +16,7 @@
<ul id="itemContainer">
{loop element}
<li><img style="width: {element.image.width}" src="{element.image.url}"/> <p>{element.name}</p> {element.browse} - <a href="{element.downloadurl}">Download</a></li>
<li><img style="width: {element.image.width}" src="{element.image.url}"/> <p>{element.name}</p> {element.browse} - {element.download} </li>
{end element}
</ul>

View File

@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Folder</title>
</head>
<body>
<div id="content">
<h1>BROWSE AND IMPORT</h1>
<h2>nombre folder?</h2>
<a href="/">Libraries</a> <a href="{upurl}">up</a>
<!--<a href="javascript:javascript:history.go(-1)">up</a>-->
<ul id="itemContainer">
{loop element}
<li><img style="width: {element.image.width}" src="{element.image.url}"/> <p>{element.name}</p> {element.browse} - {element.download} </li>
{end element}
</ul>
</div>
<div class="sombra">&nbsp;</div>
<div class="index">
<ul id="alphaIndex">
{loop index}
<li> <a href="{index.url}"> {index.indexname} </a> </li>
{end index}
</ul>
<div class="clear">&nbsp;</div>
</div>
<div class="sombra">&nbsp;</div>
<div class="index">
<ul id="pageIndex">
<li> <a class="first" href="{page.first}">first</a> </li>
<li> <a class="previous" href="{page.previous}">previous</a> </li>
{loop page} <li> <a class="{page.current}" href="{page.url}"> {page.number} </a> </li> {end page}
<li> <a class="next" href="{page.next}">next</a> </li>
<li> <a class="last" href="{page.last}">last</a> </li>
</ul>
<div class="clear">&nbsp;</div>
</div>
<div class="sombra">&nbsp;</div>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Login</title>
</head>
<body>
<div id="content">
<h1>BIBLIOTECAS</h1>
<h2>Selecciona una biblioteca</h2>
<p>
<ul id="libraryList">
{loop library}
<li><a href="/library/{library.name}/folder/1">{library.label}</a></li>
{end library}
</ul>
</p>
</div>
<div class="sombra">&nbsp;</div>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/styles.css" type="text/css" />
<title>Login</title>
</head>
<body>
<div id="content">
<h1>LIBRARIES</h1>
<h2>Select a comic library</h2>
<p>
<ul>
{loop library}
<li><a href="/library/{library.name}/folder/1">{library.label}</a></li>
{end library}
</ul>
</p>
</div>
<div class="sombra">&nbsp;</div>
</body>
</html>