a?adido #include <typeinfo> (compilaci?n Linux)

This commit is contained in:
Luis Ángel San Martín
2013-04-20 21:28:59 +02:00
commit 1c5ac619ef
429 changed files with 40460 additions and 0 deletions

View File

@ -0,0 +1,147 @@
#include "check_new_version.h"
#include <QMessageBox>
#include <QUrl>
#include <QtGlobal>
#include <QStringList>
#include <QNetworkAccessManager>
#include <QEventLoop>
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkReply>
#define PREVIOUS_VERSION "5.0.0"
HttpVersionChecker::HttpVersionChecker()
:QThread()
{
http = new QHttp(this);
connect(http, SIGNAL(requestFinished(int, bool)),
this, SLOT(httpRequestFinished(int, bool)));
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)),
this, SLOT(read(const QHttpResponseHeader &)));
}
void HttpVersionChecker::get()
{
this->start();
}
void HttpVersionChecker::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(
QUrl("http://code.google.com/p/yacreader/downloads/list")));
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
// download complete
checkNewVersion(reply->readAll());
tT.stop();
} else {
// timeout
}
/*QUrl url("http://code.google.com/p/yacreader/downloads/list");
QHttp::ConnectionMode mode = QHttp::ConnectionModeHttp;
http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
if (path.isEmpty())
path = "/";
httpGetId = http->get(path, 0);
exec();*/
}
void HttpVersionChecker::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
}
void HttpVersionChecker::read(const QHttpResponseHeader &){
content.append(http->readAll());
}
void HttpVersionChecker::httpRequestFinished(int requestId, bool error)
{
#ifdef QT_DEBUG
QString response("YACReader-5.0.0 win32.exe");
#else
QString response(content);
#endif
checkNewVersion(response);
exit();
}
//TODO escribir prueba unitaria
bool HttpVersionChecker::checkNewVersion(QString sourceContent)
{
#ifdef Q_WS_WIN
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32.*");
#endif
#ifdef Q_WS_X11
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}X11.*");
#endif
#ifdef Q_WS_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);
#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,33 @@
#ifndef __CHECKUPDATE_H
#define __CHECKUPDATE_H
#include <QWidget>
#include <QHttp>
#include <QHttpResponseHeader>
#include <QByteArray>
#include <QThread>
#include "yacreader_global.h"
class HttpVersionChecker : public QThread
{
Q_OBJECT
public:
HttpVersionChecker();
bool thereIsNewVersion();
public slots:
void httpRequestFinished(int requestId, bool error);
void readResponseHeader(const QHttpResponseHeader &);
void read(const QHttpResponseHeader &);
void get();
private:
void run();
QHttp *http;
int httpGetId;
QByteArray content;
bool found;
bool checkNewVersion(QString sourceContent);
signals:
void newVersionDetected();
};
#endif

View File

