Fixed path encoding used for opening PDF files with pdfium.

This commit is contained in:
Luis Ángel San Martín
2017-03-28 22:18:07 +02:00
commit 1459ebb261
1012 changed files with 96766 additions and 0 deletions

173
common/bookmarks.cpp Normal file
View File

@ -0,0 +1,173 @@
#include "bookmarks.h"
#include <QFile>
#include <QDataStream>
#include <QCoreApplication>
#include <QFileInfo>
#include <QList>
#include "yacreader_global.h"
Bookmarks::Bookmarks()
:lastPageIndex(0)
{
list.load();
}
void Bookmarks::setLastPage(int index,const QImage & page)
{
lastPageIndex = index;
lastPage = page;
}
void Bookmarks::setBookmark(int index,const QImage & page)
{
if(!bookmarks.contains(index))
{
bookmarks.insert(index,page);
latestBookmarks.push_front(index);
if(latestBookmarks.count()>3)
{
bookmarks.remove(latestBookmarks.back());
latestBookmarks.pop_back();
}
}
else //udate de pixmap;
{
bookmarks[index]=page;
}
}
void Bookmarks::removeBookmark(int index)
{
bookmarks.remove(index);
}
QList<int> Bookmarks::getBookmarkPages() const
{
return bookmarks.keys();
}
QImage Bookmarks::getBookmarkPixmap(int page) const
{
return bookmarks.value(page);
}
QImage Bookmarks::getLastPagePixmap() const
{
return lastPage;
}
int Bookmarks::getLastPage() const
{
return lastPageIndex;
}
bool Bookmarks::isBookmark(int page)
{
return bookmarks.contains(page);
}
bool Bookmarks::imageLoaded(int page)
{
return !bookmarks.value(page).isNull();
}
void Bookmarks::newComic(const QString & path)
{
QFileInfo f(path);
QString comicID = f.fileName().toLower()+QString::number(f.size());
clear();
BookmarksList::Bookmark b = list.get(comicID);
comicPath=comicID;
lastPageIndex = b.lastPage;
latestBookmarks = b.bookmarks;
for(int i=0;i<latestBookmarks.count();i++)
bookmarks.insert(latestBookmarks.at(i),QImage());
added = b.added;
}
void Bookmarks::clear()
{
bookmarks.clear();
latestBookmarks.clear();
lastPageIndex=0;
lastPage = QImage();
}
bool Bookmarks::load(const QList<int> & bookmarkIndexes, int lastPage)
{
lastPageIndex = lastPage;
foreach(int b, bookmarkIndexes)
if(b != -1)
{
latestBookmarks.push_back(b);
bookmarks.insert(b,QImage());
}
return true;
}
void Bookmarks::save()
{
BookmarksList::Bookmark b;
b.lastPage = lastPageIndex;
b.bookmarks = getBookmarkPages();
BookmarksList::Bookmark previousBookmarks;
bool updated = ((previousBookmarks.lastPage != b.lastPage) || (previousBookmarks.bookmarks != b.bookmarks));
if(b.added.isNull() || updated)
b.added = QDateTime::currentDateTime();
list.add(comicPath,b);
list.save();
}
//-----------------------------------------------------------------------------
void BookmarksList::load()
{
QFile f(YACReader::getSettingsPath()+"/bookmarks.yacr");
if(f.open(QIODevice::ReadOnly))
{
QDataStream dataS(&f);
dataS >> list;
f.close();
}
}
void BookmarksList::save()
{
QFile f(YACReader::getSettingsPath()+"/bookmarks.yacr");
f.open(QIODevice::WriteOnly);
QDataStream dataS(&f);
if(list.count()>numMaxBookmarks)
deleteOldest(list.count()-numMaxBookmarks);
dataS << list;
f.close();
}
void BookmarksList::deleteOldest(int num)
{
Q_UNUSED(num)
QString comic;
QDateTime date(QDate(10000,1,1));//TODO MAX_DATE??
for(QMap<QString,Bookmark>::const_iterator itr=list.begin();itr!=list.end();itr++)
{
if(itr->added<date)
{
comic=itr.key();
date = itr->added;
}
}
list.remove(comic);
}
void BookmarksList::add(const QString & comicID, const Bookmark & b)
{
list.insert(comicID,b);
}
BookmarksList::Bookmark BookmarksList::get(const QString & comicID)
{
//if(list.contains(comicID)
return list.value(comicID);
}

80
common/bookmarks.h Normal file
View File

@ -0,0 +1,80 @@
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
#include <QObject>
#include <QMap>
#include <QImage>
#include <QString>
#include <QMap>
#include <QDateTime>
class BookmarksList
{
public:
struct Bookmark {
int lastPage;
QList<int> bookmarks;
QDateTime added;
Bookmark():lastPage(0){};
friend QDataStream & operator<< ( QDataStream & out, const Bookmark & bm )
{
out << bm.lastPage;
out << bm.bookmarks;
out << bm.added;
return out;
}
friend QDataStream & operator>> ( QDataStream & in, Bookmark & bm )
{
in >> bm.lastPage;
in >> bm.bookmarks;
in >> bm.added;
return in;
}
};
BookmarksList():numMaxBookmarks(400){}
void load();
void save();
void add(const QString & comicID, const Bookmark & b);
Bookmark get(const QString & comicID);
protected:
QMap<QString,Bookmark> list;
void deleteOldest(int num);
private:
int numMaxBookmarks;
};
class Bookmarks : public QObject
{
Q_OBJECT
protected:
QString comicPath;
//bookmarks setted by the user
QMap<int,QImage> bookmarks;
QList<int> latestBookmarks;
//last page readed
int lastPageIndex;
QImage lastPage;
BookmarksList list;
QDateTime added;
public:
Bookmarks();
void setLastPage(int index,const QImage & page);
void setBookmark(int index,const QImage & page);
void removeBookmark(int index);
QList<int> getBookmarkPages() const;
QImage getBookmarkPixmap(int page) const;
QImage getLastPagePixmap() const;
int getLastPage() const;
bool isBookmark(int page);
bool imageLoaded(int page);
void newComic(const QString & path);
void clear();
void save();
bool load(const QList<int> & bookmarkIndexes, int lastPage);
};
#endif // BOOKMARKS_H

View File

@ -0,0 +1,82 @@
#include "check_new_version.h"
#include <QUrl>
#include <QtGlobal>
#include <QStringList>
#include <QNetworkAccessManager>
#include <QEventLoop>
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkReply>
#define PREVIOUS_VERSION_TESTING "6.0.0"
HttpVersionChecker::HttpVersionChecker()
:HttpWorker("https://bitbucket.org/luisangelsm/yacreader/wiki/Home")
{
connect(this,SIGNAL(dataReady(const QByteArray &)),this,SLOT(checkNewVersion(const QByteArray &)));
}
void HttpVersionChecker::checkNewVersion(const QByteArray & data)
{
checkNewVersion(QString(data));
}
bool HttpVersionChecker::checkNewVersion(QString sourceContent)
{
#ifdef Q_OS_WIN32
QRegExp rx("YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32");
#endif
#if defined Q_OS_UNIX && !defined Q_OS_MAC
QRegExp rx("YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}X11");
#endif
#ifdef Q_OS_MAC
QRegExp rx("YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}Mac");
#endif
int index = 0;
bool newVersion = false;
bool sameVersion = true;
//bool currentVersionIsNewer = false;
#ifdef QT_DEBUG
QString version(PREVIOUS_VERSION_TESTING);
#else
QString version(VERSION);
#endif
QStringList sl = version.split(".");
if((index = rx.indexIn(sourceContent))!=-1)
{
int length = qMin(sl.size(),(rx.cap(4)!="")?4:3);
for(int i=0;i<length;i++)
{
if(rx.cap(i+1).toInt()<sl.at(i).toInt())
{
return false;
}
if(rx.cap(i+1).toInt()>sl.at(i).toInt()){
newVersion=true;
break;
}
else
sameVersion = sameVersion && rx.cap(i+1).toInt()==sl.at(i).toInt();
}
if(!newVersion && sameVersion)
{
if((sl.size()==3)&&(rx.cap(4)!=""))
newVersion = true;
}
}
if(newVersion == true)
{
emit newVersionDetected();
return true;
}
else
{
return false;
}
}

View File

@ -0,0 +1,26 @@
#ifndef __CHECKUPDATE_H
#define __CHECKUPDATE_H
#include "http_worker.h"
#include "yacreader_global.h"
#include <QByteArray>
#include <QThread>
class HttpVersionChecker : public HttpWorker
{
Q_OBJECT
public:
HttpVersionChecker();
public slots:
private:
bool found;
private slots:
bool checkNewVersion(QString sourceContent);
void checkNewVersion(const QByteArray & data);
signals:
void newVersionDetected();
};
#endif

1108
common/comic.cpp Normal file

File diff suppressed because it is too large Load Diff

190
common/comic.h Normal file
View File

