mirror of
https://github.com/YACReader/yacreader
synced 2025-07-25 00:15:07 -04:00
removed some ugly defines
This commit is contained in:
@ -6,7 +6,6 @@
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QList>
|
||||
#define NUM_BOOKMARKS 250
|
||||
|
||||
Bookmarks::Bookmarks()
|
||||
:lastPageIndex(0)
|
||||
@ -138,8 +137,8 @@ void BookmarksList::save()
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
|
||||
f.open(QIODevice::WriteOnly);
|
||||
QDataStream dataS(&f);
|
||||
if(list.count()>NUM_BOOKMARKS)
|
||||
deleteOldest(list.count()-NUM_BOOKMARKS);
|
||||
if(list.count()>numMaxBookmarks)
|
||||
deleteOldest(list.count()-numMaxBookmarks);
|
||||
dataS << list;
|
||||
f.close();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
};
|
||||
BookmarksList(){}
|
||||
BookmarksList():numMaxBookmarks(400){}
|
||||
void load();
|
||||
void save();
|
||||
void add(const QString & comicID, const Bookmark & b);
|
||||
@ -39,6 +39,8 @@ public:
|
||||
protected:
|
||||
QMap<QString,Bookmark> list;
|
||||
void deleteOldest(int num);
|
||||
private:
|
||||
int numMaxBookmarks;
|
||||
|
||||
};
|
||||
|
||||
|
@ -11,17 +11,20 @@
|
||||
#include "compressed_archive.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
QStringList Comic::extensions = QStringList() << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp";
|
||||
QStringList Comic::literalExtensions = QStringList() << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::Comic()
|
||||
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
|
||||
{
|
||||
setup();
|
||||
setup();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::Comic(const QString & pathFile, int atPage )
|
||||
:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false),_firstPage(atPage)
|
||||
{
|
||||
setup();
|
||||
setup();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::~Comic()
|
||||
@ -31,7 +34,7 @@ Comic::~Comic()
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::setup()
|
||||
{
|
||||
connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int)));
|
||||
connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int)));
|
||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int)));
|
||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
|
||||
}
|
||||
@ -103,7 +106,7 @@ void Comic::setBookmark()
|
||||
{
|
||||
QImage p;
|
||||
p.loadFromData(_pages[_index]);
|
||||
bm->setBookmark(_index,p);
|
||||
bm->setBookmark(_index,p);
|
||||
//emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
}
|
||||
@ -125,7 +128,7 @@ void Comic::saveBookmarks()
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::checkIsBookmark(int index)
|
||||
{
|
||||
emit isBookmark(bm->isBookmark(index));
|
||||
emit isBookmark(bm->isBookmark(index));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::updateBookmarkImage(int index)
|
||||
@ -241,8 +244,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic)
|
||||
|
||||
QList<QString> FileComic::filter(const QList<QString> & src)
|
||||
{
|
||||
QList<QString> extensions;
|
||||
extensions EXTENSIONS_LITERAL;
|
||||
QList<QString> extensions = getSupportedImageLiteralFormats();
|
||||
QList<QString> filtered;
|
||||
bool fileAccepted = false;
|
||||
|
||||
@ -493,9 +495,8 @@ bool FolderComic::load(const QString & path, int atPage )
|
||||
void FolderComic::process()
|
||||
{
|
||||
QDir d(_path);
|
||||
QStringList l;
|
||||
l EXTENSIONS;
|
||||
d.setNameFilters(l);
|
||||
|
||||
d.setNameFilters(getSupportedImageFormats());
|
||||
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
||||
//d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
QFileInfoList list = d.entryInfoList();
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "poppler-qt4.h"
|
||||
|
||||
class ComicDB;
|
||||
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"
|
||||
#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp"
|
||||
//#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
|
||||
@ -36,6 +36,9 @@ class ComicDB;
|
||||
int _firstPage;
|
||||
|
||||
bool _isPDF;
|
||||
|
||||
static QStringList extensions;
|
||||
static QStringList literalExtensions;
|
||||
public:
|
||||
Bookmarks * bm;
|
||||
|
||||
@ -62,6 +65,9 @@ class ComicDB;
|
||||
QVector<QByteArray> * getRawData(){return &_pages;};
|
||||
QByteArray getRawPage(int page);
|
||||
bool pageIsLoaded(int page);
|
||||
|
||||
inline static QStringList getSupportedImageFormats() { return extensions;};
|
||||
inline static QStringList getSupportedImageLiteralFormats() { return literalExtensions;};
|
||||
|
||||
public slots:
|
||||
void loadFinished();
|
||||
|
@ -673,7 +673,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName)
|
||||
|
||||
QDir d(pathDir);
|
||||
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
||||
d.setNameFilters(QStringList() EXTENSIONS);
|
||||
d.setNameFilters(Comic::getSupportedImageFormats());
|
||||
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
QStringList list = d.entryList();
|
||||
|
||||
@ -1016,8 +1016,7 @@ void MainWindowViewer::dropEvent(QDropEvent *event)
|
||||
info.setFile( fName ); // information about file
|
||||
if (info.isFile())
|
||||
{
|
||||
QStringList imageSuffixs;
|
||||
imageSuffixs EXTENSIONS_LITERAL;
|
||||
QStringList imageSuffixs = Comic::getSupportedImageLiteralFormats();
|
||||
if(imageSuffixs.contains("."+info.suffix())) //image dropped
|
||||
openFolderFromPath(info.absoluteDir().absolutePath(),info.fileName());
|
||||
else
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#define NL 2
|
||||
#define NR 2
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
@ -480,7 +477,7 @@ void DoublePageRender::run()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Render::Render()
|
||||
:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(NL),numRightPages(NR)
|
||||
:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(2),numRightPages(2)
|
||||
{
|
||||
int size = numLeftPages+numRightPages+1;
|
||||
currentPageBufferedIndex = numLeftPages;
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include "notifications_label_widget.h"
|
||||
#include "comic_db.h"
|
||||
#include <QFile>
|
||||
#define STEPS 22
|
||||
|
||||
|
||||
|
||||
Viewer::Viewer(QWidget * parent)
|
||||
@ -28,8 +26,8 @@ doublePage(false),
|
||||
wheelStop(false),
|
||||
direction(1),
|
||||
restoreMagnifyingGlass(false),
|
||||
drag(false)
|
||||
|
||||
drag(false),
|
||||
numScrollSteps(22)
|
||||
{
|
||||
translator = new YACReaderTranslator(this);
|
||||
translator->hide();
|
||||
@ -362,12 +360,12 @@ void Viewer::keyPressEvent(QKeyEvent *event)
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Space:
|
||||
posByStep = height()/STEPS;
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
|
||||
scrollDown();
|
||||
break;
|
||||
case Qt::Key_B:
|
||||
posByStep = height()/STEPS;
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
|
||||
scrollUp();
|
||||
break;
|
||||
|
@ -63,7 +63,7 @@ class NotificationsLabelWidget;
|
||||
bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;}
|
||||
void setBookmark(bool);
|
||||
void save();
|
||||
void doublePageSwitch();
|
||||
void doublePageSwitch();
|
||||
void resetContent();
|
||||
void setLoadingMessage();
|
||||
void setPageUnavailableMessage();
|
||||
@ -112,6 +112,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
QTimer * hideCursorTimer;
|
||||
int direction;
|
||||
bool drag;
|
||||
int numScrollSteps;
|
||||
|
||||
//!Widgets
|
||||
QLabel *content;
|
||||
|
Reference in New Issue
Block a user