Format code using clang-format

This commit is contained in:
Luis Ángel San Martín
2019-05-30 19:46:37 +02:00
parent e0eb94e3ae
commit e3ec56aa43
356 changed files with 19824 additions and 21874 deletions

View File

@ -9,40 +9,38 @@
#include "bookmarks.h"
BookmarksDialog::BookmarksDialog(QWidget * parent)
:QDialog(parent)
BookmarksDialog::BookmarksDialog(QWidget *parent)
: QDialog(parent)
{
setModal(true);
//animation = new QPropertyAnimation(this,"windowOpacity");
//animation->setDuration(150);
QHBoxLayout * layout = new QHBoxLayout();
QHBoxLayout *layout = new QHBoxLayout();
//bookmarks
QGridLayout * bookmarksL = new QGridLayout();
QGridLayout *bookmarksL = new QGridLayout();
pages.push_back(new QLabel(tr("Lastest Page")));
for(int i=0;i<3;i++)
for (int i = 0; i < 3; i++)
pages.push_back(new QLabel("-"));
QString labelsStyle = "QLabel {color:white;}";
foreach(QLabel * label,pages)
{
foreach (QLabel *label, pages) {
label->setStyleSheet(labelsStyle);
}
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int height,width;
height = heightDesktopResolution*0.50;
width = height*0.65;
int height, width;
height = heightDesktopResolution * 0.50;
width = height * 0.65;
coverSize = QSize(width,height);
coverSize = QSize(width, height);
for(int i=0;i<4;i++)
{
QLabel * l = new QLabel();
for (int i = 0; i < 4; i++) {
QLabel *l = new QLabel();
l->setFixedSize(coverSize);
l->setScaledContents(false);
//l->setPixmap(QPixmap(":/images/notCover.png"));
@ -50,37 +48,36 @@ BookmarksDialog::BookmarksDialog(QWidget * parent)
images.push_back(l);
}
for(int i=0;i<3;i++)
bookmarksL->addWidget(pages.at(i+1),0,i,Qt::AlignCenter);
for(int i=0;i<3;i++)
bookmarksL->addWidget(images.at(i+1),1,i,Qt::AlignCenter);
for (int i = 0; i < 3; i++)
bookmarksL->addWidget(pages.at(i + 1), 0, i, Qt::AlignCenter);
for (int i = 0; i < 3; i++)
bookmarksL->addWidget(images.at(i + 1), 1, i, Qt::AlignCenter);
//last page
QGridLayout * lp = new QGridLayout();
lp->addWidget(pages.at(0),0,0,Qt::AlignCenter);
lp->addWidget(images.at(0),1,0,Qt::AlignCenter);
QGridLayout *lp = new QGridLayout();
lp->addWidget(pages.at(0), 0, 0, Qt::AlignCenter);
lp->addWidget(images.at(0), 1, 0, Qt::AlignCenter);
layout->addLayout(bookmarksL);
QFrame *f = new QFrame( this );
f->setFrameStyle( QFrame::VLine | QFrame::Sunken );
QFrame *f = new QFrame(this);
f->setFrameStyle(QFrame::VLine | QFrame::Sunken);
layout->addWidget(f);
layout->addLayout(lp);
QHBoxLayout * buttons = new QHBoxLayout();
QHBoxLayout *buttons = new QHBoxLayout();
cancel = new QPushButton(tr("Close"));
cancel->setFlat(true);
connect(cancel,SIGNAL(clicked()),this,SLOT(hide()));
connect(cancel, SIGNAL(clicked()), this, SLOT(hide()));
buttons->addStretch();
buttons->addWidget(cancel);
cancel->setStyleSheet("QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}");
QVBoxLayout * l = new QVBoxLayout();
QVBoxLayout *l = new QVBoxLayout();
l->addWidget(new QLabel("<font color=\"#FFFFFF\">"+tr("Click on any image to go to the bookmark")+"</font>"),0,Qt::AlignCenter);
l->addWidget(new QLabel("<font color=\"#FFFFFF\">" + tr("Click on any image to go to the bookmark") + "</font>"), 0, Qt::AlignCenter);
l->addLayout(layout);
#ifdef Q_OS_MAC
l->addLayout(buttons);
@ -95,73 +92,56 @@ BookmarksDialog::BookmarksDialog(QWidget * parent)
setLayout(l);
}
void BookmarksDialog::setBookmarks(const Bookmarks & bm)
void BookmarksDialog::setBookmarks(const Bookmarks &bm)
{
lastPage = bm.getLastPage();
if (lastPage > 0)
{
if (lastPage > 0) {
QPixmap p = QPixmap::fromImage(bm.getLastPagePixmap());
if(p.isNull())
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
if (p.isNull()) {
images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
images.at(0)->setText(tr("Loading..."));
} else {
images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
images.at(0)->setPixmap(p.scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
else
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
images.at(0)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
}
}
else
{
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
} else {
images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
QList<int> l = bm.getBookmarkPages();
int s = l.count();
for(int i=0;i<s;i++)
{
pages.at(i+1)->setText(QString::number(l.at(i)+1));
for (int i = 0; i < s; i++) {
pages.at(i + 1)->setText(QString::number(l.at(i) + 1));
QPixmap p = QPixmap::fromImage(bm.getBookmarkPixmap(l.at(i)));
if(p.isNull())
{
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(i+1)->setText(tr("Loading..."));
}
else
{
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
images.at(i+1)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
if (p.isNull()) {
images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
images.at(i + 1)->setText(tr("Loading..."));
} else {
images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
images.at(i + 1)->setPixmap(p.scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
}
for(int i=s;i<3;i++)
{
pages.at(i+1)->setText("-");
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
images.at(i+1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
for (int i = s; i < 3; i++) {
pages.at(i + 1)->setText("-");
images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
images.at(i + 1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
}
bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonPress)
{
if (obj == images.at(0))
{
if (event->type() == QEvent::MouseButtonPress) {
if (obj == images.at(0)) {
emit(goToPage(lastPage));
close();
event->accept();
}
for(int i=1;i<=3;i++)
{
if(obj == images.at(i))
{
for (int i = 1; i <= 3; i++) {
if (obj == images.at(i)) {
bool b;
int page = pages.at(i)->text().toInt(&b)-1;
if(b)
{
int page = pages.at(i)->text().toInt(&b) - 1;
if (b) {
emit(goToPage(page));
close();
}
@ -173,9 +153,9 @@ bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
return QDialog::eventFilter(obj, event);
}
void BookmarksDialog::keyPressEvent(QKeyEvent * event)
void BookmarksDialog::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_M)
if (event->key() == Qt::Key_M)
hide();
}
/*

View File

@ -11,35 +11,35 @@
#include "bookmarks.h"
class BookmarksDialog : public QDialog
{
class BookmarksDialog : public QDialog
{
Q_OBJECT
protected:
protected:
QList<QLabel *> pages;
QList<QLabel *> images;
int lastPage;
QPushButton * accept;
QPushButton * cancel;
QPushButton *accept;
QPushButton *cancel;
QSize coverSize;
bool eventFilter(QObject *obj, QEvent *event);
void keyPressEvent(QKeyEvent * event);
void keyPressEvent(QKeyEvent *event);
//QPropertyAnimation * animation;
public:
BookmarksDialog(QWidget * parent = 0);
public:
BookmarksDialog(QWidget *parent = 0);
public slots:
void setBookmarks(const Bookmarks & bookmarks);
public slots:
void setBookmarks(const Bookmarks &bookmarks);
//void show();
//void hide();
signals:
signals:
void goToPage(unsigned int page);
};
};
#endif // BOOKMARKS_DIALOG_H

View File

@ -25,36 +25,36 @@ QSettings *Configuration::getSettings()
//nothing
}*/
void Configuration::load(QSettings * settings)
void Configuration::load(QSettings *settings)
{
this->settings = settings;
//TODO set defaults
if(!settings->contains(PATH))
settings->setValue(PATH,".");
if(!settings->contains(GO_TO_FLOW_SIZE))
settings->setValue(GO_TO_FLOW_SIZE,QSize(126,200));
if(!settings->contains(MAG_GLASS_SIZE))
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
if(!settings->contains(ZOOM_LEVEL))
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
if(!settings->contains(FLOW_TYPE))
settings->setValue(FLOW_TYPE,0);
if(!settings->contains(FULLSCREEN))
settings->setValue(FULLSCREEN,false);
if(!settings->contains(Y_WINDOW_SIZE))
settings->setValue(Y_WINDOW_SIZE,QSize(0,0));
if(!settings->contains(MAXIMIZED))
settings->setValue(MAXIMIZED,false);
if(!settings->contains(DOUBLE_PAGE))
settings->setValue(DOUBLE_PAGE,false);
if(!settings->contains(BACKGROUND_COLOR))
settings->setValue(BACKGROUND_COLOR,QColor(40,40,40));
if(!settings->contains(ALWAYS_ON_TOP))
settings->setValue(ALWAYS_ON_TOP,false);
if(!settings->contains(SHOW_TOOLBARS))
if (!settings->contains(PATH))
settings->setValue(PATH, ".");
if (!settings->contains(GO_TO_FLOW_SIZE))
settings->setValue(GO_TO_FLOW_SIZE, QSize(126, 200));
if (!settings->contains(MAG_GLASS_SIZE))
settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
if (!settings->contains(ZOOM_LEVEL))
settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
if (!settings->contains(FLOW_TYPE))
settings->setValue(FLOW_TYPE, 0);
if (!settings->contains(FULLSCREEN))
settings->setValue(FULLSCREEN, false);
if (!settings->contains(Y_WINDOW_SIZE))
settings->setValue(Y_WINDOW_SIZE, QSize(0, 0));
if (!settings->contains(MAXIMIZED))
settings->setValue(MAXIMIZED, false);
if (!settings->contains(DOUBLE_PAGE))
settings->setValue(DOUBLE_PAGE, false);
if (!settings->contains(BACKGROUND_COLOR))
settings->setValue(BACKGROUND_COLOR, QColor(40, 40, 40));
if (!settings->contains(ALWAYS_ON_TOP))
settings->setValue(ALWAYS_ON_TOP, false);
if (!settings->contains(SHOW_TOOLBARS))
settings->setValue(SHOW_TOOLBARS, true);
if(!settings->contains(QUICK_NAVI_MODE))
if (!settings->contains(QUICK_NAVI_MODE))
settings->setValue(QUICK_NAVI_MODE, false);
//old fit stuff
/*if(!settings->contains(FIT))
@ -64,15 +64,14 @@ void Configuration::load(QSettings * settings)
if(!settings->contains(ADJUST_TO_FULL_SIZE))
settings->setValue(ADJUST_TO_FULL_SIZE,false);
*/
}
void Configuration::updateOpenRecentList (QString path)
}
void Configuration::updateOpenRecentList(QString path)
{
QStringList list = openRecentList();
list.removeAll(path);
list.prepend(path);
//TODO: Make list lenght configurable
while (list.length() > getOpenRecentSize())
{
while (list.length() > getOpenRecentSize()) {
list.removeLast();
}
settings->setValue("recentFiles", list);

View File

@ -15,12 +15,12 @@
using namespace YACReader;
class Configuration : public QObject
{
class Configuration : public QObject
{
Q_OBJECT
private:
QSettings * settings;
private:
QSettings *settings;
QString defaultPath;
//configuration properties
@ -42,34 +42,33 @@ using namespace YACReader;
Configuration();
//Configuration(const Configuration & conf);
void load(const QString & path = CONF_FILE_PATH);
void load(const QString &path = CONF_FILE_PATH);
public:
static Configuration & getConfiguration()
public:
static Configuration &getConfiguration()
{
static Configuration configuration;
return configuration;
};
QSettings *getSettings();
void load(QSettings * settings);
void load(QSettings *settings);
QString getDefaultPath() { return settings->value(PATH).toString(); }
void setDefaultPath(QString defaultPath){settings->setValue(PATH,defaultPath);}
QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize();}
void setMagnifyingGlassSize(const QSize & mgs) { settings->setValue(MAG_GLASS_SIZE,mgs);}
QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize();}
void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);}
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();}
void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);}
void setDefaultPath(QString defaultPath) { settings->setValue(PATH, defaultPath); }
QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize(); }
void setMagnifyingGlassSize(const QSize &mgs) { settings->setValue(MAG_GLASS_SIZE, mgs); }
QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize(); }
void setGotoSlideSize(const QSize &gss) { settings->setValue(GO_TO_FLOW_SIZE, gss); }
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat(); }
void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL, zl); }
//Unified enum based fitmode
YACReader::FitMode getFitMode() { return static_cast<YACReader::FitMode>(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); }
void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast<int>(fitMode)); }
void setFitMode(YACReader::FitMode fitMode) { settings->setValue(FITMODE, static_cast<int>(fitMode)); }
//openRecent
int getOpenRecentSize() { return settings->value("recentSize", 25).toInt();}
int getOpenRecentSize() { return settings->value("recentSize", 25).toInt(); }
QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
void updateOpenRecentList (QString path);
void updateOpenRecentList(QString path);
void clearOpenRecentList() { settings->remove("recentFiles"); }
//Old fitmodes
@ -82,36 +81,36 @@ using namespace YACReader;
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
*/
FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();}
void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);}
bool getFullScreen(){return settings->value(FULLSCREEN).toBool();}
void setFullScreen(bool f){settings->setValue(FULLSCREEN,f);}
FlowType getFlowType() { return (FlowType)settings->value(FLOW_TYPE_SW).toInt(); }
void setFlowType(FlowType type) { settings->setValue(FLOW_TYPE_SW, type); }
bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); }
void setFullScreen(bool f) { settings->setValue(FULLSCREEN, f); }
QPoint getPos(){return settings->value(Y_WINDOW_POS).toPoint();}
void setPos(QPoint p){settings->setValue(Y_WINDOW_POS,p);}
QSize getSize(){return settings->value(Y_WINDOW_SIZE).toSize();}
void setSize(QSize s){settings->setValue(Y_WINDOW_SIZE,s);}
bool getMaximized(){return settings->value(MAXIMIZED).toBool();}
void setMaximized(bool b){settings->setValue(MAXIMIZED,b);}
bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();}
void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);}
bool getDoubleMangaPage(){return settings->value(DOUBLE_MANGA_PAGE).toBool();}
void setDoubleMangaPage(bool b){settings->setValue(DOUBLE_MANGA_PAGE,b);}
QPoint getPos() { return settings->value(Y_WINDOW_POS).toPoint(); }
void setPos(QPoint p) { settings->setValue(Y_WINDOW_POS, p); }
QSize getSize() { return settings->value(Y_WINDOW_SIZE).toSize(); }
void setSize(QSize s) { settings->setValue(Y_WINDOW_SIZE, s); }
bool getMaximized() { return settings->value(MAXIMIZED).toBool(); }
void setMaximized(bool b) { settings->setValue(MAXIMIZED, b); }
bool getDoublePage() { return settings->value(DOUBLE_PAGE).toBool(); }
void setDoublePage(bool b) { settings->setValue(DOUBLE_PAGE, b); }
bool getDoubleMangaPage() { return settings->value(DOUBLE_MANGA_PAGE).toBool(); }
void setDoubleMangaPage(bool b) { settings->setValue(DOUBLE_MANGA_PAGE, b); }
QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value<QColor>();}
void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);}
bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();}
void setAlwaysOnTop(bool b){ settings->setValue(ALWAYS_ON_TOP,b);}
bool getShowToolbars(){return settings->value(SHOW_TOOLBARS).toBool();}
void setShowToolbars(bool b){settings->setValue(SHOW_TOOLBARS,b);}
bool getShowInformation(){return settings->value(SHOW_INFO,false).toBool();}
void setShowInformation(bool b){settings->setValue(SHOW_INFO,b);}
QDate getLastVersionCheck(){return settings->value(LAST_VERSION_CHECK).toDate();}
void setLastVersionCheck(const QDate & date){ settings->setValue(LAST_VERSION_CHECK,date);}
int getNumDaysBetweenVersionChecks() {return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS,1).toInt();}
void setNumDaysBetweenVersionChecks(int days) {return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS,days);}
bool getQuickNaviMode(){return settings->value(QUICK_NAVI_MODE).toBool();}
bool getDisableShowOnMouseOver(){return settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool();}
};
QColor getBackgroundColor() { return settings->value(BACKGROUND_COLOR).value<QColor>(); }
void setBackgroundColor(const QColor &color) { settings->value(BACKGROUND_COLOR, color); }
bool getAlwaysOnTop() { return settings->value(ALWAYS_ON_TOP).toBool(); }
void setAlwaysOnTop(bool b) { settings->setValue(ALWAYS_ON_TOP, b); }
bool getShowToolbars() { return settings->value(SHOW_TOOLBARS).toBool(); }
void setShowToolbars(bool b) { settings->setValue(SHOW_TOOLBARS, b); }
bool getShowInformation() { return settings->value(SHOW_INFO, false).toBool(); }
void setShowInformation(bool b) { settings->setValue(SHOW_INFO, b); }
QDate getLastVersionCheck() { return settings->value(LAST_VERSION_CHECK).toDate(); }
void setLastVersionCheck(const QDate &date) { settings->setValue(LAST_VERSION_CHECK, date); }
int getNumDaysBetweenVersionChecks() { return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS, 1).toInt(); }
void setNumDaysBetweenVersionChecks(int days) { return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS, days); }
bool getQuickNaviMode() { return settings->value(QUICK_NAVI_MODE).toBool(); }
bool getDisableShowOnMouseOver() { return settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool(); }
};
#endif

View File