@ -0,0 +1,190 @@
#ifndef __COMIC_H
#define __COMIC_H
#include <QtCore>
#include <QImage>
#include <QtGui>
#include <QByteArray>
#include <QMap>
#include "extract_delegate.h"
#include "bookmarks.h"
#ifndef NO_PDF
#include "pdf_comic.h"
#endif //NO_PDF
class ComicDB;
//#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" Comic::getSupportedImageFormats()
//#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //Comic::getSupportedImageLiteralFormats()
class Comic : public QObject
{
Q_OBJECT
protected:
//Comic pages, one QPixmap for each file.
QVector<QByteArray> _pages;
QVector<bool> _loadedPages;
//QVector<uint> _sizes;
QStringList _fileNames;
QMap<QString,int> _newOrder;
QList<QString> _order;
int _index;
QString _path;
bool _loaded;
int _cfi;
//open the comic at this point
int _firstPage;
bool _isPDF;
public:
static const QStringList imageExtensions;
static const QStringList literalImageExtensions;
static const QStringList comicExtensions;
static const QStringList literalComicExtensions;
Bookmarks * bm;
//Constructors
Comic();
Comic(const QString & pathFile, int atPage = -1);
~Comic();
void setup();
//Load pages from file
virtual bool load(const QString & path, int atPage = -1) = 0;
virtual bool load(const QString & path, const ComicDB & comic);
/*void loadFromFile(const QString & pathFile);
void loadFromDir(const QString & pathDir);
void loadFromPDF(const QString & pathPDF);*/
int nextPage();
int previousPage();
void setIndex(unsigned int index);
unsigned int getIndex(){return _index;};
unsigned int numPages(){return _pages.size();}
//QPixmap * currentPage();
bool loaded();
//QPixmap * operator[](unsigned int index);
QVector<QByteArray> * getRawData(){return &_pages;}
QByteArray getRawPage(int page);
bool pageIsLoaded(int page);
inline static QStringList getSupportedImageFormats() { return imageExtensions;}
inline static QStringList getSupportedImageLiteralFormats() { return literalImageExtensions;}
static bool fileIsComic(const QString &path);
static QList<QString> findValidComicFiles(const QList<QUrl> & list);
static QList<QString> findValidComicFilesInFolder(const QString &path);
public slots:
void loadFinished();
void setBookmark();
void removeBookmark();
void saveBookmarks();
void checkIsBookmark(int index);
void updateBookmarkImage(int);
void setPageLoaded(int page);
signals:
void imagesLoaded();
void imageLoaded(int index);
void imageLoaded(int index,const QByteArray & image);
void pageChanged(int index);
void openAt(int index);
void numPages(unsigned int numPages);
void errorOpening();
void errorOpening(QString);
void crcErrorFound(QString);
void isBookmark(bool);
void bookmarksUpdated();
void isCover();
void isLast();
};
class FileComic : public Comic, public ExtractDelegate
{
Q_OBJECT
private:
QList<QVector<quint32> > getSections(int & sectionIndex);
public:
FileComic();
FileComic(const QString & path, int atPage = -1);
~FileComic();
void fileExtracted(int index, const QByteArray & rawData);
virtual bool load(const QString & path, int atPage = -1);
virtual bool load(const QString & path, const ComicDB & comic);
void crcError(int index);
void unknownError(int index);
static QList<QString> filter(const QList<QString> & src);
public slots:
void process();
};
class FolderComic : public Comic
{
Q_OBJECT
private:
//void run();
public:
FolderComic();
FolderComic(const QString & path, int atPage = -1);
~FolderComic();
virtual bool load(const QString & path, int atPage = -1);
public slots:
void process();
};
#ifndef NO_PDF
class PDFComic : public Comic
{
Q_OBJECT
private:
//pdf
#if defined Q_OS_MAC && defined USE_PDFKIT
MacOSXPDFComic * pdfComic;
#elif defined USE_PDFIUM
PdfiumComic * pdfComic;
#else
Poppler::Document * pdfComic;
#endif
void renderPage(int page);
//void run();
public:
PDFComic();
PDFComic(const QString & path, int atPage = -1);
~PDFComic();
virtual bool load(const QString & path, int atPage = -1);
virtual bool load(const QString & path, const ComicDB & comic);
public slots:
void process();
};
#endif //NO_PDF
class FactoryComic
{
public:
static Comic * newComic(const QString & path);
};
#endif

607
common/comic_db.cpp Normal file
View File