@ -0,0 +1,311 @@
#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);
}
void ComicFlowWidgetSW::updateConfig(QSettings * settings)
{
//flow->setFlowType(flowType);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///OpenGL ComicFlow
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent)
:ComicFlowWidget(parent)
{
flow = new YACReaderComicFlowGL(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);
l->setContentsMargins(0,0,0,0);
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)
{
if(flowType == PictureFlow::CoverFlowLike)
flow->setPreset(presetYACReaderFlowClassicConfig);
else if(flowType == PictureFlow::Strip)
flow->setPreset(presetYACReaderFlowStripeConfig);
else if(flowType == PictureFlow::StripOverlapped)
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
else
flow->setPreset(defaultYACReaderFlowConfig);
}
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);
}
void ComicFlowWidgetGL::updateConfig(QSettings * settings)
{
Performance performance = medium;
switch (settings->value("performance").toInt())
{
case 0:
performance = low;
break;
case 1:
performance = medium;
break;
case 2:
performance = high;
break;
case 3:
performance = ultraHigh;
break;
}
flow->setPerformance(performance);
switch (settings->value("flowType").toInt())
{
case 0:
flow->setPreset(presetYACReaderFlowClassicConfig);
return;
case 1:
flow->setPreset(presetYACReaderFlowStripeConfig);
return;
case 2:
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
return;
case 3:
flow->setPreset(defaultYACReaderFlowConfig);
return;
case 4:
flow->setPreset(pressetYACReaderFlowDownConfig);
return;
}
//custom config
flow->setCF_RX(settings->value("xRotation").toInt());
flow->setCF_Y(settings->value("yPosition").toInt());
flow->setX_Distance(settings->value("coverDistance").toInt());
flow->setCenter_Distance(settings->value("centralDistance").toInt());
flow->setCF_Z(settings->value("zoomLevel").toInt());
flow->setY_Distance(settings->value("yCoverOffset").toInt());
flow->setZ_Distance(settings->value("zCoverOffset").toInt());
flow->setRotation(settings->value("coverRotation").toInt());
flow->setFadeOutDist(settings->value("fadeOutDist").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt());
flow->setMaxAngle(settings->value("maxAngle").toInt());
/* flow->setVisibility(settings->value("visibilityDistance").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt())*/;
}
//void ComicFlowWidgetGL::setCF_RX(int value){ flow->setCF_RX(value);}
//void ComicFlowWidgetGL::setCF_RY(int value){ flow->setCF_RY(value);}
//void ComicFlowWidgetGL::setCF_RZ(int value){ flow->setCF_RZ(value);}
//void ComicFlowWidgetGL::setZoom(int zoom){ flow->setZoom(zoom);}
//void ComicFlowWidgetGL::setRotation(int angle){ flow->setRotation(angle);}
//void ComicFlowWidgetGL::setX_Distance(int distance){ flow->setX_Distance(distance);}
//void ComicFlowWidgetGL::setCenter_Distance(int distance){ flow->setCenter_Distance(distance);}
//void ComicFlowWidgetGL::setZ_Distance(int distance){ flow->setZ_Distance(distance);}
//void ComicFlowWidgetGL::setCF_Y(int value){ flow->setCF_Y(value);}
//void ComicFlowWidgetGL::setY_Distance(int value){ flow->setY_Distance(value);}
//void ComicFlowWidgetGL::setPreset(const Preset & p){ flow->setPreset(p);}

119
common/comic_flow_widget.h Normal file
View File

@ -0,0 +1,119 @@
#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;
virtual void updateConfig(QSettings * settings) = 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();
void updateConfig(QSettings * settings);
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:
YACReaderComicFlowGL * 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();
void updateConfig(QSettings * settings);
//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);
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;
};

1229
common/custom_widgets.cpp Normal file

File diff suppressed because it is too large Load Diff

381
common/custom_widgets.h Normal file
View File