@ -4,10 +4,8 @@
#include <QVBoxLayout>
#include <QIntValidator>
GoToDialog::GoToDialog(QWidget * parent)
:QDialog(parent)
GoToDialog::GoToDialog(QWidget *parent)
: QDialog(parent)
{
setupUI();
}
@ -20,12 +18,12 @@ void GoToDialog::setupUI()
v->setBottom(1);
pageNumber->setValidator(v);
textLabel->setBuddy(pageNumber);
textLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
textLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
accept = new QPushButton(tr("Go To"));
connect(accept,SIGNAL(clicked()),this,SLOT(goTo()));
connect(accept, SIGNAL(clicked()), this, SLOT(goTo()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *topLayout = new QHBoxLayout;
@ -44,7 +42,7 @@ void GoToDialog::setupUI()
mainLayout->addLayout(bottomLayout);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel();
QLabel *imgLabel = new QLabel();
QPixmap p(":/images/goto.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
@ -53,7 +51,7 @@ void GoToDialog::setupUI()
setLayout(imgMainLayout);
setWindowTitle(tr("Go to..."));
setModal (true);
setModal(true);
pageNumber->setFocusPolicy(Qt::StrongFocus);
pageNumber->setFocus();
@ -64,16 +62,15 @@ void GoToDialog::goTo()
unsigned int page = pageNumber->text().toInt();
pageNumber->clear();
if(page >= 1)
emit(goToPage(page-1));
if (page >= 1)
emit(goToPage(page - 1));
close();
}
void GoToDialog::setNumPages(unsigned int numPages)
{
numPagesLabel->setText(tr("Total pages : ")+QString::number(numPages));
numPagesLabel->setText(tr("Total pages : ") + QString::number(numPages));
v->setTop(numPages);
}

View File

@ -7,26 +7,26 @@
#include <QPushButton>
#include <QIntValidator>
class GoToDialog : public QDialog
{
class GoToDialog : public QDialog
{
Q_OBJECT
public:
GoToDialog(QWidget * parent = 0);
private:
QLabel * numPagesLabel;
QLabel * textLabel;
QLineEdit * pageNumber;
QIntValidator * v;
QPushButton * accept;
QPushButton * cancel;
public:
GoToDialog(QWidget *parent = 0);
private:
QLabel *numPagesLabel;
QLabel *textLabel;
QLineEdit *pageNumber;
QIntValidator *v;
QPushButton *accept;
QPushButton *cancel;
void setupUI();
public slots:
public slots:
void goTo();
void setNumPages(unsigned int numPages);
void open();
signals:
signals:
void goToPage(unsigned int page);
};
};
#endif

View File

@ -25,30 +25,29 @@
#include "goto_flow_toolbar.h"
GoToFlow::GoToFlow(QWidget *parent,FlowType flowType)
:GoToFlowWidget(parent),ready(false)
GoToFlow::GoToFlow(QWidget *parent, FlowType flowType)
: GoToFlowWidget(parent), ready(false)
{
updateTimer = new QTimer;
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
worker = new PageLoader(&mutexGoToFlow);
flow = new YACReaderFlow(this,flowType);
flow = new YACReaderFlow(this, flowType);
flow->setReflectionEffect(PictureFlow::PlainReflection);
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setSlideSize(imageSize);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(setPageNumber(int)));
connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(showSlide(unsigned int)));
connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
connect(toolBar, SIGNAL(setCenter(unsigned int)), flow, SLOT(showSlide(unsigned int)));
mainLayout->addWidget(flow);
toolBar->raise();
resize(static_cast<int>(5*imageSize.width()),toolBar->height() + static_cast<int>(imageSize.height()*1.7));
resize(static_cast<int>(5 * imageSize.width()), toolBar->height() + static_cast<int>(imageSize.height() * 1.7));
this->setCursor(QCursor(Qt::ArrowCursor));
}
@ -62,10 +61,11 @@ GoToFlow::~GoToFlow()
void GoToFlow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
QApplication::sendEvent(flow,event);
switch (event->key()) {
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
QApplication::sendEvent(flow, event);
return;
default:
break;
@ -82,13 +82,11 @@ void GoToFlow::resizeEvent(QResizeEvent *event)
toolBar->setFixedWidth(width());
}
void GoToFlow::centerSlide(int slide)
{
if(flow->centerIndex()!=slide)
{
if (flow->centerIndex() != slide) {
flow->setCenterIndex(slide);
if(ready)// load images if pages are loaded.
if (ready) // load images if pages are loaded.
{
//worker->reset(); //BUG FIXED : image didn't load if worker was working
preload();
@ -101,7 +99,7 @@ void GoToFlow::setNumSlides(unsigned int slides)
// numPagesLabel->setText(tr("Total pages : ")+QString::number(slides));
// numPagesLabel->adjustSize();
imagesReady.clear();
imagesReady.fill(false,slides);
imagesReady.fill(false, slides);
rawImages.clear();
rawImages.resize(slides);
@ -109,10 +107,10 @@ void GoToFlow::setNumSlides(unsigned int slides)
toolBar->setTop(slides);
imagesLoaded.clear();
imagesLoaded.fill(false,slides);
imagesLoaded.fill(false, slides);
imagesSetted.clear();
imagesSetted.fill(false,slides);
imagesSetted.fill(false, slides);
numImagesLoaded = 0;
@ -123,7 +121,7 @@ void GoToFlow::setNumSlides(unsigned int slides)
worker->reset();
flow->clear();
for(unsigned int i=0;i<slides;i++)
for (unsigned int i = 0; i < slides; i++)
flow->addSlide(QImage());
flow->setCenterIndex(0);
}
@ -138,72 +136,67 @@ void GoToFlow::reset()
ready = false;
}
void GoToFlow::setImageReady(int index,const QByteArray & image)
void GoToFlow::setImageReady(int index, const QByteArray &image)
{
rawImages[index]=image;
imagesReady[index]=true;
rawImages[index] = image;
imagesReady[index] = true;
preload();
}
void GoToFlow::preload()
{
if(numImagesLoaded < imagesLoaded.size())
if (numImagesLoaded < imagesLoaded.size())
updateTimer->start(30); //TODO comprobar rendimiento, antes era 70
}
void GoToFlow::updateImageData()
{
// can't do anything, wait for the next possibility
if(worker->busy())
if (worker->busy())
return;
// set image of last one
int idx = worker->index();
if( idx >= 0 && !worker->result().isNull())
{
if(!imagesSetted[idx])
{
if (idx >= 0 && !worker->result().isNull()) {
if (!imagesSetted[idx]) {
flow->setSlide(idx, worker->result());
imagesSetted[idx] = true;
numImagesLoaded++;
rawImages[idx].clear();; //release memory
imagesLoaded[idx]=true;
rawImages[idx].clear();
; //release memory
imagesLoaded[idx] = true;
}
}
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
#define COUNT 8
int indexes[2*COUNT+1];
int indexes[2 * COUNT + 1];
int center = flow->centerIndex();
indexes[0] = center;
for(int j = 0; j < COUNT; j++)
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
for (int j = 0; j < COUNT; j++) {
indexes[j * 2 + 1] = center + j + 1;
indexes[j * 2 + 2] = center - j - 1;
}
for(int c = 0; c < 2*COUNT+1; c++)
{
for (int c = 0; c < 2 * COUNT + 1; c++) {
int i = indexes[c];
if((i >= 0) && (i < flow->slideCount()))
if(!imagesLoaded[i]&&imagesReady[i])//slide(i).isNull())
if ((i >= 0) && (i < flow->slideCount()))
if (!imagesLoaded[i] && imagesReady[i]) //slide(i).isNull())
{
// schedule thumbnail generation
worker->generate(i, flow->slideSize(),rawImages[i]);
worker->generate(i, flow->slideSize(), rawImages[i]);
return;
}
}
// no need to generate anything? stop polling...
updateTimer->stop();
}
void GoToFlow::wheelEvent(QWheelEvent * event)
void GoToFlow::wheelEvent(QWheelEvent *event)
{
if(event->delta()<0)
if (event->delta() < 0)
flow->showNext();
else
flow->showPrevious();
@ -215,13 +208,13 @@ void GoToFlow::setFlowType(FlowType flowType)
flow->setFlowType(flowType);
}
void GoToFlow::updateConfig(QSettings * settings)
void GoToFlow::updateConfig(QSettings *settings)
{
GoToFlowWidget::updateConfig(settings);
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setFlowType(Configuration::getConfiguration().getFlowType());
resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
updateSize();
}
@ -234,8 +227,8 @@ void GoToFlow::setFlowRightToLeft(bool b)
//PageLoader
//-----------------------------------------------------------------------------
PageLoader::PageLoader(QMutex * m):
QThread(),mutex(m), restart(false), working(false), idx(-1)
PageLoader::PageLoader(QMutex *m)
: QThread(), mutex(m), restart(false), working(false), idx(-1)
{
}
@ -254,7 +247,7 @@ bool PageLoader::busy() const
return isRunning() ? working : false;
}
void PageLoader::generate(int index, QSize size,const QByteArray & rImage)
void PageLoader::generate(int index, QSize size, const QByteArray &rImage)
{
mutex->lock();
this->idx = index;
@ -265,8 +258,7 @@ void PageLoader::generate(int index, QSize size,const QByteArray & rImage)
if (!isRunning())
start();
else
{
else {
mutex->lock();
// already running, wake up whenever ready
restart = true;
@ -277,18 +269,16 @@ void PageLoader::generate(int index, QSize size,const QByteArray & rImage)
void PageLoader::run()
{
for(;;)
{
for (;;) {
// copy necessary data
mutex->lock();
this->working = true;
//int idx = this->idx;
QImage image;
image.loadFromData(this->rawImage);
// let everyone knows it is ready
image = image.scaled(this->size,Qt::KeepAspectRatio,Qt::SmoothTransformation);
image = image.scaled(this->size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
mutex->unlock();

View File

@ -19,7 +19,6 @@ class QWaitCondition;
class QEvent;
class QLabel;
class Comic;
class PageLoader;
class YACReaderFlow;
@ -30,12 +29,12 @@ class GoToFlow : public GoToFlowWidget
{
Q_OBJECT
public:
GoToFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
GoToFlow(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
~GoToFlow();
bool ready; //comic is ready for read.
private:
YACReaderFlow * flow;
void keyPressEvent(QKeyEvent* event);
YACReaderFlow *flow;
void keyPressEvent(QKeyEvent *event);
//Comic * comic;
QSize imageSize;
@ -44,9 +43,9 @@ private:
int numImagesLoaded;
QVector<bool> imagesReady;
QVector<QByteArray> rawImages;
QTimer* updateTimer;
PageLoader* worker;
virtual void wheelEvent(QWheelEvent * event);
QTimer *updateTimer;
PageLoader *worker;
virtual void wheelEvent(QWheelEvent *event);
QMutex mutexGoToFlow;
private slots:
@ -54,18 +53,17 @@ private slots:
void updateImageData();
void resizeEvent(QResizeEvent *event);
public slots:
public slots:
void centerSlide(int slide);
void reset();
void setNumSlides(unsigned int slides);
void setImageReady(int index,const QByteArray & image);
void setImageReady(int index, const QByteArray &image);
void setFlowType(FlowType flowType);
void updateConfig(QSettings * settings);
void updateConfig(QSettings *settings);
void setFlowRightToLeft(bool b);
signals:
void goToPage(unsigned int page);
};
//-----------------------------------------------------------------------------
@ -74,18 +72,20 @@ signals:
class PageLoader : public QThread
{
public:
PageLoader(QMutex * m);
PageLoader(QMutex *m);
~PageLoader();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, QSize size,const QByteArray & rImage);
void reset(){idx = -1;};
void generate(int index, QSize size, const QByteArray &rImage);
void reset() { idx = -1; };
int index() const { return idx; }
QImage result() const { return img; }
protected:
void run();
private:
QMutex * mutex;
QMutex *mutex;
QWaitCondition condition;
bool restart;

View File

@ -11,9 +11,8 @@
#include "goto_flow_toolbar.h"
GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType)
:GoToFlowWidget(parent)
GoToFlowGL::GoToFlowGL(QWidget *parent, FlowType flowType)
: GoToFlowWidget(parent)
{
Q_UNUSED(flowType)
flow = new YACReaderPageFlowGL(this);
@ -22,16 +21,16 @@ GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType)
imageSize = Configuration::getConfiguration().getGotoSlideSize();
flow->setSlideSize(imageSize);
connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(setPageNumber(int)));
connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(setCenterIndex(unsigned int)));
connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
connect(toolBar, SIGNAL(setCenter(unsigned int)), flow, SLOT(setCenterIndex(unsigned int)));
mainLayout->addWidget(flow);
toolBar->raise();
resize(static_cast<int>(5*imageSize.width()),toolBar->height() + static_cast<int>(imageSize.height()*1.7));
resize(static_cast<int>(5 * imageSize.width()), toolBar->height() + static_cast<int>(imageSize.height() * 1.7));
this->setCursor(QCursor(Qt::ArrowCursor));
}
@ -48,19 +47,18 @@ void GoToFlowGL::reset()
void GoToFlowGL::centerSlide(int slide)
{
if(flow->centerIndex()!=slide)
{
if (flow->centerIndex() != slide) {
flow->setCenterIndex(slide);
}
}
void GoToFlowGL::setFlowType(FlowType flowType)
{
if(flowType == CoverFlowLike)
if (flowType == CoverFlowLike)
flow->setPreset(presetYACReaderFlowClassicConfig);
else if(flowType == Strip)
else if (flowType == Strip)
flow->setPreset(presetYACReaderFlowStripeConfig);
else if(flowType == StripOverlapped)
else if (flowType == StripOverlapped)
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
else
flow->setPreset(defaultYACReaderFlowConfig);
@ -71,19 +69,18 @@ void GoToFlowGL::setNumSlides(unsigned int slides)
flow->populate(slides);
toolBar->setTop(slides);
}
void GoToFlowGL::setImageReady(int index,const QByteArray & imageData)
void GoToFlowGL::setImageReady(int index, const QByteArray &imageData)
{
flow->rawImages[index] = imageData;
flow->imagesReady[index] = true;
}
void GoToFlowGL::updateConfig(QSettings * settings)
void GoToFlowGL::updateConfig(QSettings *settings)
{
GoToFlowWidget::updateConfig(settings);
Performance performance = medium;
switch (settings->value(PERFORMANCE).toInt())
{
switch (settings->value(PERFORMANCE).toInt()) {
case 0:
performance = low;
break;
@ -99,13 +96,12 @@ void GoToFlowGL::updateConfig(QSettings * settings)
}
imageSize = Configuration::getConfiguration().getGotoSlideSize();
resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
updateSize();
flow->setPerformance(performance);
switch (settings->value(FLOW_TYPE_GL).toInt())
{
switch (settings->value(FLOW_TYPE_GL).toInt()) {
case FlowType::CoverFlowLike:
flow->setPreset(presetYACReaderFlowClassicConfig);
break;
@ -139,12 +135,13 @@ void GoToFlowGL::updateConfig(QSettings * settings)
flow->setFadeOutDist(20);
}
void GoToFlowGL::keyPressEvent(QKeyEvent* event)
void GoToFlowGL::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
QApplication::sendEvent(flow,event);
switch (event->key()) {
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
QApplication::sendEvent(flow, event);
return;
default:
break;

View File

@ -16,22 +16,23 @@ class GoToFlowGL : public GoToFlowWidget
{
Q_OBJECT
public:
GoToFlowGL(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
GoToFlowGL(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
~GoToFlowGL();
void reset();
void centerSlide(int slide);
void setFlowType(FlowType flowType);
void setNumSlides(unsigned int slides);
void setImageReady(int index,const QByteArray & image);
void setImageReady(int index, const QByteArray &image);
void updateConfig(QSettings * settings);
void updateConfig(QSettings *settings);
void setFlowRightToLeft(bool b);
signals:
void goToPage(unsigned int page);
private:
YACReaderPageFlowGL * flow;
void keyPressEvent(QKeyEvent* event);
YACReaderPageFlowGL *flow;
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
//Comic * comic;
QSize imageSize;

View File

@ -4,20 +4,20 @@
#include "configuration.h"
GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
:QStackedWidget(parent)
GoToFlowToolBar::GoToFlowToolBar(QWidget *parent)
: QStackedWidget(parent)
{
//elementos interactivos
QWidget * normal = new QWidget(this); // container widget
QWidget * quickNavi = new QWidget(this); // container widget
QWidget *normal = new QWidget(this); // container widget
QWidget *quickNavi = new QWidget(this); // container widget
addWidget(normal);
addWidget(quickNavi);
QHBoxLayout * normalLayout = new QHBoxLayout(normal);
QHBoxLayout * naviLayout = new QHBoxLayout(quickNavi);
QHBoxLayout *normalLayout = new QHBoxLayout(normal);
QHBoxLayout *naviLayout = new QHBoxLayout(quickNavi);
normal->setLayout(normalLayout);
quickNavi->setLayout(naviLayout);
slider = new QSlider(Qt::Horizontal,this);
slider = new QSlider(Qt::Horizontal, this);
slider->setStyleSheet(
"QSlider::groove:horizontal {"
" border: 1px solid #22FFFFFF;"
@ -30,26 +30,25 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
" background: #55FFFFFF;"
" width: 48px;"
" border-radius: 1px;"
"}"
);
"}");
connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); });
pageHint = new QLabel("<b>" + tr("Page : ") + "</b>",this);
pageHint = new QLabel("<b>" + tr("Page : ") + "</b>", this);
v = new QIntValidator(this);
v->setBottom(1);
edit = new QLineEdit(this);
edit->setValidator(v);
edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
edit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}");
QPixmap p(":/images/imgEdit.png");
edit->setFixedSize(54,50);
edit->setAttribute(Qt::WA_MacShowFocusRect,false);
edit->setFixedSize(54, 50);
edit->setAttribute(Qt::WA_MacShowFocusRect, false);
//edit->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
//edit->resize(QSize(54,50));
edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
//edit->setAutoFillBackground(false);
connect(edit,SIGNAL(returnPressed()),this,SLOT(goTo()));
connect(edit, SIGNAL(returnPressed()), this, SLOT(goTo()));
QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
"QPushButton:focus { border: none; outline: none;}"
@ -57,9 +56,9 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
centerButton = new QPushButton(this);
//centerButton->setIcon(QIcon(":/images/center.png"));
centerButton->setStyleSheet(centerButtonCSS);
centerButton->setFixedSize(26,50);
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide()));
centerButton->setFixedSize(26, 50);
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
connect(centerButton, SIGNAL(clicked()), this, SLOT(centerSlide()));
QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
"QPushButton:focus { border: none; outline: none;}"
@ -67,10 +66,10 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
goToButton = new QPushButton(this);
//goToButton->setIcon(QIcon(":/images/goto.png"));
goToButton->setStyleSheet(goToButtonCSS);
goToButton->setFixedSize(32,50);
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
goToButton->setFixedSize(32, 50);
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
connect(goToButton, SIGNAL(clicked()), this, SLOT(goTo()));
normalLayout->setMargin(0);
normalLayout->setSpacing(0);
@ -94,31 +93,31 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
void GoToFlowToolBar::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#99000000"));
painter.fillRect(0, 0, width(), height(), QColor("#99000000"));
}
void GoToFlowToolBar::setPage(int pageNumber)
{
edit->setText(QString::number(pageNumber+1));
edit->setText(QString::number(pageNumber + 1));
slider->setValue(pageNumber);
}
void GoToFlowToolBar::setTop(int numPages)
{
v->setTop(numPages);
slider->setMaximum(numPages-1); // min is 0
slider->setMaximum(numPages - 1); // min is 0
}
void GoToFlowToolBar::goTo()
{
if(edit->text().toInt()!=0)
emit(goTo(edit->text().toInt()-1));
if (edit->text().toInt() != 0)
emit(goTo(edit->text().toInt() - 1));
}
void GoToFlowToolBar::centerSlide()
{
if(edit->text().toInt()!=0)
emit(setCenter(edit->text().toInt()-1));
if (edit->text().toInt() != 0)
emit(setCenter(edit->text().toInt() - 1));
}
void GoToFlowToolBar::updateOptions()

View File

@ -13,26 +13,26 @@ class QLabel;
class GoToFlowToolBar : public QStackedWidget
{
Q_OBJECT
private:
QLineEdit * edit;
QSlider * slider;
QIntValidator * v;
QPushButton * centerButton;
QPushButton * goToButton;
QLabel * pageHint;
QWidget * bar;
private:
QLineEdit *edit;
QSlider *slider;
QIntValidator *v;
QPushButton *centerButton;
QPushButton *goToButton;
QLabel *pageHint;
QWidget *bar;
void paintEvent(QPaintEvent *);
public:
GoToFlowToolBar(QWidget * parent = 0);
public:
GoToFlowToolBar(QWidget *parent = 0);
public slots:
public slots:
void setPage(int pageNumber);
void setTop(int numPages);
void goTo();
void centerSlide();
void updateOptions();
signals:
signals:
void setCenter(unsigned int);
void goTo(unsigned int);
};

View File

@ -8,8 +8,8 @@
#include "goto_flow_toolbar.h"
#include "configuration.h"
GoToFlowWidget::GoToFlowWidget(QWidget * parent)
:QWidget(parent)
GoToFlowWidget::GoToFlowWidget(QWidget *parent)
: QWidget(parent)
{
mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
@ -22,7 +22,8 @@ GoToFlowWidget::GoToFlowWidget(QWidget * parent)
//toolBar->installEventFilter(this);
}
GoToFlowWidget::~GoToFlowWidget() {
GoToFlowWidget::~GoToFlowWidget()
{
delete toolBar;
delete mainLayout;
}
@ -32,11 +33,11 @@ void GoToFlowWidget::setPageNumber(int page)
toolBar->setPage(page);
}
void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
void GoToFlowWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Return: case Qt::Key_Enter:
switch (event->key()) {
case Qt::Key_Return:
case Qt::Key_Enter:
toolBar->goTo();
toolBar->centerSlide();
break;
@ -44,14 +45,14 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
toolBar->centerSlide();
break;
case Qt::Key_S:
QCoreApplication::sendEvent(this->parent(),event);
QCoreApplication::sendEvent(this->parent(), event);
break;
}
event->accept();
}
void GoToFlowWidget::updateConfig(QSettings * settings)
void GoToFlowWidget::updateConfig(QSettings *settings)
{
Q_UNUSED(settings)
toolBar->updateOptions();
@ -63,7 +64,7 @@ void GoToFlowWidget::updateSize()
// no need to update width when QuickNaviMode disabled
// height is set in updateConfig
if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr)
resize(parentWidget()->width(),height());
resize(parentWidget()->width(), height());
}
/*bool GoToFlowWidget::eventFilter(QObject * target, QEvent * event)

View File

@ -15,10 +15,11 @@ class GoToFlowWidget : public QWidget
{
Q_OBJECT
protected:
QVBoxLayout * mainLayout;
GoToFlowToolBar * toolBar;
QVBoxLayout *mainLayout;
GoToFlowToolBar *toolBar;
public:
GoToFlowWidget(QWidget * paret = 0);
GoToFlowWidget(QWidget *paret = 0);
virtual ~GoToFlowWidget() = 0;
public slots:
virtual void reset() = 0;
@ -26,15 +27,14 @@ public slots:
virtual void setPageNumber(int page);
virtual void setFlowType(FlowType flowType) = 0;
virtual void setNumSlides(unsigned int slides) = 0;
virtual void setImageReady(int index,const QByteArray & image) = 0;
virtual void setImageReady(int index, const QByteArray &image) = 0;
virtual void updateSize();
virtual void updateConfig(QSettings * settings);
virtual void updateConfig(QSettings *settings);
virtual void setFlowRightToLeft(bool b) = 0;
protected:
void keyPressEvent(QKeyEvent* event);
void keyPressEvent(QKeyEvent *event);
//bool eventFilter(QObject *, QEvent *);
};
#endif

View File

@ -5,27 +5,27 @@
#include <QScrollBar>
MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent)
:QLabel(parent),zoomLevel(0.5)
MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget *parent)
: QLabel(parent), zoomLevel(0.5)
{
setup(QSize(w,h));
setup(QSize(w, h));
}
MagnifyingGlass::MagnifyingGlass(const QSize & size, QWidget * parent)
:QLabel(parent),zoomLevel(0.5)
MagnifyingGlass::MagnifyingGlass(const QSize &size, QWidget *parent)
: QLabel(parent), zoomLevel(0.5)
{
setup(size);
}
void MagnifyingGlass::setup(const QSize & size)
void MagnifyingGlass::setup(const QSize &size)
{
resize(size);
setScaledContents(true);
setMouseTracking(true);
setCursor(QCursor(QBitmap(1,1),QBitmap(1,1)));
setCursor(QCursor(QBitmap(1, 1), QBitmap(1, 1)));
}
void MagnifyingGlass::mouseMoveEvent(QMouseEvent * event)
void MagnifyingGlass::mouseMoveEvent(QMouseEvent *event)
{
updateImage();
event->accept();
@ -36,153 +36,134 @@ void MagnifyingGlass::updateImage(int x, int y)
//image section augmented
int zoomWidth = static_cast<int>(width() * zoomLevel);
int zoomHeight = static_cast<int>(height() * zoomLevel);
Viewer * p = (Viewer *)parent();
Viewer *p = (Viewer *)parent();
int currentPos = p->verticalScrollBar()->sliderPosition();
const QPixmap * image = p->pixmap();
const QPixmap *image = p->pixmap();
int iWidth = image->width();
int iHeight = image->height();
float wFactor = static_cast<float>(iWidth) / p->widget()->width();
float hFactor = static_cast<float>(iHeight) / p->widget()->height();
zoomWidth *= wFactor;
zoomHeight *= hFactor;
if(p->verticalScrollBar()->minimum()==p->verticalScrollBar()->maximum())
{
int xp = static_cast<int>(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
int yp = static_cast<int>((y-p->widget()->pos().y()+currentPos)*hFactor-zoomHeight/2);
int xOffset=0;
int yOffset=0;
int zw=zoomWidth;
int zh=zoomHeight;
if (p->verticalScrollBar()->minimum() == p->verticalScrollBar()->maximum()) {
int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
int yp = static_cast<int>((y - p->widget()->pos().y() + currentPos) * hFactor - zoomHeight / 2);
int xOffset = 0;
int yOffset = 0;
int zw = zoomWidth;
int zh = zoomHeight;
//int wOffset,hOffset=0;
bool outImage = false;
if(xp<0)
{
if (xp < 0) {
xOffset = -xp;
xp=0;
xp = 0;
zw = zw - xOffset;
outImage = true;
}
if(yp<0)
{
if (yp < 0) {
yOffset = -yp;
yp=0;
yp = 0;
zh = zh - yOffset;
outImage = true;
}
if(xp+zoomWidth >= image->width())
{
zw -= xp+zw - image->width();
if (xp + zoomWidth >= image->width()) {
zw -= xp + zw - image->width();
outImage = true;
}
if(yp+zoomHeight >= image->height())
{
zh -= yp+zh - image->height();
if (yp + zoomHeight >= image->height()) {
zh -= yp + zh - image->height();
outImage = true;
}
if(outImage)
{
QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.fill(Configuration::getConfiguration().getBackgroundColor());
if(zw>0&&zh>0)
{
if (zw > 0 && zh > 0) {
QPainter painter(&img);
painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh));
}
setPixmap(QPixmap().fromImage(img));
}
else
setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
}
else
{
int xp = static_cast<int>(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
int yp = static_cast<int>((y+currentPos)*hFactor-zoomHeight/2);
int xOffset=0;
int yOffset=0;
int zw=zoomWidth;
int zh=zoomHeight;
} else
setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight));
} else {
int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
int yp = static_cast<int>((y + currentPos) * hFactor - zoomHeight / 2);
int xOffset = 0;
int yOffset = 0;
int zw = zoomWidth;
int zh = zoomHeight;
//int wOffset,hOffset=0;
bool outImage = false;
if(xp<0)
{
if (xp < 0) {
xOffset = -xp;
xp=0;
xp = 0;
zw = zw - xOffset;
outImage = true;
}
if(yp<0)
{
if (yp < 0) {
yOffset = -yp;
yp=0;
yp = 0;
zh = zh - yOffset;
outImage = true;
}
if(xp+zoomWidth >= image->width())
{
zw -= xp+zw - image->width();
if (xp + zoomWidth >= image->width()) {
zw -= xp + zw - image->width();
outImage = true;
}
if(yp+zoomHeight >= image->height())
{
zh -= yp+zh - image->height();
if (yp + zoomHeight >= image->height()) {
zh -= yp + zh - image->height();
outImage = true;
}
if(outImage)
{
QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
if (outImage) {
QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
img.fill(Configuration::getConfiguration().getBackgroundColor());
if(zw>0&&zh>0)
{
if (zw > 0 && zh > 0) {
QPainter painter(&img);
painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh));
}
setPixmap(QPixmap().fromImage(img));
} else
setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight));
}
else
setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
}
move(static_cast<int>(x-float(width())/2),static_cast<int>(y-float(height())/2));
move(static_cast<int>(x - float(width()) / 2), static_cast<int>(y - float(height()) / 2));
}
void MagnifyingGlass::updateImage()
{
if(isVisible())
{
QPoint p = QPoint(cursor().pos().x(),cursor().pos().y());
if (isVisible()) {
QPoint p = QPoint(cursor().pos().x(), cursor().pos().y());
p = this->parentWidget()->mapFromGlobal(p);
updateImage(p.x(),p.y());
updateImage(p.x(), p.y());
}
}
void MagnifyingGlass::wheelEvent(QWheelEvent * event)
void MagnifyingGlass::wheelEvent(QWheelEvent *event)
{
switch(event->modifiers())
{
switch (event->modifiers()) {
//size
case Qt::NoModifier:
if(event->delta()<0)
if (event->delta() < 0)
sizeUp();
else
sizeDown();
break;
//size height
case Qt::ControlModifier:
if(event->delta()<0)
if (event->delta() < 0)
heightUp();
else
heightDown();
break;
//size width
case Qt::AltModifier:
if(event->delta()<0)
if (event->delta() < 0)
widthUp();
else
widthDown();
break;
//zoom level
case Qt::ShiftModifier:
if(event->delta()<0)
if (event->delta() < 0)
zoomIn();
else
zoomOut();
@ -193,53 +174,53 @@ void MagnifyingGlass::wheelEvent(QWheelEvent * event)
}
void MagnifyingGlass::zoomIn()
{
if(zoomLevel>0.2f)
if (zoomLevel > 0.2f)
zoomLevel -= 0.025f;
}
void MagnifyingGlass::zoomOut()
{
if(zoomLevel<0.9f)
if (zoomLevel < 0.9f)
zoomLevel += 0.025f;
}
void MagnifyingGlass::sizeUp()
{
Viewer * p = (Viewer *)parent();
if(width()<(p->width()*0.90f))
resize(width()+30,height()+15);
Viewer *p = (Viewer *)parent();
if (width() < (p->width() * 0.90f))
resize(width() + 30, height() + 15);
}
void MagnifyingGlass::sizeDown()
{
if(width()>175)
resize(width()-30,height()-15);
if (width() > 175)
resize(width() - 30, height() - 15);
}
void MagnifyingGlass::heightUp()
{
Viewer * p = (Viewer *)parent();
if(height()<(p->height()*0.90f))
resize(width(),height()+15);
Viewer *p = (Viewer *)parent();
if (height() < (p->height() * 0.90f))
resize(width(), height() + 15);
}
void MagnifyingGlass::heightDown()
{
if(height()>80)
resize(width(),height()-15);
if (height() > 80)
resize(width(), height() - 15);
}
void MagnifyingGlass::widthUp()
{
Viewer * p = (Viewer *)parent();
if(width()<(p->width()*0.90f))
resize(width()+30,height());
Viewer *p = (Viewer *)parent();
if (width() < (p->width() * 0.90f))
resize(width() + 30, height());
}
void MagnifyingGlass::widthDown()
{
if(width()>175)
resize(width()-30,height());
if (width() > 175)
resize(width() - 30, height());
}
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
@ -249,7 +230,7 @@ void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
int _key = event->key();
Qt::KeyboardModifiers modifiers = event->modifiers();
if(modifiers & Qt::ShiftModifier)
if (modifiers & Qt::ShiftModifier)
_key |= Qt::SHIFT;
if (modifiers & Qt::ControlModifier)
_key |= Qt::CTRL;
@ -260,32 +241,27 @@ void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
QKeySequence key(_key);
if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y))
{
if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y)) {
sizeUp();
validKey = true;
}
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y))
{
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y)) {
sizeDown();
validKey = true;
}
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y))
{
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y)) {
zoomIn();
validKey = true;
}
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))
{
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y)) {
zoomOut();
validKey = true;
}
if(validKey)
{
if (validKey) {
updateImage();
event->setAccepted(true);
}

View File

@ -6,21 +6,22 @@
#include <QMouseEvent>
#include <QWidget>
class MagnifyingGlass : public QLabel
{
class MagnifyingGlass : public QLabel
{
Q_OBJECT
private:
private:
float zoomLevel;
void setup(const QSize & size);
void keyPressEvent(QKeyEvent * event);
public:
MagnifyingGlass(int width,int height,QWidget * parent);
MagnifyingGlass(const QSize & size, QWidget * parent);
void mouseMoveEvent(QMouseEvent * event);
public slots:
void setup(const QSize &size);
void keyPressEvent(QKeyEvent *event);
public:
MagnifyingGlass(int width, int height, QWidget *parent);
MagnifyingGlass(const QSize &size, QWidget *parent);
void mouseMoveEvent(QMouseEvent *event);
public slots:
void updateImage(int x, int y);
void updateImage();
void wheelEvent(QWheelEvent * event);
void wheelEvent(QWheelEvent *event);
void zoomIn();
void zoomOut();
void sizeUp();
@ -29,6 +30,6 @@
void heightDown();
void widthUp();
void widthDown();
};
};
#endif

View File

@ -13,32 +13,33 @@
using namespace QsLogging;
#if defined(WIN32) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#ifdef Q_OS_MAC
#include <QEvent>
#include <QFileOpenEvent>
class YACReaderApplication: public QApplication
class YACReaderApplication : public QApplication
{
public:
YACReaderApplication(int & argc, char ** argv) : QApplication(argc,argv)
{}
public:
YACReaderApplication(int &argc, char **argv)
: QApplication(argc, argv)
{
}
void setWindow(MainWindowViewer * w)
void setWindow(MainWindowViewer *w)
{
window = w;
}
protected:
bool event(QEvent * event)
{
switch(event->type())
protected:
bool event(QEvent *event)
{
switch (event->type()) {
case QEvent::FileOpen:
window->openComicFromPath(static_cast<QFileOpenEvent *>(event)->file());
return true;
@ -46,20 +47,21 @@ class YACReaderApplication: public QApplication
return QApplication::event(event);
}
}
private:
MainWindowViewer * window;
private:
MainWindowViewer *window;
};
#endif
int main(int argc, char * argv[])
int main(int argc, char *argv[])
{
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef Q_OS_MAC
YACReaderApplication app(argc,argv);
YACReaderApplication app(argc, argv);
#else
QApplication app(argc, argv);
#endif
@ -82,24 +84,24 @@ int main(int argc, char * argv[])
parser.addPositionalArgument("[File|Directory]", "File or directory to open.");
QCommandLineOption comicId("comicId", "", "comicId");
QCommandLineOption libraryId("libraryId", "", "libraryId");
// hide comicId and libraryId from help
#if QT_VERSION >= 0x050800
// hide comicId and libraryId from help
#if QT_VERSION >= 0x050800
comicId.setFlags(QCommandLineOption::HiddenFromHelp);
libraryId.setFlags(QCommandLineOption::HiddenFromHelp);
#else
#else
comicId.setHidden(true);
libraryId.setHidden(true);
#endif
#endif
// process
parser.addOption(comicId);
parser.addOption(libraryId);
parser.process(app);
QString destLog = YACReader::getSettingsPath()+"/yacreader.log";
QString destLog = YACReader::getSettingsPath() + "/yacreader.log";
QDir().mkpath(YACReader::getSettingsPath());
Logger& logger = Logger::instance();
Logger &logger = Logger::instance();
logger.setLoggingLevel(QsLogging::InfoLevel);
DestinationPtr fileDestination(DestinationFactory::MakeFileDestination(
@ -111,21 +113,18 @@ int main(int argc, char * argv[])
QTranslator translator;
QString sufix = QLocale::system().name();
#if defined Q_OS_UNIX && !defined Q_OS_MAC
translator.load(QString(DATADIR)+"/yacreader/languages/yacreader_"+sufix);
translator.load(QString(DATADIR) + "/yacreader/languages/yacreader_" + sufix);
#else
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
translator.load(QCoreApplication::applicationDirPath() + "/languages/yacreader_" + sufix);
#endif
app.installTranslator(&translator);
MainWindowViewer * mwv = new MainWindowViewer();
MainWindowViewer *mwv = new MainWindowViewer();
// some arguments need to be parsed after MainWindowViewer creation
QStringList arglist = parser.positionalArguments();
if (parser.isSet(comicId) && parser.isSet(libraryId) && arglist.count() >=1)
{
if (parser.isSet(comicId) && parser.isSet(libraryId) && arglist.count() >= 1) {
mwv->open(arglist.at(0), parser.value(comicId).toULongLong(), parser.value(libraryId).toULongLong());
}
else if (arglist.count() >= 1)
{
} else if (arglist.count() >= 1) {
mwv->openComicFromPath(arglist.at(0));
}

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
#include <QSettings>
#ifdef Q_OS_MAC
#include "yacreader_macosx_toolbar.h"
#include "yacreader_macosx_toolbar.h"
#endif
#include "comic_db.h"
@ -25,13 +25,13 @@ class YACReaderSliderAction;
class YACReaderSlider;
class EditShortcutsDialog;
class MainWindowViewer : public QMainWindow
{
class MainWindowViewer : public QMainWindow
{
Q_OBJECT
public slots:
public slots:
void open();
void open(QString path, ComicDB & comic, QList<ComicDB> & siblings);
void open(QString path, ComicDB &comic, QList<ComicDB> &siblings);
void open(QString path, qint64 comicId, qint64 libraryId);
void openFolder();
void openRecent();
@ -76,8 +76,7 @@ class EditShortcutsDialog;
void next();
void updatePage();*/
private:
private:
//!State
bool fullscreen;
bool toolbars;
@ -91,25 +90,25 @@ class EditShortcutsDialog;
QString currentDirectory;
QString currentDirectoryImgDest;
//!Widgets
Viewer * viewer;
Viewer *viewer;
//GoToDialog * goToDialog;
OptionsDialog * optionsDialog;
HelpAboutDialog * had;
OptionsDialog *optionsDialog;
HelpAboutDialog *had;
//ShortcutsDialog * shortcutsDialog;
EditShortcutsDialog * editShortcutsDialog;
EditShortcutsDialog *editShortcutsDialog;
//! ToolBars
#ifdef Q_OS_MAC
YACReaderMacOSXToolbar * comicToolBar;
#ifdef Q_OS_MAC
YACReaderMacOSXToolbar *comicToolBar;
#else
QToolBar * comicToolBar;
QToolBar *comicToolBar;
#endif
//! Actions
QAction *openAction;
QAction *openFolderAction;
QAction *openLatestComicAction;
QList<QAction*> recentFilesActionList;
QList<QAction *> recentFilesActionList;
QAction *clearRecentFilesAction;
QAction *saveImageAction;
QAction *openPreviousComicAction;
@ -143,9 +142,9 @@ class EditShortcutsDialog;
QAction *showEditShortcutsAction;
YACReaderSlider * zoomSliderAction;
YACReaderSlider *zoomSliderAction;
HttpVersionChecker * versionChecker;
HttpVersionChecker *versionChecker;
QString previousComicPath;
QString nextComicPath;
//! Método que inicializa el interfaz.
@ -154,16 +153,16 @@ class EditShortcutsDialog;
void createToolBars();
void refreshRecentFilesActionList();
void clearRecentFiles();
void getSiblingComics(QString path,QString currentComic);
void getSiblingComics(QString path, QString currentComic);
//! Manejadores de evento:
void keyPressEvent(QKeyEvent *event);
//void resizeEvent(QResizeEvent * event);
void mouseDoubleClickEvent ( QMouseEvent * event );
void mouseDoubleClickEvent(QMouseEvent *event);
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
QSettings * settings;
QSettings *settings;
ComicDB currentComicDB;
QList<ComicDB> siblingComics;
@ -177,11 +176,13 @@ class EditShortcutsDialog;
QSize previousSize;
signals:
void closed();
protected:
virtual void closeEvent ( QCloseEvent * event );
protected:
virtual void closeEvent(QCloseEvent *event);
void sendComic();
public:
public:
MainWindowViewer();
~MainWindowViewer();
};
};
#endif

View File

@ -2,29 +2,29 @@
#include <QtWidgets>
NotificationsLabelWidget::NotificationsLabelWidget(QWidget * parent)
:QWidget(parent)
NotificationsLabelWidget::NotificationsLabelWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
effect = new QGraphicsOpacityEffect(this);
effect->setOpacity(1.0);
anim = new QPropertyAnimation(effect,"opacity");
anim = new QPropertyAnimation(effect, "opacity");
anim->setDuration(500);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
anim->setEasingCurve(QEasingCurve::InExpo);
connect(anim,SIGNAL(finished()),this,SLOT(hide()));
connect(anim, SIGNAL(finished()), this, SLOT(hide()));
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
textLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
textLabel->setStyleSheet("QLabel { color : white; font-size:24px; }");
textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
textLabel->setFixedSize(200, 120);
@ -60,17 +60,16 @@ void NotificationsLabelWidget::flash()
setVisible(true);
}
void NotificationsLabelWidget::setText(const QString & text)
void NotificationsLabelWidget::setText(const QString &text)
{
textLabel->setText(text);
}
void NotificationsLabelWidget::updatePosition()
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
QWidget *parent = dynamic_cast<QWidget *>(this->parent());
if (parent == 0) {
return;
}
move(QPoint((parent->geometry().size().width()-this->width())/2,(parent->geometry().size().height()-this->height())/2));
move(QPoint((parent->geometry().size().width() - this->width()) / 2, (parent->geometry().size().height() - this->height()) / 2));
}

View File

@ -9,21 +9,21 @@ class QGraphicsOpacityEffect;
class NotificationsLabelWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
QLabel * textLabel;
QPropertyAnimation * anim;
QGraphicsOpacityEffect * effect;
QLabel *textLabel;
QPropertyAnimation *anim;
QGraphicsOpacityEffect *effect;
protected:
void paintEvent(QPaintEvent *);
public:
NotificationsLabelWidget(QWidget * parent);
NotificationsLabelWidget(QWidget *parent);
public slots:
void flash();
void setText(const QString & text);
void setText(const QString &text);
void updatePosition();
};

View File

@ -19,21 +19,21 @@
#include "yacreader_gl_flow_config_widget.h"
#endif
OptionsDialog::OptionsDialog(QWidget * parent)
:YACReaderOptionsDialog(parent)
OptionsDialog::OptionsDialog(QWidget *parent)
: YACReaderOptionsDialog(parent)
{
QTabWidget * tabWidget = new QTabWidget();
QTabWidget *tabWidget = new QTabWidget();
QVBoxLayout * layout = new QVBoxLayout(this);
QVBoxLayout *layout = new QVBoxLayout(this);
QWidget * pageGeneral = new QWidget();
QWidget * pageFlow = new QWidget();
QWidget * pageImage = new QWidget();
QVBoxLayout * layoutGeneral = new QVBoxLayout();
QVBoxLayout * layoutFlow = new QVBoxLayout();
QVBoxLayout * layoutImageV = new QVBoxLayout();
QGridLayout * layoutImage = new QGridLayout();
QWidget *pageGeneral = new QWidget();
QWidget *pageFlow = new QWidget();
QWidget *pageImage = new QWidget();
QVBoxLayout *layoutGeneral = new QVBoxLayout();
QVBoxLayout *layoutFlow = new QVBoxLayout();
QVBoxLayout *layoutImageV = new QVBoxLayout();
QGridLayout *layoutImage = new QGridLayout();
QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size"));
//slideSizeLabel = new QLabel(,this);
@ -42,18 +42,18 @@ OptionsDialog::OptionsDialog(QWidget * parent)
slideSize->setMaximum(350);
slideSize->setPageStep(5);
slideSize->setOrientation(Qt::Horizontal);
QHBoxLayout * slideLayout = new QHBoxLayout();
QHBoxLayout *slideLayout = new QHBoxLayout();
slideLayout->addWidget(slideSize);
slideSizeBox->setLayout(slideLayout);
QGroupBox *pathBox = new QGroupBox(tr("My comics path"));
QHBoxLayout * path = new QHBoxLayout();
QHBoxLayout *path = new QHBoxLayout();
path->addWidget(pathEdit = new QLineEdit());
path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"),""));
path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"), ""));
pathBox->setLayout(path);
connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder()));
connect(pathFindButton, SIGNAL(clicked()), this, SLOT(findFolder()));
//fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this);
/*QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
@ -67,49 +67,49 @@ OptionsDialog::OptionsDialog(QWidget * parent)
fitLayout->addWidget(fitToWidthRatioS);
fitBox->setLayout(fitLayout);*/
QHBoxLayout * colorSelection = new QHBoxLayout;
QHBoxLayout *colorSelection = new QHBoxLayout;
backgroundColor = new QLabel();
QPalette pal = backgroundColor->palette();
pal.setColor(backgroundColor->backgroundRole(), Qt::black);
backgroundColor->setPalette(pal);
backgroundColor->setAutoFillBackground(true);
colorDialog = new QColorDialog(Qt::red,this);
connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(updateColor(QColor)));
colorDialog = new QColorDialog(Qt::red, this);
connect(colorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateColor(QColor)));
QGroupBox *colorBox = new QGroupBox(tr("Background color"));
//backgroundColor->setMinimumWidth(100);
colorSelection->addWidget(backgroundColor);
colorSelection->addWidget(selectBackgroundColorButton = new QPushButton(tr("Choose")));
colorSelection->setStretchFactor(backgroundColor,1);
colorSelection->setStretchFactor(selectBackgroundColorButton,0);
colorSelection->setStretchFactor(backgroundColor, 1);
colorSelection->setStretchFactor(selectBackgroundColorButton, 0);
//colorSelection->addStretch();
connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show()));
colorBox->setLayout(colorSelection);
brightnessS = new YACReaderSpinSliderWidget(this,true);
brightnessS->setRange(0,100);
brightnessS = new YACReaderSpinSliderWidget(this, true);
brightnessS->setRange(0, 100);
//brightnessS->setText(tr("Brightness"));
brightnessS->setTracking(false);
connect(brightnessS,SIGNAL(valueChanged(int)),this,SLOT(brightnessChanged(int)));
connect(brightnessS, SIGNAL(valueChanged(int)), this, SLOT(brightnessChanged(int)));
contrastS = new YACReaderSpinSliderWidget(this,true);
contrastS->setRange(0,250);
contrastS = new YACReaderSpinSliderWidget(this, true);
contrastS->setRange(0, 250);
//contrastS->setText(tr("Contrast"));
contrastS->setTracking(false);
connect(contrastS,SIGNAL(valueChanged(int)),this,SLOT(contrastChanged(int)));
connect(contrastS, SIGNAL(valueChanged(int)), this, SLOT(contrastChanged(int)));
gammaS = new YACReaderSpinSliderWidget(this,true);
gammaS->setRange(0,250);
gammaS = new YACReaderSpinSliderWidget(this, true);
gammaS->setRange(0, 250);
//gammaS->setText(tr("Gamma"));
gammaS->setTracking(false);
connect(gammaS,SIGNAL(valueChanged(int)),this,SLOT(gammaChanged(int)));
connect(gammaS, SIGNAL(valueChanged(int)), this, SLOT(gammaChanged(int)));
//connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions()));
quickNavi = new QCheckBox(tr("Quick Navigation Mode"));
disableShowOnMouseOver = new QCheckBox(tr("Disable mouse over activation"));
QHBoxLayout * buttons = new QHBoxLayout();
QHBoxLayout *buttons = new QHBoxLayout();
buttons->addStretch();
buttons->addWidget(new QLabel(tr("Restart is needed")));
buttons->addWidget(accept);
@ -131,31 +131,29 @@ OptionsDialog::OptionsDialog(QWidget * parent)
layoutFlow->addWidget(disableShowOnMouseOver);
layoutFlow->addStretch();
layoutImage->addWidget(new QLabel(tr("Brightness")),0,0);
layoutImage->addWidget(new QLabel(tr("Contrast")),1,0);
layoutImage->addWidget(new QLabel(tr("Gamma")),2,0);
layoutImage->addWidget(brightnessS,0,1);
layoutImage->addWidget(contrastS,1,1);
layoutImage->addWidget(gammaS,2,1);
QPushButton * pushButton = new QPushButton(tr("Reset"));
connect(pushButton,SIGNAL(pressed()),this,SLOT(resetImageConfig()));
layoutImage->addWidget(pushButton,3,0);
layoutImage->setColumnStretch(1,1);
layoutImage->addWidget(new QLabel(tr("Brightness")), 0, 0);
layoutImage->addWidget(new QLabel(tr("Contrast")), 1, 0);
layoutImage->addWidget(new QLabel(tr("Gamma")), 2, 0);
layoutImage->addWidget(brightnessS, 0, 1);
layoutImage->addWidget(contrastS, 1, 1);
layoutImage->addWidget(gammaS, 2, 1);
QPushButton *pushButton = new QPushButton(tr("Reset"));
connect(pushButton, SIGNAL(pressed()), this, SLOT(resetImageConfig()));
layoutImage->addWidget(pushButton, 3, 0);
layoutImage->setColumnStretch(1, 1);
QGroupBox *imageBox = new QGroupBox(tr("Image options"));
imageBox->setLayout(layoutImage);
layoutImageV->addWidget(imageBox);
layoutImageV->addStretch();
pageGeneral->setLayout(layoutGeneral);
pageFlow->setLayout(layoutFlow);
pageImage->setLayout(layoutImageV);
tabWidget->addTab(pageGeneral,tr("General"));
tabWidget->addTab(pageFlow,tr("Page Flow"));
tabWidget->addTab(pageImage,tr("Image adjustment"));
tabWidget->addTab(pageGeneral, tr("General"));
tabWidget->addTab(pageFlow, tr("Page Flow"));
tabWidget->addTab(pageImage, tr("Image adjustment"));
layout->addWidget(tabWidget);
layout->addLayout(buttons);
@ -168,7 +166,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
#endif
//restoreOptions(); //load options
//resize(400,0);
setModal (true);
setModal(true);
setWindowTitle(tr("Options"));
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
@ -176,9 +174,8 @@ OptionsDialog::OptionsDialog(QWidget * parent)
void OptionsDialog::findFolder()
{
QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),".");
if(!s.isEmpty())
{
QString s = QFileDialog::getExistingDirectory(0, tr("Comics directory"), ".");
if (!s.isEmpty()) {
pathEdit->setText(s);
}
}
@ -186,32 +183,31 @@ void OptionsDialog::findFolder()
void OptionsDialog::saveOptions()
{
settings->setValue(GO_TO_FLOW_SIZE,QSize(static_cast<int>(slideSize->sliderPosition()/SLIDE_ASPECT_RATIO),slideSize->sliderPosition()));
settings->setValue(GO_TO_FLOW_SIZE, QSize(static_cast<int>(slideSize->sliderPosition() / SLIDE_ASPECT_RATIO), slideSize->sliderPosition()));
if(sw->radio1->isChecked())
settings->setValue(FLOW_TYPE_SW,0);
if(sw->radio2->isChecked())
settings->setValue(FLOW_TYPE_SW,1);
if(sw->radio3->isChecked())
settings->setValue(FLOW_TYPE_SW,2);
if (sw->radio1->isChecked())
settings->setValue(FLOW_TYPE_SW, 0);
if (sw->radio2->isChecked())
settings->setValue(FLOW_TYPE_SW, 1);
if (sw->radio3->isChecked())
settings->setValue(FLOW_TYPE_SW, 2);
settings->setValue(PATH,pathEdit->text());
settings->setValue(PATH, pathEdit->text());
settings->setValue(BACKGROUND_COLOR,colorDialog->currentColor());
settings->setValue(BACKGROUND_COLOR, colorDialog->currentColor());
//settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
settings->setValue(QUICK_NAVI_MODE,quickNavi->isChecked());
settings->setValue(DISABLE_MOUSE_OVER_GOTO_FLOW,disableShowOnMouseOver->isChecked());
settings->setValue(QUICK_NAVI_MODE, quickNavi->isChecked());
settings->setValue(DISABLE_MOUSE_OVER_GOTO_FLOW, disableShowOnMouseOver->isChecked());
YACReaderOptionsDialog::saveOptions();
}
void OptionsDialog::restoreOptions(QSettings * settings)
void OptionsDialog::restoreOptions(QSettings *settings)
{
YACReaderOptionsDialog::restoreOptions(settings);
slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height());
switch(settings->value(FLOW_TYPE_SW).toInt())
{
switch (settings->value(FLOW_TYPE_SW).toInt()) {
case 0:
sw->radio1->setChecked(true);
break;
@ -234,13 +230,12 @@ void OptionsDialog::restoreOptions(QSettings * settings)
quickNavi->setChecked(settings->value(QUICK_NAVI_MODE).toBool());
disableShowOnMouseOver->setChecked(settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool());
brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt());
contrastS->setValue(settings->value(CONTRAST,100).toInt());
gammaS->setValue(settings->value(GAMMA,100).toInt());
brightnessS->setValue(settings->value(BRIGHTNESS, 0).toInt());
contrastS->setValue(settings->value(CONTRAST, 100).toInt());
gammaS->setValue(settings->value(GAMMA, 100).toInt());
}
void OptionsDialog::updateColor(const QColor & color)
void OptionsDialog::updateColor(const QColor &color)
{
QPalette pal = backgroundColor->palette();
pal.setColor(backgroundColor->backgroundRole(), color);
@ -248,7 +243,7 @@ void OptionsDialog::updateColor(const QColor & color)
backgroundColor->setAutoFillBackground(true);
colorDialog->setCurrentColor(color);
settings->setValue(BACKGROUND_COLOR,color);
settings->setValue(BACKGROUND_COLOR, color);
emit(changedOptions());
}
@ -261,24 +256,24 @@ void OptionsDialog::updateColor(const QColor & color)
void OptionsDialog::brightnessChanged(int value)
{
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(BRIGHTNESS,value);
QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
settings.setValue(BRIGHTNESS, value);
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
//emit(changedImageOptions());
}
void OptionsDialog::contrastChanged(int value)
{
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(CONTRAST,value);
QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
settings.setValue(CONTRAST, value);
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
///emit(changedImageOptions());
}
void OptionsDialog::gammaChanged(int value)
{
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(GAMMA,value);
QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
settings.setValue(GAMMA, value);
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
//emit(changedImageOptions());
}
@ -288,10 +283,10 @@ void OptionsDialog::resetImageConfig()
brightnessS->setValue(0);
contrastS->setValue(100);
gammaS->setValue(100);
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(BRIGHTNESS,0);
settings.setValue(CONTRAST,100);
settings.setValue(GAMMA,100);
QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
settings.setValue(BRIGHTNESS, 0);
settings.setValue(CONTRAST, 100);
settings.setValue(GAMMA, 100);
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
//emit(changedImageOptions());
}
@ -299,7 +294,7 @@ void OptionsDialog::resetImageConfig()
void OptionsDialog::show()
{
//TODO solucionar el tema de las settings, esto sólo debería aparecer en una única línea de código
QSettings *s = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
QSettings *s = new QSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
//fitToWidthRatioS->disconnect();
//fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
//connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
@ -309,17 +304,16 @@ void OptionsDialog::show()
void OptionsDialog::setFilters(int brightness, int contrast, int gamma)
{
if(brightness != -1)
if (brightness != -1)
brightnessS->setValue(brightness);
else
brightnessS->setValue(0);
if(contrast != -1)
if (contrast != -1)
contrastS->setValue(contrast);
else
contrastS->setValue(100);
if(gamma != -1)
if (gamma != -1)
gammaS->setValue(gamma);
else
gammaS->setValue(100);
}

View File

@ -13,45 +13,45 @@ class QRadioButton;
class QColorDialog;
class YACReaderSpinSliderWidget;
class OptionsDialog : public YACReaderOptionsDialog
{
Q_OBJECT
public:
OptionsDialog(QWidget * parent = 0);
private:
Q_OBJECT
public:
OptionsDialog(QWidget *parent = 0);
private:
//QLabel * pathLabel;
QLineEdit * pathEdit;
QPushButton * pathFindButton;
QCheckBox * quickNavi;
QCheckBox * disableShowOnMouseOver;
QLineEdit *pathEdit;
QPushButton *pathFindButton;
QCheckBox *quickNavi;
QCheckBox *disableShowOnMouseOver;
QLabel * magGlassSizeLabel;
QLabel *magGlassSizeLabel;
QLabel * zoomLevel;
QLabel *zoomLevel;
//QLabel * slideSizeLabel;
QSlider * slideSize;
QSlider *slideSize;
//QLabel * fitToWidthRatioLabel;
//QSlider * fitToWidthRatioS;
QLabel * backgroundColor;
QPushButton * selectBackgroundColorButton;
QLabel *backgroundColor;
QPushButton *selectBackgroundColorButton;
QColorDialog * colorDialog;
QColorDialog *colorDialog;
YACReaderSpinSliderWidget * brightnessS;
YACReaderSpinSliderWidget *brightnessS;
YACReaderSpinSliderWidget * contrastS;
YACReaderSpinSliderWidget *contrastS;
YACReaderSpinSliderWidget * gammaS;
YACReaderSpinSliderWidget *gammaS;
public slots:
public slots:
void saveOptions();
void restoreOptions(QSettings * settings);
void restoreOptions(QSettings *settings);
void findFolder();
void updateColor(const QColor & color);
void updateColor(const QColor &color);
//void fitToWidthRatio(int value);
void brightnessChanged(int value);
void contrastChanged(int value);
@ -65,8 +65,6 @@ signals:
void changedImageOptions();
void changedFilters(int brightness, int contrast, int gamma);
//void fitToWidthRatioChanged(float ratio);
};
#endif

View File

@ -2,18 +2,18 @@
#include <QtWidgets>
PageLabelWidget::PageLabelWidget(QWidget * parent)
:QWidget(parent)
PageLabelWidget::PageLabelWidget(QWidget *parent)
: QWidget(parent)
{
animation = new QPropertyAnimation(this,"pos");
animation = new QPropertyAnimation(this, "pos");
animation->setDuration(150);
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
int verticalRes = QApplication::desktop()->screenGeometry().height();
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
QSize labelSize;
if (verticalRes <= 1024)
@ -24,8 +24,8 @@ PageLabelWidget::PageLabelWidget(QWidget * parent)
labelSize = QSize(205, 45);
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
if(verticalRes <= 1024)
textLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
if (verticalRes <= 1024)
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }");
else if (verticalRes <= 1200)
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}");
@ -34,20 +34,18 @@ PageLabelWidget::PageLabelWidget(QWidget * parent)
setFixedSize(labelSize);
if(parent != 0)
move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
if (parent != 0)
move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
layout->addWidget(textLabel, 0 , Qt::AlignCenter);
layout->addWidget(textLabel, 0, Qt::AlignCenter);
setLayout(layout);
}
void PageLabelWidget::show()
{
if(this->pos().y() <= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
if (this->pos().y() <= 0 && animation->state() != QPropertyAnimation::Running) {
QWidget *parent = dynamic_cast<QWidget *>(this->parent());
if (parent == 0) {
return;
}
@ -55,29 +53,27 @@ void PageLabelWidget::show()
//connect(animation,SIGNAL(finished()),this,SLOT(QWidget::hide()));
animation->disconnect();
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),0));
animation->setStartValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), 0));
animation->start();
}
}
void PageLabelWidget::hide()
{
if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
if (this->pos().y() >= 0 && animation->state() != QPropertyAnimation::Running) {
QWidget *parent = dynamic_cast<QWidget *>(this->parent());
if (parent == 0) {
return;
}
//connect(animation,SIGNAL(finished()),this,SLOT(setHidden()));
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),0));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
animation->setStartValue(QPoint((parent->geometry().size().width() - this->width()), 0));
animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
animation->start();
}
}
void PageLabelWidget::setText(const QString & text)
void PageLabelWidget::setText(const QString &text)
{
textLabel->setText(text);
}
@ -86,20 +82,19 @@ void PageLabelWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
}
void PageLabelWidget::updatePosition()
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
QWidget *parent = dynamic_cast<QWidget *>(this->parent());
if (parent == 0) {
return;
}
animation->stop();
if (animation->endValue().toPoint().y() == 0)
move(QPoint((parent->geometry().size().width()-this->width()),0));
move(QPoint((parent->geometry().size().width() - this->width()), 0));
else
move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
}