@ -0,0 +1,607 @@
#include "comic_db.h"
#include <QVariant>
#include <QFileInfo>
//-----------------------------------------------------------------------------
//COMIC------------------------------------------------------------------------
//-----------------------------------------------------------------------------
ComicDB::ComicDB()
{
}
ComicDB::ComicDB(const ComicDB &comicDB)
{
operator=(comicDB);
}
bool ComicDB::isDir()
{
return false;
}
QString ComicDB::toTXT()
{
QString txt;
//Legacy info
txt.append(QString("comicid:%1\r\n").arg(id));
txt.append(QString("hash:%1\r\n").arg(info.hash));
txt.append(QString("path:%1\r\n").arg(path));
txt.append(QString("numpages:%1\r\n").arg(info.numPages.toString()));
//new 7.0
txt.append(QString("rating:%1\r\n").arg(info.rating));
txt.append(QString("currentPage:%1\r\n").arg(info.currentPage));
txt.append(QString("contrast:%1\r\n").arg(info.contrast));
//Informaci<63>n general
if(!info.coverPage.isNull())
txt.append(QString("coverPage:%1\r\n").arg(info.coverPage.toString()));
if(!info.title.isNull())
txt.append(QString("title:%1\r\n").arg(info.title.toString()));
if(!info.number.isNull())
txt.append(QString("number:%1\r\n").arg(info.number.toString()));
if(!info.isBis.isNull())
txt.append(QString("isBis:%1\r\n").arg(info.isBis.toBool()?"1":"0"));
if(!info.count.isNull())
txt.append(QString("count:%1\r\n").arg(info.count.toString()));
if(!info.volume.isNull())
txt.append(QString("volume:%1\r\n").arg(info.volume.toString()));
if(!info.storyArc.isNull())
txt.append(QString("storyArc:%1\r\n").arg(info.storyArc.toString()));
if(!info.arcNumber.isNull())
txt.append(QString("arcNumber:%1\r\n").arg(info.arcNumber.toString()));
if(!info.arcCount.isNull())
txt.append(QString("arcCount:%1\r\n").arg(info.arcCount.toString()));
if(!info.genere.isNull())
txt.append(QString("genere:%1\r\n").arg(info.genere.toString()));
//Autores
if(!info.writer.isNull())
txt.append(QString("writer:%1\r\n").arg(info.writer.toString()));
if(!info.penciller.isNull())
txt.append(QString("penciller:%1\r\n").arg(info.penciller.toString()));
if(!info.inker.isNull())
txt.append(QString("inker:%1\r\n").arg(info.inker.toString()));
if(!info.colorist.isNull())
txt.append(QString("colorist:%1\r\n").arg(info.colorist.toString()));
if(!info.letterer.isNull())
txt.append(QString("letterer:%1\r\n").arg(info.letterer.toString()));
if(!info.coverArtist.isNull())
txt.append(QString("coverArtist:%1\r\n").arg(info.coverArtist.toString()));
//Publicaci<63>n
if(!info.date.isNull())
txt.append(QString("date:%1\r\n").arg(info.date.toString()));
if(!info.publisher.isNull())
txt.append(QString("publisher:%1\r\n").arg(info.publisher.toString()));
if(!info.format.isNull())
txt.append(QString("format:%1\r\n").arg(info.format.toString()));
if(!info.color.isNull())
txt.append(QString("color:%1\r\n").arg(info.color.toString()));
if(!info.ageRating.isNull())
txt.append(QString("ageRating:%1\r\n").arg(info.ageRating.toString()));
//Argumento
if(!info.synopsis.isNull())
txt.append(QString("synopsis:%1\r\n").arg(info.synopsis.toString()));
if(!info.characters.isNull())
txt.append(QString("characters:%1\r\n").arg(info.characters.toString()));
if(!info.notes.isNull())
txt.append(QString("notes:%1\r\n").arg(info.notes.toString()));
return txt;
}
ComicDB &ComicDB::operator=(const ComicDB &other)
{
LibraryItem::operator =(other);
this->_hasCover = other._hasCover;
this->info = other.info;
return *this;
}
QString ComicDB::getFileName() const
{
return QFileInfo(path).fileName();
}
QString ComicDB::getTitleOrFileName() const
{
if(!info.title.isNull() && info.title.toString().isEmpty())
return info.title.toString();
else
return QFileInfo(path).fileName();
}
QString ComicDB::getParentFolderName() const
{
QStringList paths = path.split('/');
if(paths.length()<2)
return "";
else
return paths[paths.length()-2];
}
qulonglong ComicDB::getFileSize() const
{
//the size is encoded in the hash after the SHA-1
return info.hash.right(info.hash.length()-40).toLongLong();
}
QString ComicDB::getTitleIncludingNumber() const
{
if(!info.number.isNull())
{
return "#" + info.number.toString() + " - " + getTitleOrFileName();
}
return getTitleOrFileName();
}
//-----------------------------------------------------------------------------
//COMIC_INFO-------------------------------------------------------------------
//-----------------------------------------------------------------------------
ComicInfo::ComicInfo()
:existOnDb(false),
rating(0),
hasBeenOpened(false),
currentPage(1),
bookmark1(-1),
bookmark2(-1),
bookmark3(-1),
brightness(-1),
contrast(-1),
gamma(-1)
{
}
ComicInfo::ComicInfo(const ComicInfo & comicInfo)
{
operator=(comicInfo);
}
ComicInfo::~ComicInfo()
{
}
//the default operator= should work
ComicInfo & ComicInfo::operator=(const ComicInfo & comicInfo)
{
hash = comicInfo.hash;
id = comicInfo.id;
existOnDb = comicInfo.existOnDb;
read = comicInfo.read;
edited = comicInfo.edited;
hasBeenOpened = comicInfo.hasBeenOpened;
rating = comicInfo.rating;
currentPage = comicInfo.currentPage;
bookmark1 = comicInfo.bookmark1;
bookmark2 = comicInfo.bookmark2;
bookmark3 = comicInfo.bookmark3;
brightness = comicInfo.brightness;
contrast = comicInfo.contrast;
gamma = comicInfo.gamma;
title = comicInfo.title;
coverPage = comicInfo.coverPage;
numPages = comicInfo.numPages;
number = comicInfo.number;
isBis = comicInfo.isBis;
count = comicInfo.count;
volume = comicInfo.volume;
storyArc = comicInfo.storyArc;
arcNumber = comicInfo.arcNumber;
arcCount = comicInfo.arcCount;
genere = comicInfo.genere;
writer = comicInfo.writer;
penciller = comicInfo.penciller;
inker = comicInfo.inker;
colorist = comicInfo.colorist;
letterer = comicInfo.letterer;
coverArtist = comicInfo.coverArtist;
date = comicInfo.date;
publisher = comicInfo.publisher;
format = comicInfo.format;
color = comicInfo.color;
ageRating = comicInfo.ageRating;
synopsis = comicInfo.synopsis;
characters = comicInfo.characters;
notes = comicInfo.notes;
comicVineID = comicInfo.comicVineID;
return *this;
}
//set fields
/*
void ComicInfo::setTitle(QString value)
{
setValue(title,value);
}
void ComicInfo::setCoverPage(int value)
{
setValue(coverPage,value);
}
void ComicInfo::setNumPages(int value)
{
setValue(numPages,value);
}
void ComicInfo::setNumber(int value)
{
setValue(number,value);
}
void ComicInfo::setIsBis(bool value)
{
setValue(isBis,value);
}
void ComicInfo::setCount(int value)
{
setValue(count,value);
}
void ComicInfo::setVolume(QString value)
{
setValue(volume,value);
}
void ComicInfo::setStoryArc(QString value)
{
setValue(storyArc,value);
}
void ComicInfo::setArcNumber(int value)
{
setValue(arcNumber,value);
}
void ComicInfo::setArcCount(int value)
{
setValue(arcCount,value);
}
void ComicInfo::setGenere(QString value)
{
setValue(genere,value);
}
void ComicInfo::setWriter(QString value)
{
setValue(writer,value);
}
void ComicInfo::setPenciller(QString value)
{
setValue(penciller,value);
}
void ComicInfo::setInker(QString value)
{
setValue(inker,value);
}
void ComicInfo::setColorist(QString value)
{
setValue(colorist,value);
}
void ComicInfo::setLetterer(QString value)
{
setValue(letterer,value);
}
void ComicInfo::setCoverArtist(QString value)
{
setValue(coverArtist,value);
}
void ComicInfo::setDate(QString value)
{
setValue(date,value);
}
void ComicInfo::setPublisher(QString value)
{
setValue(publisher,value);
}
void ComicInfo::setFormat(QString value)
{
setValue(format,value);
}
void ComicInfo::setColor(bool value)
{
setValue(color,value);
}
void ComicInfo::setAgeRating(QString value)
{
setValue(ageRating,value);
}
void ComicInfo::setSynopsis(QString value)
{
setValue(synopsis,value);
}
void ComicInfo::setCharacters(QString value)
{
setValue(characters,value);
}
void ComicInfo::setNotes(QString value)
{
setValue(notes,value);
}*/
QPixmap ComicInfo::getCover(const QString & basePath)
{
if(cover.isNull())
{
cover.load(basePath + "/.yacreaderlibrary/covers/" + hash + ".jpg");
}
QPixmap c;
c.convertFromImage(cover);
return c;
}
QStringList ComicInfo::getWriters()
{
if(writer.toString().length()>0)
{
return writer.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getPencillers()
{
if(penciller.toString().length()>0)
{
return penciller.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getInkers()
{
if(inker.toString().length()>0)
{
return inker.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getColorists()
{
if(colorist.toString().length()>0)
{
return colorist.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getLetterers()
{
if(letterer.toString().length()>0)
{
return letterer.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getCoverArtists()
{
if(coverArtist.toString().length()>0)
{
return coverArtist.toString().split("\n");
}
return QStringList();
}
QStringList ComicInfo::getCharacters()
{
if(characters.toString().length()>0)
{
return characters.toString().split("\n");
}
return QStringList();
}
void ComicInfo::setRead(bool r)
{
if(r != read)
{
read = r;
emit readChanged();
}
}
void ComicInfo::setRating(int r)
{
if(r != rating)
{
rating = r;
emit ratingChanged();
}
}
void ComicInfo::setFavorite(bool f)
{
if(f != isFavorite)
{
isFavorite = f;
emit favoriteChanged();
}
}
QDataStream &operator<<(QDataStream & stream, const ComicDB & comic)
{
stream << comic.id;
stream << comic.name;
stream << comic.parentId;
stream << comic.path;
stream << comic._hasCover;
stream << comic.info;
return stream;
}
QDataStream &operator>>(QDataStream & stream, ComicDB & comic)
{
stream >> comic.id;
stream >> comic.name;
stream >> comic.parentId;
stream >> comic.path;
stream >> comic._hasCover;
stream >> comic.info;
return stream;
}
QDataStream &operator<<(QDataStream & stream, const ComicInfo & comicInfo)
{
stream << comicInfo.id;
stream << comicInfo.read;
stream << comicInfo.edited;
stream << comicInfo.hash;
stream << comicInfo.existOnDb;
stream << comicInfo.hasBeenOpened;
stream << comicInfo.rating;
stream << comicInfo.currentPage;
stream << comicInfo.bookmark1;
stream << comicInfo.bookmark2;
stream << comicInfo.bookmark3;
stream << comicInfo.brightness;
stream << comicInfo.contrast;
stream << comicInfo.gamma;
stream << comicInfo.title;
stream << comicInfo.coverPage;
stream << comicInfo.numPages;
stream << comicInfo.number;
stream << comicInfo.isBis;
stream << comicInfo.count;
stream << comicInfo.volume;
stream << comicInfo.storyArc;
stream << comicInfo.arcNumber;
stream << comicInfo.arcCount;
stream << comicInfo.genere;
stream << comicInfo.writer;
stream << comicInfo.penciller;
stream << comicInfo.inker;
stream << comicInfo.colorist;
stream << comicInfo.letterer;
stream << comicInfo.coverArtist;
stream << comicInfo.date;
stream << comicInfo.publisher;
stream << comicInfo.format;
stream << comicInfo.color;
stream << comicInfo.ageRating;
stream << comicInfo.synopsis;
stream << comicInfo.characters;
stream << comicInfo.notes;
stream << comicInfo.comicVineID;
return stream;
}
QDataStream &operator>>(QDataStream & stream, ComicInfo & comicInfo)
{
stream >> comicInfo.id;
stream >> comicInfo.read;
stream >> comicInfo.edited;
stream >> comicInfo.hash;
stream >> comicInfo.existOnDb;
stream >> comicInfo.hasBeenOpened;
stream >> comicInfo.rating;
stream >> comicInfo.currentPage;
stream >> comicInfo.bookmark1;
stream >> comicInfo.bookmark2;
stream >> comicInfo.bookmark3;
stream >> comicInfo.brightness;
stream >> comicInfo.contrast;
stream >> comicInfo.gamma;
stream >> comicInfo.title;
stream >> comicInfo.coverPage;
stream >> comicInfo.numPages;
stream >> comicInfo.number;
stream >> comicInfo.isBis;
stream >> comicInfo.count;
stream >> comicInfo.volume;
stream >> comicInfo.storyArc;
stream >> comicInfo.arcNumber;
stream >> comicInfo.arcCount;
stream >> comicInfo.genere;
stream >> comicInfo.writer;
stream >> comicInfo.penciller;
stream >> comicInfo.inker;
stream >> comicInfo.colorist;
stream >> comicInfo.letterer;
stream >> comicInfo.coverArtist;
stream >> comicInfo.date;
stream >> comicInfo.publisher;
stream >> comicInfo.format;
stream >> comicInfo.color;
stream >> comicInfo.ageRating;
stream >> comicInfo.synopsis;
stream >> comicInfo.characters;
stream >> comicInfo.notes;
stream >> comicInfo.comicVineID;
return stream;
}

248
common/comic_db.h Normal file
View File

@ -0,0 +1,248 @@
#ifndef __COMICDB_H
#define __COMICDB_H
#include "library_item.h"
#include <QVariant>
#include <QList>
#include <QPixmap>
#include <QImage>
#include <QMetaType>
typedef QPair<QString,QString> YACReaderComicInfoPair;
Q_DECLARE_METATYPE(YACReaderComicInfoPair)
class ComicInfo : public QObject
{
Q_OBJECT
public:
ComicInfo();
ComicInfo(const ComicInfo & comicInfo);
~ComicInfo();
ComicInfo & operator=(const ComicInfo & comicInfo);
bool operator==(const ComicInfo & other){return id == other.id;}
bool operator!=(const ComicInfo & other){return id != other.id;}
//mandatory fields
qulonglong id;
bool read;
bool edited;
QString hash;
bool existOnDb;
int rating;
bool hasBeenOpened;
//viewer
int currentPage;
int bookmark1;
int bookmark2;
int bookmark3;
int brightness;
int contrast;
int gamma;
//-----------------
QVariant title;//string
QVariant coverPage;//int
QVariant numPages;//int
QVariant number;//int
QVariant isBis;//bool
QVariant count;//int
QVariant volume;//string
QVariant storyArc;//string
QVariant arcNumber;//int
QVariant arcCount;//int
QVariant genere;//string
QVariant writer;//string
QVariant penciller;//string
QVariant inker;//string
QVariant colorist;//string
QVariant letterer;//string
QVariant coverArtist;//string
QVariant date;//string
QVariant publisher;//string
QVariant format;//string
QVariant color;//bool
QVariant ageRating;//string
QVariant synopsis;//string
QVariant characters;//string
QVariant notes;//string
QVariant comicVineID;//string
QImage cover;
/*void setTitle(QVariant value);
void setCoverPage(QVariant value);
void setNumPages(QVariant value);
void setNumber(QVariant value);
void setIsBis(QVariant value);
void setCount(QVariant value);
void setVolume(QVariant value);
void setStoryArc(QVariant value);
void setArcNumber(QVariant value);
void setArcCount(QVariant value);
void setGenere(QVariant value);
void setWriter(QVariant value);
void setPenciller(QVariant value);
void setInker(QVariant value);
void setColorist(QVariant value);
void setLetterer(QVariant value);
void setCoverArtist(QVariant value);
void setDate(QVariant value);
void setPublisher(QVariant value);
void setFormat(QVariant value);
void setColor(QVariant value);
void setAgeRating(QVariant value);
void setSynopsis(QVariant value);
void setCharacters(QVariant value);
void setNotes(QVariant value);*/
QPixmap getCover(const QString & basePath);
Q_INVOKABLE QStringList getWriters();
Q_INVOKABLE QStringList getPencillers();
Q_INVOKABLE QStringList getInkers();
Q_INVOKABLE QStringList getColorists();
Q_INVOKABLE QStringList getLetterers();
Q_INVOKABLE QStringList getCoverArtists();
Q_INVOKABLE QStringList getCharacters();
friend QDataStream &operator<<(QDataStream & stream, const ComicInfo & comicInfo);
friend QDataStream &operator>>(QDataStream & stream, ComicInfo & comicInfo);
Q_PROPERTY(qulonglong id MEMBER id CONSTANT)
Q_PROPERTY(bool read MEMBER read WRITE setRead NOTIFY readChanged)
Q_PROPERTY(bool edited MEMBER edited CONSTANT)
Q_PROPERTY(QString hash MEMBER hash CONSTANT)
Q_PROPERTY(bool existOnDb MEMBER existOnDb CONSTANT)
Q_PROPERTY(int rating MEMBER rating WRITE setRating NOTIFY ratingChanged)
Q_PROPERTY(bool hasBeenOpened MEMBER hasBeenOpened CONSTANT)
Q_PROPERTY(int currentPage MEMBER currentPage CONSTANT)
Q_PROPERTY(int bookmark1 MEMBER bookmark1 CONSTANT)
Q_PROPERTY(int bookmark2 MEMBER bookmark2 CONSTANT)
Q_PROPERTY(int bookmark3 MEMBER bookmark3 CONSTANT)
Q_PROPERTY(int brightness MEMBER brightness CONSTANT)
Q_PROPERTY(int contrast MEMBER contrast CONSTANT)
Q_PROPERTY(int gamma MEMBER gamma CONSTANT)
Q_PROPERTY(QVariant title MEMBER title CONSTANT)
Q_PROPERTY(QVariant coverPage MEMBER coverPage CONSTANT)
Q_PROPERTY(QVariant numPages MEMBER numPages CONSTANT)
Q_PROPERTY(QVariant number MEMBER number CONSTANT)
Q_PROPERTY(QVariant isBis MEMBER isBis CONSTANT)
Q_PROPERTY(QVariant count MEMBER count CONSTANT)
Q_PROPERTY(QVariant volume MEMBER volume CONSTANT)
Q_PROPERTY(QVariant storyArc MEMBER storyArc CONSTANT)
Q_PROPERTY(QVariant arcNumber MEMBER arcNumber CONSTANT)
Q_PROPERTY(QVariant arcCount MEMBER arcCount CONSTANT)
Q_PROPERTY(QVariant genere MEMBER genere CONSTANT)
Q_PROPERTY(QVariant writer MEMBER writer CONSTANT)
Q_PROPERTY(QVariant penciller MEMBER penciller CONSTANT)
Q_PROPERTY(QVariant inker MEMBER inker CONSTANT)
Q_PROPERTY(QVariant colorist MEMBER colorist CONSTANT)
Q_PROPERTY(QVariant letterer MEMBER letterer CONSTANT)
Q_PROPERTY(QVariant coverArtist MEMBER coverArtist CONSTANT)
Q_PROPERTY(QVariant date MEMBER date CONSTANT)
Q_PROPERTY(QVariant publisher MEMBER publisher CONSTANT)
Q_PROPERTY(QVariant format MEMBER format CONSTANT)
Q_PROPERTY(QVariant color MEMBER color CONSTANT)
Q_PROPERTY(QVariant ageRating MEMBER ageRating CONSTANT)
Q_PROPERTY(QVariant synopsis MEMBER synopsis CONSTANT)
Q_PROPERTY(QVariant characters MEMBER characters CONSTANT)
Q_PROPERTY(QVariant notes MEMBER notes CONSTANT)
Q_PROPERTY(QVariant comicVineID MEMBER comicVineID CONSTANT)
Q_PROPERTY(QImage cover MEMBER cover CONSTANT)
//-new properties, not loaded from the DB automatically
bool isFavorite;
Q_PROPERTY(bool isFavorite MEMBER isFavorite WRITE setFavorite NOTIFY favoriteChanged)
//setters, used in QML only by now
void setRead(bool r);
void setRating(int r);
void setFavorite(bool f);
private:
signals:
void readChanged();
void ratingChanged();
void favoriteChanged();
};
class ComicDB : public LibraryItem
{
Q_OBJECT
public:
ComicDB();
ComicDB(const ComicDB & comicDB);
bool isDir();
bool _hasCover;
bool hasCover() {return _hasCover;}
//return comic file name
QString getFileName() const;
//returns comic title if it isn't null or empty, in other case returns fileName
Q_INVOKABLE QString getTitleOrFileName() const;
//returns parent folder name
QString getParentFolderName() const;
//return the size of the file in bytes
Q_INVOKABLE qulonglong getFileSize() const;
Q_INVOKABLE QString getTitleIncludingNumber() const;
QString toTXT();
ComicInfo info;
Q_PROPERTY(ComicInfo info MEMBER info)
ComicDB & operator=(const ComicDB & other);
bool operator==(const ComicDB & other){return id == other.id;}
friend QDataStream &operator<<(QDataStream &, const ComicDB &);
friend QDataStream &operator>>(QDataStream &, ComicDB &);
};
Q_DECLARE_METATYPE(ComicDB)
#endif

View File

@ -0,0 +1 @@
#include "custom_widgets.h"

6
common/custom_widgets.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __CUSTOM_WIDGETS_H
#define __CUSTOM_WIDGETS_H
#endif

21
common/exit_check.cpp Normal file
View File

@ -0,0 +1,21 @@
#include "exit_check.h"
#include "yacreader_global.h"
#include <QMessageBox>
using namespace YACReader;
void YACReader::exitCheck(int ret)
{
switch(ret)
{
case YACReader::SevenZNotFound:
QMessageBox::critical(0,QObject::tr("7z lib not found"),QObject::tr("unable to load 7z lib from ./utils"));
break;
default:
break;
}
}

9
common/exit_check.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef EXIT_CHECK_H
#define EXIT_CHECK_H
namespace YACReader
{
void exitCheck(int ret);
}
#endif

19
common/folder.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "folder.h"
Folder::Folder(const Folder &folder)
{
operator=(folder);
}
Folder &Folder::operator =(const Folder &other)
{
LibraryItem::operator =(other);
this->knownParent = other.knownParent;
this->knownId = other.knownId;
this->finished = other.finished;
this->completed = other.completed;
return *this;
}

32
common/folder.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef __FOLDER_H
#define __FOLDER_H
#include "library_item.h"
#include <QList>
class Folder : public LibraryItem
{
public:
bool knownParent;
bool knownId;
Folder():knownParent(false), knownId(false){}
Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;}
Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;}
Folder(const Folder &folder);
Folder &operator =(const Folder & other);
void setId(qulonglong sid){id = sid;knownId = true;}
void setFather(qulonglong pid){parentId = pid;knownParent = true;}
bool isDir() {return true;}
bool isFinished() const {return finished;}
bool isCompleted() const {return completed;}
void setFinished(bool b) {finished = b;}
void setCompleted(bool b) {completed = b;}
private:
bool finished;
bool completed;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,388 @@
//OpenGL Coverflow API by J.Roth
#ifndef __YACREADER_FLOW_GL_H
#define __YACREADER_FLOW_GL_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#include <QtWidgets>
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
#include "scroll_management.h"
class ImageLoaderGL;
class QGLContext;
class WidgetLoader;
class ImageLoaderByteArrayGL;
enum Performance
{
low=0,
medium,
high,
ultraHigh
};
//Cover Vector
struct YACReader3DVector{
float x;
float y;
float z;
float rot;
};
//the image/texture info struct
struct YACReader3DImage{
QOpenGLTexture * texture;
//char name[256];
float width;
float height;
int index;
YACReader3DVector current;
YACReader3DVector 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;
float zoom;
};
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 QOpenGLWidget, public ScrollManagement
{
Q_OBJECT
protected:
int timerId;
/*** System variables ***/
YACReader3DImage dummy;
int viewRotateActive;
float stepBackup;
/*functions*/
void calcPos(YACReader3DImage & image, int pos);
void calcVector(YACReader3DVector & vector, int pos);
//returns true if the animation is finished for Current
bool animate(YACReader3DVector &currentVector, YACReader3DVector &toVector);
void drawCover(const YACReader3DImage & image);
void udpatePerspective(int width, int height);
int updateCount;
WidgetLoader * loader;
int fontSize;
QOpenGLTexture * defaultTexture;
QOpenGLTexture * markTexture;
QOpenGLTexture * readingTexture;
void initializeGL();
void paintGL();
void timerEvent(QTimerEvent *);
//number of Covers
int numObjects;
int lazyPopulateObjects;
bool showMarks;
QVector<bool> loaded;
QVector<YACReaderComicReadStatus> marks;
QVector<YACReader3DImage> images;
bool hasBeenInitialized;
Performance performance;
bool bUseVSync;
/*** Animation Settings ***/
Preset config;
//sets/returns the curent selected cover
int currentSelected;
//defines the position of the centered cover
YACReader3DVector 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;
//sets the updateInterval in ms
static int updateInterval;
// sets flow direction right-to-left (manga mode)
bool flowRightToLeft;
void startAnimationTimer();
void stopAnimationTimer();
public:
/*Constructor*/
YACReaderFlowGL(QWidget *parent = 0,struct Preset p = pressetYACReaderFlowDownConfig);
virtual ~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, QOpenGLTexture * texture, float x, float y, int item = -1);
//removes a item
virtual void remove(int item);
//replaces the texture of the item 'item' with Tex
void replace(char *name, QOpenGLTexture * texture, float x, float y, int item);
//create n covers with the default nu
void populate(int n);
/*Info*/
//retuns the YACReader3DImage Struct of the current selected item
//to read title or textures
YACReader3DImage 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 setCF_Z(int value);
void setY_Distance(int value);
void setFadeOutDist(int value);
void setLightStrenght(int value);
void setMaxAngle(int value);
void setPreset(const Preset & p);
void setPerformance(Performance performance);
void useVSync(bool b);
void setFlowRightToLeft(bool b);
virtual void updateImageData() = 0;
void reset();
void reload();
//interface with yacreaderlibrary, compatibility
void setShowMarks(bool value);
void setMarks(QVector<YACReaderComicReadStatus> marks);
void setMarkImage(QImage & image);
void markSlide(int index, YACReaderComicReadStatus status);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setCenterIndex(unsigned 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);
friend class ImageLoaderGL;
friend class ImageLoaderByteArrayGL;
signals:
void centerIndexChanged(int);
void selected(unsigned int);
};
class YACReaderComicFlowGL : public YACReaderFlowGL
{
public:
YACReaderComicFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
void setImagePaths(QStringList paths);
void updateImageData();
void remove(int item);
void resortCovers(QList<int> newOrder);
friend class ImageLoaderGL;
private:
ImageLoaderGL * worker;
protected:
QList<QString> paths;
};
class YACReaderPageFlowGL : public YACReaderFlowGL
{
public:
YACReaderPageFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
~YACReaderPageFlowGL();
void updateImageData();
void populate(int n);
QVector<bool> imagesReady;
QVector<QByteArray> rawImages;
QVector<bool> imagesSetted;
friend class ImageLoaderByteArrayGL;
private:
ImageLoaderByteArrayGL * worker;
};
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;fileName="";}
int index() const { return idx; }
void lock();
void unlock();
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 ImageLoaderByteArrayGL : public QThread
{
public:
ImageLoaderByteArrayGL(YACReaderFlowGL * flow);
~ImageLoaderByteArrayGL();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, const QByteArray& raw);
void reset(){idx = -1; rawData.clear();}
int index() const { return idx; }
QImage result();
YACReaderFlowGL * flow;
GLuint resultTexture;
QImage loadImage(const QByteArray& rawData);
protected:
void run();
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool working;
int idx;
QByteArray rawData;
QSize size;
QImage img;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,380 @@
//OpenGL Coverflow API by J.Roth
#ifndef __YACREADER_FLOW_GL_H
#define __YACREADER_FLOW_GL_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <QtOpenGL>
#include <QGLWidget>
#include <QtWidgets>
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
#include "scroll_management.h"
class ImageLoaderGL;
class QGLContext;
class WidgetLoader;
class ImageLoaderByteArrayGL;
enum Performance
{
low=0,
medium,
high,
ultraHigh
};
//Cover Vector
struct YACReader3DVector{
float x;
float y;
float z;
float rot;
};
//the image/texture info struct
struct YACReader3DImage{
GLuint texture;
//char name[256];
float width;
float height;
int index;
YACReader3DVector current;
YACReader3DVector 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;
float zoom;
};
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, public ScrollManagement
{
Q_OBJECT
protected:
int timerId;
/*** System variables ***/
YACReader3DImage dummy;
int viewRotateActive;
float stepBackup;
/*functions*/
void calcPos(YACReader3DImage & image, int pos);
void calcVector(YACReader3DVector & vector, int pos);
//returns true if the animation is finished for Current
bool animate(YACReader3DVector &currentVector, YACReader3DVector &toVector);
void drawCover(const YACReader3DImage & image);
void udpatePerspective(int width, int height);
int updateCount;
WidgetLoader * loader;
int fontSize;
GLuint defaultTexture;
GLuint markTexture;
GLuint readingTexture;
void initializeGL();
void paintGL();
void timerEvent(QTimerEvent *);
//number of Covers
int numObjects;
int lazyPopulateObjects;
bool showMarks;
QVector<bool> loaded;
QVector<YACReaderComicReadStatus> marks;
QVector<YACReader3DImage> images;
bool hasBeenInitialized;
Performance performance;
bool bUseVSync;
/*** Animation Settings ***/
Preset config;
//sets/returns the curent selected cover
int currentSelected;
//defines the position of the centered cover
YACReader3DVector 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;
//sets the updateInterval in ms
static int updateInterval;
void startAnimationTimer();
void stopAnimationTimer();
public:
/*Constructor*/
YACReaderFlowGL(QWidget *parent = 0,struct Preset p = pressetYACReaderFlowDownConfig);
virtual ~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(const char *name, GLuint Tex, float x, float y,int item = -1);
//removes a item
virtual void remove(int item);
//replaces the texture of the item 'item' with Tex
void replace(const char *name, GLuint Tex, float x, float y,int item);
//create n covers with the default nu
void populate(int n);
/*Info*/
//retuns the YACReader3DImage Struct of the current selected item
//to read title or textures
YACReader3DImage 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 setCF_Z(int value);
void setY_Distance(int value);
void setFadeOutDist(int value);
void setLightStrenght(int value);
void setMaxAngle(int value);
void setPreset(const Preset & p);
void setPerformance(Performance performance);
void useVSync(bool b);
virtual void updateImageData() = 0;
void reset();
void reload();
//interface with yacreaderlibrary, compatibility
void setShowMarks(bool value);
void setMarks(QVector<YACReaderComicReadStatus> marks);
void setMarkImage(QImage & image);
void markSlide(int index, YACReaderComicReadStatus status);
void unmarkSlide(int index);
void setSlideSize(QSize size);
void clear();
void setCenterIndex(unsigned 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);
friend class ImageLoaderGL;
friend class ImageLoaderByteArrayGL;
signals:
void centerIndexChanged(int);
void selected(unsigned int);
};
class YACReaderComicFlowGL : public YACReaderFlowGL
{
public:
YACReaderComicFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
void setImagePaths(QStringList paths);
void updateImageData();
void remove(int item);
void resortCovers(QList<int> newOrder);
friend class ImageLoaderGL;
private:
ImageLoaderGL * worker;
protected:
QList<QString> paths;
};
class YACReaderPageFlowGL : public YACReaderFlowGL
{
public:
YACReaderPageFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
~YACReaderPageFlowGL();
void updateImageData();
void populate(int n);
QVector<bool> imagesReady;
QVector<QByteArray> rawImages;
QVector<bool> imagesSetted;
friend class ImageLoaderByteArrayGL;
private:
ImageLoaderByteArrayGL * worker;
};
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;fileName="";}
int index() const { return idx; }
void lock();
void unlock();
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 ImageLoaderByteArrayGL : public QThread
{
public:
ImageLoaderByteArrayGL(YACReaderFlowGL * flow);
~ImageLoaderByteArrayGL();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, const QByteArray& raw);
void reset(){idx = -1; rawData.clear();}
int index() const { return idx; }
QImage result();
YACReaderFlowGL * flow;
GLuint resultTexture;
QImage loadImage(const QByteArray& rawData);
protected:
void run();
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool working;
int idx;
QByteArray rawData;
QSize size;
QImage img;
};
#endif

65
common/http_worker.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "http_worker.h"
#include <QUrl>
#include <QtGlobal>
#include <QStringList>
#include <QNetworkAccessManager>
#include <QEventLoop>
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkReply>
#define PREVIOUS_VERSION "6.0.0"
HttpWorker::HttpWorker(const QString & urlString)
:QThread(),url(urlString),_error(false),_timeout(false)
{
}
void HttpWorker::get()
{
this->start();
}
QByteArray HttpWorker::getResult()
{
return result;
}
bool HttpWorker::wasValid()
{
return !_error;
}
bool HttpWorker::wasTimeout()
{
return _timeout;
}
void HttpWorker::run()
{
QNetworkAccessManager manager;
QEventLoop q;
QTimer tT;
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
QNetworkReply *reply = manager.get(QNetworkRequest(url));
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
// download complete
_error = !(reply->error() == QNetworkReply::NoError);
result = reply->readAll();
emit dataReady(result);
tT.stop();
} else {
_timeout = true;
emit timeout();
}
}

31
common/http_worker.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef __HTTP_WORKER_H
#define __HTTP_WORKER_H
#include <QByteArray>
#include <QThread>
#include <QUrl>
#include "yacreader_global.h"
class HttpWorker : public QThread
{
Q_OBJECT
public:
HttpWorker(const QString & urlString);
public slots:
void get();
QByteArray getResult();
bool wasValid();
bool wasTimeout();
private:
void run();
QUrl url;
int httpGetId;
QByteArray result;
bool _error;
bool _timeout;
signals:
void dataReady(const QByteArray &);
void timeout();
};
#endif

12
common/library_item.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "library_item.h"
LibraryItem &LibraryItem::operator=(const LibraryItem &other)
{
this->name = other.name;
this->path = other.path;
this->parentId = other.parentId;
this->id = other.id;
return *this;
}

18
common/library_item.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __LIBRARY_ITEM_H
#define __LIBRARY_ITEM_H
#include <QObject>
class LibraryItem : public QObject
{
Q_OBJECT
public:
virtual bool isDir() = 0;
LibraryItem & operator=(const LibraryItem & other);
QString name;
QString path;
qulonglong parentId;
qulonglong id;
};
#endif

View File

@ -0,0 +1,54 @@
#include "onstart_flow_selection_dialog.h"
#include <QPushButton>
#include <QHBoxLayout>
#include <qlocale.h>
OnStartFlowSelectionDialog::OnStartFlowSelectionDialog(QWidget * parent)
:QDialog(parent)
{
setModal(true);
QPushButton * acceptHW = new QPushButton(this);
connect(acceptHW,SIGNAL(clicked()),this,SLOT(accept()));
QPushButton * rejectHW = new QPushButton(this); //and use SW flow
connect(rejectHW,SIGNAL(clicked()),this,SLOT(reject()));
acceptHW->setGeometry(90,165,110,118);
acceptHW->setFlat(true);
acceptHW->setAutoFillBackground(true);
rejectHW->setGeometry(464,165,110,118);
rejectHW->setFlat(true);
rejectHW->setAutoFillBackground(true);
QPalette paletteHW;
QLocale locale = this->locale();
QLocale::Language language = locale.language();
/*if(language == QLocale::Spanish)
paletteHW.setBrush(acceptHW->backgroundRole(), QBrush(QImage(":/images/useNewFlowButton_es.png")));
else
paletteHW.setBrush(acceptHW->backgroundRole(), QBrush(QImage(":/images/useNewFlowButton.png")));*/
paletteHW.setBrush(acceptHW->backgroundRole(), QBrush(QImage(":/images/nonexxx.png")));
acceptHW->setPalette(paletteHW);
QPalette paletteSW;
paletteSW.setBrush(rejectHW->backgroundRole(), QBrush(QImage(":/images/nonexxx.png")));
rejectHW->setPalette(paletteSW);
//QHBoxLayout * layout = new QHBoxLayout;
//layout->addWidget(acceptHW);
//layout->addWidget(rejectHW);
QPalette palette;
if(language == QLocale::Spanish)
palette.setBrush(this->backgroundRole(), QBrush(QImage(":/images/onStartFlowSelection_es.png")));
else
palette.setBrush(this->backgroundRole(), QBrush(QImage(":/images/onStartFlowSelection.png")));
setPalette(palette);
//setLayout(layout);
resize(664,371);
}

View File

@ -0,0 +1,13 @@
#ifndef ONSTART_FLOW_SELECTION_DIALOG_H
#define ONSTART_FLOW_SELECTION_DIALOG_H
#include <QDialog>
class OnStartFlowSelectionDialog : public QDialog
{
Q_OBJECT
public:
OnStartFlowSelectionDialog(QWidget * parent = 0);
};
#endif

69
common/opengl_checker.cpp Normal file
View File

@ -0,0 +1,69 @@
#include "opengl_checker.h"
#include "QsLog.h"
OpenGLChecker::OpenGLChecker()
:compatibleOpenGLVersion(true)
{
QOpenGLContext * openGLContext = new QOpenGLContext();
openGLContext->create();
if(!openGLContext->isValid())
{
compatibleOpenGLVersion = false;
description = "unable to create QOpenGLContext";
}
QSurfaceFormat format = openGLContext->format();
int majorVersion = format.majorVersion();
int minorVersion = format.minorVersion();
QString type;
switch (format.renderableType()) {
case QSurfaceFormat::OpenGL:
type = "desktop";
break;
case QSurfaceFormat::OpenGLES:
type = "OpenGL ES";
break;
case QSurfaceFormat::OpenVG:
type = "OpenVG";
default: case QSurfaceFormat::DefaultRenderableType:
type = "unknown";
break;
}
delete openGLContext;
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
if(format.renderableType() != QSurfaceFormat::OpenGL) //Desktop OpenGL
compatibleOpenGLVersion = false;
#ifdef Q_OS_WIN //TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget
static const int majorTargetVersion = 1;
static const int minorTargetVersion = 4;
#else
static const int majorTargetVersion = 2;
static const int minorTargetVersion = 0;
#endif
if(majorVersion < majorTargetVersion)
compatibleOpenGLVersion = false;
if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
compatibleOpenGLVersion = false;
}
QString OpenGLChecker::textVersionDescription()
{
return description;
}
bool OpenGLChecker::hasCompatibleOpenGLVersion()
{
return compatibleOpenGLVersion;
}

17
common/opengl_checker.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef OPENGL_CHECKER_H
#define OPENGL_CHECKER_H
#include <QOpenGLContext>
class OpenGLChecker
{
public:
OpenGLChecker();
bool hasCompatibleOpenGLVersion();
QString textVersionDescription();
private:
QString description;
bool compatibleOpenGLVersion;
};
#endif // OPENGL_CHECKER_H

77
common/pdf_comic.cpp Normal file
View File

@ -0,0 +1,77 @@
#include "comic.h"
#include "pdf_comic.h"
#if defined USE_PDFIUM && !defined NO_PDF
PdfiumComic::PdfiumComic()
{
FPDF_InitLibrary();
}
PdfiumComic::~PdfiumComic()
{
if (doc)
{
FPDF_CloseDocument(doc);
}
FPDF_DestroyLibrary();
}
bool PdfiumComic::openComic(const QString & path)
{
doc = FPDF_LoadDocument(path.toLocal8Bit().constData(), NULL);
if (doc)
{
return true;
}
else
{
qDebug() << FPDF_GetLastError();
return false;
}
}
void PdfiumComic::closeComic()
{
FPDF_CloseDocument(doc);
}
unsigned int PdfiumComic::numPages()
{
if (doc)
{
return FPDF_GetPageCount(doc);
}
else
{
return 0; //-1?
}
}
QImage PdfiumComic::getPage(const int page)
{
QImage image;
FPDF_PAGE pdfpage;
FPDF_BITMAP bitmap;
pdfpage = FPDF_LoadPage(doc, page);
if (!pdfpage)
{
qDebug() << FPDF_GetLastError();
return QImage();
}
//TODO: make target DPI configurable
double width = (FPDF_GetPageWidth(pdfpage)/72)*150;
double height = (FPDF_GetPageHeight(pdfpage)/72)*150;
image = QImage(width, height, QImage::Format_ARGB32);// QImage::Format_RGBX8888);
image.fill(0xFFFFFFFF);
bitmap = FPDFBitmap_CreateEx(image.width(), image.height(), FPDFBitmap_BGRA, image.scanLine(0), image.bytesPerLine());
//TODO: make render flags costumizable
FPDF_RenderPageBitmap(bitmap, pdfpage, 0,0, image.width(), image.height(), 0, (FPDF_LCD_TEXT));
FPDFBitmap_Destroy(bitmap);
FPDF_ClosePage(pdfpage);
return image;
}
#endif //USE_PDFIUM

44
common/pdf_comic.h Normal file
View File

@ -0,0 +1,44 @@
#if !defined PDF_COMIC_H && !defined NO_PDF
#define PDF_COMIC_H
#include <QObject>
#include <QImage>
#if defined Q_OS_MAC && defined USE_PDFKIT
class MacOSXPDFComic
{
public:
MacOSXPDFComic();
~MacOSXPDFComic();
bool openComic(const QString & path);
void closeComic();
unsigned int numPages();
QImage getPage(const int page);
//void releaseLastPageData();
private:
void * document;
void * lastPageData;
};
#elif defined USE_PDFIUM
#include <fpdfview.h>
class PdfiumComic
{
public:
PdfiumComic();
~PdfiumComic();
bool openComic(const QString & path);
void closeComic();
unsigned int numPages();
QImage getPage(const int page);
private:
FPDF_LIBRARY_CONFIG config;
FPDF_DOCUMENT doc;
};
#else
#include "poppler-qt5.h"
#endif // Q_OS_MAC
#endif // PDF_COMIC_H

130
common/pdf_comic.mm Normal file
View File

@ -0,0 +1,130 @@
#include "pdf_comic.h"
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
#include "QsLog.h"
#include "QsLogDest.h"
MacOSXPDFComic::MacOSXPDFComic()
{
}
MacOSXPDFComic::~MacOSXPDFComic()
{
CGPDFDocumentRelease((CGPDFDocumentRef)document);
}
bool MacOSXPDFComic::openComic(const QString &path)
{
CFURLRef pdfFileUrl;
CFStringRef str;
str=CFStringCreateWithCString( kCFAllocatorDefault,path.toUtf8().data(),kCFStringEncodingUTF8);
pdfFileUrl=CFURLCreateWithFileSystemPath( kCFAllocatorDefault,str,kCFURLPOSIXPathStyle,true );
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfFileUrl);
document = pdf;
CFRelease(str);
CFRelease(pdfFileUrl);
return true;
}
void MacOSXPDFComic::closeComic()
{
//CGPDFDocumentRelease((CGPDFDocumentRef)document);
}
unsigned int MacOSXPDFComic::numPages()
{
return (int)CGPDFDocumentGetNumberOfPages((CGPDFDocumentRef)document);
}
QImage MacOSXPDFComic::getPage(const int pageNum)
{
CGPDFPageRef page = CGPDFDocumentGetPage((CGPDFDocumentRef)document, pageNum+1);
// Changed this line for the line above which is a generic line
//CGPDFPageRef page = [self getPage:page_number];
CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
int width = 1200;
//NSLog(@"-----%f",pageRect.size.width);
CGFloat pdfScale = float(width)/pageRect.size.width;
pageRect.size = CGSizeMake(pageRect.size.width*pdfScale, pageRect.size.height*pdfScale);
pageRect.origin = CGPointZero;
CGColorSpaceRef genericColorSpace = CGColorSpaceCreateDeviceRGB();
QImage renderImage = QImage(pageRect.size.width, pageRect.size.height, QImage::Format_ARGB32_Premultiplied);
CGContextRef bitmapContext = CGBitmapContextCreate(renderImage.scanLine(0),
pageRect.size.width,
pageRect.size.height,
8,renderImage.bytesPerLine(),
genericColorSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little //may need to be changed to kCGBitmapByteOrder32Big
);
CGContextSetInterpolationQuality(bitmapContext, kCGInterpolationHigh);
CGContextSetRenderingIntent(bitmapContext, kCGRenderingIntentDefault);
CGContextSetRGBFillColor( bitmapContext, 1.0, 1.0, 1.0, 1.0 );
CGContextFillRect( bitmapContext, CGContextGetClipBoundingBox( bitmapContext ));
//CGContextTranslateCTM( bitmapContext, 0, pageRect.size.height );
//CGContextScaleCTM( bitmapContext, 1.0, -1.0 );
CGContextConcatCTM(bitmapContext, CGAffineTransformMakeScale(pdfScale, pdfScale));
/*CGAffineTransform pdfXfm = CGPDFPageGetDrawingTransform( page, kCGPDFMediaBox, CGRectMake(pageRect.origin.x, pageRect.origin.y, pageRect.size.width, pageRect.size.height) , 0, true );
*/
//CGContextConcatCTM( bitmapContext, pdfXfm );
CGContextDrawPDFPage(bitmapContext, page);
//CGImageRef image = CGBitmapContextCreateImage(bitmapContext);
//QImage qtImage;
//CFDataRef dataRef = CGDataProviderCopyData(CGImageGetDataProvider(image));
/*lastPageData = (void *)dataRef;
if(!lastPageData)
{
QLOG_ERROR() << "Unable to extract image from PDF file using CGPDFDocument";
CGImageRelease(image);
CGContextRelease(bitmapContext);
CGColorSpaceRelease(genericColorSpace);
return QImage();
}
const uchar *bytes = (const uchar *)CFDataGetBytePtr(dataRef);
qtImage = QImage(bytes, pageRect.size.width, pageRect.size.height, QImage::Format_ARGB32);
*/
//CGImageRelease(image);
//CFRelease(dataRef);
CGContextRelease(bitmapContext);
//CGPDFPageRelease(page);
CGColorSpaceRelease(genericColorSpace);
//return qtImage;
return renderImage;
}
/*void MacOSXPDFComic::releaseLastPageData()
{
CFRelease((CFDataRef)lastPageData);
}*/

1473
common/pictureflow.cpp Normal file

File diff suppressed because it is too large Load Diff

234
common/pictureflow.h Normal file
View File

@ -0,0 +1,234 @@
/*
PictureFlow - animated image show widget
http://pictureflow.googlecode.com
Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PICTUREFLOW_H
#define PICTUREFLOW_H
#include <qwidget.h>
#include "yacreader_global_gui.h" //FlowType
class PictureFlowPrivate;
using namespace YACReader;
/*!
Class PictureFlow implements an image show widget with animation effect
like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form
of slides, one main slide is shown at the center with few slides on
the left and right sides of the center slide. When the next or previous
slide is brought to the front, the whole slides flow to the right or
the right with smooth animation effect; until the new slide is finally
placed at the center.
*/
class PictureFlow : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize)
Q_PROPERTY(int slideCount READ slideCount)
Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex)
public:
enum ReflectionEffect
{
NoReflection,
PlainReflection,
BlurredReflection
};
/*!
Creates a new PictureFlow widget.
*/
PictureFlow(QWidget* parent = 0, FlowType flowType = CoverFlowLike);
/*!
Destroys the widget.
*/
~PictureFlow();
/*!
Returns the background color.
*/
QColor backgroundColor() const;
/*!
Sets the background color. By default it is black.
*/
void setBackgroundColor(const QColor& c);
/*!
Returns the dimension of each slide (in pixels).
*/
QSize slideSize() const;
/*!
Sets the dimension of each slide (in pixels).
*/
void setSlideSize(QSize size);
/*!
Returns the total number of slides.
*/
int slideCount() const;
/*!
Returns QImage of specified slide.
*/
QImage slide(int index) const;
/*!
Returns the index of slide currently shown in the middle of the viewport.
*/
int centerIndex() const;
/*!
Returns the effect applied to the reflection.
*/
ReflectionEffect reflectionEffect() const;
/*!
Sets the effect applied to the reflection. The default is PlainReflection.
*/
void setReflectionEffect(ReflectionEffect effect);
/*!
Sets the flow direction right-to-left (manga mode)
*/
void setFlowRightToLeft(bool b);
public slots:
/*!
Adds a new slide.
*/
void addSlide(const QImage& image);
/*!
Adds a new slide.
*/
void addSlide(const QPixmap& pixmap);
/*!
Removes an existing slide.
*/
void removeSlide(int index);
/*!
Sets an image for specified slide. If the slide already exists,
it will be replaced.
*/
void setSlide(int index, const QImage& image);
/*!
Sets a pixmap for specified slide. If the slide already exists,
it will be replaced.
*/
void setSlide(int index, const QPixmap& pixmap);
/*!
Sets slide to be shown in the middle of the viewport. No animation
effect will be produced, unlike using showSlide.
*/
void setCenterIndex(int index);
/*!
Clears all slides.
*/
void clear();
/*!
Shows previous slide using animation effect.
*/
void showPrevious();
/*!
Shows next slide using animation effect.
*/
void showNext();
/*!
Go to specified slide using animation effect.
*/
void showSlide(unsigned int index);
/*!
Rerender the widget. Normally this function will be automatically invoked
whenever necessary, e.g. during the transition animation.
*/
void render();
/*!
Schedules a rendering update. Unlike render(), this function does not cause
immediate rendering.
*/
void triggerRender();
void setFlowType(FlowType flowType);
void setMarkImage(const QImage & mark);
void markSlide(int index, YACReaderComicReadStatus readStatus = Read);
void updateMarks();
void unmarkSlide(int index);
void setMarks(const QVector<YACReaderComicReadStatus> & marks);
void setShowMarks(bool enable);
QVector<YACReaderComicReadStatus> getMarks();
void resortCovers(QList<int> newOrder);
signals:
void centerIndexChanged(int index);
void centerIndexChangedSilent(int index);
public:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event, int slideWidth);
void resizeEvent(QResizeEvent* event);
private slots:
void updateAnimation();
private:
PictureFlowPrivate* d;
QImage mark;
int framesSkip;
};
#endif // PICTUREFLOW_H