@ -0,0 +1,381 @@
#ifndef __CUSTOM_WIDGETS_H
#define __CUSTOM_WIDGETS_H
#include <QDialog>
#include <QHBoxLayout>
#include <QTabWidget>
#include <QTextBrowser>
#include <QDir>
#include <QFileIconProvider>
#include <QDirModel>
#include <QFileInfo>
#include <QItemDelegate>
#include <QStyleOptionViewItemV2>
#include <QStyleOptionViewItemV4>
#include <QVariant>
#include <QSortFilterProxyModel>
#include <QModelIndex>
#include <QRegExp>
#include <QHash>
#include <QLineEdit>
#include <QAction>
#include <QPlainTextEdit>
#include <QTableView>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
#include <QRadioButton>
#include "yacreader_global.h"
#include "pictureflow.h"
#include "yacreader_flow_gl.h"
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class QToolBarStretch : public QWidget
{
public:
QToolBarStretch(QWidget * parent=0):QWidget(parent)
{
QHBoxLayout * l= new QHBoxLayout();
l->addStretch();
setLayout(l);
}
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class HelpAboutDialog : public QDialog
{
Q_OBJECT
public:
HelpAboutDialog(QWidget * parent=0);
HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0);
public slots:
void loadAboutInformation(const QString & path);
void loadHelp(const QString & path);
private:
QTabWidget *tabWidget;
QTextBrowser *aboutText;
QTextBrowser *helpText;
QString fileToString(const QString & path);
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderIconProvider : public QFileIconProvider
{
public:
YACReaderIconProvider();
virtual QIcon icon ( IconType type ) const;
virtual QIcon icon ( const QFileInfo & info ) const;
virtual QString type ( const QFileInfo & info ) const;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderFlow : public PictureFlow
{
Q_OBJECT
public:
YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
signals:
void selected(unsigned int centerIndex);
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderComicDirModel : public QDirModel
{
Q_OBJECT
public:
YACReaderComicDirModel( const QStringList & nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject * parent = 0 );
QString fileName ( const QModelIndex & index ) const;
QFileInfo fileInfo ( const QModelIndex & index ) const;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderComicViewDelegate : public QItemDelegate
{
Q_OBJECT
public:
YACReaderComicViewDelegate(QObject * parent = 0);
virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
QRect textLayoutBounds(const QStyleOptionViewItemV2 &option) const;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class ModelIndexCache
{
public:
struct CacheData{
bool visited;
bool acepted;
};
ModelIndexCache();
void setModelIndex(const QString & index, const CacheData & cd);
CacheData getCacheData(const QString & index) const;
void clear();
private:
QHash<QString, CacheData> cache;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderTreeSearch : public QSortFilterProxyModel
{
Q_OBJECT
public:
YACReaderTreeSearch(QObject * parent = 0);
protected:
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex & source_parent ) const;
bool itemMatchesExpression(const QModelIndex &index, const QRegExp &exp) const;
bool containsFiles(QString path,const QRegExp &exp) const;
public slots:
void reset();
void softReset();
private:
ModelIndexCache * cache;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderSortComics : public QSortFilterProxyModel
{
Q_OBJECT
public:
YACReaderSortComics(QObject * parent = 0);
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void delTree(QDir dir);
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderFieldEdit : public QLineEdit
{
Q_OBJECT
public:
YACReaderFieldEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
private:
QAction * restore;
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderFieldPlainTextEdit : public QPlainTextEdit
{
Q_OBJECT
public:
YACReaderFieldPlainTextEdit(QWidget * parent = 0);
void clear();
void setDisabled(bool disabled);
protected:
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e);
private:
QAction * restore;
};
//class YACReaderTableView : public QTableView
//{
// Q_OBJECT
//public:
// YACReaderTableView(QWidget *parent = 0)
// : QTableView(parent) {}
//
//protected:
// bool viewportEvent ( QEvent * event )
// {
// resizeColumnsToContents();
// return QTableView::viewportEvent(event);
// }
//};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderSpinSliderWidget : public QWidget
{
Q_OBJECT
private:
QLabel * label;
QSpinBox * spinBox;
QSlider * slider;
bool tracking;
public:
YACReaderSpinSliderWidget(QWidget * parent = 0,bool strechableSlider = false);
public slots:
void setRange(int lowValue, int topValue, int step=1);
void setValue(int value);
void setText(const QString & text);
int getValue();
QSize minimumSizeHint() const;
void setTracking(bool b);
void valueWillChange(int);
void valueWillChangeFromSpinBox(int);
void sliderRelease();
signals:
void valueChanged(int);
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
QRadioButton *radio1;
QRadioButton *radio2;
QRadioButton *radio3;
YACReaderFlowConfigWidget(QWidget * parent = 0);
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderGLFlowConfigWidget : public QWidget
{
Q_OBJECT
public:
YACReaderGLFlowConfigWidget(QWidget * parent = 0);
//GL.........................
QRadioButton *radioClassic;
QRadioButton *radioStripe;
QRadioButton *radioOver;
QRadioButton *radionModern;
QRadioButton *radioDown;
YACReaderSpinSliderWidget * xRotation;
YACReaderSpinSliderWidget * yPosition;
YACReaderSpinSliderWidget * coverDistance;
YACReaderSpinSliderWidget * centralDistance;
YACReaderSpinSliderWidget * zoomLevel;
YACReaderSpinSliderWidget * yCoverOffset;
YACReaderSpinSliderWidget * zCoverOffset;
YACReaderSpinSliderWidget * coverRotation;
YACReaderSpinSliderWidget * fadeOutDist;
YACReaderSpinSliderWidget * lightStrength;
YACReaderSpinSliderWidget * maxAngle;
QSlider * performanceSlider;
QCheckBox * vSyncCheck;
public slots:
void setValues(Preset preset);
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class YACReaderOptionsDialog : public QDialog
{
Q_OBJECT
protected:
YACReaderFlowConfigWidget * sw;
YACReaderGLFlowConfigWidget * gl;
QCheckBox * useGL;
QPushButton * accept;
QPushButton * cancel;
QSettings * settings;
QSettings * previousSettings;
public:
YACReaderOptionsDialog(QWidget * parent);
public slots:
virtual void restoreOptions(QSettings * settings);
virtual void saveOptions();
protected slots:
virtual void savePerformance(int value);
virtual void saveUseVSync(int b);
virtual void saveUseGL(int b);
virtual void saveXRotation(int value);
virtual void saveYPosition(int value);
virtual void saveCoverDistance(int value);
virtual void saveCentralDistance(int value);
virtual void saveZoomLevel(int value);
virtual void saveYCoverOffset(int value);
virtual void saveZCoverOffset(int value);
virtual void saveCoverRotation(int value);
virtual void saveFadeOutDist(int value);
virtual void saveLightStrength(int value);
virtual void saveMaxAngle(int value);
virtual void loadConfig();
virtual void setClassicConfig();
virtual void setStripeConfig();
virtual void setOverlappedStripeConfig();
virtual void setModernConfig();
virtual void setRouletteConfig();
virtual void setClassicConfigSW();
virtual void setStripeConfigSW();
virtual void setOverlappedStripeConfigSW();
virtual void saveFlowParameters();
signals:
void optionsChanged();
};
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#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

1342
common/pictureflow.cpp Normal file

File diff suppressed because it is too large Load Diff

220
common/pictureflow.h Normal file
View File

@ -0,0 +1,220 @@
/*
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.h" //FlowType
class PictureFlowPrivate;
/*!
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);
public slots:
/*!
Adds a new slide.
*/
void addSlide(const QImage& image);
/*!
Adds a new slide.
*/
void addSlide(const QPixmap& pixmap);
/*!
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);
void updateMarks();
void unmarkSlide(int index);
void setMarks(const QVector<bool> & marks);
void setShowMarks(bool enable);
QVector<bool> getMarks();
signals:
void centerIndexChanged(int index);
public:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
private slots:
void updateAnimation();
private:
PictureFlowPrivate* d;
QImage mark;
QVector<bool> marks;
int framesSkip;
};
#endif // PICTUREFLOW_H

257
common/qnaturalsorting.cpp Normal file
View File

@ -0,0 +1,257 @@
/* This file contains parts of the KDE libraries
Copyright (C) 1999 Ian Zepp (icszepp@islc.net)
Copyright (C) 2006 by Dominic Battre <dominic@battre.de>
Copyright (C) 2006 by Martin Pool <mbp@canonical.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "qnaturalsorting.h"
//from KDE
/*
int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity)
{
// This method chops the input a and b into pieces of
// digits and non-digits (a1.05 becomes a | 1 | . | 05)
// and compares these pieces of a and b to each other
// (first with first, second with second, ...).
//
// This is based on the natural sort order code code by Martin Pool
// http://sourcefrog.net/projects/natsort/
// Martin Pool agreed to license this under LGPL or GPL.
// FIXME: Using toLower() to implement case insensitive comparison is
// sub-optimal, but is needed because we compare strings with
// localeAwareCompare(), which does not know about case sensitivity.
// A task has been filled for this in Qt Task Tracker with ID 205990.
// http://trolltech.com/developer/task-tracker/index_html?method=entry&id=205990
QString a;
QString b;
if (caseSensitivity == Qt::CaseSensitive) {
a = _a;
b = _b;
} else {
a = _a.toLower();
b = _b.toLower();
}
const QChar* currA = a.unicode(); // iterator over a
const QChar* currB = b.unicode(); // iterator over b
if (currA == currB) {
return 0;
}
const QChar* begSeqA = currA; // beginning of a new character sequence of a
const QChar* begSeqB = currB;
while (!currA->isNull() && !currB->isNull()) {
if (currA->unicode() == QChar::ObjectReplacementCharacter) {
return 1;
}
if (currB->unicode() == QChar::ObjectReplacementCharacter) {
return -1;
}
if (currA->unicode() == QChar::ReplacementCharacter) {
return 1;
}
if (currB->unicode() == QChar::ReplacementCharacter) {
return -1;
}
// find sequence of characters ending at the first non-character
while (!currA->isNull() && !currA->isDigit() && !currA->isPunct() && !currA->isSpace()) {
++currA;
}
while (!currB->isNull() && !currB->isDigit() && !currB->isPunct() && !currB->isSpace()) {
++currB;
}
// compare these sequences
const QStringRef& subA(a.midRef(begSeqA - a.unicode(), currA - begSeqA));
const QStringRef& subB(b.midRef(begSeqB - b.unicode(), currB - begSeqB));
const int cmp = QStringRef::localeAwareCompare(subA, subB);
if (cmp != 0) {
return cmp < 0 ? -1 : +1;
}
if (currA->isNull() || currB->isNull()) {
break;
}
// find sequence of characters ending at the first non-character
while (currA->isPunct() || currA->isSpace() || currB->isPunct() || currB->isSpace()) {
if (*currA != *currB) {
return (*currA < *currB) ? -1 : +1;
}
++currA;
++currB;
}
// now some digits follow...
if ((*currA == '0') || (*currB == '0')) {
// one digit-sequence starts with 0 -> assume we are in a fraction part
// do left aligned comparison (numbers are considered left aligned)
while (1) {
if (!currA->isDigit() && !currB->isDigit()) {
break;
} else if (!currA->isDigit()) {
return +1;
} else if (!currB->isDigit()) {
return -1;
} else if (*currA < *currB) {
return -1;
} else if (*currA > *currB) {
return + 1;
}
++currA;
++currB;
}
} else {
// No digit-sequence starts with 0 -> assume we are looking at some integer
// do right aligned comparison.
//
// The longest run of digits wins. That aside, the greatest
// value wins, but we can't know that it will until we've scanned
// both numbers to know that they have the same magnitude.
bool isFirstRun = true;
int weight = 0;
while (1) {
if (!currA->isDigit() && !currB->isDigit()) {
if (weight != 0) {
return weight;
}
break;
} else if (!currA->isDigit()) {
if (isFirstRun) {
return *currA < *currB ? -1 : +1;
} else {
return -1;
}
} else if (!currB->isDigit()) {
if (isFirstRun) {
return *currA < *currB ? -1 : +1;
} else {
return +1;
}
} else if ((*currA < *currB) && (weight == 0)) {
weight = -1;
} else if ((*currA > *currB) && (weight == 0)) {
weight = + 1;
}
++currA;
++currB;
isFirstRun = false;
}
}
begSeqA = currA;
begSeqB = currB;
}
if (currA->isNull() && currB->isNull()) {
return 0;
}
return currA->isNull() ? -1 : + 1;
}
*/
static inline QChar getNextChar(const QString &s, int location)
{
return (location < s.length()) ? s.at(location) : QChar();
}
int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
{
for (int l1 = 0, l2 = 0; l1 <= s1.count() && l2 <= s2.count(); ++l1, ++l2) {
// skip spaces, tabs and 0's
QChar c1 = getNextChar(s1, l1);
while (c1.isSpace())
c1 = getNextChar(s1, ++l1);
QChar c2 = getNextChar(s2, l2);
while (c2.isSpace())
c2 = getNextChar(s2, ++l2);
if (c1.isDigit() && c2.isDigit()) {
while (c1.digitValue() == 0)
c1 = getNextChar(s1, ++l1);
while (c2.digitValue() == 0)
c2 = getNextChar(s2, ++l2);
int lookAheadLocation1 = l1;
int lookAheadLocation2 = l2;
int currentReturnValue = 0;
// find the last digit, setting currentReturnValue as we go if it isn't equal
for (
QChar lookAhead1 = c1, lookAhead2 = c2;
(lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length());
lookAhead1 = getNextChar(s1, ++lookAheadLocation1),
lookAhead2 = getNextChar(s2, ++lookAheadLocation2)
) {
bool is1ADigit = !lookAhead1.isNull() && lookAhead1.isDigit();
bool is2ADigit = !lookAhead2.isNull() && lookAhead2.isDigit();
if (!is1ADigit && !is2ADigit)
break;
if (!is1ADigit)
return -1;
if (!is2ADigit)
return 1;
if (currentReturnValue == 0) {
if (lookAhead1 < lookAhead2) {
currentReturnValue = -1;
} else if (lookAhead1 > lookAhead2) {
currentReturnValue = 1;
}
}
}
if (currentReturnValue != 0)
return currentReturnValue;
}
if (cs == Qt::CaseInsensitive) {
if (!c1.isLower()) c1 = c1.toLower();
if (!c2.isLower()) c2 = c2.toLower();
}
int r = QString::localeAwareCompare(c1, c2);
if (r < 0)
return -1;
if (r > 0)
return 1;
}
// The two strings are the same (02 == 2) so fall back to the normal sort
return QString::compare(s1, s2, cs);
}
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());
}

13
common/qnaturalsorting.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __QNATURALSORTING_H
#define __QNATURALSORTING_H
#include <QString>
#include <QFileInfo>
bool naturalSortLessThanCS( const QString &left, const QString &right );
bool naturalSortLessThanCI( const QString &left, const QString &right );
bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right);
#endif

1437
common/yacreader_flow_gl.cpp Normal file

File diff suppressed because it is too large Load Diff

390
common/yacreader_flow_gl.h Normal file
View File

@ -0,0 +1,390 @@
//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 <QMutex>
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
class ImageLoaderGL;
class QGLContext;
class WidgetLoader;
class ImageLoaderByteArrayGL;
enum Performance
{
low=0,
medium,
high,
ultraHigh
};
//Cover Vector
struct RVect{
float x;
float y;
float z;
float rot;
};
//the cover info struct
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;
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
{
Q_OBJECT
protected:
int timerId;
/*** System variables ***/
CFImage dummy;
int viewRotateActive;
float stepBackup;
/*functions*/
void calcPos(CFImage *CF,int pos);
void calcRV(RVect *RV,int pos);
void animate(RVect *Current,RVect to);
void drawCover(CFImage *CF);
void udpatePerspective(int width, int height);
int updateCount;
WidgetLoader * loader;
int fontSize;
GLuint defaultTexture;
GLuint markTexture;
void initializeGL();
void paintGL();
void timerEvent(QTimerEvent *);
//number of Covers
int numObjects;
int lazyPopulateObjects;
bool showMarks;
QVector<bool> loaded;
QVector<bool> marks;
QList<QString> paths;
CFImage * cfImages;
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
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;
public:
/*Constructor*/
YACReaderFlowGL(QWidget *parent = 0,struct Preset p = pressetYACReaderFlowDownConfig);
~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 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<bool> marks);
void setMarkImage(QImage & image);
void markSlide(int index);
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 WidgetLoader : public QGLWidget
//{
// Q_OBJECT
//public:
// WidgetLoader(QWidget *parent, QGLWidget * shared);
// YACReaderFlowGL * flow;
//public slots:
// void loadTexture(int index);
//
//};
class YACReaderComicFlowGL : public YACReaderFlowGL
{
public:
YACReaderComicFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
void setImagePaths(QStringList paths);
void updateImageData();
friend class ImageLoaderGL;
private:
ImageLoaderGL * worker;
};
class YACReaderPageFlowGL : public YACReaderFlowGL
{
public:
YACReaderPageFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
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; };
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;
};
//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();
//
//};
#endif

60
common/yacreader_global.h Normal file
View File

@ -0,0 +1,60 @@
#ifndef __YACREADER_GLOBAL_H
#define __YACREADER_GLOBAL_H
#define VERSION "6.0.0"
#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 FIT "FIT"
#define FLOW_TYPE "FLOW_TYPE"
#define FULLSCREEN "FULLSCREEN"
#define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO"
#define Y_WINDOW_POS "POS"
#define Y_WINDOW_SIZE "SIZE"
#define MAXIMIZED "MAXIMIZED"
#define DOUBLE_PAGE "DOUBLE_PAGE"
#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE"
#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 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"
enum FlowType
{
CoverFlowLike=0,
Strip,
StripOverlapped,
Modern,
Roulette,
Custom
};
#endif