View File

@ -8,21 +8,21 @@ class QPropertyAnimation;
class PageLabelWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
private:
QLabel * textLabel;
QPropertyAnimation * animation;
QLabel *textLabel;
QPropertyAnimation *animation;
protected:
virtual void paintEvent(QPaintEvent *);
public:
PageLabelWidget(QWidget * parent);
PageLabelWidget(QWidget *parent);
public slots:
void show();
void hide();
void setText(const QString & text);
void setText(const QString &text);
void updatePosition();
};

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#ifndef RENDER_H
#ifndef RENDER_H
#define RENDER_H
#include <QImage>
@ -18,51 +18,62 @@ class Comic;
class ComicDB;
class Render;
class ImageFilter {
class ImageFilter
{
public:
ImageFilter(){};
ImageFilter() {};
virtual ~ImageFilter() {};
virtual QImage setFilter(const QImage & image) = 0;
inline int getLevel() {return level;};
inline void setLevel(int l) {level = l;};
virtual QImage setFilter(const QImage &image) = 0;
inline int getLevel() { return level; };
inline void setLevel(int l) { level = l; };
protected:
int level;
};
class MeanNoiseReductionFilter : public ImageFilter {
class MeanNoiseReductionFilter : public ImageFilter
{
public:
enum NeighborghoodSize{SMALL=9, LARGE=25 };
enum NeighborghoodSize { SMALL = 9,
LARGE = 25 };
MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
virtual QImage setFilter(const QImage & image);
virtual QImage setFilter(const QImage &image);
private:
enum NeighborghoodSize neighborghoodSize;
};
class MedianNoiseReductionFilter : public ImageFilter {
class MedianNoiseReductionFilter : public ImageFilter
{
public:
enum NeighborghoodSize{SMALL=9, LARGE=25 };
enum NeighborghoodSize { SMALL = 9,
LARGE = 25 };
MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
virtual QImage setFilter(const QImage & image);
virtual QImage setFilter(const QImage &image);
private:
enum NeighborghoodSize neighborghoodSize;
};
class BrightnessFilter : public ImageFilter {
class BrightnessFilter : public ImageFilter
{
public:
BrightnessFilter(int l=-1);
virtual QImage setFilter(const QImage & image);
BrightnessFilter(int l = -1);
virtual QImage setFilter(const QImage &image);
};
class ContrastFilter : public ImageFilter {
class ContrastFilter : public ImageFilter
{
public:
ContrastFilter(int l=-1);
virtual QImage setFilter(const QImage & image);
ContrastFilter(int l = -1);
virtual QImage setFilter(const QImage &image);
};
class GammaFilter : public ImageFilter {
class GammaFilter : public ImageFilter
{
public:
GammaFilter(int l=-1);
virtual QImage setFilter(const QImage & image);
GammaFilter(int l = -1);
virtual QImage setFilter(const QImage &image);
};
//-----------------------------------------------------------------------------
@ -74,23 +85,23 @@ class PageRender : public QThread
Q_OBJECT
public:
PageRender();
PageRender(Render * render,int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
int getNumPage(){return numPage;};
void setData(const QByteArray & rawData){data = rawData;};
void setPage(QImage * p){page = p;};
void setRotation(unsigned int d){degrees = d;};
void setFilters(QVector<ImageFilter *> f){filters = f;};
PageRender(Render *render, int numPage, const QByteArray &rawData, QImage *page, unsigned int degrees = 0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
int getNumPage() { return numPage; };
void setData(const QByteArray &rawData) { data = rawData; };
void setPage(QImage *p) { page = p; };
void setRotation(unsigned int d) { degrees = d; };
void setFilters(QVector<ImageFilter *> f) { filters = f; };
private:
int numPage;
QByteArray data;
QImage * page;
QImage *page;
unsigned int degrees;
QVector<ImageFilter *> filters;
void run();
Render * render;
Render *render;
signals:
void pageReady(int);
};
//-----------------------------------------------------------------------------
// RENDER
@ -116,17 +127,18 @@ signals:
};
*/
class Render : public QObject {
Q_OBJECT
class Render : public QObject
{
Q_OBJECT
public:
Render();
~Render();
public slots:
void render();
QPixmap * getCurrentPage();
QPixmap * getCurrentDoublePage();
QPixmap * getCurrentDoubleMangaPage();
QPixmap *getCurrentPage();
QPixmap *getCurrentDoublePage();
QPixmap *getCurrentDoubleMangaPage();
bool currentPageIsDoublePage();
bool nextPageIsDoublePage();
bool previousPageIsDoublePage();
@ -134,7 +146,7 @@ public slots:
void doublePageSwitch();
void doubleMangaPageSwitch();
void setRotation(int degrees);
void setComic(Comic * c);
void setComic(Comic *c);
void prepareAvailablePage(int page);
void update();
void setNumPages(unsigned int numPages);
@ -144,11 +156,11 @@ public slots:
void previousPage();
void nextDoublePage();
void previousDoublePage();
void load(const QString & path, const ComicDB & comic);
void load(const QString & path, int atPage);
void createComic(const QString & path);
void loadComic(const QString & path,const ComicDB & comic);
void loadComic(const QString & path, int atPage);
void load(const QString &path, const ComicDB &comic);
void load(const QString &path, int atPage);
void createComic(const QString &path);
void loadComic(const QString &path, const ComicDB &comic);
void loadComic(const QString &path, int atPage);
void startLoad();
void rotateRight();
void rotateLeft();
@ -165,7 +177,7 @@ public slots:
void reset();
void reload();
void updateFilters(int brightness, int contrast, int gamma);
Bookmarks * getBookmarks();
Bookmarks *getBookmarks();
//sets the firt page to render
void renderAt(int page);
@ -174,7 +186,7 @@ signals:
void processingPage();
void imagesLoaded();
void imageLoaded(int index);
void imageLoaded(int index,const QByteArray & image);
void imageLoaded(int index, const QByteArray &image);
void pageChanged(int index);
void numPages(unsigned int numPages);
void errorOpening();
@ -186,9 +198,8 @@ signals:
void bookmarksUpdated();
private:
Comic * comic;
Comic *comic;
bool doublePage;
bool doubleMangaPage;
int previousIndex;
@ -212,5 +223,4 @@ private:
friend class PageRender;
};
#endif // RENDER_H

View File

@ -8,23 +8,23 @@
#include <QTextStream>
#include <QTextCodec>
ShortcutsDialog::ShortcutsDialog(QWidget * parent)
:QDialog(parent)//,Qt::FramelessWindowHint)
ShortcutsDialog::ShortcutsDialog(QWidget *parent)
: QDialog(parent) //,Qt::FramelessWindowHint)
{
setModal(true);
setWindowIcon(QIcon(":/images/shortcuts.png"));
setWindowTitle(tr("YACReader keyboard shortcuts"));
QVBoxLayout * mainLayout = new QVBoxLayout;
QVBoxLayout *mainLayout = new QVBoxLayout;
close = new QPushButton(tr("Close"));
connect(close,SIGNAL(clicked()),this,SLOT(close()));
connect(close, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(close);
QHBoxLayout * shortcutsLayout = new QHBoxLayout;
QHBoxLayout *shortcutsLayout = new QHBoxLayout;
shortcuts = new QTextEdit();
shortcuts->setFrameStyle(QFrame::NoFrame);
@ -39,7 +39,7 @@ ShortcutsDialog::ShortcutsDialog(QWidget * parent)
setLayout(mainLayout);
setFixedSize(QSize(700,500));
setFixedSize(QSize(700, 500));
QFile f(":/files/shortcuts.html");
f.open(QIODevice::ReadOnly);

View File

@ -7,13 +7,14 @@
class ShortcutsDialog : public QDialog
{
Q_OBJECT
public:
ShortcutsDialog(QWidget * parent = 0);
private:
QTextEdit * shortcuts;
QPushButton * close;
public slots:
Q_OBJECT
public:
ShortcutsDialog(QWidget *parent = 0);
private:
QTextEdit *shortcuts;
QPushButton *close;
public slots:
};
#endif // SHORTCUTS_DIALOG_H

View File

@ -33,8 +33,8 @@
#define APPID "417CEAD93449502CC3C9B69FED26C54118E62BCC"
YACReaderTranslator::YACReaderTranslator(QWidget * parent)
:QWidget(parent),drag(false)
YACReaderTranslator::YACReaderTranslator(QWidget *parent)
: QWidget(parent), drag(false)
{
QString scrollBarStyle = "QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
@ -56,19 +56,19 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
QVBoxLayout *layout = new QVBoxLayout(this);
//TITLE BAR
QHBoxLayout * titleBar = new QHBoxLayout();
QPushButton * close = new QPushButton(QIcon(QPixmap(":/images/close.png")),"");
QHBoxLayout *titleBar = new QHBoxLayout();
QPushButton *close = new QPushButton(QIcon(QPixmap(":/images/close.png")), "");
close->setFlat(true);
QLabel * title = new QLabel(tr("YACReader translator"));
QLabel *title = new QLabel(tr("YACReader translator"));
title->setStyleSheet("QLabel {font-size:18px; font-family:Arial; color:white;}");
titleBar->addWidget(title);
titleBar->addStretch();
close->resize(14,14);
close->resize(14, 14);
close->setStyleSheet("QPushButton {margin:0;padding:0;border:none;}");
titleBar->addWidget(close);
titleBar->setContentsMargins(0,0,0,0);
titleBar->setContentsMargins(0, 0, 0, 0);
titleBar->setSpacing(0);
connect(close,SIGNAL(clicked()),this->parent(),SLOT(animateHideTranslator()));
connect(close, SIGNAL(clicked()), this->parent(), SLOT(animateHideTranslator()));
layout->addLayout(titleBar);
@ -78,50 +78,49 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
text->setMaximumHeight(110);
layout->addSpacing(12);
layout->addWidget(text);
text->setStyleSheet("QTextEdit{border:none;background:#2a2a2a;color:white; font-size:12px; padding:6px;}"+scrollBarStyle);
text->setStyleSheet("QTextEdit{border:none;background:#2a2a2a;color:white; font-size:12px; padding:6px;}" + scrollBarStyle);
//COMBOBOXES
QHBoxLayout * combos = new QHBoxLayout();
QHBoxLayout *combos = new QHBoxLayout();
from = new QComboBox(this);
to = new QComboBox(this);
QString comboBoxStyle = "QComboBox {border:none;background:#2a2a2a;color:white;font-size:12px;font-family:Arial;padding-left:8px;}"
"QComboBox::down-arrow {image: url(:/images/dropDownArrow.png);}"
"QComboBox::drop-down {border:none; padding-right:10px;}"
"QComboBox QAbstractItemView {border: none; background:#272727; color:white; selection-background-color: #202020; outline:none;}"
"QComboBox QAbstractItemView::item {padding-left:8px;}" + scrollBarStyle
;
"QComboBox QAbstractItemView::item {padding-left:8px;}" +
scrollBarStyle;
from->setStyleSheet(comboBoxStyle);
to->setStyleSheet(comboBoxStyle);
from->setFixedHeight(22);
to->setFixedHeight(22);
QLabel * arrow = new QLabel(this);
QLabel *arrow = new QLabel(this);
QPixmap arrowPixmap(":/images/fromTo.png");
arrow->setPixmap(arrowPixmap);
QPushButton * searchButton = new QPushButton(this);
QPushButton *searchButton = new QPushButton(this);
searchButton->setIcon(QIcon(":/images/translatorSearch.png"));
searchButton->setStyleSheet("QPushButton {border:none; background:#2a2a2a;}");
searchButton->setFixedSize(22,22);
combos->addWidget(from,1);
searchButton->setFixedSize(22, 22);
combos->addWidget(from, 1);
combos->addSpacing(9);
combos->addWidget(arrow,0);
combos->addWidget(arrow, 0);
combos->addSpacing(9);
combos->addWidget(to,1);
combos->addWidget(to, 1);
combos->addSpacing(9);
combos->addWidget(searchButton,0);
combos->addWidget(searchButton, 0);
layout->addSpacing(12);
layout->addLayout(combos);
//RESULTS
QHBoxLayout * resultsTitleLayout = new QHBoxLayout();
QHBoxLayout *resultsTitleLayout = new QHBoxLayout();
resultsTitle = new QLabel(tr("Translation"));
resultsTitle->setStyleSheet("QLabel {font-family:Arial;font-size:14px;color:#e3e3e3;}");
speakButton = new QPushButton(this);
speakButton->setStyleSheet("QPushButton {border:none;}");
speakButton->setIcon(QIcon(":/images/speaker.png"));
resultsTitleLayout->addWidget(resultsTitle,0,Qt::AlignVCenter);
resultsTitleLayout->addWidget(resultsTitle, 0, Qt::AlignVCenter);
resultsTitleLayout->addSpacing(10);
resultsTitleLayout->addWidget(speakButton,0,Qt::AlignVCenter);
resultsTitleLayout->addWidget(speakButton, 0, Qt::AlignVCenter);
resultsTitleLayout->addStretch();
layout->addSpacing(15);
@ -138,29 +137,29 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
//CLEAR BUTTON
clearButton = new QPushButton(tr("clear"));
layout->addWidget(clearButton,0,Qt::AlignRight);
layout->addWidget(clearButton, 0, Qt::AlignRight);
clearButton->setMinimumWidth(95);
clearButton->setStyleSheet("QPushButton {border:1px solid #212121; background:#2a2a2a; color:white; font-family:Arial; font-size:12px; padding-top:5px; padding-bottom:5px;}");
resize(400,479);
resize(400, 479);
layout->setMargin(0);
layout->setContentsMargins(18,12,18,12);
setContentsMargins(0,0,0,0);
layout->setContentsMargins(18, 12, 18, 12);
setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
hideResults();
populateCombos();
busyIndicator = new YACReaderBusyWidget(this);
busyIndicator->move((this->width()-busyIndicator->width())/2,(this->height()-busyIndicator->height())*2/3);
busyIndicator->move((this->width() - busyIndicator->width()) / 2, (this->height() - busyIndicator->height()) * 2 / 3);
busyIndicator->hide();
show();
connect(searchButton,SIGNAL(pressed()),this,SLOT(translate()));
connect(speakButton,SIGNAL(pressed()),this,SLOT(play()));
connect(clearButton,SIGNAL(pressed()),this,SLOT(clear()));
connect(searchButton, SIGNAL(pressed()), this, SLOT(translate()));
connect(speakButton, SIGNAL(pressed()), this, SLOT(play()));
connect(clearButton, SIGNAL(pressed()), this, SLOT(clear()));
//multimedia/phonon
#if QT_VERSION >= 0x050000
@ -168,7 +167,6 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
#else
music = createPlayer(MusicCategory);
#endif
}
void YACReaderTranslator::hideResults()
@ -187,22 +185,22 @@ void YACReaderTranslator::clear()
void YACReaderTranslator::translate()
{
QString text = this->text->toPlainText();
if(text.isEmpty())
if (text.isEmpty())
return;
QString from = this->from->itemData(this->from->currentIndex()).toString();
QString to = this->to->itemData(this->to->currentIndex()).toString();
TranslationLoader * translationLoader = new TranslationLoader(text,from,to);
connect(translationLoader,SIGNAL(requestFinished(QString)),this,SLOT(setTranslation(QString)));
connect(translationLoader,SIGNAL(error()),this,SLOT(error()));
connect(translationLoader,SIGNAL(timeOut()),this,SLOT(error()));
connect(translationLoader,SIGNAL(finished()),translationLoader,SLOT(deleteLater()));
TranslationLoader *translationLoader = new TranslationLoader(text, from, to);
connect(translationLoader, SIGNAL(requestFinished(QString)), this, SLOT(setTranslation(QString)));
connect(translationLoader, SIGNAL(error()), this, SLOT(error()));
connect(translationLoader, SIGNAL(timeOut()), this, SLOT(error()));
connect(translationLoader, SIGNAL(finished()), translationLoader, SLOT(deleteLater()));
TextToSpeachLoader * tts = new TextToSpeachLoader(text,from);
connect(tts,SIGNAL(requestFinished(QUrl)),this,SLOT(setSpeak(QUrl)));
connect(tts,SIGNAL(error()),this,SLOT(error()));
connect(tts,SIGNAL(timeOut()),this,SLOT(error()));
connect(tts,SIGNAL(finished()),tts,SLOT(deleteLater()));
TextToSpeachLoader *tts = new TextToSpeachLoader(text, from);
connect(tts, SIGNAL(requestFinished(QUrl)), this, SLOT(setSpeak(QUrl)));
connect(tts, SIGNAL(error()), this, SLOT(error()));
connect(tts, SIGNAL(timeOut()), this, SLOT(error()));
connect(tts, SIGNAL(finished()), tts, SLOT(deleteLater()));
translationLoader->start();
tts->start();
@ -221,7 +219,7 @@ void YACReaderTranslator::error()
busyIndicator->hide();
}
void YACReaderTranslator::setSpeak(const QUrl & url)
void YACReaderTranslator::setSpeak(const QUrl &url)
{
resultsTitle->setHidden(false);
speakButton->setHidden(false);
@ -229,7 +227,7 @@ void YACReaderTranslator::setSpeak(const QUrl & url)
ttsSource = url;
}
void YACReaderTranslator::setTranslation(const QString & string)
void YACReaderTranslator::setTranslation(const QString &string)
{
resultText->setText(string);
@ -244,46 +242,45 @@ void YACReaderTranslator::populateCombos()
combos.append(from);
combos.append(to);
for(int i=0;i<combos.count();i++)
{
QComboBox * combo = combos.at(i);
combo->addItem("Arabic","ar");
combo->addItem("Bulgarian","bg");
combo->addItem("Catalan","ca");
combo->addItem("Chinese Simplified","zh-CHS");
combo->addItem("Chinese Traditional","zh-CHT");
combo->addItem("Czech","cs");
combo->addItem("Danish","da");
combo->addItem("Dutch","nl");
combo->addItem("English","en");
combo->addItem("Estonian","et");
combo->addItem("Finnish","fi");
combo->addItem("French","fr");
combo->addItem("German","de");
combo->addItem("Greek","el");
combo->addItem("Haitian Creole","ht");
combo->addItem("Hebrew","he");
combo->addItem("Hindi","hi");
combo->addItem("Hungarian","hu");
combo->addItem("Indonesian","id");
combo->addItem("Italian","it");
combo->addItem("Japanese","ja");
combo->addItem("Korean","ko");
combo->addItem("Latvian","lv");
combo->addItem("Lithuanian","lt");
combo->addItem("Norwegian","no");
combo->addItem("Polish","pl");
combo->addItem("Portuguese","pt");
combo->addItem("Romanian","ro");
combo->addItem("Russian","ru");
combo->addItem("Slovak","sk");
combo->addItem("Slovenian","sl");
combo->addItem("Spanish","es");
combo->addItem("Swedish","sv");
combo->addItem("Thai","th");
combo->addItem("Turkish","tr");
combo->addItem("Ukrainian","uk");
combo->addItem("Vietnamese","vi");
for (int i = 0; i < combos.count(); i++) {
QComboBox *combo = combos.at(i);
combo->addItem("Arabic", "ar");
combo->addItem("Bulgarian", "bg");
combo->addItem("Catalan", "ca");
combo->addItem("Chinese Simplified", "zh-CHS");
combo->addItem("Chinese Traditional", "zh-CHT");
combo->addItem("Czech", "cs");
combo->addItem("Danish", "da");
combo->addItem("Dutch", "nl");
combo->addItem("English", "en");
combo->addItem("Estonian", "et");
combo->addItem("Finnish", "fi");
combo->addItem("French", "fr");
combo->addItem("German", "de");
combo->addItem("Greek", "el");
combo->addItem("Haitian Creole", "ht");
combo->addItem("Hebrew", "he");
combo->addItem("Hindi", "hi");
combo->addItem("Hungarian", "hu");
combo->addItem("Indonesian", "id");
combo->addItem("Italian", "it");
combo->addItem("Japanese", "ja");
combo->addItem("Korean", "ko");
combo->addItem("Latvian", "lv");
combo->addItem("Lithuanian", "lt");
combo->addItem("Norwegian", "no");
combo->addItem("Polish", "pl");
combo->addItem("Portuguese", "pt");
combo->addItem("Romanian", "ro");
combo->addItem("Russian", "ru");
combo->addItem("Slovak", "sk");
combo->addItem("Slovenian", "sl");
combo->addItem("Spanish", "es");
combo->addItem("Swedish", "sv");
combo->addItem("Thai", "th");
combo->addItem("Turkish", "tr");
combo->addItem("Ukrainian", "uk");
combo->addItem("Vietnamese", "vi");
}
from->setCurrentIndex(from->findText("English"));
to->setCurrentIndex(from->findText("Spanish"));
@ -315,9 +312,8 @@ YACReaderTranslator::~YACReaderTranslator()
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
{
QPoint p = mapTo(this,event->pos());
if(p.y() < 40)
{
QPoint p = mapTo(this, event->pos());
if (p.y() < 40) {
drag = true;
click = event->pos();
}
@ -329,10 +325,10 @@ void YACReaderTranslator::mouseReleaseEvent(QMouseEvent *event)
event->accept();
}
void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event)
void YACReaderTranslator::mouseMoveEvent(QMouseEvent *event)
{
if(drag)
this->move(QPoint(mapToParent(event->pos())-click));
if (drag)
this->move(QPoint(mapToParent(event->pos()) - click));
event->accept();
}
@ -341,7 +337,7 @@ void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event)
//---------------------------------------------------------------------------
TranslationLoader::TranslationLoader(QString text, QString from, QString to)
:QThread(),text(text),from(from),to(to)
: QThread(), text(text), from(from), to(to)
{
}
@ -353,7 +349,7 @@ void TranslationLoader::run()
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit()));
QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appid=%1&from=%2&to=%3&text=%4&contentType=text/plain";
url = url.arg(APPID).arg(from).arg(to).arg(text);
@ -363,18 +359,16 @@ void TranslationLoader::run()
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
if (tT.isActive()) {
// download complete
if(reply->error() == QNetworkReply::NoError)
{
if (reply->error() == QNetworkReply::NoError) {
QString utf8 = QString::fromUtf8(reply->readAll());
utf8 = utf8.remove(0,1);
utf8 = utf8.remove(utf8.count()-1,1);
utf8 = utf8.remove(0, 1);
utf8 = utf8.remove(utf8.count() - 1, 1);
QString translated(utf8);
emit(requestFinished(translated));
}
else
} else
emit(error());
} else {
emit(timeOut());
@ -385,13 +379,11 @@ void TranslationLoader::run()
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TextToSpeachLoader::TextToSpeachLoader(QString text, QString language)
:QThread(),text(text),language(language)
: QThread(), text(text), language(language)
{
}
void TextToSpeachLoader::run()
{
QNetworkAccessManager manager;
@ -400,7 +392,7 @@ void TextToSpeachLoader::run()
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
connect(&manager, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit()));
QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appid=%1&language=%2&text=%3&contentType=text/plain";
url = url.arg(APPID).arg(language).arg(text);
@ -410,18 +402,16 @@ void TextToSpeachLoader::run()
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
if (tT.isActive()) {
// download complete
if(reply->error() == QNetworkReply::NoError)
{
if (reply->error() == QNetworkReply::NoError) {
QString utf8 = QString::fromUtf8(reply->readAll());
utf8 = utf8.remove(0,1);
utf8 = utf8.remove(utf8.count()-1,1);
utf8 = utf8.replace("\\","");
utf8 = utf8.remove(0, 1);
utf8 = utf8.remove(utf8.count() - 1, 1);
utf8 = utf8.replace("\\", "");
emit(requestFinished(QUrl(utf8)));
}
else
} else
emit(error());
} else {
emit(timeOut());

View File

@ -15,58 +15,55 @@ class YACReaderBusyWidget;
#include <QUrl>
#if QT_VERSION >= 0x050000
class QMediaPlayer;
class QMediaPlayer;
#else
#include<Phonon/MediaObject>
using namespace Phonon;
#include <Phonon/MediaObject>
using namespace Phonon;
#endif
class YACReaderTranslator : public QWidget
{
Q_OBJECT
public:
YACReaderTranslator(QWidget * parent = 0);
public:
YACReaderTranslator(QWidget *parent = 0);
~YACReaderTranslator();
public slots:
public slots:
void play();
protected slots:
protected slots:
void translate();
void setSpeak(const QUrl & url);
void setTranslation(const QString & string);
void setSpeak(const QUrl &url);
void setTranslation(const QString &string);
void error();
void clear();
protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent ( QMouseEvent * event );
void mouseMoveEvent(QMouseEvent *event);
void hideResults();
void populateCombos();
bool drag;
QPoint click;
private:
private:
#if QT_VERSION >= 0x050000
QMediaPlayer *player;
#else
MediaObject * music;
MediaObject *music;
#endif
QTextEdit * text;
QComboBox * from;
QComboBox * to;
QLabel * resultsTitle;
QPushButton * speakButton;
QLabel * resultText;
YACReaderBusyWidget * busyIndicator;
QTextEdit *text;
QComboBox *from;
QComboBox *to;
QLabel *resultsTitle;
QPushButton *speakButton;
QLabel *resultText;
YACReaderBusyWidget *busyIndicator;
QUrl ttsSource;
QPushButton * clearButton;
QPushButton *clearButton;
};
class TranslationLoader : public QThread
@ -78,6 +75,7 @@ signals:
void requestFinished(QString);
void timeOut();
void error();
private:
QString text;
QString from;
@ -94,6 +92,7 @@ signals:
void requestFinished(QUrl);
void timeOut();
void error();
private:
QString text;
QString language;

File diff suppressed because it is too large Load Diff

View File

@ -32,12 +32,12 @@ class Bookmarks;
class PageLabelWidget;
class NotificationsLabelWidget;
class Viewer : public QScrollArea, public ScrollManagement
{
class Viewer : public QScrollArea, public ScrollManagement
{
Q_OBJECT
public:
public:
bool fullscreen; //TODO, change by the right use of windowState();
public slots:
public slots:
void increaseZoomFactor();
void decreaseZoomFactor();
void setZoomFactor(int);
@ -45,7 +45,7 @@ class NotificationsLabelWidget;
void prepareForOpening();
void open(QString pathFile, int atPage = -1);
void open(QString pathFile, const ComicDB & comic);
void open(QString pathFile, const ComicDB &comic);
void prev();
void next();
void showGoToDialog();
@ -72,7 +72,7 @@ class NotificationsLabelWidget;
void animateHideGoToFlow();
void rotateLeft();
void rotateRight();
bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;}
bool magnifyingGlassIsVisible() { return magnifyingGlassShowed; }
void setBookmark(bool);
void save();
void doublePageSwitch();
@ -87,48 +87,48 @@ class NotificationsLabelWidget;
void translatorSwitch();
void animateShowTranslator();
void animateHideTranslator();
virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseReleaseEvent ( QMouseEvent * event );
void updateBackgroundColor(const QColor & color);
void updateConfig(QSettings * settings);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
void updateBackgroundColor(const QColor &color);
void updateConfig(QSettings *settings);
void showMessageErrorOpening();
void showMessageErrorOpening(QString);
void processCRCError(QString message);
void setBookmarks();
//deprecated
void updateImageOptions();
void updateFilters(int brightness, int contrast,int gamma);
void updateFilters(int brightness, int contrast, int gamma);
void showIsCoverMessage();
void showIsLastMessage();
int getCurrentPageNumber();
void updateZoomRatio(int ratio);
private:
private:
bool information;
bool doublePage;
bool doubleMangaPage;
int zoom;
PageLabelWidget * informationLabel;
PageLabelWidget *informationLabel;
//QTimer * scroller;
QPropertyAnimation * verticalScroller;
QPropertyAnimation * horizontalScroller;
QParallelAnimationGroup * groupScroller;
QPropertyAnimation *verticalScroller;
QPropertyAnimation *horizontalScroller;
QParallelAnimationGroup *groupScroller;
int posByStep;
int nextPos;
GoToFlowWidget * goToFlow;
QPropertyAnimation * showGoToFlowAnimation;
GoToDialog * goToDialog;
GoToFlowWidget *goToFlow;
QPropertyAnimation *showGoToFlowAnimation;
GoToDialog *goToDialog;
//!Image properties
//! Comic
//Comic * comic;
int index;
QPixmap *currentPage;
BookmarksDialog * bd;
BookmarksDialog *bd;
bool wheelStop;
Render * render;
QTimer * hideCursorTimer;
Render *render;
QTimer *hideCursorTimer;
int direction;
bool drag;
int numScrollSteps;
@ -136,47 +136,50 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
//!Widgets
QLabel *content;
YACReaderTranslator * translator;
YACReaderTranslator *translator;
int translatorXPos;
QPropertyAnimation * translatorAnimation;
QPropertyAnimation *translatorAnimation;
int yDragOrigin;
int xDragOrigin;
NotificationsLabelWidget * notificationsLabel;
NotificationsLabelWidget *notificationsLabel;
bool shouldOpenNext;
bool shouldOpenPrevious;
private:
private:
//!Magnifying glass
MagnifyingGlass *mglass;
bool magnifyingGlassShowed;
bool restoreMagnifyingGlass;
//! Manejadores de evento:
void keyPressEvent(QKeyEvent * event);
void resizeEvent(QResizeEvent * event);
void wheelEvent(QWheelEvent * event);
void mouseMoveEvent(QMouseEvent * event);
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
void wheelEvent(QWheelEvent *event);
void mouseMoveEvent(QMouseEvent *event);
//!ZigzagScroll
enum scrollDirection{ UP, DOWN, LEFT, RIGHT };
enum scrollDirection { UP,
DOWN,
LEFT,
RIGHT };
bool isEdge(scrollDirection d);
void scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward);
void scrollTo(int x, int y);
public:
Viewer(QWidget * parent = 0);
public:
Viewer(QWidget *parent = 0);
~Viewer();
void toggleFullScreen();
const QPixmap * pixmap();
const QPixmap *pixmap();
//Comic * getComic(){return comic;}
const BookmarksDialog * getBookmarksDialog(){return bd;}
const BookmarksDialog *getBookmarksDialog() { return bd; }
//returns the current index starting in 1 [1,nPages]
unsigned int getIndex();
void updateComic(ComicDB & comic);
signals:
void updateComic(ComicDB &comic);
signals:
void backgroundChanges();
void pageAvailable(bool);
void pageIsBookmark(bool);
@ -184,6 +187,6 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
void openNextComic();
void openPreviousComic();
void zoomUpdated(int);
};
};
#endif

View File

@ -4,13 +4,14 @@
#include "configuration.h"
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
:QWidgetAction (parent) {
YACReaderSliderAction::YACReaderSliderAction(QWidget *parent)
: QWidgetAction(parent)
{
widget = new YACReaderSlider();
setDefaultWidget(widget);
connect(widget,SIGNAL(zoomRatioChanged(int)),this,SIGNAL(zoomRatioChanged(int)));
connect(widget, SIGNAL(zoomRatioChanged(int)), this, SIGNAL(zoomRatioChanged(int)));
}
void YACReaderSliderAction::updateText(int value)
@ -24,7 +25,7 @@ void YACReaderSliderAction::updateZoomRatio(int value)
}
YACReaderSlider::YACReaderSlider(QWidget *parent)
:QWidget(parent)
: QWidget(parent)
{
const int sliderWidth = 200;
const int contentsMargin = 10;
@ -33,7 +34,7 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
setFocusPolicy(Qt::StrongFocus);
QHBoxLayout* pLayout = new QHBoxLayout();
QHBoxLayout *pLayout = new QHBoxLayout();
pLayout->addStretch();
@ -56,10 +57,10 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
pLayout->setMargin(0);
setLayout (pLayout);
setLayout(pLayout);
setAutoFillBackground(false);
setContentsMargins(contentsMargin,contentsMargin,contentsMargin,contentsMargin);
setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin);
setFixedSize(sliderWidth + 2 * contentsMargin + 2 * elementsSpacing + percentageLabelWidth + resetButton->sizeHint().width(), 45);
slider->setMinimum(30);
@ -78,7 +79,7 @@ void YACReaderSlider::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
}
void YACReaderSlider::show()
@ -87,7 +88,7 @@ void YACReaderSlider::show()
setFocus();
}
void YACReaderSlider::focusOutEvent(QFocusEvent * event)
void YACReaderSlider::focusOutEvent(QFocusEvent *event)
{
QWidget::focusOutEvent(event);
hide();

View File

@ -10,15 +10,15 @@ class YACReaderSlider : public QWidget
{
Q_OBJECT
private:
QLabel * percentageLabel;
QSlider * slider;
QLabel *percentageLabel;
QSlider *slider;
public:
YACReaderSlider (QWidget * parent = 0);
YACReaderSlider(QWidget *parent = 0);
void show();
protected:
virtual void focusOutEvent(QFocusEvent * event);
virtual void focusOutEvent(QFocusEvent *event);
virtual void paintEvent(QPaintEvent *);
public slots:
@ -26,7 +26,6 @@ public slots:
void updateZoomRatio(int value);
void resetValueToDefault();
signals:
void zoomRatioChanged(int value);
};
@ -35,17 +34,15 @@ class YACReaderSliderAction : public QWidgetAction
{
Q_OBJECT
private:
YACReaderSlider * widget;
YACReaderSlider *widget;
public:
YACReaderSliderAction (QWidget * parent = 0);
YACReaderSliderAction(QWidget *parent = 0);
public slots:
void updateText(int value);
void updateZoomRatio(int value);
signals:
void zoomRatioChanged(int value);
};

View File

@ -8,8 +8,8 @@
using namespace YACReader;
YACReaderLocalClient::YACReaderLocalClient(QObject *parent) :
QObject(parent)
YACReaderLocalClient::YACReaderLocalClient(QObject *parent)
: QObject(parent)
{
localSocket = new QLocalSocket(this);
@ -25,15 +25,13 @@ YACReaderLocalClient::~YACReaderLocalClient()
//información de comic recibida...
void YACReaderLocalClient::readMessage()
{
}
#include <QMessageBox>
bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & siblings)
bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings)
{
localSocket->connectToServer(YACREADERLIBRARY_GUID);
if(localSocket->isOpen())
{
if (localSocket->isOpen()) {
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_8);
@ -47,16 +45,14 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
int written = 0;
int previousWritten = 0;
quint16 tries = 0;
while(written != block.size() && tries < 200)
{
while (written != block.size() && tries < 200) {
written += localSocket->write(block);
localSocket->flush();
if(written == previousWritten) //no bytes were written
if (written == previousWritten) //no bytes were written
tries++;
previousWritten = written;
}
if(tries == 200)
{
if (tries == 200) {
localSocket->close();
QLOG_ERROR() << "Requesting Comic Info : unable to send request";
return false;
@ -69,23 +65,20 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
int dataAvailable = 0;
QByteArray packageSize;
localSocket->waitForReadyRead(1000);
while(packageSize.size() < (int)sizeof(quint32) && tries < 20)
{
while (packageSize.size() < (int)sizeof(quint32) && tries < 20) {
packageSize.append(localSocket->read(sizeof(quint32) - packageSize.size()));
localSocket->waitForReadyRead(100);
if(dataAvailable == packageSize.size())
{
if (dataAvailable == packageSize.size()) {
tries++; //TODO apply 'tries' fix
}
dataAvailable = packageSize.size();
}
if(tries == 20)
{
if (tries == 20) {
localSocket->close();
QLOG_ERROR() << "Requesting Comic Info : unable to read package size";
return false;
}
QDataStream sizeStream(packageSize);//localSocket->read(sizeof(quint32)));
QDataStream sizeStream(packageSize); //localSocket->read(sizeof(quint32)));
sizeStream.setVersion(QDataStream::Qt_4_8);
quint32 totalSize = 0;
sizeStream >> totalSize;
@ -95,18 +88,16 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
tries = 0;
int dataRead = 0;
localSocket->waitForReadyRead(1000);
while((unsigned int)data.length() < totalSize && tries < 20 )
{
while ((unsigned int)data.length() < totalSize && tries < 20) {
data.append(localSocket->readAll());
if((unsigned int)data.length() < totalSize)
if ((unsigned int)data.length() < totalSize)
localSocket->waitForReadyRead(100);
if(data.length() == dataRead)
if (data.length() == dataRead)
tries++;
dataRead = data.length();
}
if(tries == 20)
{
if (tries == 20) {
localSocket->close();
QLOG_ERROR() << "Requesting Comic Info : unable to read data (" << data.length() << "," << totalSize << ")";
return false;
@ -117,20 +108,16 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
dataStream >> siblings;
localSocket->close();
return true;
}
else
{
} else {
QLOG_ERROR() << "Requesting Comic Info : unable to connect to the server";
return false;
}
}
bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB &comic)
{
localSocket->connectToServer(YACREADERLIBRARY_GUID);
if(localSocket->isOpen())
{
if (localSocket->isOpen()) {
//QLOG_INFO() << "Connection opened for sending ComicInfo";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
@ -145,18 +132,16 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
int written, previousWritten;
written = previousWritten = 0;
int tries = 0;
while(written != block.size() && tries < 100)
{
while (written != block.size() && tries < 100) {
written += localSocket->write(block);
if(written == previousWritten)
if (written == previousWritten)
tries++;
previousWritten = written;
}
localSocket->waitForBytesWritten(2000);
localSocket->close();
//QLOG_INFO() << QString("Sending Comic Info : writen data (%1,%2)").arg(written).arg(block.size());
if(tries == 100 && written != block.size())
{
if (tries == 100 && written != block.size()) {
emit finished();
QLOG_ERROR() << QString("Sending Comic Info : unable to write data (%1,%2)").arg(written).arg(block.size());
return false;
@ -170,11 +155,10 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
return false;
}
bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic, qulonglong nextComicId)
bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB &comic, qulonglong nextComicId)
{
localSocket->connectToServer(YACREADERLIBRARY_GUID);
if(localSocket->isOpen())
{
if (localSocket->isOpen()) {
//QLOG_INFO() << "Connection opened for sending ComicInfo";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
@ -190,18 +174,16 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic, qul
int written, previousWritten;
written = previousWritten = 0;
int tries = 0;
while(written != block.size() && tries < 100)
{
while (written != block.size() && tries < 100) {
written += localSocket->write(block);
if(written == previousWritten)
if (written == previousWritten)
tries++;
previousWritten = written;
}
localSocket->waitForBytesWritten(2000);
localSocket->close();
//QLOG_INFO() << QString("Sending Comic Info : writen data (%1,%2)").arg(written).arg(block.size());
if(tries == 100 && written != block.size())
{
if (tries == 100 && written != block.size()) {
emit finished();
QLOG_ERROR() << QString("Sending Comic Info : unable to write data (%1,%2)").arg(written).arg(block.size());
return false;

View File

@ -16,14 +16,12 @@ signals:
void finished();
public slots:
void readMessage();
bool requestComicInfo(quint64 libraryId, ComicDB & comic,QList<ComicDB> & siblings);
bool sendComicInfo(quint64 libraryId, ComicDB & comic);
bool sendComicInfo(quint64 libraryId, ComicDB & comic, qulonglong nextComicId);
bool requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings);
bool sendComicInfo(quint64 libraryId, ComicDB &comic);
bool sendComicInfo(quint64 libraryId, ComicDB &comic, qulonglong nextComicId);
private:
QLocalSocket * localSocket;
QLocalSocket *localSocket;
};
#endif // YACREADER_LOCAL_CLIENT_H

View File

@ -1,15 +1,15 @@
#include "add_label_dialog.h"
AddLabelDialog::AddLabelDialog(QWidget *parent) :
QDialog(parent)
AddLabelDialog::AddLabelDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout * layout = new QVBoxLayout;
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(new QLabel(tr("Label name:")));
layout->addWidget(edit = new QLineEdit());
layout->addWidget(new QLabel(tr("Choose a color:")));
layout->addWidget(list = new QListWidget() );
layout->addWidget(list = new QListWidget());
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_red.png"), tr("red")));
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_orange.png"), tr("orange")));
@ -33,10 +33,10 @@ AddLabelDialog::AddLabelDialog(QWidget *parent) :
setMinimumHeight(340);
//buttons
acceptButton = new QPushButton(tr("accept"),this);
cancelButton = new QPushButton(tr("cancel"),this);
acceptButton = new QPushButton(tr("accept"), this);
cancelButton = new QPushButton(tr("cancel"), this);
QHBoxLayout * buttons = new QHBoxLayout;
QHBoxLayout *buttons = new QHBoxLayout;
buttons->addStretch();
buttons->addWidget(acceptButton);
buttons->addWidget(cancelButton);
@ -47,15 +47,14 @@ AddLabelDialog::AddLabelDialog(QWidget *parent) :
setLayout(layout);
//connections
connect(edit,SIGNAL(textChanged(QString)),this,SLOT(validateName(QString)));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(close()));
connect(acceptButton,SIGNAL(clicked()),this,SLOT(accept()));
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(validateName(QString)));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));
}
YACReader::LabelColors AddLabelDialog::selectedColor()
{
return YACReader::LabelColors(list->currentRow()+1);
return YACReader::LabelColors(list->currentRow() + 1);
}
QString AddLabelDialog::name()
@ -77,7 +76,7 @@ int AddLabelDialog::exec()
void AddLabelDialog::validateName(const QString &name)
{
if(name.isEmpty())
if (name.isEmpty())
acceptButton->setDisabled(true);
else
acceptButton->setEnabled(true);

View File

@ -18,14 +18,14 @@ public slots:
int exec();
protected slots:
void validateName(const QString & name);
void validateName(const QString &name);
protected:
QLineEdit * edit;
QListWidget * list;
QLineEdit *edit;
QListWidget *list;
QPushButton * acceptButton;
QPushButton * cancelButton;
QPushButton *acceptButton;
QPushButton *cancelButton;
};
#endif // ADD_LABEL_DIALOG_H

View File

@ -5,9 +5,8 @@
#include <QFileDialog>
#include <QGridLayout>
AddLibraryDialog::AddLibraryDialog(QWidget * parent)
:QDialog(parent)
AddLibraryDialog::AddLibraryDialog(QWidget *parent)
: QDialog(parent)
{
setupUI();
}
@ -17,32 +16,32 @@ void AddLibraryDialog::setupUI()
textLabel = new QLabel(tr("Comics folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
connect(path, SIGNAL(textChanged(QString)), this, SLOT(pathSetted(QString)));
nameLabel = new QLabel(tr("Library name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameSetted(QString)));
accept = new QPushButton(tr("Add"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(add()));
connect(accept, SIGNAL(clicked()), this, SLOT(add()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
find = new QPushButton(QIcon(":/images/find_folder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
find = new QPushButton(QIcon(":/images/find_folder.png"), "");
connect(find, SIGNAL(clicked()), this, SLOT(findPath()));
QGridLayout * content = new QGridLayout;
QGridLayout *content = new QGridLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
content->addWidget(nameLabel, 0, 0);
content->addWidget(nameEdit, 0, 1);
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnStretch(2,0);
content->addWidget(textLabel, 1, 0);
content->addWidget(path, 1, 1);
content->addWidget(find, 1, 2);
content->setColumnStretch(2, 0);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@ -54,11 +53,11 @@ void AddLibraryDialog::setupUI()
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel *imgLabel = new QLabel(this);
QPixmap p(":/images/openLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
imgMainLayout->addWidget(imgLabel); //,0,Qt::AlignTop);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
@ -70,48 +69,41 @@ void AddLibraryDialog::setupUI()
void AddLibraryDialog::add()
{
//accept->setEnabled(false);
emit(addLibrary(QDir::cleanPath(path->text()),nameEdit->text()));
emit(addLibrary(QDir::cleanPath(path->text()), nameEdit->text()));
}
void AddLibraryDialog::nameSetted(const QString & text)
void AddLibraryDialog::nameSetted(const QString &text)
{
if(!text.isEmpty())
{
if(!path->text().isEmpty())
{
if (!text.isEmpty()) {
if (!path->text().isEmpty()) {
QFileInfo fi(path->text());
if(fi.isDir())
if (fi.isDir())
accept->setEnabled(true);
else
accept->setEnabled(false);
}
}
else
} else
accept->setEnabled(false);
}
void AddLibraryDialog::pathSetted(const QString & text)
void AddLibraryDialog::pathSetted(const QString &text)
{
QFileInfo fi(text);
if(fi.isDir())
{
if(!nameEdit->text().isEmpty())
if (fi.isDir()) {
if (!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
} else
accept->setEnabled(false);
}
void AddLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
if (!s.isEmpty()) {
path->setText(s);
if(!nameEdit->text().isEmpty())
if (!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
} else
accept->setEnabled(false);
}

View File

@ -7,29 +7,29 @@
#include <QPushButton>
#include <QThread>
class AddLibraryDialog : public QDialog
{
class AddLibraryDialog : public QDialog
{
Q_OBJECT
public:
AddLibraryDialog(QWidget * parent = 0);
private:
QLabel * nameLabel;
QLabel * textLabel;
QLineEdit * path;
QLineEdit * nameEdit;
QPushButton * find;
QPushButton * accept;
QPushButton * cancel;
public:
AddLibraryDialog(QWidget *parent = 0);
private:
QLabel *nameLabel;
QLabel *textLabel;
QLineEdit *path;
QLineEdit *nameEdit;
QPushButton *find;
QPushButton *accept;
QPushButton *cancel;
void setupUI();
public slots:
public slots:
void add();
void findPath();
void close();
void nameSetted(const QString & text);
void pathSetted(const QString & text);
signals:
void nameSetted(const QString &text);
void pathSetted(const QString &text);
signals:
void addLibrary(QString target, QString name);
};
};
#endif

View File

@ -1,13 +1,10 @@
#include "bundle_creator.h"
BundleCreator::BundleCreator(void)
:QObject()
: QObject()
{
}
BundleCreator::~BundleCreator(void)
{
}

View File

@ -5,7 +5,7 @@
class BundleCreator : public QObject
{
Q_OBJECT
Q_OBJECT
public:
BundleCreator(void);
~BundleCreator(void);

View File

@ -9,17 +9,17 @@
#include "yacreader_tool_bar_stretch.h"
ClassicComicsView::ClassicComicsView(QWidget *parent)
:ComicsView(parent),searching(false)
: ComicsView(parent), searching(false)
{
QHBoxLayout * layout = new QHBoxLayout;
QHBoxLayout *layout = new QHBoxLayout;
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("libraryConfig");
//FLOW-----------------------------------------------------------------------
//---------------------------------------------------------------------------
//FORCE_ANGLE is not used here, because ComicFlowWidgetGL will use OpenGL ES in the future
#ifndef NO_OPENGL
if((settings->value(USE_OPEN_GL).toBool() == true))
if ((settings->value(USE_OPEN_GL).toBool() == true))
comicFlow = new ComicFlowWidgetGL(0);
else
comicFlow = new ComicFlowWidgetSW(0);
@ -35,7 +35,6 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
comicFlow->setContextMenuPolicy(Qt::CustomContextMenu);
//layout-----------------------------------------------
sVertical = new QSplitter(Qt::Vertical); //spliter derecha
@ -44,12 +43,11 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
setupSearchingIcon();
stack->addWidget(searchingIcon);
sVertical->addWidget(stack);
comics = new QWidget;
QVBoxLayout * comicsLayout = new QVBoxLayout;
QVBoxLayout *comicsLayout = new QVBoxLayout;
comicsLayout->setSpacing(0);
comicsLayout->setContentsMargins(0,0,0,0);
comicsLayout->setContentsMargins(0, 0, 0, 0);
//TODO ComicsView:(set toolbar) comicsLayout->addWidget(editInfoToolBar);
tableView = new YACReaderTableView;
@ -62,17 +60,17 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
tableView->setContextMenuPolicy(Qt::CustomContextMenu);
//config--------------------------------------------------
if(settings->contains(COMICS_VIEW_HEADERS))
if (settings->contains(COMICS_VIEW_HEADERS))
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
//connections---------------------------------------------
connect(tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(centerComicFlow(QModelIndex)));
connect(tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectedComicForOpening(QModelIndex)));
connect(comicFlow, SIGNAL(centerIndexChanged(int)), this, SLOT(updateTableView(int)));
connect(tableView, SIGNAL(comicRated(int,QModelIndex)), this, SIGNAL(comicRated(int,QModelIndex)));
connect(tableView, SIGNAL(comicRated(int, QModelIndex)), this, SIGNAL(comicRated(int, QModelIndex)));
connect(comicFlow, SIGNAL(selected(uint)), this, SIGNAL(selected(uint)));
connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveTableHeadersStatus()));
connect(tableView->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveTableHeadersStatus()));
connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveTableHeadersStatus()));
connect(tableView->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveTableHeadersStatus()));
connect(comicFlow, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(requestedViewContextMenu(QPoint)));
connect(tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(requestedItemContextMenu(QPoint)));
layout->addWidget(sVertical);
@ -81,10 +79,10 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
layout->setMargin(0);
#ifdef Q_OS_MAC
sVertical->setCollapsible(1,false);
sVertical->setCollapsible(1, false);
#endif
if(settings->contains(COMICS_VIEW_FLOW_SPLITTER_STATUS))
if (settings->contains(COMICS_VIEW_FLOW_SPLITTER_STATUS))
sVertical->restoreState(settings->value(COMICS_VIEW_FLOW_SPLITTER_STATUS).toByteArray());
//hide flow widgets
@ -96,25 +94,22 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
hideFlowViewAction->setCheckable(true);
hideFlowViewAction->setChecked(false);
connect(hideFlowViewAction, SIGNAL(toggled(bool)),this, SLOT(hideComicFlow(bool)));
connect(hideFlowViewAction, SIGNAL(toggled(bool)), this, SLOT(hideComicFlow(bool)));
}
void ClassicComicsView::hideComicFlow(bool hide)
{
if(hide)
{
if (hide) {
QList<int> sizes;
sizes.append(0);
int total = sVertical->sizes().at(0) + sVertical->sizes().at(1);
sizes.append(total);
sVertical->setSizes(sizes);
}
else
{
} else {
QList<int> sizes;
int total = sVertical->sizes().at(0) + sVertical->sizes().at(1);
sizes.append(2*total/3);
sizes.append(total/3);
sizes.append(2 * total / 3);
sizes.append(total / 3);
sVertical->setSizes(sizes);
}
}
@ -122,7 +117,7 @@ void ClassicComicsView::hideComicFlow(bool hide)
//the toolbar has to be populated
void ClassicComicsView::setToolBar(QToolBar *toolBar)
{
static_cast<QVBoxLayout *>(comics->layout())->insertWidget(0,toolBar);
static_cast<QVBoxLayout *>(comics->layout())->insertWidget(0, toolBar);
this->toolbar = toolBar;
toolBarStretch = new YACReaderToolBarStretch(this);
@ -135,31 +130,28 @@ void ClassicComicsView::setModel(ComicModel *model)
{
ComicsView::setModel(model);
if(model == NULL)
{
if (model == NULL) {
comicFlow->clear();
}
else
{
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(applyModelChanges(QModelIndex,QModelIndex,QVector<int>)),Qt::UniqueConnection);
connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(removeItemsFromFlow(QModelIndex,int,int)),Qt::UniqueConnection);
connect(model, SIGNAL(resortedIndexes(QList<int>)),comicFlow,SLOT(resortCovers(QList<int>)),Qt::UniqueConnection);
connect(model, SIGNAL(newSelectedIndex(QModelIndex)),this,SLOT(setCurrentIndex(QModelIndex)),Qt::UniqueConnection);
} else {
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), this, SLOT(applyModelChanges(QModelIndex, QModelIndex, QVector<int>)), Qt::UniqueConnection);
connect(model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(removeItemsFromFlow(QModelIndex, int, int)), Qt::UniqueConnection);
connect(model, SIGNAL(resortedIndexes(QList<int>)), comicFlow, SLOT(resortCovers(QList<int>)), Qt::UniqueConnection);
connect(model, SIGNAL(newSelectedIndex(QModelIndex)), this, SLOT(setCurrentIndex(QModelIndex)), Qt::UniqueConnection);
tableView->setModel(model);
if(model->rowCount()>0)
tableView->setCurrentIndex(model->index(0,0));
if (model->rowCount() > 0)
tableView->setCurrentIndex(model->index(0, 0));
tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
#if QT_VERSION >= 0x050000
#if QT_VERSION >= 0x050000
tableView->horizontalHeader()->setSectionsMovable(true);
#else
#else
tableView->horizontalHeader()->setMovable(true);
#endif
#endif
//TODO parametrizar la configuración de las columnas
/*if(!settings->contains(COMICS_VIEW_HEADERS))
{*/
for(int i = 0;i<tableView->horizontalHeader()->count();i++)
for (int i = 0; i < tableView->horizontalHeader()->count(); i++)
tableView->horizontalHeader()->hideSection(i);
tableView->horizontalHeader()->showSection(ComicModel::Number);
@ -176,13 +168,12 @@ void ClassicComicsView::setModel(ComicModel *model)
//así que se ecala la primera vez y después se deja el control al usuario.
//if(!settings->contains(COMICS_VIEW_HEADERS))
QStringList paths = model->getPaths(model->getCurrentPath());//TODO ComicsView: get currentpath from somewhere currentPath());
QStringList paths = model->getPaths(model->getCurrentPath()); //TODO ComicsView: get currentpath from somewhere currentPath());
comicFlow->setImagePaths(paths);
comicFlow->setMarks(model->getReadList());
//comicFlow->setFocus(Qt::OtherFocusReason);
if(settings->contains(COMICS_VIEW_HEADERS))
if (settings->contains(COMICS_VIEW_HEADERS))
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
tableView->resizeColumnsToContents();
@ -207,7 +198,7 @@ QItemSelectionModel *ClassicComicsView::selectionModel()
return tableView->selectionModel();
}
void ClassicComicsView::scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint)
void ClassicComicsView::scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint)
{
Q_UNUSED(hint);
@ -242,15 +233,13 @@ void ClassicComicsView::updateConfig(QSettings *settings)
void ClassicComicsView::enableFilterMode(bool enabled)
{
if(enabled)
{
if (enabled) {
comicFlow->clear();
if(previousSplitterStatus.isEmpty())
if (previousSplitterStatus.isEmpty())
previousSplitterStatus = sVertical->saveState();
sVertical->setSizes(QList<int> () << 100 << 10000000);
sVertical->setSizes(QList<int>() << 100 << 10000000);
showSearchingIcon();
}else
{
} else {
hideSearchingIcon();
sVertical->restoreState(previousSplitterStatus);
previousSplitterStatus.clear();
@ -267,7 +256,6 @@ void ClassicComicsView::selectIndex(int index)
void ClassicComicsView::updateCurrentComicView()
{
}
void ClassicComicsView::selectAll()
@ -295,7 +283,7 @@ void ClassicComicsView::setShowMarks(bool show)
comicFlow->setShowMarks(show);
}
void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
void ClassicComicsView::centerComicFlow(const QModelIndex &mi)
{
comicFlow->showSlide(mi.row());
comicFlow->setFocus(Qt::OtherFocusReason);
@ -303,20 +291,20 @@ void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
void ClassicComicsView::updateTableView(int i)
{
QModelIndex mi = model->index(i,2);
QModelIndex mi = model->index(i, 2);
tableView->setCurrentIndex(mi);
tableView->scrollTo(mi,QAbstractItemView::EnsureVisible);
tableView->scrollTo(mi, QAbstractItemView::EnsureVisible);
}
void ClassicComicsView::saveTableHeadersStatus()
{
settings->setValue(COMICS_VIEW_HEADERS,tableView->horizontalHeader()->saveState());
settings->setValue(COMICS_VIEW_HEADERS, tableView->horizontalHeader()->saveState());
}
void ClassicComicsView::saveSplitterStatus()
{
settingsMutex.lock();
if(!searching)
if (!searching)
settings->setValue(COMICS_VIEW_FLOW_SPLITTER_STATUS, sVertical->saveState());
settingsMutex.unlock();
}
@ -325,8 +313,7 @@ void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QMod
{
Q_UNUSED(topLeft);
Q_UNUSED(bottomRight);
if(roles.contains(ComicModel::ReadColumnRole))
{
if (roles.contains(ComicModel::ReadColumnRole)) {
comicFlow->setMarks(model->getReadList());
comicFlow->updateMarks();
}
@ -335,7 +322,7 @@ void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QMod
void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, int to)
{
Q_UNUSED(parent);
for(int i = from; i<=to; i++)
for (int i = from; i <= to; i++)
comicFlow->remove(i);
}
@ -353,13 +340,13 @@ void ClassicComicsView::setupSearchingIcon()
{
searchingIcon = new QWidget(comicFlow);
QHBoxLayout * h = new QHBoxLayout;
QHBoxLayout *h = new QHBoxLayout;
QPixmap p(":/images/searching_icon.png");
QLabel * l = new QLabel(searchingIcon);
QLabel *l = new QLabel(searchingIcon);
l->setPixmap(p);
l->setFixedSize(p.size());
h->addWidget(l,0,Qt::AlignCenter);
h->addWidget(l, 0, Qt::AlignCenter);
searchingIcon->setLayout(h);
QPalette pal(searchingIcon->palette());
@ -379,4 +366,3 @@ void ClassicComicsView::hideSearchingIcon()
{
stack->setCurrentWidget(comicFlow);
}

View File

@ -20,54 +20,53 @@ class ClassicComicsView : public ComicsView
Q_OBJECT
public:
ClassicComicsView(QWidget *parent = 0);
void setToolBar(QToolBar * toolBar);
void setToolBar(QToolBar *toolBar);
void setModel(ComicModel *model);
QModelIndex currentIndex();
QItemSelectionModel * selectionModel();
void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
QItemSelectionModel *selectionModel();
void scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint);
void toFullScreen();
void toNormal();
void updateConfig(QSettings * settings);
void updateConfig(QSettings *settings);
void enableFilterMode(bool enabled);
void selectIndex(int index);
void updateCurrentComicView();
public slots:
void setCurrentIndex(const QModelIndex &index);
void centerComicFlow(const QModelIndex & mi);
void centerComicFlow(const QModelIndex &mi);
void updateTableView(int i);
void saveTableHeadersStatus();
void saveSplitterStatus();
void applyModelChanges(const QModelIndex & topLeft,const QModelIndex & bottomRight,const QVector<int> & roles);
void removeItemsFromFlow(const QModelIndex & parent, int from, int to);
void applyModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
void removeItemsFromFlow(const QModelIndex &parent, int from, int to);
//ComicsView
void setShowMarks(bool show);
void selectAll();
void selectedComicForOpening(const QModelIndex & mi);
void selectedComicForOpening(const QModelIndex &mi);
protected slots:
void hideComicFlow(bool hide);
void requestedViewContextMenu(const QPoint & point);
void requestedItemContextMenu(const QPoint & point);
void requestedViewContextMenu(const QPoint &point);
void requestedItemContextMenu(const QPoint &point);
private:
YACReaderTableView * tableView;
YACReaderToolBarStretch * toolBarStretch;
QAction * toolBarStretchAction;
QToolBar * toolbar;
YACReaderTableView *tableView;
YACReaderToolBarStretch *toolBarStretch;
QAction *toolBarStretchAction;
QToolBar *toolbar;
QWidget *comics;
QSplitter * sVertical;
ComicFlowWidget * comicFlow;
QSettings * settings;
void closeEvent ( QCloseEvent * event );
QAction * hideFlowViewAction;
QSplitter *sVertical;
ComicFlowWidget *comicFlow;
QSettings *settings;
void closeEvent(QCloseEvent *event);
QAction *hideFlowViewAction;
QStackedWidget * stack;
QStackedWidget *stack;
QByteArray previousSplitterStatus;
QWidget * searchingIcon;
QWidget *searchingIcon;
bool searching;
void setupSearchingIcon();
void showSearchingIcon();

View File

@ -7,12 +7,12 @@
#include "comic.h"
ComicFilesManager::ComicFilesManager(QObject *parent) :
QObject(parent), canceled(false)
ComicFilesManager::ComicFilesManager(QObject *parent)
: QObject(parent), canceled(false)
{
}
void ComicFilesManager::copyComicsTo(const QList<QPair<QString,QString> > &sourceComics, const QString &folderDest, const QModelIndex & dest)
void ComicFilesManager::copyComicsTo(const QList<QPair<QString, QString>> &sourceComics, const QString &folderDest, const QModelIndex &dest)
{
comics = sourceComics;
folder = folderDest;
@ -20,7 +20,7 @@ void ComicFilesManager::copyComicsTo(const QList<QPair<QString,QString> > &sourc
move = false;
}
void ComicFilesManager::moveComicsTo(const QList<QPair<QString, QString> > &sourceComics, const QString &folderDest, const QModelIndex &dest)
void ComicFilesManager::moveComicsTo(const QList<QPair<QString, QString>> &sourceComics, const QString &folderDest, const QModelIndex &dest)
{
comics = sourceComics;
folder = folderDest;
@ -28,27 +28,23 @@ void ComicFilesManager::moveComicsTo(const QList<QPair<QString, QString> > &sour
move = true;
}
QList<QPair<QString, QString> > ComicFilesManager::getDroppedFiles(const QList<QUrl> &urls)
QList<QPair<QString, QString>> ComicFilesManager::getDroppedFiles(const QList<QUrl> &urls)
{
QList<QPair<QString,QString> > dropedFiles;
QList<QPair<QString, QString>> dropedFiles;
QString currentPath;
foreach(QUrl url, urls)
{
foreach (QUrl url, urls) {
currentPath = url.toLocalFile();
if(currentPath.endsWith('/'))
currentPath = currentPath.remove(currentPath.length()-1,1); //QTBUG-35896 QUrl.toLocalFile inconsistency.
if(Comic::fileIsComic(currentPath))
dropedFiles << QPair<QString, QString>(currentPath,"/");
else
{
if (currentPath.endsWith('/'))
currentPath = currentPath.remove(currentPath.length() - 1, 1); //QTBUG-35896 QUrl.toLocalFile inconsistency.
if (Comic::fileIsComic(currentPath))
dropedFiles << QPair<QString, QString>(currentPath, "/");
else {
QLOG_DEBUG() << "XXXXXXXXXXXX :" << currentPath;
QFileInfo info(currentPath);
if(info.isDir())
{
if (info.isDir()) {
QLOG_DEBUG() << "origin path prior to absoluteFilePath : " << info.absolutePath();
foreach(QString comicPath, Comic::findValidComicFilesInFolder(info.absoluteFilePath()))
{
foreach (QString comicPath, Comic::findValidComicFilesInFolder(info.absoluteFilePath())) {
QFileInfo comicInfo(comicPath);
QString path = comicInfo.absolutePath();
QLOG_DEBUG() << "comic path : " << comicPath;
@ -65,14 +61,13 @@ QList<QPair<QString, QString> > ComicFilesManager::getDroppedFiles(const QList<Q
void ComicFilesManager::process()
{
int i=0;
int i = 0;
bool successProcesingFiles = false;
QPair<QString, QString> source;
foreach (source, comics) {
if(canceled)
{
if(successProcesingFiles)
if (canceled) {
if (successProcesingFiles)
emit success(folderDestinationModelIndex);
emit finished();
@ -80,14 +75,12 @@ void ComicFilesManager::process()
}
QFileInfo info(source.first);
QString destPath = QDir::cleanPath(folder+'/'+source.second);
QString destPath = QDir::cleanPath(folder + '/' + source.second);
QLOG_DEBUG() << "crear : " << destPath;
QDir().mkpath(destPath);
if(QFile::copy(source.first, QDir::cleanPath(destPath+'/'+info.fileName())))
{
if (QFile::copy(source.first, QDir::cleanPath(destPath + '/' + info.fileName()))) {
successProcesingFiles = true;
if(move)
{
if (move) {
QFile::remove(source.first); //TODO: remove the whole path....
}
}
@ -96,7 +89,7 @@ void ComicFilesManager::process()
emit progress(i);
}
if(successProcesingFiles)
if (successProcesingFiles)
emit success(folderDestinationModelIndex);
emit finished();
}

View File

@ -6,16 +6,15 @@
#include <QPair>
#include <QModelIndex>
//this class is intended to work in background, just use moveToThread and process to start working
class ComicFilesManager : public QObject
{
Q_OBJECT
public:
explicit ComicFilesManager(QObject *parent = 0);
void copyComicsTo(const QList<QPair<QString,QString> > & sourceComics, const QString & folderDest, const QModelIndex &dest);
void moveComicsTo(const QList<QPair<QString,QString> > & comics, const QString & folderDest, const QModelIndex &dest);
static QList<QPair<QString, QString> > getDroppedFiles(const QList<QUrl> & urls);
void copyComicsTo(const QList<QPair<QString, QString>> &sourceComics, const QString &folderDest, const QModelIndex &dest);
void moveComicsTo(const QList<QPair<QString, QString>> &comics, const QString &folderDest, const QModelIndex &dest);
static QList<QPair<QString, QString>> getDroppedFiles(const QList<QUrl> &urls);
signals:
void currentComic(QString);
void progress(int);
@ -28,10 +27,9 @@ public slots:
protected:
bool move;
bool canceled;
QList<QPair<QString,QString> > comics;
QList<QPair<QString, QString>> comics;
QString folder;
QModelIndex folderDestinationModelIndex;
};
#endif // COMIC_FILES_MANAGER_H

View File

@ -9,8 +9,8 @@
#include <QImageReader>
#include <QTimer>
ComicFlow::ComicFlow(QWidget* parent,FlowType flowType)
:YACReaderFlow(parent,flowType)
ComicFlow::ComicFlow(QWidget *parent, FlowType flowType)
: YACReaderFlow(parent, flowType)
{
updateTimer = new QTimer;
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
@ -29,28 +29,27 @@ ComicFlow::~ComicFlow()
delete updateTimer;
}
void ComicFlow::setImagePaths(const QStringList& paths)
void ComicFlow::setImagePaths(const QStringList &paths)
{
clear();
//imagePath = path;
imageFiles = paths;
imagesLoaded.clear();
imagesLoaded.fill(false,imageFiles.size());
imagesLoaded.fill(false, imageFiles.size());
numImagesLoaded = 0;
imagesSetted.clear();
imagesSetted.fill(false,imageFiles.size());
imagesSetted.fill(false, imageFiles.size());
// populate with empty images
QImage img; //TODO remove
QString s;
for(int i = 0; i < (int)imageFiles.size(); i++)
{
for (int i = 0; i < (int)imageFiles.size(); i++) {
addSlide(img);
s = imageFiles.at(i);
s.remove(s.size()-4,4);
if(QFileInfo(s+".r").exists())
s.remove(s.size() - 4, 4);
if (QFileInfo(s + ".r").exists())
markSlide(i);
}
@ -61,50 +60,45 @@ void ComicFlow::setImagePaths(const QStringList& paths)
void ComicFlow::preload()
{
if(numImagesLoaded < imagesLoaded.size())
if (numImagesLoaded < imagesLoaded.size())
updateTimer->start(30); //TODO comprobar rendimiento, originalmente era 70
}
void ComicFlow::updateImageData()
{
// can't do anything, wait for the next possibility
if(worker->busy())
if (worker->busy())
return;
// set image of last one
int idx = worker->index();
if( idx >= 0 && !worker->result().isNull())
{
if(!imagesSetted[idx])
{
if (idx >= 0 && !worker->result().isNull()) {
if (!imagesSetted[idx]) {
setSlide(idx, worker->result());
imagesSetted[idx] = true;
numImagesLoaded++;
imagesLoaded[idx]=true;
imagesLoaded[idx] = true;
}
}
// try to load only few images on the left and right side
// i.e. all visible ones plus some extra
#define COUNT 8
int indexes[2*COUNT+1];
int indexes[2 * COUNT + 1];
int center = centerIndex();
indexes[0] = center;
for(int j = 0; j < COUNT; j++)
{
indexes[j*2+1] = center+j+1;
indexes[j*2+2] = center-j-1;
for (int j = 0; j < COUNT; j++) {
indexes[j * 2 + 1] = center + j + 1;
indexes[j * 2 + 2] = center - j - 1;
}
for(int c = 0; c < 2*COUNT+1; c++)
{
for (int c = 0; c < 2 * COUNT + 1; c++) {
int i = indexes[c];
if((i >= 0) && (i < slideCount()))
if(!imagesLoaded[i])//slide(i).isNull())
if ((i >= 0) && (i < slideCount()))
if (!imagesLoaded[i]) //slide(i).isNull())
{
// schedule thumbnail generation
QString fname = imageFiles[i];
worker->generate(i, fname, slideSize());
return;
}
@ -114,14 +108,14 @@ void ComicFlow::updateImageData()
updateTimer->stop();
}
void ComicFlow::keyPressEvent(QKeyEvent* event)
void ComicFlow::keyPressEvent(QKeyEvent *event)
{
PictureFlow::keyPressEvent(event);
}
void ComicFlow::wheelEvent(QWheelEvent * event)
void ComicFlow::wheelEvent(QWheelEvent *event)
{
if(event->delta()<0)
if (event->delta() < 0)
showNext();
else
showPrevious();
@ -135,7 +129,7 @@ void ComicFlow::removeSlide(int cover)
worker->reset();
imageFiles.removeAt(cover);
if(imagesLoaded[cover])
if (imagesLoaded[cover])
numImagesLoaded--;
imagesLoaded.remove(cover);
imagesSetted.remove(cover);
@ -156,15 +150,12 @@ void ComicFlow::resortCovers(QList<int> newOrder)
QStringList imageFilesNew;
QVector<bool> imagesLoadedNew;
QVector<bool> imagesSettedNew;
foreach(int index, newOrder)
{
foreach (int index, newOrder) {
imageFilesNew << imageFiles.at(index);
imagesLoadedNew << imagesLoaded.at(index);
imagesSettedNew << imagesSetted.at(index);
}
imageFiles = imageFilesNew;
imagesLoaded = imagesLoadedNew;
imagesSetted = imagesSettedNew;
@ -174,19 +165,19 @@ void ComicFlow::resortCovers(QList<int> newOrder)
//-----------------------------------------------------------------------------
//ImageLoader
//-----------------------------------------------------------------------------
static QImage loadImage(const QString& fileName)
static QImage loadImage(const QString &fileName)
{
QImage image;
bool result = image.load(fileName);
if(!result)
if (!result)
return QImage();
return image;
}
ImageLoader::ImageLoader():
QThread(), restart(false), working(false), idx(-1)
ImageLoader::ImageLoader()
: QThread(), restart(false), working(false), idx(-1)
{
}
@ -203,7 +194,7 @@ bool ImageLoader::busy() const
return isRunning() ? working : false;
}
void ImageLoader::generate(int index, const QString& fileName, QSize size)
void ImageLoader::generate(int index, const QString &fileName, QSize size)
{
mutex.lock();
this->idx = index;
@ -214,8 +205,7 @@ void ImageLoader::generate(int index, const QString& fileName, QSize size)
if (!isRunning())
start();
else
{
else {
// already running, wake up whenever ready
restart = true;
condition.wakeOne();
@ -234,8 +224,7 @@ void ImageLoader::unlock()
void ImageLoader::run()
{
for(;;)
{
for (;;) {
// copy necessary data
mutex.lock();
this->working = true;

View File

@ -17,12 +17,12 @@ class ComicFlow : public YACReaderFlow
{
Q_OBJECT
public:
ComicFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
ComicFlow(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
virtual ~ComicFlow();
void setImagePaths(const QStringList& paths);
void setImagePaths(const QStringList &paths);
//bool eventFilter(QObject *target, QEvent *event);
void keyPressEvent(QKeyEvent* event);
void keyPressEvent(QKeyEvent *event);
void removeSlide(int cover);
void resortCovers(QList<int> newOrder);
@ -36,12 +36,11 @@ private:
QVector<bool> imagesLoaded;
QVector<bool> imagesSetted;
int numImagesLoaded;
QTimer* updateTimer;
ImageLoader* worker;
virtual void wheelEvent(QWheelEvent * event);
QTimer *updateTimer;
ImageLoader *worker;
virtual void wheelEvent(QWheelEvent *event);
};
//-----------------------------------------------------------------------------
// Source code of ImageLoader class was modified from http://code.google.com/p/photoflow/
//------------------------------------------------------------------------------
@ -52,8 +51,8 @@ public:
~ImageLoader();
// returns FALSE if worker is still busy and can't take the task
bool busy() const;
void generate(int index, const QString& fileName, QSize size);
void reset(){idx = -1;};
void generate(int index, const QString &fileName, QSize size);
void reset() { idx = -1; };
int index() const { return idx; };
void lock();
void unlock();
@ -74,5 +73,4 @@ private:
QImage img;
};
#endif

View File

@ -1,20 +1,19 @@
#include "comic_flow_widget.h"
#include <QVBoxLayout>
ComicFlowWidget::ComicFlowWidget(QWidget * parent)
:QWidget(parent)
ComicFlowWidget::ComicFlowWidget(QWidget *parent)
: QWidget(parent)
{
}
ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget * parent)
:ComicFlowWidget(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)));
connect(flow, SIGNAL(centerIndexChanged(int)), this, SIGNAL(centerIndexChanged(int)));
connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
l->addWidget(flow);
setLayout(l);
@ -28,9 +27,9 @@ ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget * parent)
//config
QMatrix m;
m.rotate(-90);
m.scale(-1,1);
m.scale(-1, 1);
QImage image(":/images/setRead.png");
QImage imageTransformed = image.transformed(m,Qt::SmoothTransformation);
QImage imageTransformed = image.transformed(m, Qt::SmoothTransformation);
setMarkImage(imageTransformed);
}
@ -51,13 +50,13 @@ void ComicFlowWidgetSW::setMarks(QVector<YACReaderComicReadStatus> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetSW::setMarkImage(QImage & image)
void ComicFlowWidgetSW::setMarkImage(QImage &image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetSW::markSlide(int index, YACReaderComicReadStatus status)
{
flow->markSlide(index,status);
flow->markSlide(index, status);
}
void ComicFlowWidgetSW::unmarkSlide(int index)
{
@ -99,7 +98,7 @@ void ComicFlowWidgetSW::render()
{
flow->render();
}
void ComicFlowWidgetSW::keyPressEvent(QKeyEvent* event)
void ComicFlowWidgetSW::keyPressEvent(QKeyEvent *event)
{
flow->keyPressEvent(event);
}
@ -107,22 +106,21 @@ void ComicFlowWidgetSW::paintEvent(QPaintEvent *event)
{
ComicFlowWidget::paintEvent(event);
}
void ComicFlowWidgetSW::mousePressEvent(QMouseEvent* event)
void ComicFlowWidgetSW::mousePressEvent(QMouseEvent *event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetSW::resizeEvent(QResizeEvent* event)
void ComicFlowWidgetSW::resizeEvent(QResizeEvent *event)
{
flow->resizeEvent(event);
}
void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent* event)
void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent *event)
{
flow->mouseDoubleClickEvent(event);
}
void ComicFlowWidgetSW::updateConfig(QSettings * settings)
void ComicFlowWidgetSW::updateConfig(QSettings *settings)
{
switch (settings->value(FLOW_TYPE_SW).toInt())
{
switch (settings->value(FLOW_TYPE_SW).toInt()) {
case CoverFlowLike:
flow->setFlowType(CoverFlowLike);
return;
@ -152,17 +150,17 @@ void ComicFlowWidgetSW::resortCovers(QList<int> newOrder)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent)
:ComicFlowWidget(parent)
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)));
connect(flow, SIGNAL(centerIndexChanged(int)), this, SIGNAL(centerIndexChanged(int)));
connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(selected(unsigned int)));
QVBoxLayout * l = new QVBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
l->addWidget(flow);
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
//TODO eleminar "padding"
@ -190,13 +188,13 @@ void ComicFlowWidgetGL::setMarks(QVector<YACReaderComicReadStatus> marks)
{
flow->setMarks(marks);
}
void ComicFlowWidgetGL::setMarkImage(QImage & image)
void ComicFlowWidgetGL::setMarkImage(QImage &image)
{
flow->setMarkImage(image);
}
void ComicFlowWidgetGL::markSlide(int index, YACReaderComicReadStatus status)
{
flow->markSlide(index,status);
flow->markSlide(index, status);
}
void ComicFlowWidgetGL::unmarkSlide(int index)
{
@ -232,11 +230,11 @@ void ComicFlowWidgetGL::updateMarks()
}
void ComicFlowWidgetGL::setFlowType(FlowType flowType)
{
if(flowType == CoverFlowLike)
if (flowType == CoverFlowLike)
flow->setPreset(presetYACReaderFlowClassicConfig);
else if(flowType == Strip)
else if (flowType == Strip)
flow->setPreset(presetYACReaderFlowStripeConfig);
else if(flowType == StripOverlapped)
else if (flowType == StripOverlapped)
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
else
flow->setPreset(defaultYACReaderFlowConfig);
@ -245,7 +243,7 @@ void ComicFlowWidgetGL::render()
{
flow->render();
}
void ComicFlowWidgetGL::keyPressEvent(QKeyEvent* event)
void ComicFlowWidgetGL::keyPressEvent(QKeyEvent *event)
{
flow->keyPressEvent(event);
}
@ -254,25 +252,24 @@ void ComicFlowWidgetGL::paintEvent(QPaintEvent *event)
//flow->paintEvent(event);
ComicFlowWidget::paintEvent(event);
}
void ComicFlowWidgetGL::mousePressEvent(QMouseEvent* event)
void ComicFlowWidgetGL::mousePressEvent(QMouseEvent *event)
{
flow->mousePressEvent(event);
}
void ComicFlowWidgetGL::resizeEvent(QResizeEvent* event)
void ComicFlowWidgetGL::resizeEvent(QResizeEvent *event)
{
flow->resizeGL(event->size().width(),event->size().height());
flow->resizeGL(event->size().width(), event->size().height());
}
void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent* event)
void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent *event)
{
flow->mouseDoubleClickEvent(event);
}
void ComicFlowWidgetGL::updateConfig(QSettings * settings)
void ComicFlowWidgetGL::updateConfig(QSettings *settings)
{
Performance performance = medium;
switch (settings->value(PERFORMANCE).toInt())
{
switch (settings->value(PERFORMANCE).toInt()) {
case 0:
performance = low;
break;
@ -288,13 +285,12 @@ void ComicFlowWidgetGL::updateConfig(QSettings * settings)
}
flow->setPerformance(performance);
if(!settings->contains(V_SYNC))
if (!settings->contains(V_SYNC))
flow->useVSync(false);
else
flow->useVSync(settings->value(V_SYNC).toBool());
switch (settings->value(FLOW_TYPE_GL).toInt())
{
switch (settings->value(FLOW_TYPE_GL).toInt()) {
case 0:
flow->setPreset(presetYACReaderFlowClassicConfig);
return;
@ -312,7 +308,6 @@ void ComicFlowWidgetGL::updateConfig(QSettings * settings)
return;
}
//custom config
flow->setCF_RX(settings->value(X_ROTATION).toInt());
@ -327,9 +322,9 @@ void ComicFlowWidgetGL::updateConfig(QSettings * settings)
flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
/* flow->setVisibility(settings->value("visibilityDistance").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt())*/;
/* flow->setVisibility(settings->value("visibilityDistance").toInt());
flow->setLightStrenght(settings->value("lightStrength").toInt())*/
;
}
void ComicFlowWidgetGL::remove(int cover)

View File

@ -1,7 +1,6 @@
#ifndef __COMIC_FLOW_WIDGET_H
#define __COMIC_FLOW_WIDGET_H
#include <QWidget>
#include "pictureflow.h"
@ -13,12 +12,12 @@ class ComicFlowWidget : public QWidget
{
Q_OBJECT
public:
ComicFlowWidget(QWidget * paret = 0);
ComicFlowWidget(QWidget *paret = 0);
public slots:
virtual void setShowMarks(bool value) = 0;
virtual void setMarks(QVector<YACReaderComicReadStatus> marks) = 0;
virtual void setMarkImage(QImage & image) = 0;
virtual void setMarkImage(QImage &image) = 0;
virtual void markSlide(int index, YACReaderComicReadStatus status) = 0;
virtual void unmarkSlide(int index) = 0;
virtual void setSlideSize(QSize size) = 0;
@ -30,7 +29,7 @@ public slots:
virtual void updateMarks() = 0;
virtual void setFlowType(FlowType flowType) = 0;
virtual void render() = 0;
virtual void updateConfig(QSettings * settings) = 0;
virtual void updateConfig(QSettings *settings) = 0;
virtual void remove(int cover) = 0;
virtual void resortCovers(QList<int> newOrder) = 0;
signals:
@ -38,18 +37,18 @@ signals:
void selected(unsigned int);
};
class ComicFlowWidgetSW : public ComicFlowWidget
{
Q_OBJECT
private:
ComicFlow * flow;
ComicFlow *flow;
public:
ComicFlowWidgetSW(QWidget * parent = 0);
ComicFlowWidgetSW(QWidget *parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<YACReaderComicReadStatus> marks);
void setMarkImage(QImage & image);
void setMarkImage(QImage &image);
void markSlide(int index, YACReaderComicReadStatus status);
void unmarkSlide(int index);
void setSlideSize(QSize size);
@ -61,15 +60,16 @@ public:
void updateMarks();
void setFlowType(FlowType flowType);
void render();
void updateConfig(QSettings * settings);
void updateConfig(QSettings *settings);
void remove(int cover);
void resortCovers(QList<int> newOrder);
protected:
void keyPressEvent(QKeyEvent* event);
void keyPressEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
QSize slideSizeW;
@ -81,13 +81,14 @@ class ComicFlowWidgetGL : public ComicFlowWidget
{
Q_OBJECT
private:
YACReaderComicFlowGL * flow;
YACReaderComicFlowGL *flow;
public:
ComicFlowWidgetGL(QWidget * parent = 0);
ComicFlowWidgetGL(QWidget *parent = 0);
void setShowMarks(bool value);
void setMarks(QVector<YACReaderComicReadStatus> marks);
void setMarkImage(QImage & image);
void setMarkImage(QImage &image);
void markSlide(int index, YACReaderComicReadStatus status);
void unmarkSlide(int index);
void setSlideSize(QSize size);
@ -99,33 +100,33 @@ public:
void updateMarks();
void setFlowType(FlowType flowType);
void render();
void updateConfig(QSettings * settings);
void updateConfig(QSettings *settings);
void remove(int cover);
void resortCovers(QList<int> newOrder);
//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);
//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 keyPressEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};

View File

@ -9,28 +9,28 @@
#include "yacreader_global_gui.h"
ApiKeyDialog::ApiKeyDialog(QWidget *parent) :
QDialog(parent)
ApiKeyDialog::ApiKeyDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout * layout = new QVBoxLayout;
QHBoxLayout * buttonsLayout = new QHBoxLayout;
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *buttonsLayout = new QHBoxLayout;
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("ComicVine");
QLabel * info = new QLabel(tr("Before you can connect to Comic Vine, you need your own API key. Please, get one free <a href=\"http://www.comicvine.com/api/\">here</a>"));
QLabel *info = new QLabel(tr("Before you can connect to Comic Vine, you need your own API key. Please, get one free <a href=\"http://www.comicvine.com/api/\">here</a>"));
info->setWordWrap(true);
info->setOpenExternalLinks(true);
edit = new QLineEdit();
edit->setPlaceholderText(tr("Paste here your Comic Vine API key"));
connect(edit,SIGNAL(textChanged(QString)),this,SLOT(enableAccept(QString)));
connect(edit, SIGNAL(textChanged(QString)), this, SLOT(enableAccept(QString)));
acceptButton = new QPushButton(tr("Accept"));
acceptButton->setDisabled(true);
connect(acceptButton,SIGNAL(clicked()),this,SLOT(saveApiKey()));
connect(acceptButton, SIGNAL(clicked()), this, SLOT(saveApiKey()));
cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
layout->addWidget(info);
layout->addWidget(edit);
@ -44,9 +44,9 @@ ApiKeyDialog::ApiKeyDialog(QWidget *parent) :
setLayout(layout);
resize(400,150);
resize(400, 150);
if(settings->contains(COMIC_VINE_API_KEY))
if (settings->contains(COMIC_VINE_API_KEY))
edit->setText(settings->value(COMIC_VINE_API_KEY).toString());
}
@ -63,6 +63,6 @@ void ApiKeyDialog::enableAccept(const QString &text)
void ApiKeyDialog::saveApiKey()
{
settings->setValue(COMIC_VINE_API_KEY,edit->text().trimmed());
settings->setValue(COMIC_VINE_API_KEY, edit->text().trimmed());
accept();
}

View File

@ -18,14 +18,14 @@ signals:
public slots:
protected slots:
void enableAccept(const QString & text);
void enableAccept(const QString &text);
void saveApiKey();
protected:
QPushButton * acceptButton;
QPushButton * cancelButton;
QLineEdit * edit;
QSettings * settings;
QPushButton *acceptButton;
QPushButton *cancelButton;
QLineEdit *edit;
QSettings *settings;
};
#endif // API_KEY_DIALOG_H

View File

@ -8,7 +8,6 @@
ComicVineAllVolumeComicsRetriever::ComicVineAllVolumeComicsRetriever(const QString &volumeURLString, QObject *parent)
: QObject(parent), volumeURLString(volumeURLString)
{
}
void ComicVineAllVolumeComicsRetriever::getAllVolumeComics()
@ -18,11 +17,11 @@ void ComicVineAllVolumeComicsRetriever::getAllVolumeComics()
void ComicVineAllVolumeComicsRetriever::getAllVolumeComics(int range)
{
HttpWorker * search = new HttpWorker(volumeURLString.arg(range));
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(appendVolumeComicsInfo(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
connect(search,SIGNAL(timeout()),this,SIGNAL(finished()));
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(volumeURLString.arg(range));
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(appendVolumeComicsInfo(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
connect(search, SIGNAL(timeout()), this, SIGNAL(finished()));
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
@ -42,9 +41,7 @@ void ComicVineAllVolumeComicsRetriever::appendVolumeComicsInfo(const QByteArray
if (!isLastResponse) {
getAllVolumeComics(currentPage * 100);
}
else
{
} else {
emit allVolumeComicsInfo(consolidateJSON());
emit finished();
}
@ -58,28 +55,23 @@ QString ComicVineAllVolumeComicsRetriever::consolidateJSON()
foreach (QByteArray json, jsonResponses) {
QJsonDocument doc = QJsonDocument::fromJson(json);
if(doc.isNull() || !doc.isObject() || doc.isEmpty())
{
if (doc.isNull() || !doc.isObject() || doc.isEmpty()) {
continue;
}
QJsonObject main = doc.object();
QJsonValue error = main["error"];
if (error.isUndefined() || error.toString() != "OK")
{
if (error.isUndefined() || error.toString() != "OK") {
continue;
}
else
{
} else {
QJsonValue results = main["results"];
if (results.isUndefined() || !results.isArray())
{
if (results.isUndefined() || !results.isArray()) {
continue;
}
QJsonArray resultsArray = results.toArray();
foreach (const QJsonValue & v, resultsArray)
foreach (const QJsonValue &v, resultsArray)
comicsInfo.append(v);
}
}
@ -93,5 +85,3 @@ QString ComicVineAllVolumeComicsRetriever::consolidateJSON()
QJsonDocument doc(consolidatedJSON);
return doc.toJson(QJsonDocument::Compact);
}

View File

@ -9,6 +9,7 @@ class ComicVineAllVolumeComicsRetriever : public QObject
public:
explicit ComicVineAllVolumeComicsRetriever(const QString &volumeURLString, QObject *parent = 0);
void getAllVolumeComics();
protected:
void getAllVolumeComics(const int range);
signals:

View File

@ -44,10 +44,10 @@ static const QString CV_COVER_URL = CV_WEB_ADDRESS + "/issue/4000-%1/?api_key="
//gets comics matching name %1 and number %2
//http://comicvine.com/api/issues/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&limit=20&filter=name:super,issue_number:15
ComicVineClient::ComicVineClient(QObject *parent) :
QObject(parent)
ComicVineClient::ComicVineClient(QObject *parent)
: QObject(parent)
{
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("ComicVine");
baseURL = settings->value(COMIC_VINE_BASE_URL, "https://comicvine.gamespot.com/api").toString();
}
@ -58,16 +58,16 @@ ComicVineClient::~ComicVineClient()
}
//CV_SEARCH
void ComicVineClient::search(const QString & query, int page)
void ComicVineClient::search(const QString &query, int page)
{
HttpWorker * search = new HttpWorker(QString(CV_SEARCH).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(query).arg(page));
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessVolumesSearchData(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(QString(CV_SEARCH).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(query).arg(page));
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessVolumesSearchData(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
//CV_SEARCH result
void ComicVineClient::proccessVolumesSearchData(const QByteArray & data)
void ComicVineClient::proccessVolumesSearchData(const QByteArray &data)
{
QString json(data);
emit searchResult(json);
@ -96,38 +96,38 @@ void ComicVineClient::proccessComicDetailData(const QByteArray &data)
}
//CV_SERIES_DETAIL
void ComicVineClient::getSeriesDetail(const QString & id)
void ComicVineClient::getSeriesDetail(const QString &id)
{
HttpWorker * search = new HttpWorker(QString(CV_SERIES_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessSeriesDetailData(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(QString(CV_SERIES_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessSeriesDetailData(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
void ComicVineClient::getSeriesCover(const QString & url)
void ComicVineClient::getSeriesCover(const QString &url)
{
HttpWorker * search = new HttpWorker(url);
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SIGNAL(seriesCover(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(url);
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SIGNAL(seriesCover(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
//CV_COMIC_IDS
void ComicVineClient::getVolumeComicsInfo(const QString & idVolume, int page)
void ComicVineClient::getVolumeComicsInfo(const QString &idVolume, int page)
{
HttpWorker * search = new HttpWorker(QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(idVolume).arg((page-1)*100)); //page doesn't work for search, using offset instead
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(processVolumeComicsInfo(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(idVolume).arg((page - 1) * 100)); //page doesn't work for search, using offset instead
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(processVolumeComicsInfo(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
void ComicVineClient::getAllVolumeComicsInfo(const QString &idVolume)
{
QString url = QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(idVolume);
ComicVineAllVolumeComicsRetriever * comicsRetriever = new ComicVineAllVolumeComicsRetriever(url);
QString url = QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(idVolume);
ComicVineAllVolumeComicsRetriever *comicsRetriever = new ComicVineAllVolumeComicsRetriever(url);
connect(comicsRetriever, &ComicVineAllVolumeComicsRetriever::allVolumeComicsInfo, this, &ComicVineClient::volumeComicsInfo);
connect(comicsRetriever, &ComicVineAllVolumeComicsRetriever::finished, this, &ComicVineClient::finished);
@ -138,16 +138,16 @@ void ComicVineClient::getAllVolumeComicsInfo(const QString &idVolume)
}
//CV_COMIC_ID
void ComicVineClient::getComicId(const QString & id, int comicNumber)
void ComicVineClient::getComicId(const QString &id, int comicNumber)
{
Q_UNUSED(id);
Q_UNUSED(comicNumber);
}
//CV_COMIC_DETAIL
QByteArray ComicVineClient::getComicDetail(const QString & id, bool & outError, bool & outTimeout)
QByteArray ComicVineClient::getComicDetail(const QString &id, bool &outError, bool &outTimeout)
{
HttpWorker * search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
HttpWorker *search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
//connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
//connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
@ -163,27 +163,27 @@ QByteArray ComicVineClient::getComicDetail(const QString & id, bool & outError,
}
//CV_COMIC_DETAIL
void ComicVineClient::getComicDetailAsync(const QString & id)
void ComicVineClient::getComicDetailAsync(const QString &id)
{
HttpWorker * search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
HttpWorker *search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessComicDetailData(const QByteArray &)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
void ComicVineClient::getComicCover(const QString &url)
{
HttpWorker * search = new HttpWorker(url);
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SIGNAL(comicCover(QByteArray)));
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
HttpWorker *search = new HttpWorker(url);
connect(search, SIGNAL(dataReady(const QByteArray &)), this, SIGNAL(comicCover(QByteArray)));
connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
//CV_COVER_DETAIL
void ComicVineClient::getCoverURL(const QString & id)
void ComicVineClient::getCoverURL(const QString &id)
{
Q_UNUSED(id);
}

View File

@ -15,34 +15,33 @@ public:
signals:
void searchResult(QString);
void seriesDetail(QString);//JSON
void comicDetail(QString);//JSON
void seriesDetail(QString); //JSON
void comicDetail(QString); //JSON
void seriesCover(const QByteArray &);
void comicCover(const QByteArray &);
void volumeComicsInfo(QString);
void timeOut();
void finished();
public slots:
void search(const QString & query, int page = 1);
void getSeriesDetail(const QString & id);
void getSeriesCover(const QString & url);
void getVolumeComicsInfo(const QString & idVolume, int page=1);
void getAllVolumeComicsInfo(const QString & idVolume);
QByteArray getComicDetail(const QString & id, bool &outError, bool &outTimeout);
void getComicCover(const QString & url);
void search(const QString &query, int page = 1);
void getSeriesDetail(const QString &id);
void getSeriesCover(const QString &url);
void getVolumeComicsInfo(const QString &idVolume, int page = 1);
void getAllVolumeComicsInfo(const QString &idVolume);
QByteArray getComicDetail(const QString &id, bool &outError, bool &outTimeout);
void getComicCover(const QString &url);
void getComicId(const QString & id, int comicNumber);
void getCoverURL(const QString & id);
void getComicId(const QString &id, int comicNumber);
void getCoverURL(const QString &id);
void getComicDetailAsync(const QString &id);
protected slots:
void proccessVolumesSearchData(const QByteArray & data);
void proccessSeriesDetailData(const QByteArray & data);
void processVolumeComicsInfo(const QByteArray & data);
void proccessComicDetailData(const QByteArray & data);
void proccessVolumesSearchData(const QByteArray &data);
void proccessSeriesDetailData(const QByteArray &data);
void processVolumeComicsInfo(const QByteArray &data);
void proccessComicDetailData(const QByteArray &data);
protected:
QSettings * settings;
QSettings *settings;
QString baseURL;
};
#endif // COMIC_VINE_CLIENT_H

View File

@ -9,9 +9,9 @@
#include <QMessageBox>
#include <QTableView>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun>
#include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#include <QtConcurrentRun>
#endif
#include <QSqlDatabase>
#include <QtScript>
@ -32,10 +32,8 @@
#include "QsLog.h"
ComicVineDialog::ComicVineDialog(QWidget *parent) :
QDialog(parent)
ComicVineDialog::ComicVineDialog(QWidget *parent)
: QDialog(parent)
{
setWindowFlags(Qt::Window);
@ -66,9 +64,9 @@ void ComicVineDialog::doLayout()
content = new QStackedWidget(this);
QVBoxLayout * mainLayout = new QVBoxLayout;
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout * buttonLayout = new QHBoxLayout;
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
buttonLayout->addWidget(skipButton);
@ -76,13 +74,13 @@ void ComicVineDialog::doLayout()
buttonLayout->addWidget(nextButton);
buttonLayout->addWidget(searchButton);
buttonLayout->addWidget(closeButton);
buttonLayout->setContentsMargins(0,0,0,0);
buttonLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(titleHeader = new TitleHeader, 0);
mainLayout->addWidget(content, 1);
mainLayout->addLayout(buttonLayout, 0);
mainLayout->setContentsMargins(26,16,26,11);
mainLayout->setContentsMargins(26, 16, 26, 11);
setLayout(mainLayout);
@ -102,15 +100,15 @@ void ComicVineDialog::doStackedWidgets()
void ComicVineDialog::doConnections()
{
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
connect(nextButton,SIGNAL(clicked()),this,SLOT(goNext()));
connect(backButton,SIGNAL(clicked()),this,SLOT(goBack()));
connect(searchButton,SIGNAL(clicked()),this,SLOT(search()));
connect(skipButton,SIGNAL(clicked()),this,SLOT(goToNextComic()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect(nextButton, SIGNAL(clicked()), this, SLOT(goNext()));
connect(backButton, SIGNAL(clicked()), this, SLOT(goBack()));
connect(searchButton, SIGNAL(clicked()), this, SLOT(search()));
connect(skipButton, SIGNAL(clicked()), this, SLOT(goToNextComic()));
connect(selectVolumeWidget,SIGNAL(loadPage(QString,int)),this,SLOT(searchVolume(QString,int)));
connect(selectComicWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int)));
connect(sortVolumeComicsWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int)));
connect(selectVolumeWidget, SIGNAL(loadPage(QString, int)), this, SLOT(searchVolume(QString, int)));
connect(selectComicWidget, SIGNAL(loadPage(QString, int)), this, SLOT(getVolumeComicsInfo(QString, int)));
connect(sortVolumeComicsWidget, SIGNAL(loadPage(QString, int)), this, SLOT(getVolumeComicsInfo(QString, int)));
connect(this, SIGNAL(accepted()), this, SLOT(close()), Qt::QueuedConnection);
}
@ -118,35 +116,29 @@ void ComicVineDialog::doConnections()
void ComicVineDialog::goNext()
{
//
if(content->currentWidget() == seriesQuestionWidget)
{
if(seriesQuestionWidget->getYes())
{
if (content->currentWidget() == seriesQuestionWidget) {
if (seriesQuestionWidget->getYes()) {
QString volumeSearchString = comics[0].getParentFolderName();
mode = Volume;
if(volumeSearchString.isEmpty())
if (volumeSearchString.isEmpty())
showSearchVolume();
else
{
else {
status = AutoSearching;
showLoading(tr("Looking for volume..."));
searchVolume(volumeSearchString);
}
}
else
{
} else {
status = AutoSearching;
mode = SingleComicInList;
ComicDB comic = comics[currentIndex];
QString title = comic.getTitleOrFileName();
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
showLoading(tr("Looking for volume..."));
searchVolume(title);
}
}
else if (content->currentWidget() == selectVolumeWidget) {
} else if (content->currentWidget() == selectVolumeWidget) {
currentVolumeId = selectVolumeWidget->getSelectedVolumeId();
getVolumeComicsInfo(currentVolumeId);
@ -154,17 +146,16 @@ void ComicVineDialog::goNext()
showLoading();
//ComicDB-ComicVineID
QList<QPair<ComicDB,QString> > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
QList<QPair<ComicDB, QString>> matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo,count,publisher);
} else if (content->currentWidget() == selectComicWidget)
{
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo, matchingInfo, count, publisher);
} else if (content->currentWidget() == selectComicWidget) {
showLoading();
QString comicId = selectComicWidget->getSelectedComicId();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
QtConcurrent::run(this, &ComicVineDialog::getComicInfo,comicId,count,publisher);
QtConcurrent::run(this, &ComicVineDialog::getComicInfo, comicId, count, publisher);
}
}
@ -172,7 +163,7 @@ void ComicVineDialog::goBack()
{
switch (status) {
case SelectingSeries:
if(mode == Volume)
if (mode == Volume)
showSearchVolume();
else
showSearchSingleComic();
@ -181,17 +172,17 @@ void ComicVineDialog::goBack()
showSelectVolume();
break;
case SelectingComic:
if(mode == SingleComic)
if (mode == SingleComic)
showSelectVolume();
break;
case AutoSearching:
if(mode == Volume)
if (mode == Volume)
showSearchVolume();
else
showSearchSingleComic();
break;
default:
if(mode == Volume)
if (mode == Volume)
showSearchVolume();
else
showSearchSingleComic();
@ -199,7 +190,7 @@ void ComicVineDialog::goBack()
}
}
void ComicVineDialog::setComics(const QList<ComicDB> & comics)
void ComicVineDialog::setComics(const QList<ComicDB> &comics)
{
this->comics = comics;
}
@ -208,8 +199,8 @@ QSize ComicVineDialog::sizeHint() const
{
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
int height,width;
height = qMax(529, static_cast<int>(heightDesktopResolution*0.5));
int height, width;
height = qMax(529, static_cast<int>(heightDesktopResolution * 0.5));
width = height * 1.65;
if (width > widthDesktopResolution)
@ -233,8 +224,7 @@ void ComicVineDialog::show()
searchSingleComicWidget->clean();
searchVolumeWidget->clean();
if(comics.length() == 1)
{
if (comics.length() == 1) {
status = AutoSearching;
mode = SingleComic;
@ -245,8 +235,7 @@ void ComicVineDialog::show()
searchVolume(singleComic.getParentFolderName());
QLOG_TRACE() << singleComic.getParentFolderName();
}else if(comics.length()>1)
{
} else if (comics.length() > 1) {
titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length()));
showSeriesQuestion();
}
@ -254,52 +243,47 @@ void ComicVineDialog::show()
void ComicVineDialog::doLoading()
{
QWidget * w = new QWidget;
QVBoxLayout * l = new QVBoxLayout;
QWidget *w = new QWidget;
QVBoxLayout *l = new QVBoxLayout;
YACReaderBusyWidget * bw = new YACReaderBusyWidget;
YACReaderBusyWidget *bw = new YACReaderBusyWidget;
loadingMessage = new QLabel;
loadingMessage->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
l->addStretch();
l->addWidget(bw,0,Qt::AlignHCenter);
l->addWidget(bw, 0, Qt::AlignHCenter);
l->addStretch();
l->addWidget(loadingMessage);
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
w->setLayout(l);
w->setContentsMargins(0,0,0,0);
w->setContentsMargins(0, 0, 0, 0);
content->addWidget(w);
}
void ComicVineDialog::debugClientResults(const QString & string)
void ComicVineDialog::debugClientResults(const QString &string)
{
ResponseParser p;
p.loadJSONResponse(string);
//QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
if(p.responseError())
{
QMessageBox::critical(0,tr("Error connecting to ComicVine"), p.errorDescription());
if (p.responseError()) {
QMessageBox::critical(0, tr("Error connecting to ComicVine"), p.errorDescription());
goBack();
}
else
{
switch(mode)
{
case SingleComic: case SingleComicInList:
if(p.getNumResults() == 0)
} else {
switch (mode) {
case SingleComic:
case SingleComicInList:
if (p.getNumResults() == 0)
showSearchSingleComic();
else
if(status == SearchingVolume)
else if (status == SearchingVolume)
showSelectVolume(string);
else
showSelectComic(string);
break;
case Volume:
if(p.getNumResults() == 0)
if (p.getNumResults() == 0)
showSearchVolume();
else
showSelectVolume(string);
@ -318,7 +302,7 @@ void ComicVineDialog::showSeriesQuestion()
searchButton->setHidden(true);
closeButton->setVisible(true);
if(mode == SingleComicInList)
if (mode == SingleComicInList)
skipButton->setVisible(true);
else
skipButton->setHidden(true);
@ -334,7 +318,7 @@ void ComicVineDialog::showSearchSingleComic()
searchButton->setVisible(true);
closeButton->setVisible(true);
if(mode == SingleComicInList)
if (mode == SingleComicInList)
skipButton->setVisible(true);
else
skipButton->setHidden(true);
@ -351,10 +335,10 @@ void ComicVineDialog::showSearchVolume()
toggleSkipButton();
}
void ComicVineDialog::showSelectVolume(const QString & json)
void ComicVineDialog::showSelectVolume(const QString &json)
{
showSelectVolume();
selectVolumeWidget->load(json,currentVolumeSearchString);
selectVolumeWidget->load(json, currentVolumeSearchString);
}
void ComicVineDialog::showSelectVolume()
@ -375,7 +359,7 @@ void ComicVineDialog::showSelectComic(const QString &json)
status = SelectingComic;
content->setCurrentWidget(selectComicWidget);
selectComicWidget->load(json,currentVolumeId);
selectComicWidget->load(json, currentVolumeId);
backButton->setVisible(true);
nextButton->setVisible(true);
@ -401,17 +385,17 @@ void ComicVineDialog::showSortVolumeComics(const QString &json)
void ComicVineDialog::queryTimeOut()
{
QMessageBox::warning(this,"Comic Vine error", "Time out connecting to Comic Vine");
QMessageBox::warning(this, "Comic Vine error", "Time out connecting to Comic Vine");
switch (status) {
case AutoSearching:
if(mode == Volume)
if (mode == Volume)
showSearchVolume();
else
showSearchSingleComic();
break;
case SearchingVolume:
if(mode == Volume)
if (mode == Volume)
showSearchVolume();
else
showSearchSingleComic();
@ -427,21 +411,21 @@ void ComicVineDialog::queryTimeOut()
}
}
void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingInfo, int count,const QString & publisher)
void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString>> &matchingInfo, int count, const QString &publisher)
{
QPair<ComicDB, QString> p;
QList<ComicDB> comics;
foreach (p, matchingInfo) {
ComicVineClient * comicVineClient = new ComicVineClient;
ComicVineClient *comicVineClient = new ComicVineClient;
//connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
//connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
//connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
bool error;
bool timeout;
QByteArray result = comicVineClient->getComicDetail(p.second,error,timeout); //TODO check timeOut or Connection error
if(error || timeout)
QByteArray result = comicVineClient->getComicDetail(p.second, error, timeout); //TODO check timeOut or Connection error
if (error || timeout)
continue; //TODO
ComicDB comic = parseComicInfo(p.first,result,count,publisher);//TODO check result error
ComicDB comic = parseComicInfo(p.first, result, count, publisher); //TODO check result error
comic.info.comicVineID = p.second;
comics.push_back(comic);
@ -451,9 +435,8 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
db.open();
db.transaction();
foreach(ComicDB comic, comics)
{
DBHelper::update(&(comic.info),db);
foreach (ComicDB comic, comics) {
DBHelper::update(&(comic.info), db);
}
db.commit();
db.close();
@ -465,23 +448,20 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QString &publisher)
{
ComicVineClient * comicVineClient = new ComicVineClient;
ComicVineClient *comicVineClient = new ComicVineClient;
bool error;
bool timeout;
QByteArray result = comicVineClient->getComicDetail(comicId,error,timeout); //TODO check timeOut or Connection error
if(error || timeout)
{
QByteArray result = comicVineClient->getComicDetail(comicId, error, timeout); //TODO check timeOut or Connection error
if (error || timeout) {
//TODO
if(mode == SingleComic || currentIndex == (comics.count()-1))
{
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
emit accepted();
} else
{
} else {
goToNextComic();
}
}
ComicDB comic = parseComicInfo(comics[currentIndex],result,count,publisher); //TODO check result error
ComicDB comic = parseComicInfo(comics[currentIndex], result, count, publisher); //TODO check result error
comic.info.comicVineID = comicId;
setLoadingMessage(tr("Retrieving tags for : %1").arg(comics[currentIndex].getFileName()));
@ -489,37 +469,31 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
db.open();
db.transaction();
DBHelper::update(&(comic.info),db);
DBHelper::update(&(comic.info), db);
db.commit();
db.close();
QSqlDatabase::removeDatabase(db.connectionName());
if(mode == SingleComic || currentIndex == (comics.count()-1))
{
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
emit accepted();
} else
{
} else {
goToNextComic();
}
}
ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, int count, const QString & publisher)
ComicDB ComicVineDialog::parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher)
{
QScriptEngine engine;
QScriptValue sc;
sc = engine.evaluate("(" + json + ")");
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
{
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
qDebug("Error detected");
}
else
{
} else {
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
if(numResults > 0)
{
if (numResults > 0) {
QScriptValue result = sc.property("results");
if (!result.property("name").isNull()) {
@ -541,7 +515,7 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, i
}
if (!result.property("person_credits").isNull()) {
QMap<QString,QString> authors = getAuthors(result.property("person_credits"));
QMap<QString, QString> authors = getAuthors(result.property("person_credits"));
QString writer = QStringList(authors.values("writer")).join("\n");
QString penciller = QStringList(authors.values("penciller")).join("\n");
@ -564,7 +538,7 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, i
QStringList tempList = date.split("-");
if (tempList.length() == 3) {
std::reverse(tempList.begin(),tempList.end());
std::reverse(tempList.begin(), tempList.end());
comic.info.date = tempList.join("/");
}
}
@ -597,7 +571,7 @@ QString ComicVineDialog::getCharacters(const QScriptValue &json_characters)
QScriptValue resultsValue;
while (it.hasNext()) {
it.next();
if(it.flags() & QScriptValue::SkipInEnumeration)
if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
resultsValue = it.value();
@ -615,27 +589,26 @@ QMap<QString, QString> ComicVineDialog::getAuthors(const QScriptValue &json_auth
QScriptValue resultsValue;
while (it.hasNext()) {
it.next();
if(it.flags() & QScriptValue::SkipInEnumeration)
if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
resultsValue = it.value();
QString authorName = resultsValue.property("name").toString();
QStringList roles = resultsValue.property("role").toString().split(",");
foreach(QString role, roles)
{
if(role.trimmed() == "writer")
authors.insertMulti("writer",authorName);
else if(role.trimmed() == "inker")
authors.insertMulti("inker",authorName);
else if(role.trimmed() == "penciler" || role.trimmed() == "penciller")
authors.insertMulti("penciller",authorName);
else if(role.trimmed() == "colorist")
authors.insertMulti("colorist",authorName);
else if(role.trimmed() == "letterer")
authors.insertMulti("letterer",authorName);
else if(role.trimmed() == "cover")
authors.insertMulti("cover",authorName);
foreach (QString role, roles) {
if (role.trimmed() == "writer")
authors.insertMulti("writer", authorName);
else if (role.trimmed() == "inker")
authors.insertMulti("inker", authorName);
else if (role.trimmed() == "penciler" || role.trimmed() == "penciller")
authors.insertMulti("penciller", authorName);
else if (role.trimmed() == "colorist")
authors.insertMulti("colorist", authorName);
else if (role.trimmed() == "letterer")
authors.insertMulti("letterer", authorName);
else if (role.trimmed() == "cover")
authors.insertMulti("cover", authorName);
}
}
@ -652,8 +625,7 @@ void ComicVineDialog::toggleSkipButton()
void ComicVineDialog::goToNextComic()
{
if(mode == SingleComic || currentIndex == (comics.count()-1))
{
if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
emit accepted();
return;
}
@ -664,7 +636,7 @@ void ComicVineDialog::goToNextComic()
ComicDB comic = comics[currentIndex];
QString title = comic.getTitleOrFileName();
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
}
void ComicVineDialog::showLoading(const QString &message)
@ -701,11 +673,11 @@ void ComicVineDialog::searchVolume(const QString &v, int page)
currentVolumeSearchString = v;
ComicVineClient * comicVineClient = new ComicVineClient;
connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
comicVineClient->search(v,page);
ComicVineClient *comicVineClient = new ComicVineClient;
connect(comicVineClient, SIGNAL(searchResult(QString)), this, SLOT(debugClientResults(QString)));
connect(comicVineClient, SIGNAL(timeOut()), this, SLOT(queryTimeOut()));
connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
comicVineClient->search(v, page);
status = SearchingVolume;
}
@ -716,13 +688,13 @@ void ComicVineDialog::getVolumeComicsInfo(const QString &vID, int /* page */)
status = GettingVolumeComics;
ComicVineClient * comicVineClient = new ComicVineClient;
if(mode == Volume)
connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSortVolumeComics(QString)));
ComicVineClient *comicVineClient = new ComicVineClient;
if (mode == Volume)
connect(comicVineClient, SIGNAL(volumeComicsInfo(QString)), this, SLOT(showSortVolumeComics(QString)));
else
connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSelectComic(QString)));
connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
connect(comicVineClient, SIGNAL(volumeComicsInfo(QString)), this, SLOT(showSelectComic(QString)));
connect(comicVineClient, SIGNAL(timeOut()), this, SLOT(queryTimeOut()));
connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
QLOG_TRACE() << vID;
@ -747,4 +719,3 @@ void ComicVineDialog::launchSearchComic()
//if(comicInfo.isEmpty() && comicNumber == -1)
searchVolume(volumeInfo);
}

View File

@ -29,7 +29,7 @@ public:
explicit ComicVineDialog(QWidget *parent = 0);
QString databasePath;
QString basePath;
void setComics(const QList<ComicDB> & comics);
void setComics(const QList<ComicDB> &comics);
QSize sizeHint() const;
QSize minimumSizeHint() const;
@ -41,44 +41,41 @@ public slots:
protected slots:
void goNext();
void goBack();
void debugClientResults(const QString & string);
void debugClientResults(const QString &string);
//show widget methods
void showSeriesQuestion();
void showSearchSingleComic();
void showSearchVolume();
void showLoading(const QString & message = "");
void showLoading(const QString &message = "");
void search();
void searchVolume(const QString & v, int page = 1);
void searchVolume(const QString &v, int page = 1);
void getVolumeComicsInfo(const QString &vID, int page = 1);
void launchSearchVolume();
void launchSearchComic();
void showSelectVolume(const QString & json);
void showSelectVolume(const QString &json);
void showSelectVolume();
void showSelectComic(const QString & json);
void showSortVolumeComics(const QString & json);
void showSelectComic(const QString &json);
void showSortVolumeComics(const QString &json);
void queryTimeOut();
void getComicsInfo(QList<QPair<ComicDB,QString> > & matchingInfo, int count, const QString & publisher);
void getComicInfo(const QString & comicId, int count, const QString & publisher);
ComicDB parseComicInfo(ComicDB &comic, const QString & json, int count, const QString &publisher);
void getComicsInfo(QList<QPair<ComicDB, QString>> &matchingInfo, int count, const QString &publisher);
void getComicInfo(const QString &comicId, int count, const QString &publisher);
ComicDB parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher);
void setLoadingMessage(const QString &message);
void goToNextComic();
private:
QString getCharacters(const QScriptValue & json_characters);
QMap<QString,QString> getAuthors(const QScriptValue & json_authors);
QString getCharacters(const QScriptValue &json_characters);
QMap<QString, QString> getAuthors(const QScriptValue &json_authors);
void toggleSkipButton();
enum ScraperMode
{
enum ScraperMode {
SingleComic, //the scraper has been opened for a single comic
Volume, //the scraper is trying to get comics info for a whole volume
SingleComicInList //the scraper has been opened for a list of unrelated comics
};
enum ScraperStatus
{
enum ScraperStatus {
AutoSearching,
AskingForInfo,
SelectingComic,
@ -94,21 +91,21 @@ private:
int currentIndex;
TitleHeader * titleHeader;
TitleHeader *titleHeader;
QPushButton * skipButton;
QPushButton * backButton;
QPushButton * nextButton;
QPushButton * searchButton;
QPushButton * closeButton;
QPushButton *skipButton;
QPushButton *backButton;
QPushButton *nextButton;
QPushButton *searchButton;
QPushButton *closeButton;
//stacked widgets
QStackedWidget * content;
QStackedWidget *content;
QWidget * infoNotFound;
QWidget * singleComicBrowser;
QWidget *infoNotFound;
QWidget *singleComicBrowser;
QLabel * loadingMessage;
QLabel *loadingMessage;
void doLayout();
void doStackedWidgets();
@ -117,12 +114,12 @@ private:
QList<ComicDB> comics;
SeriesQuestion * seriesQuestionWidget;
SearchSingleComic * searchSingleComicWidget;
SearchVolume * searchVolumeWidget;
SelectVolume * selectVolumeWidget;
SelectComic * selectComicWidget;
SortVolumeComics * sortVolumeComicsWidget;
SeriesQuestion *seriesQuestionWidget;
SearchSingleComic *searchSingleComicWidget;
SearchVolume *searchVolumeWidget;
SelectVolume *selectVolumeWidget;
SelectComic *selectComicWidget;
SortVolumeComics *sortVolumeComicsWidget;
QString currentVolumeSearchString;
QString currentVolumeId;

View File

@ -1,6 +1,6 @@
#include "comics_model.h"
ComicsModel::ComicsModel(QObject *parent) :
JSONModel(parent)
ComicsModel::ComicsModel(QObject *parent)
: JSONModel(parent)
{
}

View File

@ -12,7 +12,6 @@ public:
signals:
public slots:
};
#endif // COMICS_MODEL_H

View File

@ -1,6 +1,6 @@
#include "json_model.h"
JSONModel::JSONModel(QObject *parent) :
QAbstractItemModel(parent)
JSONModel::JSONModel(QObject *parent)
: QAbstractItemModel(parent)
{
}

View File

@ -8,12 +8,11 @@ class JSONModel : public QAbstractItemModel
Q_OBJECT
public:
explicit JSONModel(QObject *parent = 0);
virtual void load(const QString & json) = 0 ;
virtual void load(const QString &json) = 0;
signals:
public slots:
};
#endif // JSON_MODEL_H

View File

@ -1,7 +1,7 @@
#include "local_comic_list_model.h"
LocalComicListModel::LocalComicListModel(QObject *parent) :
QAbstractItemModel(parent),numExtraRows(0)
LocalComicListModel::LocalComicListModel(QObject *parent)
: QAbstractItemModel(parent), numExtraRows(0)
{
}
@ -10,7 +10,6 @@ void LocalComicListModel::load(QList<ComicDB> &comics)
_data = comics;
}
QModelIndex LocalComicListModel::parent(const QModelIndex &index) const
{
Q_UNUSED(index)
@ -26,10 +25,10 @@ int LocalComicListModel::rowCount(const QModelIndex &parent) const
int LocalComicListModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
if(_data.isEmpty())
if (_data.isEmpty())
return 0;
else
return 1;//_data.at(0)->count();
return 1; //_data.at(0)->count();
}
QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
@ -37,16 +36,14 @@ QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
if (role == Qt::DecorationRole)
{
if (role == Qt::DecorationRole) {
return QVariant();
}
if (role == Qt::TextAlignmentRole)
{
if (role == Qt::TextAlignmentRole) {
//TODO
}
if(role != Qt::DisplayRole)
if (role != Qt::DisplayRole)
return QVariant();
int row = index.row();
@ -68,11 +65,10 @@ QVariant LocalComicListModel::headerData(int section, Qt::Orientation orientatio
{
Q_UNUSED(section);
if ( role == Qt::TextAlignmentRole)
if (role == Qt::TextAlignmentRole)
return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
return QVariant(QString(tr("file name")));
}
@ -99,18 +95,17 @@ void LocalComicListModel::removeComics(const QList<QModelIndex> &selectedIndexes
int sourceRow = mi.row();
int sourceLastRow = lastMi.row();
beginRemoveRows(QModelIndex(),selectedIndexes.first().row(),selectedIndexes.last().row());
beginRemoveRows(QModelIndex(), selectedIndexes.first().row(), selectedIndexes.last().row());
for(int i = sourceLastRow;i>=sourceRow;i--)
{
for (int i = sourceLastRow; i >= sourceRow; i--) {
_removed.push_front(_data.at(i));
_data.removeAt(i);
}
endRemoveRows();
beginInsertRows(QModelIndex(),_data.count()-_removed.count(),_data.count()-1);
for(int i = 0; i<_removed.count(); i++)
beginInsertRows(QModelIndex(), _data.count() - _removed.count(), _data.count() - 1);
for (int i = 0; i < _removed.count(); i++)
_data.append(ComicDB());
endInsertRows();
}
@ -118,16 +113,14 @@ void LocalComicListModel::removeComics(const QList<QModelIndex> &selectedIndexes
void LocalComicListModel::restoreAll()
{
int numItemsToRemove = 0;
for(int i = 0;numItemsToRemove<_removed.count();i++)
{
if(_data.at(i).getFileName().isEmpty())
{
beginRemoveRows(QModelIndex(),i,i);
for (int i = 0; numItemsToRemove < _removed.count(); i++) {
if (_data.at(i).getFileName().isEmpty()) {
beginRemoveRows(QModelIndex(), i, i);
_data.removeAt(i);
endRemoveRows();
beginInsertRows(QModelIndex(),i,i);
_data.insert(i,_removed.at(numItemsToRemove));
beginInsertRows(QModelIndex(), i, i);
_data.insert(i, _removed.at(numItemsToRemove));
endInsertRows();
numItemsToRemove++;
@ -145,13 +138,13 @@ void LocalComicListModel::moveSelectionUp(const QList<QModelIndex> &selectedInde
int sourceLastRow = lastMi.row();
int destRow = sourceRow - 1;
if(destRow < 0)
if (destRow < 0)
return;
beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow);
beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow);
for(int i = sourceRow; i <= sourceLastRow; i++)
_data.swap(i, i-1);
for (int i = sourceRow; i <= sourceLastRow; i++)
_data.swap(i, i - 1);
endMoveRows();
}
@ -164,13 +157,13 @@ void LocalComicListModel::moveSelectionDown(const QList<QModelIndex> &selectedIn
int sourceLastRow = lastMi.row();
int destRow = sourceLastRow + 1;
if(destRow >= _data.count())
if (destRow >= _data.count())
return;
beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow+1);
beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow + 1);
for(int i = sourceLastRow; i >= sourceRow; i--)
_data.swap(i, i+1);
for (int i = sourceLastRow; i >= sourceRow; i--)
_data.swap(i, i + 1);
endMoveRows();
}
@ -178,7 +171,6 @@ void LocalComicListModel::moveSelectionDown(const QList<QModelIndex> &selectedIn
void LocalComicListModel::addExtraRows(int numRows)
{
numExtraRows = numRows;
for(int i = 0; i<numExtraRows; i++)
for (int i = 0; i < numExtraRows; i++)
_data.append(ComicDB());
}

View File

@ -11,7 +11,7 @@ class LocalComicListModel : public QAbstractItemModel
public:
explicit LocalComicListModel(QObject *parent = 0);
void load(QList<ComicDB> & comics);
void load(QList<ComicDB> &comics);
//QAbstractItemModel methods
QModelIndex parent(const QModelIndex &index) const;
@ -24,13 +24,13 @@ public:
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QList<ComicDB> getData();
void removeComics(const QList<QModelIndex> & selectedIndexes);
void removeComics(const QList<QModelIndex> &selectedIndexes);
void restoreAll();
signals:
public slots:
void moveSelectionUp(const QList<QModelIndex> & selectedIndexes);
void moveSelectionDown(const QList<QModelIndex> & selectedIndexes);
void moveSelectionUp(const QList<QModelIndex> &selectedIndexes);
void moveSelectionDown(const QList<QModelIndex> &selectedIndexes);
void addExtraRows(int numRows);
private:

View File

@ -3,8 +3,8 @@
#include <QtScript>
#include <QDebug>
ResponseParser::ResponseParser(QObject *parent) :
QObject(parent),error(false),errorTxt("None"),numResults(-1),currentPage(-1),totalPages(-1)
ResponseParser::ResponseParser(QObject *parent)
: QObject(parent), error(false), errorTxt("None"), numResults(-1), currentPage(-1), totalPages(-1)
{
}
@ -35,8 +35,7 @@ qint32 ResponseParser::getTotalPages()
bool ResponseParser::isError(qint32 error)
{
switch(error)
{
switch (error) {
case 100:
return true;
@ -53,31 +52,26 @@ void ResponseParser::loadJSONResponse(const QString &response)
errorTxt = "None";
if (!sc.property("status_code").isValid() || isError(sc.property("status_code").toInt32()))
{
if (!sc.property("status_code").isValid() || isError(sc.property("status_code").toInt32())) {
error = true;
if(sc.property("error").isValid())
if (sc.property("error").isValid())
errorTxt = sc.property("error").toString();
else
errorTxt = "Unknown error";
}
else
{
} else {
error = false;
if(sc.property("number_of_total_results").isValid())
numResults = sc.property("number_of_total_results").toString().toInt();// sc.property("number_of_total_results").toInt32();
if (sc.property("number_of_total_results").isValid())
numResults = sc.property("number_of_total_results").toString().toInt(); // sc.property("number_of_total_results").toInt32();
else
qDebug() << sc.property("oops").toString();
int limit = sc.property("limit").toInt32();
int offset = sc.property("offset").toInt32();
int total = sc.property("number_of_total_results").toInt32();
if(limit > 0)
{
totalPages = (total / limit) + (total%limit>0?1:0);
if (limit > 0) {
totalPages = (total / limit) + (total % limit > 0 ? 1 : 0);
currentPage = (offset / limit) + 1;
}
else
} else
totalPages = currentPage = 1;
}
}

View File

@ -17,7 +17,7 @@ public:
signals:
public slots:
void loadJSONResponse(const QString & response);
void loadJSONResponse(const QString &response);
protected:
bool error;

View File

@ -1,40 +1,36 @@
#include "volume_comics_model.h"
#include "qnaturalsorting.h"
#include <QtScript>
bool lessThan(const QList<QString> & left, const QList<QString> & right)
bool lessThan(const QList<QString> &left, const QList<QString> &right)
{
if ((left.count() > 0) && (right.count() > 0))
return naturalSortLessThanCI(left.at(0),right.at(0));
return naturalSortLessThanCI(left.at(0), right.at(0));
else
return true;
}
VolumeComicsModel::VolumeComicsModel(QObject * parent) :
JSONModel(parent),numExtraRows(0)
VolumeComicsModel::VolumeComicsModel(QObject *parent)
: JSONModel(parent), numExtraRows(0)
{
}
void VolumeComicsModel::load(const QString & json)
void VolumeComicsModel::load(const QString &json)
{
QScriptEngine engine;
QScriptValue sc;
sc = engine.evaluate("(" + json + ")");
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
{
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
qDebug("Error detected");
}
else
{
} else {
QScriptValueIterator it(sc.property("results"));
//bool test;
QScriptValue resultsValue;
while (it.hasNext()) {
it.next();
if(it.flags() & QScriptValue::SkipInEnumeration)
if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
resultsValue = it.value();
QString issueNumber = resultsValue.property("issue_number").toString();
@ -47,7 +43,7 @@ void VolumeComicsModel::load(const QString & json)
_data.push_back(l);
}
qSort(_data.begin(),_data.end(),lessThan);
qSort(_data.begin(), _data.end(), lessThan);
}
}
@ -73,7 +69,7 @@ int VolumeComicsModel::rowCount(const QModelIndex &parent) const
int VolumeComicsModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
if(_data.isEmpty())
if (_data.isEmpty())
return 0;
else
return 2;
@ -87,13 +83,11 @@ QVariant VolumeComicsModel::data(const QModelIndex &index, int role) const
int row = index.row();
int column = index.column();
if (role == Qt::DecorationRole)
{
if (role == Qt::DecorationRole) {
return QVariant();
}
if (role == Qt::TextAlignmentRole)
{
switch(column)//TODO obtener esto de la query
if (role == Qt::TextAlignmentRole) {
switch (column) //TODO obtener esto de la query
{
case ISSUE:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@ -102,10 +96,10 @@ QVariant VolumeComicsModel::data(const QModelIndex &index, int role) const
}
}
if(role != Qt::DisplayRole)
if (role != Qt::DisplayRole)
return QVariant();
if(row<_data.count())
if (row < _data.count())
return _data[row][column];
else
return QVariant();
@ -120,9 +114,8 @@ Qt::ItemFlags VolumeComicsModel::flags(const QModelIndex &index) const
QVariant VolumeComicsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch(section)//TODO obtener esto de la query
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) //TODO obtener esto de la query
{
case ISSUE:
return QVariant(QString("issue"));
@ -131,9 +124,8 @@ QVariant VolumeComicsModel::headerData(int section, Qt::Orientation orientation,
}
}
if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole)
{
switch(section)//TODO obtener esto de la query
if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole) {
switch (section) //TODO obtener esto de la query
{
case ISSUE:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@ -156,14 +148,14 @@ QModelIndex VolumeComicsModel::index(int row, int column, const QModelIndex &par
QString VolumeComicsModel::getComicId(const QModelIndex &index) const
{
int row = index.row();
if(row >= _data.count())
if (row >= _data.count())
return "";
return _data[row][ID];
}
QString VolumeComicsModel::getComicId(int row) const
{
if(row >= _data.count())
if (row >= _data.count())
return "";
return _data[row][ID];
}
@ -177,4 +169,3 @@ void VolumeComicsModel::addExtraRows(int numRows)
{
numExtraRows = numRows;
}

View File

@ -8,7 +8,7 @@ class VolumeComicsModel : public JSONModel
Q_OBJECT
public:
explicit VolumeComicsModel(QObject *parent = 0);
void load(const QString & json);
void load(const QString &json);
//void load(const QStringList & jsonList);
QModelIndex parent(const QModelIndex &index) const;
@ -29,7 +29,7 @@ public slots:
private:
int numExtraRows;
QList <QList <QString> > _data;
QList<QList<QString>> _data;
enum Column {
ISSUE = 0,

View File

@ -2,9 +2,8 @@
#include <QtScript>
VolumesModel::VolumesModel(QObject *parent) :
JSONModel(parent)
VolumesModel::VolumesModel(QObject *parent)
: JSONModel(parent)
{
}
@ -19,12 +18,9 @@ void VolumesModel::load(const QString &json)
QScriptValue sc;
sc = engine.evaluate("(" + json + ")");
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
{
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
qDebug("Error detected");
}
else
{
} else {
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
QScriptValueIterator it(sc.property("results"));
bool test;
@ -42,7 +38,7 @@ void VolumesModel::load(const QString &json)
QStringList l;
l << name << year << numIssues << publisher << url << deck << id;
test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
if(numResults>0 && !test)
if (numResults > 0 && !test)
_data.push_back(l);
numResults--;
}
@ -64,10 +60,10 @@ int VolumesModel::rowCount(const QModelIndex &parent) const
int VolumesModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
if(_data.isEmpty())
if (_data.isEmpty())
return 0;
else
return 4;//_data.at(0)->count();
return 4; //_data.at(0)->count();
}
QVariant VolumesModel::data(const QModelIndex &index, int role) const
@ -75,18 +71,15 @@ QVariant VolumesModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
if (role == Qt::DecorationRole)
{
if (role == Qt::DecorationRole) {
return QVariant();
}
int row = index.row();
int column = index.column();
if (role == Qt::TextAlignmentRole)
{
switch(column)
{
if (role == Qt::TextAlignmentRole) {
switch (column) {
case YEAR:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case ISSUES:
@ -96,15 +89,12 @@ QVariant VolumesModel::data(const QModelIndex &index, int role) const
}
}
if(role != Qt::DisplayRole)
if (role != Qt::DisplayRole)
return QVariant();
if (column == YEAR || column == ISSUES)
{
if (column == YEAR || column == ISSUES) {
return _data[row][column].toInt();
}
else
{
} else {
return _data[row][column];
}
}
@ -119,9 +109,8 @@ Qt::ItemFlags VolumesModel::flags(const QModelIndex &index) const
QVariant VolumesModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch(section)//TODO obtener esto de la query
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) //TODO obtener esto de la query
{
case SERIES:
return QVariant(QString("series"));
@ -134,9 +123,8 @@ QVariant VolumesModel::headerData(int section, Qt::Orientation orientation, int
}
}
if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole)
{
switch(section)//TODO obtener esto de la query
if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole) {
switch (section) //TODO obtener esto de la query
{
case YEAR:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@ -177,4 +165,3 @@ QString VolumesModel::getCoverURL(const QModelIndex &index) const
{
return _data[index.row()][COVER_URL];
}

View File

@ -10,7 +10,7 @@ public:
explicit VolumesModel(QObject *parent = 0);
virtual ~VolumesModel();
//receive a valid json with a list of volumes
void load(const QString & json);
void load(const QString &json);
//QAbstractItemModel methods
QModelIndex parent(const QModelIndex &index) const;
@ -22,17 +22,17 @@ public:
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QString getVolumeId(const QModelIndex & index) const;
int getNumIssues(const QModelIndex & index) const;
QString getPublisher(const QModelIndex & index) const;
QString getCoverURL(const QModelIndex & index) const;
QString getVolumeId(const QModelIndex &index) const;
int getNumIssues(const QModelIndex &index) const;
QString getPublisher(const QModelIndex &index) const;
QString getCoverURL(const QModelIndex &index) const;
signals:
public slots:
private:
QList <QList <QString> > _data;
QList<QList<QString>> _data;
public:
enum Column {

View File

@ -1,15 +1,16 @@
#include "scraper_lineedit.h"
#include <QLabel>
ScraperLineEdit::ScraperLineEdit(const QString & title, QWidget * widget)
:QLineEdit(widget)
ScraperLineEdit::ScraperLineEdit(const QString &title, QWidget *widget)
: QLineEdit(widget)
{
titleLabel = new QLabel(title,this);
titleLabel = new QLabel(title, this);
titleLabel->setStyleSheet("QLabel {color:white;}");
setStyleSheet(QString("QLineEdit {"
"border:none; background-color: #2E2E2E; color : white; padding-left: %1; padding-bottom: 1px; margin-bottom: 0px;"
"}").arg(titleLabel->sizeHint().width()+6));
"}")
.arg(titleLabel->sizeHint().width() + 6));
setFixedHeight(22);
}
@ -17,5 +18,5 @@ ScraperLineEdit::ScraperLineEdit(const QString & title, QWidget * widget)
void ScraperLineEdit::resizeEvent(QResizeEvent *)
{
QSize szl = titleLabel->sizeHint();
titleLabel->move(6,(rect().bottom() + 1 - szl.height())/2);
titleLabel->move(6, (rect().bottom() + 1 - szl.height()) / 2);
}

View File

@ -9,11 +9,13 @@ class ScraperLineEdit : public QLineEdit
{
Q_OBJECT
public:
ScraperLineEdit(const QString & title, QWidget * widget = 0);
ScraperLineEdit(const QString &title, QWidget *widget = 0);
protected:
void resizeEvent(QResizeEvent *);
private:
QLabel * titleLabel;
QLabel *titleLabel;
};
#endif // SCRAPPER_LINEEDIT_H

View File

@ -6,11 +6,10 @@
#include <QToolButton>
#include <QtScript>
ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent) :
QWidget(parent),customLabel("items")
ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent)
: QWidget(parent), customLabel("items")
{
QHBoxLayout * pagesButtonsLayout = new QHBoxLayout;
QHBoxLayout *pagesButtonsLayout = new QHBoxLayout;
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
@ -26,8 +25,8 @@ ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent) :
previousPage->setIconSize(pp.size());
previousPage->setIcon(pp);
connect(nextPage,SIGNAL(clicked()),this,SIGNAL(loadNextPage()));
connect(previousPage,SIGNAL(clicked()),this,SIGNAL(loadPreviousPage()));
connect(nextPage, SIGNAL(clicked()), this, SIGNAL(loadNextPage()));
connect(previousPage, SIGNAL(clicked()), this, SIGNAL(loadPreviousPage()));
numElements = new QLabel(tr("Number of volumes found : %1"));
numElements->setStyleSheet(labelStylesheet);
@ -41,8 +40,8 @@ ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent) :
pagesButtonsLayout->addWidget(previousPage);
pagesButtonsLayout->addWidget(nextPage);
setContentsMargins(0,0,0,0);
pagesButtonsLayout->setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
pagesButtonsLayout->setContentsMargins(0, 0, 0, 0);
setLayout(pagesButtonsLayout);
}
@ -59,9 +58,9 @@ void ScraperResultsPaginator::update(const QString &json)
previousPage->setDisabled(currentPage == 1);
nextPage->setDisabled(currentPage == rp.getTotalPages());
numPages->setHidden(rp.getTotalPages()==1);
previousPage->setHidden(rp.getTotalPages()==1);
nextPage->setHidden(rp.getTotalPages()==1);
numPages->setHidden(rp.getTotalPages() == 1);
previousPage->setHidden(rp.getTotalPages() == 1);
nextPage->setHidden(rp.getTotalPages() == 1);
}
int ScraperResultsPaginator::getCurrentPage()

View File

@ -11,9 +11,9 @@ class ScraperResultsPaginator : public QWidget
Q_OBJECT
public:
explicit ScraperResultsPaginator(QWidget *parent = 0);
void update(const QString & json);
void update(const QString &json);
int getCurrentPage();
void setCustomLabel(const QString & label);
void setCustomLabel(const QString &label);
signals:
void loadNextPage();
void loadPreviousPage();
@ -21,10 +21,10 @@ signals:
public slots:
private:
QToolButton * nextPage;
QToolButton * previousPage;
QLabel * numElements;
QLabel * numPages;
QToolButton *nextPage;
QToolButton *previousPage;
QLabel *numElements;
QLabel *numPages;
int currentPage;

View File

@ -4,14 +4,14 @@
#include <QDesktopServices>
#include <QUrl>
ScraperScrollLabel::ScraperScrollLabel(QWidget *parent) :
QScrollArea(parent)
ScraperScrollLabel::ScraperScrollLabel(QWidget *parent)
: QScrollArea(parent)
{
textLabel = new QLabel(this);
textLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
textLabel->setWordWrap(true);
textLabel->setMinimumSize(168,12);
textLabel->setMinimumSize(168, 12);
setWidget(textLabel);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -27,27 +27,26 @@ ScraperScrollLabel::ScraperScrollLabel(QWidget *parent) :
"QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }"
);
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }");
connect(textLabel,SIGNAL(linkActivated(QString)),this,SLOT(openLink(QString)));
connect(textLabel, SIGNAL(linkActivated(QString)), this, SLOT(openLink(QString)));
}
void ScraperScrollLabel::setAltText(const QString &text)
{
textLabel->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
textLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
textLabel->setText(text);
textLabel->adjustSize();
}
void ScraperScrollLabel::setText(const QString &text)
{
textLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
textLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
textLabel->setText(text);
textLabel->adjustSize();
}
void ScraperScrollLabel::openLink(const QString & link)
void ScraperScrollLabel::openLink(const QString &link)
{
QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link));
QDesktopServices::openUrl(QUrl("http://www.comicvine.com" + link));
}

View File

@ -14,12 +14,13 @@ public:
signals:
public slots:
void setText(const QString & text);
void setText(const QString &text);
void setAltText(const QString &text);
void openLink(const QString &link);
private:
QLabel * textLabel;
QLabel *textLabel;
};
#endif // SCRAPER_SCROLL_LABEL_H

View File

@ -1,11 +1,11 @@
#include "scraper_selector.h"
ScraperSelector::ScraperSelector(QWidget *parent) :
QWidget(parent)
ScraperSelector::ScraperSelector(QWidget *parent)
: QWidget(parent)
{
paginator = new ScraperResultsPaginator;
connect(paginator,SIGNAL(loadNextPage()),this,SLOT(loadNextPage()));
connect(paginator,SIGNAL(loadPreviousPage()),this,SLOT(loadPreviousPage()));
connect(paginator, SIGNAL(loadNextPage()), this, SLOT(loadNextPage()));
connect(paginator, SIGNAL(loadPreviousPage()), this, SLOT(loadPreviousPage()));
}
void ScraperSelector::load(const QString &json, const QString &searchString)
@ -16,10 +16,10 @@ void ScraperSelector::load(const QString &json, const QString &searchString)
void ScraperSelector::loadNextPage()
{
emit loadPage(currentSearchString,paginator->getCurrentPage()+1);
emit loadPage(currentSearchString, paginator->getCurrentPage() + 1);
}
void ScraperSelector::loadPreviousPage()
{
emit loadPage(currentSearchString,paginator->getCurrentPage()-1);
emit loadPage(currentSearchString, paginator->getCurrentPage() - 1);
}

View File

@ -10,11 +10,11 @@ class ScraperSelector : public QWidget
Q_OBJECT
public:
explicit ScraperSelector(QWidget *parent = 0);
virtual void load(const QString & json, const QString & searchString);
virtual void load(const QString &json, const QString &searchString);
public slots:
signals:
void loadPage(QString,int);
void loadPage(QString, int);
private slots:
void loadNextPage();
@ -22,7 +22,7 @@ private slots:
protected:
QString currentSearchString;
ScraperResultsPaginator * paginator;
ScraperResultsPaginator *paginator;
};
#endif // SCRAPER_SELECTOR_H

View File

@ -2,8 +2,8 @@
#include <QHeaderView>
ScraperTableView::ScraperTableView(QWidget *parent) :
QTableView(parent)
ScraperTableView::ScraperTableView(QWidget *parent)
: QTableView(parent)
{
QString tableStylesheet = "QTableView {color:white; border:0px;alternate-background-color: #2E2E2E;background-color: #2B2B2B; outline: 0px;}"
"QTableView::item {outline: 0px; border: 0px; color:#FFFFFF;}"

View File

@ -12,7 +12,6 @@ public:
signals:
public slots:
};
#endif // SCRAPPER_TABLEVIEW_H

View File

@ -6,12 +6,12 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
SearchSingleComic::SearchSingleComic(QWidget * parent)
:QWidget(parent)
SearchSingleComic::SearchSingleComic(QWidget *parent)
: QWidget(parent)
{
//QLabel * label = new QLabel(tr("Please provide some additional information. At least one field is needed."));
QLabel * label = new QLabel(tr("Please provide some additional information."));
QLabel *label = new QLabel(tr("Please provide some additional information."));
label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
//titleEdit = new ScraperLineEdit(tr("Title:"));
@ -20,7 +20,7 @@ SearchSingleComic::SearchSingleComic(QWidget * parent)
//numberEdit->setMaximumWidth(126);
QVBoxLayout * l = new QVBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
//QHBoxLayout * hl = new QHBoxLayout;
//hl->addWidget(titleEdit);
//hl->addWidget(numberEdit);
@ -31,9 +31,9 @@ SearchSingleComic::SearchSingleComic(QWidget * parent)
l->addWidget(volumeEdit);
l->addStretch();
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
}
QString SearchSingleComic::getVolumeInfo()

View File

@ -9,14 +9,15 @@ class SearchSingleComic : public QWidget
{
Q_OBJECT
public:
SearchSingleComic(QWidget * parent = 0);
SearchSingleComic(QWidget *parent = 0);
QString getVolumeInfo();
QString getComicInfo();
int getComicNumber();
void clean();
private:
ScraperLineEdit * titleEdit;
ScraperLineEdit * numberEdit;
ScraperLineEdit * volumeEdit;
ScraperLineEdit *titleEdit;
ScraperLineEdit *numberEdit;
ScraperLineEdit *volumeEdit;
};
#endif // SEARCH_SINGLE_COMIC_H

View File

@ -5,24 +5,24 @@
#include <QLabel>
#include <QVBoxLayout>
SearchVolume::SearchVolume(QWidget * parent)
:QWidget(parent)
SearchVolume::SearchVolume(QWidget *parent)
: QWidget(parent)
{
QLabel * label = new QLabel(tr("Please provide some additional information."));
QLabel *label = new QLabel(tr("Please provide some additional information."));
label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
volumeEdit = new ScraperLineEdit(tr("Series:"));
QVBoxLayout * l = new QVBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
l->addSpacing(35);
l->addWidget(label);
l->addWidget(volumeEdit);
l->addStretch();
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
}
void SearchVolume::clean()

View File

@ -5,17 +5,17 @@
class ScraperLineEdit;
class SearchVolume : public QWidget
{
Q_OBJECT
public:
SearchVolume(QWidget * parent = 0);
SearchVolume(QWidget *parent = 0);
void clean();
public slots:
QString getVolumeInfo();
private:
ScraperLineEdit * volumeEdit;
ScraperLineEdit *volumeEdit;
};
#endif // SEARCH_VOLUME_H

View File

@ -10,76 +10,76 @@
#include <QtScript>
SelectComic::SelectComic(QWidget *parent)
:ScraperSelector(parent),model(0)
: ScraperSelector(parent), model(0)
{
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
QLabel * label = new QLabel(tr("Please, select the right comic info."));
QLabel *label = new QLabel(tr("Please, select the right comic info."));
label->setStyleSheet(labelStylesheet);
QVBoxLayout * l = new QVBoxLayout;
QWidget * leftWidget = new QWidget;
QVBoxLayout * left = new QVBoxLayout;
QGridLayout * content = new QGridLayout;
QVBoxLayout *l = new QVBoxLayout;
QWidget *leftWidget = new QWidget;
QVBoxLayout *left = new QVBoxLayout;
QGridLayout *content = new QGridLayout;
//widgets
cover = new QLabel();
cover->setScaledContents(true);
cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
cover->setMinimumSize(168,168*5.0/3);
cover->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
cover->setMinimumSize(168, 168 * 5.0 / 3);
cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
detailLabel = new ScraperScrollLabel(this);
tableComics = new ScraperTableView(this);
//connections
connect(tableComics,SIGNAL(clicked(QModelIndex)),this,SLOT(loadComicInfo(QModelIndex)));
connect(tableComics, SIGNAL(clicked(QModelIndex)), this, SLOT(loadComicInfo(QModelIndex)));
paginator->setCustomLabel(tr("comics"));
left->addWidget(cover);
left->addWidget(detailLabel,1);
left->addWidget(detailLabel, 1);
leftWidget->setMaximumWidth(180);
leftWidget->setLayout(left);
left->setContentsMargins(0,0,0,0);
leftWidget->setContentsMargins(0,0,0,0);
left->setContentsMargins(0, 0, 0, 0);
leftWidget->setContentsMargins(0, 0, 0, 0);
content->addWidget(leftWidget, 0, 0);
content->addWidget(tableComics, 0, 1);
content->addWidget(paginator, 1, 1);
content->setColumnStretch(1, 1);
content->setRowStretch(0, 1);;
content->setRowStretch(0, 1);
;
l->addSpacing(15);
l->addWidget(label);
l->addSpacing(5);
l->addLayout(content);
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
}
void SelectComic::load(const QString &json, const QString & searchString)
void SelectComic::load(const QString &json, const QString &searchString)
{
VolumeComicsModel * tempM = new VolumeComicsModel();
VolumeComicsModel *tempM = new VolumeComicsModel();
tempM->load(json);
tableComics->setModel(tempM);
if(model != 0)
if (model != 0)
delete model;
model = tempM;
if(model->rowCount()>0)
{
if (model->rowCount() > 0) {
tableComics->selectRow(0);
loadComicInfo(model->index(0,0));
loadComicInfo(model->index(0, 0));
}
tableComics->resizeColumnToContents(0);
ScraperSelector::load(json,searchString);
ScraperSelector::load(json, searchString);
}
SelectComic::~SelectComic() {}
@ -93,18 +93,18 @@ void SelectComic::loadComicInfo(const QModelIndex &mi)
cover->setText(loadingStyle.arg(tr("loading cover")));
detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
ComicVineClient * comicVineClient = new ComicVineClient;
connect(comicVineClient,SIGNAL(comicCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
ComicVineClient *comicVineClient = new ComicVineClient;
connect(comicVineClient, SIGNAL(comicCover(const QByteArray &)), this, SLOT(setCover(const QByteArray &)));
connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
comicVineClient->getComicCover(coverURL);
ComicVineClient * comicVineClient2 = new ComicVineClient;
connect(comicVineClient2,SIGNAL(comicDetail(QString)),this,SLOT(setDescription(QString)));
connect(comicVineClient2,SIGNAL(finished()),comicVineClient2,SLOT(deleteLater()));
ComicVineClient *comicVineClient2 = new ComicVineClient;
connect(comicVineClient2, SIGNAL(comicDetail(QString)), this, SLOT(setDescription(QString)));
connect(comicVineClient2, SIGNAL(finished()), comicVineClient2, SLOT(deleteLater()));
comicVineClient2->getComicDetailAsync(id);
}
void SelectComic::setCover(const QByteArray & data)
void SelectComic::setCover(const QByteArray &data)
{
QPixmap p;
p.loadFromData(data);
@ -112,9 +112,9 @@ void SelectComic::setCover(const QByteArray & data)
int h = p.height();
cover->setPixmap(p);
float aspectRatio = static_cast<float>(w)/h;
float aspectRatio = static_cast<float>(w) / h;
cover->setFixedSize(180,static_cast<int>(180/aspectRatio));
cover->setFixedSize(180, static_cast<int>(180 / aspectRatio));
cover->update();
}
@ -125,16 +125,13 @@ void SelectComic::setDescription(const QString &jsonDetail)
QScriptValue sc;
sc = engine.evaluate("(" + jsonDetail + ")");
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
{
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
qDebug("Error detected");
}
else
{
} else {
QScriptValue descriptionValues = sc.property("results").property("description");
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
detailLabel->setText(valid?descriptionValues.toString().replace("<a","<a style = 'color:#827A68; text-decoration:none;'"):tr("description unavailable"));
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
}
}

View File

@ -14,21 +14,21 @@ class SelectComic : public ScraperSelector
{
Q_OBJECT
public:
SelectComic(QWidget * parent = 0);
void load(const QString & json, const QString & searchString);
SelectComic(QWidget *parent = 0);
void load(const QString &json, const QString &searchString);
virtual ~SelectComic();
public slots:
void loadComicInfo(const QModelIndex & mi);
void loadComicInfo(const QModelIndex &mi);
void setCover(const QByteArray &);
void setDescription(const QString & jsonDetail);
void setDescription(const QString &jsonDetail);
QString getSelectedComicId();
private:
QLabel * cover;
ScraperScrollLabel * detailLabel;
ScraperTableView * tableComics;
VolumeComicsModel * model;
QLabel *cover;
ScraperScrollLabel *detailLabel;
ScraperTableView *tableComics;
VolumeComicsModel *model;
};
#endif // SELECT_COMIC_H

View File

@ -23,25 +23,25 @@
#include "scraper_results_paginator.h"
SelectVolume::SelectVolume(QWidget *parent)
:ScraperSelector(parent),model(0)
: ScraperSelector(parent), model(0)
{
proxyModel = new QSortFilterProxyModel;
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
QLabel * label = new QLabel(tr("Please, select the right series for your comic."));
QLabel *label = new QLabel(tr("Please, select the right series for your comic."));
label->setStyleSheet(labelStylesheet);
QVBoxLayout * l = new QVBoxLayout;
QWidget * leftWidget = new QWidget;
QVBoxLayout * left = new QVBoxLayout;
QGridLayout * content = new QGridLayout;
QVBoxLayout *l = new QVBoxLayout;
QWidget *leftWidget = new QWidget;
QVBoxLayout *left = new QVBoxLayout;
QGridLayout *content = new QGridLayout;
//widgets
cover = new QLabel();
cover->setScaledContents(true);
cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
cover->setMinimumSize(168,168*5.0/3);
cover->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
cover->setMinimumSize(168, 168 * 5.0 / 3);
cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
detailLabel = new ScraperScrollLabel();
@ -53,18 +53,18 @@ SelectVolume::SelectVolume(QWidget *parent)
tableVolumes->horizontalHeader()->setClickable(true);
#endif
//tableVolumes->horizontalHeader()->setSortIndicatorShown(false);
connect(tableVolumes->horizontalHeader(),SIGNAL(sectionClicked(int)), tableVolumes, SLOT(sortByColumn(int)));
connect(tableVolumes->horizontalHeader(), SIGNAL(sectionClicked(int)), tableVolumes, SLOT(sortByColumn(int)));
//connections
connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex)));
connect(tableVolumes, SIGNAL(clicked(QModelIndex)), this, SLOT(loadVolumeInfo(QModelIndex)));
paginator->setCustomLabel(tr("volumes"));
left->addWidget(cover);
left->addWidget(detailLabel,1);
left->addWidget(detailLabel, 1);
leftWidget->setMaximumWidth(180);
leftWidget->setLayout(left);
left->setContentsMargins(0,0,0,0);
leftWidget->setContentsMargins(0,0,0,0);
left->setContentsMargins(0, 0, 0, 0);
leftWidget->setContentsMargins(0, 0, 0, 0);
content->addWidget(leftWidget, 0, 0);
content->addWidget(tableVolumes, 0, 1);
@ -78,41 +78,40 @@ SelectVolume::SelectVolume(QWidget *parent)
l->addSpacing(5);
l->addLayout(content);
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
}
void SelectVolume::load(const QString & json, const QString & searchString)
void SelectVolume::load(const QString &json, const QString &searchString)
{
VolumesModel * tempM = new VolumesModel();
VolumesModel *tempM = new VolumesModel();
tempM->load(json);
//tableVolumes->setModel(tempM);
proxyModel->setSourceModel( tempM );
proxyModel->setSourceModel(tempM);
tableVolumes->setModel(proxyModel);
tableVolumes->sortByColumn(0,Qt::AscendingOrder);
tableVolumes->sortByColumn(0, Qt::AscendingOrder);
tableVolumes->resizeColumnsToContents();
if(model != 0)
if (model != 0)
delete model;
model = tempM;
if(model->rowCount()>0)
{
if (model->rowCount() > 0) {
tableVolumes->selectRow(0);
loadVolumeInfo(proxyModel->index(0,0));
loadVolumeInfo(proxyModel->index(0, 0));
}
tableVolumes->setColumnWidth(0,350);
tableVolumes->setColumnWidth(0, 350);
ScraperSelector::load(json,searchString);
ScraperSelector::load(json, searchString);
}
SelectVolume::~SelectVolume() {}
void SelectVolume::loadVolumeInfo(const QModelIndex & omi)
void SelectVolume::loadVolumeInfo(const QModelIndex &omi)
{
QModelIndex mi = proxyModel->mapToSource(omi);
QString coverURL = model->getCoverURL(mi);
@ -122,18 +121,18 @@ void SelectVolume::loadVolumeInfo(const QModelIndex & omi)
cover->setText(loadingStyle.arg(tr("loading cover")));
detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
ComicVineClient * comicVineClient = new ComicVineClient;
connect(comicVineClient,SIGNAL(seriesCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
ComicVineClient *comicVineClient = new ComicVineClient;
connect(comicVineClient, SIGNAL(seriesCover(const QByteArray &)), this, SLOT(setCover(const QByteArray &)));
connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
comicVineClient->getSeriesCover(coverURL);
ComicVineClient * comicVineClient2 = new ComicVineClient;
connect(comicVineClient2,SIGNAL(seriesDetail(QString)),this,SLOT(setDescription(QString)));
connect(comicVineClient2,SIGNAL(finished()),comicVineClient2,SLOT(deleteLater()));
ComicVineClient *comicVineClient2 = new ComicVineClient;
connect(comicVineClient2, SIGNAL(seriesDetail(QString)), this, SLOT(setDescription(QString)));
connect(comicVineClient2, SIGNAL(finished()), comicVineClient2, SLOT(deleteLater()));
comicVineClient2->getSeriesDetail(id);
}
void SelectVolume::setCover(const QByteArray & data)
void SelectVolume::setCover(const QByteArray &data)
{
QPixmap p;
p.loadFromData(data);
@ -141,29 +140,26 @@ void SelectVolume::setCover(const QByteArray & data)
int h = p.height();
cover->setPixmap(p);
float aspectRatio = static_cast<float>(w)/h;
float aspectRatio = static_cast<float>(w) / h;
cover->setFixedSize(180,static_cast<int>(180/aspectRatio));
cover->setFixedSize(180, static_cast<int>(180 / aspectRatio));
cover->update();
}
void SelectVolume::setDescription(const QString & jsonDetail)
void SelectVolume::setDescription(const QString &jsonDetail)
{
QScriptEngine engine;
QScriptValue sc;
sc = engine.evaluate("(" + jsonDetail + ")");
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
{
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
qDebug("Error detected");
}
else
{
} else {
QScriptValue descriptionValues = sc.property("results").property("description");
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
detailLabel->setText(valid?descriptionValues.toString().replace("<a","<a style = 'color:#827A68; text-decoration:none;'"):tr("description unavailable"));
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
}
}
@ -181,5 +177,3 @@ QString SelectVolume::getSelectedVolumePublisher()
{
return model->getPublisher(proxyModel->mapToSource(tableVolumes->currentIndex()));
}

View File

@ -16,24 +16,24 @@ class SelectVolume : public ScraperSelector
{
Q_OBJECT
public:
SelectVolume(QWidget * parent = 0);
void load(const QString & json, const QString & searchString);
SelectVolume(QWidget *parent = 0);
void load(const QString &json, const QString &searchString);
virtual ~SelectVolume();
public slots:
void loadVolumeInfo(const QModelIndex & mi);
void loadVolumeInfo(const QModelIndex &mi);
void setCover(const QByteArray &);
void setDescription(const QString & jsonDetail);
void setDescription(const QString &jsonDetail);
QString getSelectedVolumeId();
int getSelectedVolumeNumIssues();
QString getSelectedVolumePublisher();
private:
QLabel * cover;
ScraperScrollLabel * detailLabel;
ScraperTableView * tableVolumes;
VolumesModel * model;
QSortFilterProxyModel * proxyModel;
QLabel *cover;
ScraperScrollLabel *detailLabel;
ScraperTableView *tableVolumes;
VolumesModel *model;
QSortFilterProxyModel *proxyModel;
};
#endif // SELECT_VOLUME_H

View File

@ -4,13 +4,12 @@
#include <QVBoxLayout>
#include <QLabel>
SeriesQuestion::SeriesQuestion(QWidget * parent)
:QWidget(parent)
SeriesQuestion::SeriesQuestion(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout * l = new QVBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
QLabel * questionLabel = new QLabel(tr("You are trying to get information for various comics at once, are they part of the same series?"));
QLabel *questionLabel = new QLabel(tr("You are trying to get information for various comics at once, are they part of the same series?"));
questionLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
yes = new QRadioButton(tr("yes"));
no = new QRadioButton(tr("no"));
@ -30,9 +29,9 @@ SeriesQuestion::SeriesQuestion(QWidget * parent)
l->addWidget(no);
l->addStretch();
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
}
bool SeriesQuestion::getYes()

View File

@ -10,14 +10,13 @@ class SeriesQuestion : public QWidget
Q_OBJECT
public:
SeriesQuestion(QWidget * parent = 0);
SeriesQuestion(QWidget *parent = 0);
bool getYes();
void setYes(bool yes = true);
private:
QRadioButton * yes;
QRadioButton * no;
QRadioButton *yes;
QRadioButton *no;
};
#endif // SERIES_QUESTION_H

View File

@ -10,15 +10,15 @@
#include "local_comic_list_model.h"
#include "volume_comics_model.h"
SortVolumeComics::SortVolumeComics(QWidget *parent) :
ScraperSelector(parent)
SortVolumeComics::SortVolumeComics(QWidget *parent)
: ScraperSelector(parent)
{
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
QLabel * label = new QLabel(tr("Please, sort the list of comics on the left until it matches the comics' information."));
QLabel *label = new QLabel(tr("Please, sort the list of comics on the left until it matches the comics' information."));
label->setStyleSheet(labelStylesheet);
QLabel * sortLabel = new QLabel(tr("sort comics to match comic information"));
QLabel *sortLabel = new QLabel(tr("sort comics to match comic information"));
sortLabel->setStyleSheet(labelStylesheet);
moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
@ -32,14 +32,14 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
//moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
//moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
connect(moveUpButtonCL,SIGNAL(clicked()),this,SLOT(moveUpCL()));
connect(moveDownButtonCL,SIGNAL(clicked()),this,SLOT(moveDownCL()));
connect(moveUpButtonCL, SIGNAL(clicked()), this, SLOT(moveUpCL()));
connect(moveDownButtonCL, SIGNAL(clicked()), this, SLOT(moveDownCL()));
//connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveUpIL()));
//connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveDownIL()));
QVBoxLayout * l = new QVBoxLayout;
QGridLayout * content = new QGridLayout;
QHBoxLayout * sortButtonsLayout = new QHBoxLayout;
QVBoxLayout *l = new QVBoxLayout;
QGridLayout *content = new QGridLayout;
QHBoxLayout *sortButtonsLayout = new QHBoxLayout;
tableFiles = new ScraperTableView();
tableVolumeComics = new ScraperTableView();
@ -79,13 +79,13 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
l->addLayout(content, 1);
l->addLayout(sortButtonsLayout, 0);
l->setContentsMargins(0,0,0,0);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
//rows actions
QAction * removeItemFromList = new QAction(tr("remove selected comics"),this);
QAction * restoreAllItems = new QAction(tr("restore all removed comics"),this);
QAction *removeItemFromList = new QAction(tr("remove selected comics"), this);
QAction *restoreAllItems = new QAction(tr("restore all removed comics"), this);
//QAction * restoreItems = new QAction(tr("restore removed comics"),this);
tableFiles->setContextMenuPolicy(Qt::ActionsContextMenu);
@ -93,12 +93,12 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
tableFiles->addAction(restoreAllItems);
//tableFiles->addAction(restoreItems);
connect(removeItemFromList,SIGNAL(triggered()),this,SLOT(removeSelectedComics()));
connect(restoreAllItems,SIGNAL(triggered()),this,SLOT(restoreAllComics()));
connect(removeItemFromList, SIGNAL(triggered()), this, SLOT(removeSelectedComics()));
connect(restoreAllItems, SIGNAL(triggered()), this, SLOT(restoreAllComics()));
//connect(restoreItems,SIGNAL(triggered()),this,SLOT(showRemovedComicsSelector()));
}
void SortVolumeComics::setData(QList<ComicDB> & comics, const QString &json, const QString &vID)
void SortVolumeComics::setData(QList<ComicDB> &comics, const QString &json, const QString &vID)
{
//set up models
localComicsModel = new LocalComicListModel;
@ -110,9 +110,9 @@ void SortVolumeComics::setData(QList<ComicDB> & comics, const QString &json, con
int numLocalComics = localComicsModel->rowCount();
int numVolumeComics = volumeComicsModel->rowCount();
if(numLocalComics > numVolumeComics)
if (numLocalComics > numVolumeComics)
volumeComicsModel->addExtraRows(numLocalComics - numVolumeComics);
if(numLocalComics < numVolumeComics)
if (numLocalComics < numVolumeComics)
localComicsModel->addExtraRows(numVolumeComics - numLocalComics);
tableFiles->setModel(localComicsModel);
@ -120,28 +120,25 @@ void SortVolumeComics::setData(QList<ComicDB> & comics, const QString &json, con
tableVolumeComics->resizeColumnToContents(0);
ScraperSelector::load(json,vID);
ScraperSelector::load(json, vID);
}
void SortVolumeComics::synchronizeScroll(int pos)
{
void * senderObject = sender();
void *senderObject = sender();
if(senderObject == 0) //invalid call
if (senderObject == 0) //invalid call
return;
QScrollBar * tableVolumeComicsScrollBar = tableVolumeComics->verticalScrollBar();
QScrollBar * tableFilesScrollBar = tableFiles->verticalScrollBar();
QScrollBar *tableVolumeComicsScrollBar = tableVolumeComics->verticalScrollBar();
QScrollBar *tableFilesScrollBar = tableFiles->verticalScrollBar();
if(senderObject == tableVolumeComicsScrollBar)
{
disconnect(tableFilesScrollBar,SIGNAL(valueChanged(int)),this,0);
if (senderObject == tableVolumeComicsScrollBar) {
disconnect(tableFilesScrollBar, SIGNAL(valueChanged(int)), this, 0);
tableFilesScrollBar->setValue(pos);
connect(tableFilesScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
}
else
{
disconnect(tableVolumeComicsScrollBar,SIGNAL(valueChanged(int)),this,0);
} else {
disconnect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, 0);
tableVolumeComicsScrollBar->setValue(pos);
connect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
}
@ -151,7 +148,7 @@ void SortVolumeComics::moveUpCL()
{
QList<QModelIndex> selection = tableFiles->selectionModel()->selectedIndexes();
if(selection.count() == 0)
if (selection.count() == 0)
return;
localComicsModel->moveSelectionUp(selection);
@ -164,8 +161,7 @@ void SortVolumeComics::moveDownCL()
{
QList<QModelIndex> selection = tableFiles->selectionModel()->selectedIndexes();
if(selection.count() > 0)
{
if (selection.count() > 0) {
localComicsModel->moveSelectionDown(selection);
selection = tableFiles->selectionModel()->selectedIndexes();
@ -175,12 +171,10 @@ void SortVolumeComics::moveDownCL()
void SortVolumeComics::moveUpIL()
{
}
void SortVolumeComics::moveDownIL()
{
}
void SortVolumeComics::removeSelectedComics()
@ -197,23 +191,21 @@ void SortVolumeComics::restoreAllComics()
void SortVolumeComics::showRemovedComicsSelector()
{
}
QList<QPair<ComicDB, QString> > SortVolumeComics::getMatchingInfo()
QList<QPair<ComicDB, QString>> SortVolumeComics::getMatchingInfo()
{
QList<ComicDB> comicList = localComicsModel->getData();
QList<QPair<ComicDB, QString> > l;
QList<QPair<ComicDB, QString>> l;
int index = 0;
QString id;
foreach(ComicDB c, comicList)
{
foreach (ComicDB c, comicList) {
id = volumeComicsModel->getComicId(index);
if(!c.getFileName().isEmpty() && !id.isEmpty()) //there is a valid comic, and valid comic ID
if (!c.getFileName().isEmpty() && !id.isEmpty()) //there is a valid comic, and valid comic ID
{
l.push_back(QPair<ComicDB, QString>(c,id));
l.push_back(QPair<ComicDB, QString>(c, id));
}
index++;
}

View File

@ -23,28 +23,34 @@ public:
RIGHT
};
ScrapperToolButton(ScrapperToolButton::Appearance appearance = DEFAULT, QWidget * parent=0):QPushButton(parent),appearance(appearance) {
ScrapperToolButton(ScrapperToolButton::Appearance appearance = DEFAULT, QWidget *parent = 0)
: QPushButton(parent), appearance(appearance)
{
setStyleSheet("QPushButton {border: none; background: #2e2e2e; color:white; border-radius:2px;}"
"QPushButton::pressed {border: none; background: #282828; color:white; border-radius:2px;}");
setFixedSize(18,17);
setFixedSize(18, 17);
}
static QWidget * getSeparator(){QWidget * w = new QWidget; w->setFixedWidth(1); w->setStyleSheet("QWidget {background:#282828;}"); return w;}
void setAppearance(ScrapperToolButton::Appearance appearance){this->appearance = appearance;}
static QWidget *getSeparator()
{
QWidget *w = new QWidget;
w->setFixedWidth(1);
w->setStyleSheet("QWidget {background:#282828;}");
return w;
}
void setAppearance(ScrapperToolButton::Appearance appearance) { this->appearance = appearance; }
virtual ~ScrapperToolButton() {}
protected:
void paintEvent(QPaintEvent * e)
void paintEvent(QPaintEvent *e)
{
QPainter p(this);
switch (appearance) {
case LEFT:
p.fillRect(16,0,2,18,QColor("#2E2E2E"));
p.fillRect(16, 0, 2, 18, QColor("#2E2E2E"));
break;
case RIGHT:
p.fillRect(0,0,2,18,QColor("#2E2E2E"));
p.fillRect(0, 0, 2, 18, QColor("#2E2E2E"));
break;
default:
break;
@ -57,7 +63,6 @@ private:
Appearance appearance;
};
class SortVolumeComics : public ScraperSelector
{
Q_OBJECT
@ -67,8 +72,8 @@ public:
signals:
public slots:
void setData(QList<ComicDB> & comics, const QString &json, const QString & vID);
QList<QPair<ComicDB,QString> > getMatchingInfo();
void setData(QList<ComicDB> &comics, const QString &json, const QString &vID);
QList<QPair<ComicDB, QString>> getMatchingInfo();
protected slots:
void synchronizeScroll(int pos);
@ -81,19 +86,17 @@ protected slots:
void restoreAllComics();
void showRemovedComicsSelector();
private:
ScraperTableView * tableFiles;
ScraperTableView * tableVolumeComics;
ScraperTableView *tableFiles;
ScraperTableView *tableVolumeComics;
LocalComicListModel * localComicsModel;
VolumeComicsModel * volumeComicsModel;
ScrapperToolButton * moveUpButtonCL;
ScrapperToolButton * moveDownButtonCL;
ScrapperToolButton * moveUpButtonIL;
ScrapperToolButton * moveDownButtonIL;
LocalComicListModel *localComicsModel;
VolumeComicsModel *volumeComicsModel;
ScrapperToolButton *moveUpButtonCL;
ScrapperToolButton *moveDownButtonCL;
ScrapperToolButton *moveUpButtonIL;
ScrapperToolButton *moveDownButtonIL;
};
#endif // SORT_VOLUME_COMICS_H

View File

@ -4,8 +4,8 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
TitleHeader::TitleHeader(QWidget * parent )
:QWidget(parent)
TitleHeader::TitleHeader(QWidget *parent)
: QWidget(parent)
{
mainTitleLabel = new QLabel();
subTitleLabel = new QLabel();
@ -13,41 +13,37 @@ TitleHeader::TitleHeader(QWidget * parent )
mainTitleLabel->setStyleSheet("QLabel {color:white; font-size:18px;font-family:Arial;}");
subTitleLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
QHBoxLayout * titleLayout = new QHBoxLayout;
QVBoxLayout * titleLabelsLayout = new QVBoxLayout;
QHBoxLayout *titleLayout = new QHBoxLayout;
QVBoxLayout *titleLabelsLayout = new QVBoxLayout;
titleLabelsLayout->addWidget(mainTitleLabel);
titleLabelsLayout->addWidget(subTitleLabel);
titleLabelsLayout->setSpacing(0);
titleLayout->addLayout(titleLabelsLayout);
titleLayout->setContentsMargins(0,0,0,0);
titleLayout->setContentsMargins(0, 0, 0, 0);
setLayout(titleLayout);
setContentsMargins(0,0,0,0);
setContentsMargins(0, 0, 0, 0);
setTitle(tr("SEARCH"));
}
void TitleHeader::setTitle(const QString & title)
void TitleHeader::setTitle(const QString &title)
{
mainTitleLabel->setText(title);
}
void TitleHeader::setSubTitle(const QString & title)
void TitleHeader::setSubTitle(const QString &title)
{
subTitleLabel->setText(title);
}
void TitleHeader::showButtons(bool show)
{
if(show)
{
}
else
{
if (show) {
} else {
}
}

View File

@ -9,14 +9,15 @@ class TitleHeader : public QWidget
{
Q_OBJECT
public:
TitleHeader(QWidget * parent = 0);
TitleHeader(QWidget *parent = 0);
public slots:
void setTitle(const QString & title);
void setSubTitle(const QString & title);
void setTitle(const QString &title);
void setSubTitle(const QString &title);
void showButtons(bool show);
private:
QLabel * mainTitleLabel;
QLabel * subTitleLabel;
QLabel *mainTitleLabel;
QLabel *subTitleLabel;
};
#endif // TITLE_HEADER_H

View File

@ -5,8 +5,8 @@
#include "QsLog.h"
ComicsRemover::ComicsRemover(QModelIndexList & il, QList<QString> & ps, qulonglong parentId, QObject *parent)
:QObject(parent),indexList(il), paths(ps), parentId(parentId)
ComicsRemover::ComicsRemover(QModelIndexList &il, QList<QString> &ps, qulonglong parentId, QObject *parent)
: QObject(parent), indexList(il), paths(ps), parentId(parentId)
{
}
@ -18,11 +18,10 @@ void ComicsRemover::process()
i.toBack();
i2.toBack();
while (i.hasPrevious() && i2.hasPrevious())
{
while (i.hasPrevious() && i2.hasPrevious()) {
QModelIndex mi = i.previous();
currentComicPath = i2.previous();
if(QFile::remove(currentComicPath))
if (QFile::remove(currentComicPath))
emit remove(mi.row());
else
emit removeError();
@ -32,11 +31,9 @@ void ComicsRemover::process()
emit removedItemsFromFolder(parentId);
}
FoldersRemover::FoldersRemover(QModelIndexList &il, QList<QString> &ps, QObject *parent)
:QObject(parent),indexList(il), paths(ps)
: QObject(parent), indexList(il), paths(ps)
{
}
void FoldersRemover::process()
@ -49,12 +46,11 @@ void FoldersRemover::process()
QLOG_DEBUG() << "Deleting folders" << paths.at(0);
while (i.hasPrevious() && i2.hasPrevious())
{
while (i.hasPrevious() && i2.hasPrevious()) {
QModelIndex mi = i.previous();
currentFolderPath = i2.previous();
QDir d(currentFolderPath);
if(d.removeRecursively() || !d.exists()) //the folder is in the DB but no in the drive...
if (d.removeRecursively() || !d.exists()) //the folder is in the DB but no in the drive...
emit remove(mi);
else
emit removeError();

View File

@ -10,7 +10,7 @@ class ComicsRemover : public QObject
{
Q_OBJECT
public:
explicit ComicsRemover(QModelIndexList & indexList, QList<QString> & paths, qulonglong parentId, QObject *parent = 0);
explicit ComicsRemover(QModelIndexList &indexList, QList<QString> &paths, qulonglong parentId, QObject *parent = 0);
signals:
void remove(int);
@ -31,7 +31,7 @@ class FoldersRemover : public QObject
{
Q_OBJECT
public:
explicit FoldersRemover(QModelIndexList & indexList, QList<QString> & paths, QObject *parent = 0);
explicit FoldersRemover(QModelIndexList &indexList, QList<QString> &paths, QObject *parent = 0);
signals:
void remove(QModelIndex);

View File

@ -8,8 +8,8 @@
#include <QtQuick>
#include <QQuickWidget>
ComicsView::ComicsView(QWidget *parent) :
QWidget(parent),model(NULL),comicDB(nullptr)
ComicsView::ComicsView(QWidget *parent)
: QWidget(parent), model(NULL), comicDB(nullptr)
{
setAcceptDrops(true);
}
@ -23,11 +23,12 @@ void ComicsView::updateInfoForIndex(int index)
{
QQmlContext *ctxt = view->rootContext();
if(comicDB != nullptr) delete comicDB;
if (comicDB != nullptr)
delete comicDB;
comicDB = new ComicDB(model->getComic(this->model->index(index, 0)));
ComicInfo *comicInfo = &(comicDB->info);
comicInfo->isFavorite = model->isFavorite(model->index(index,0));
comicInfo->isFavorite = model->isFavorite(model->index(index, 0));
ctxt->setContextProperty("comic", comicDB);
ctxt->setContextProperty("comicInfo", comicInfo);
@ -37,23 +38,19 @@ void ComicsView::updateInfoForIndex(int index)
void ComicsView::dragEnterEvent(QDragEnterEvent *event)
{
if(model->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
if (model->canDropMimeData(event->mimeData(), event->proposedAction(), 0, 0, QModelIndex()))
event->acceptProposedAction();
else
{
else {
QLOG_TRACE() << "dragEnterEvent";
QList<QUrl> urlList;
if (event->mimeData()->hasUrls() && event->dropAction() == Qt::CopyAction)
{
if (event->mimeData()->hasUrls() && event->dropAction() == Qt::CopyAction) {
urlList = event->mimeData()->urls();
QString currentPath;
foreach (QUrl url, urlList)
{
foreach (QUrl url, urlList) {
//comics or folders are accepted, folders' content is validate in dropEvent (avoid any lag before droping)
currentPath = url.toLocalFile();
if(Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir())
{
if (Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir()) {
event->acceptProposedAction();
return;
}
@ -66,20 +63,16 @@ void ComicsView::dropEvent(QDropEvent *event)
{
QLOG_DEBUG() << "drop" << event->dropAction();
bool validAction = event->dropAction() == Qt::CopyAction;// || event->dropAction() & Qt::MoveAction; TODO move
bool validAction = event->dropAction() == Qt::CopyAction; // || event->dropAction() & Qt::MoveAction; TODO move
if(event->mimeData()->hasUrls() && validAction)
{
if (event->mimeData()->hasUrls() && validAction) {
QList<QPair<QString, QString> > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
QList<QPair<QString, QString>> droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
if(event->dropAction() == Qt::CopyAction)
{
if (event->dropAction() == Qt::CopyAction) {
QLOG_DEBUG() << "copy :" << droppedFiles;
emit copyComicsToCurrentFolder(droppedFiles);
}
else if(event->dropAction() & Qt::MoveAction)
{
} else if (event->dropAction() & Qt::MoveAction) {
QLOG_DEBUG() << "move :" << droppedFiles;
emit moveComicsToCurrentFolder(droppedFiles);
}

View File

@ -17,15 +17,15 @@ class ComicsView : public QWidget
Q_OBJECT
public:
explicit ComicsView(QWidget *parent = 0);
virtual void setToolBar(QToolBar * toolBar) = 0;
virtual void setToolBar(QToolBar *toolBar) = 0;
virtual void setModel(ComicModel *model);
virtual void setCurrentIndex(const QModelIndex &index) = 0;
virtual QModelIndex currentIndex() = 0;
virtual QItemSelectionModel * selectionModel() = 0;
virtual void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint ) = 0;
virtual QItemSelectionModel *selectionModel() = 0;
virtual void scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint) = 0;
virtual void toFullScreen() = 0;
virtual void toNormal() = 0;
virtual void updateConfig(QSettings * settings) = 0;
virtual void updateConfig(QSettings *settings) = 0;
virtual void enableFilterMode(bool enabled) = 0;
virtual void selectIndex(int index) = 0;
virtual void updateCurrentComicView() = 0;
@ -37,19 +37,19 @@ public slots:
signals:
void selected(unsigned int);
void openComic(const ComicDB& comic);
void comicRated(int,QModelIndex);
void openComic(const ComicDB &comic);
void comicRated(int, QModelIndex);
//Context menus
void customContextMenuViewRequested(QPoint);
void customContextMenuItemRequested(QPoint);
//Drops
void copyComicsToCurrentFolder(QList<QPair<QString, QString> >);
void moveComicsToCurrentFolder(QList<QPair<QString, QString> >);
void copyComicsToCurrentFolder(QList<QPair<QString, QString>>);
void moveComicsToCurrentFolder(QList<QPair<QString, QString>>);
protected:
ComicModel * model;
ComicModel *model;
//Drop to import
void dragEnterEvent(QDragEnterEvent *event);
@ -61,7 +61,6 @@ protected:
ComicDB *comicDB;
private:
};
#endif // COMICS_VIEW_H

View File

@ -10,29 +10,28 @@
#include "yacreader_global_gui.h"
ComicsViewTransition::ComicsViewTransition(QWidget *parent) :
QWidget(parent)
ComicsViewTransition::ComicsViewTransition(QWidget *parent)
: QWidget(parent)
{
#ifdef Q_OS_MAC
setStyleSheet("QWidget {background:#FFFFFF}");
#else
setStyleSheet("QWidget {background:#2A2A2A}");
#endif
}
QSize ComicsViewTransition::sizeHint()
{
return QSize(450,350);
return QSize(450, 350);
}
void ComicsViewTransition::paintEvent(QPaintEvent *)
{
QPainter painter (this);
QPainter painter(this);
#ifdef Q_OS_MAC
painter.fillRect(0,0,width(),height(),QColor("#FFFFFF"));
painter.fillRect(0, 0, width(), height(), QColor("#FFFFFF"));
#else
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
painter.fillRect(0, 0, width(), height(), QColor("#2A2A2A"));
#endif
}

Some files were not shown because too many files have changed in this diff Show More