View File

@ -0,0 +1,32 @@
#include "qnaturalsorting.h"
#include <QCollator>
int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity caseSensitivity)
{
QCollator c;
c.setCaseSensitivity(caseSensitivity);
c.setNumericMode(true);
return c.compare(s1, s2);
}
bool naturalSortLessThanCS( const QString &left, const QString &right )
{
return (naturalCompare( left, right, Qt::CaseSensitive ) < 0);
}
bool naturalSortLessThanCI( const QString &left, const QString &right )
{
return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0);
}
bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right)
{
return naturalSortLessThanCI(left.fileName(),right.fileName());
}
bool naturalSortLessThanCILibraryItem(LibraryItem * left, LibraryItem * right)
{
return naturalSortLessThanCI(left->name,right->name);
}

15
common/qnaturalsorting.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __QNATURALSORTING_H
#define __QNATURALSORTING_H
#include <QString>
#include <QFileInfo>
#include "library_item.h"
bool naturalSortLessThanCS( const QString &left, const QString &right );
bool naturalSortLessThanCI( const QString &left, const QString &right );
bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right);
bool naturalSortLessThanCILibraryItem(LibraryItem * left, LibraryItem * right);
#endif

View File

@ -0,0 +1,61 @@
#include "scroll_management.h"
ScrollManagement::ScrollManagement()
{
wheelTimer = new QTime();
wheelTimer->start();
wheelAccumulator = 0;
}
ScrollManagement::Movement ScrollManagement::getMovement(QWheelEvent *event)
{
/*QLOG_DEBUG() << "WheelEvent angle delta : " << event->angleDelta();
QLOG_DEBUG() << "WheelEvent pixel delta : " << event->pixelDelta();*/
int tooFast = 1;
int timeThrottle = 16;
int minimumMove = 70;
//avoid any events overflood
if((wheelTimer->elapsed() < tooFast)){
event->setAccepted(true);
return None;
}
// Accumulate the delta
if(event->delta()<0 != wheelAccumulator<0 ) //different sign means change in direction
wheelAccumulator = 0;
wheelAccumulator += event->delta();
//Do not process events too fast
if((wheelTimer->elapsed() < timeThrottle)){
event->setAccepted(true);
return None;
}
//small intervals are ignored until with have enough acumulated delta
if((wheelAccumulator < minimumMove) && (wheelAccumulator > -minimumMove)){
event->setAccepted(true);
return None;
}
Movement m;
if(wheelAccumulator<0)
m = Forward;
else
m = Backward;
event->accept();
//Clean up
wheelAccumulator = 0;
wheelTimer->restart();
return m;
}
ScrollManagement::~ScrollManagement()
{
}

View File

@ -0,0 +1,25 @@
#ifndef SCROLLMANAGAMENT_H
#define SCROLLMANAGAMENT_H
#include <QTime>
#include <QWheelEvent>
class ScrollManagement
{
public:
enum Movement{
None,
Forward,
Backward
};
ScrollManagement();
ScrollManagement::Movement getMovement(QWheelEvent * event);
~ScrollManagement();
private:
QTime * wheelTimer;
int wheelAccumulator;
};
#endif // SCROLLMANAGAMENT_H

View File

@ -0,0 +1,92 @@
#include "yacreader_global.h"
using namespace YACReader;
QString YACReader::getSettingsPath()
{
#if QT_VERSION >= 0x050000
return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#else
return QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif
}
QString YACReader::colorToName(LabelColors colors)
{
switch(colors){
case YRed:
return "red";
case YOrange:
return "orange";
case YYellow:
return "yellow";
case YGreen:
return "green";
case YCyan:
return "cyan";
case YBlue:
return "blue";
case YViolet:
return "violet";
case YPurple:
return "purple";
case YPink:
return "pink";
case YWhite:
return "white";
case YLight:
return "light";
case YDark:
return "dark";
}
return "";
}
QString YACReader::labelColorToRGBString(LabelColors color)
{
switch (color) {
case YRed:
return "#FD777C";
case YOrange:
return "#FEBF34";
case YYellow:
return "#F5E934";
case YGreen:
return "#B6E525";
case YCyan:
return "#9FFFDD";
case YBlue:
return "#82C7FF";
case YViolet:
return "#8286FF";
case YPurple:
return "#E39FFF";
case YPink:
return "#FF9FDD";
#ifdef Q_OS_MAC
case YWhite:
return "#E3E3E3";
#else
case YWhite:
return "#FFFFFF";
#endif
case YLight:
return "#C8C8C8";
case YDark:
return "#ABABAB";
}
return "";
}

73
common/yacreader_global.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef __YACREADER_GLOBAL_H
#define __YACREADER_GLOBAL_H
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#else
#include <QDesktopServices>
#endif
#define VERSION "8.6.0"
#define USE_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW "OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW "BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS"
#define LAST_VERSION_CHECK "LAST_VERSION_CHECK"
#define YACREADERLIBRARY_GUID "ea343ff3-2005-4865-b212-7fa7c43999b8"
#define LIBRARIES "LIBRARIES"
namespace YACReader
{
enum YACReaderIPCMessages
{
RequestComicInfo = 0,
SendComicInfo,
};
enum YACReaderComicReadStatus
{
Unread = 0,
Read = 1,
Opened = 2
};
enum YACReaderErrors
{
SevenZNotFound = 700
};
enum SearchModifiers{
NoModifiers = 0,
OnlyRead,
OnlyUnread,
ByAuthor
};
enum LabelColors{
YRed = 1,
YOrange,
YYellow,
YGreen,
YCyan,
YBlue,
YViolet,
YPurple,
YPink,
YWhite,
YLight,
YDark
};
QString getSettingsPath();
QString colorToName(LabelColors colors);
QString labelColorToRGBString(LabelColors color);
}
#endif

View File

@ -0,0 +1,51 @@
#include "yacreader_global_gui.h"
#include <QtCore>
#include <QAction>
using namespace YACReader;
void YACReader::addSperator(QWidget *w)
{
QAction * separator = new QAction(w);
separator->setSeparator(true);
w->addAction(separator);
}
QAction * YACReader::createSeparator()
{
QAction * a = new QAction(0);
a->setSeparator(true);
return a;
}
QIcon YACReader::noHighlightedIcon(const QString &path)
{
QPixmap p(path);
QIcon icon;//(path);
icon.addFile(path,p.size(),QIcon::Normal);
icon.addFile(path,p.size(),QIcon::Selected);
return icon;
}
void YACReader::colorize(QImage &img, QColor &col)
{
QRgb *data = (QRgb *)img.bits();
QRgb *end = data + img.width()*img.height();
int rcol = col.red(), gcol = col.green(), bcol = col.blue();
while(data != end) {
*data = qRgba(rcol,gcol,bcol,qAlpha(*data));
++data;
}
}
QList<qulonglong> YACReader::mimeDataToComicsIds(const QMimeData *data)
{
QList<qulonglong> comicIds;
QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
QDataStream in(&rawData,QIODevice::ReadOnly);
in >> comicIds; //deserialize the list of indentifiers
return comicIds;
}

View File

@ -0,0 +1,104 @@
#ifndef __YACREADER_GLOBAL_GUI_H
#define __YACREADER_GLOBAL_GUI_H
#include "yacreader_global.h"
#include <QWidget>
#include <QMimeData>
#define PATH "PATH"
#define MAG_GLASS_SIZE "MAG_GLASS_SIZE"
#define ZOOM_LEVEL "ZOOM_LEVEL"
#define SLIDE_SIZE "SLIDE_SIZE"
#define GO_TO_FLOW_SIZE "GO_TO_FLOW_SIZE"
#define FLOW_TYPE_SW "FLOW_TYPE_SW"
#define FITMODE "FITMODE"
#define FLOW_TYPE "FLOW_TYPE"
#define FULLSCREEN "FULLSCREEN"
#define Y_WINDOW_POS "POS"
#define Y_WINDOW_SIZE "SIZE"
#define MAXIMIZED "MAXIMIZED"
#define DOUBLE_PAGE "DOUBLE_PAGE"
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
#define BRIGHTNESS "BRIGHTNESS"
#define CONTRAST "CONTRAST"
#define GAMMA "GAMMA"
#define SHOW_INFO "SHOW_INFO"
#define QUICK_NAVI_MODE "QUICK_NAVI_MODE"
#define DISABLE_MOUSE_OVER_GOTO_FLOW "DISABLE_MOUSE_OVER_GOTO_FLOW"
#define FLOW_TYPE_GL "FLOW_TYPE_GL"
#define Y_POSITION "Y_POSITION"
#define COVER_DISTANCE "COVER_DISTANCE"
#define CENTRAL_DISTANCE "CENTRAL_DISTANCE"
#define ZOOM_LEVEL "ZOOM_LEVEL"
#define Z_COVER_OFFSET "Z_COVER_OFFSET"
#define COVER_ROTATION "COVER_ROTATION"
#define FADE_OUT_DIST "FADE_OUT_DIST"
#define LIGHT_STRENGTH "LIGHT_STRENGTH"
#define MAX_ANGLE "MAX_ANGLE"
#define PERFORMANCE "PERFORMANCE"
#define USE_OPEN_GL "USE_OPEN_GL"
#define X_ROTATION "X_ROTATION"
#define Y_COVER_OFFSET "Y_COVER_OFFSET"
#define V_SYNC "V_SYNC"
#define SERVER_ON "SERVER_ON"
#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY"
#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE"
#define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS"
#define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY"
#define COMICS_VIEW_STATUS "COMICS_VIEW_STATUS"
#define COMICS_VIEW_FLOW_SPLITTER_STATUS "COMICS_VIEW_FLOW_SPLITTER_STATUS"
#define SIDEBAR_SPLITTER_STATUS "SIDEBAR_SPLITTER_STATUS"
#define COMICS_GRID_COVER_SIZES "COMICS_GRID_COVER_SIZES"
#define COMICS_GRID_SHOW_INFO "COMICS_GRID_SHOW_INFO"
#define COMICS_GRID_INFO_WIDTH "COMICS_GRID_INFO_WIDTH"
#define COMIC_VINE_API_KEY "COMIC_VINE_API_KEY"
#define COMIC_VINE_BASE_URL "COMIC_VINE_BASE_URL"
namespace YACReader
{
static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids";
static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/yacreaderlibrary-sublist-rows";
enum FlowType
{
CoverFlowLike=0,
Strip,
StripOverlapped,
Modern,
Roulette,
Custom
};
enum ComicsViewStatus
{
Flow,
Grid,
Info
};
enum FitMode{
ToWidth=0x01,
ToHeight=0x02,
FullRes=0x03,
FullPage=0x04//,
//Text=0x05
};
void addSperator(QWidget * w);
QAction * createSeparator();
QIcon noHighlightedIcon(const QString & path);
void colorize(QImage &img, QColor &col);
QList<qulonglong> mimeDataToComicsIds(const QMimeData * data);
}
#endif