From b88715e26e79e3f6001aaa7cbb84ee85b8a1f9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 6 Oct 2013 18:13:27 +0200 Subject: [PATCH] removed current cover indicator from 'flow' enabled volume search in comic vine dialog --- YACReaderLibrary/comic_vine_dialog.cpp | 128 +++++++++++++++++++++++-- YACReaderLibrary/comic_vine_dialog.h | 44 ++++++++- common/comic_db.cpp | 9 ++ common/comic_db.h | 3 + common/pictureflow.cpp | 11 +-- common/yacreader_flow_gl.cpp | 11 +-- 6 files changed, 176 insertions(+), 30 deletions(-) diff --git a/YACReaderLibrary/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine_dialog.cpp index c33ca73a..0b4c3ab3 100644 --- a/YACReaderLibrary/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine_dialog.cpp @@ -26,10 +26,16 @@ void ComicVineDialog::doLayout() QString dialogButtonsStyleSheet = "QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}"; + skipButton = new QPushButton(tr("skip")); + backButton = new QPushButton(tr("back")); nextButton = new QPushButton(tr("next")); + searchButton = new QPushButton(tr("search")); closeButton = new QPushButton(tr("close")); + skipButton->setStyleSheet(dialogButtonsStyleSheet); + backButton->setStyleSheet(dialogButtonsStyleSheet); nextButton->setStyleSheet(dialogButtonsStyleSheet); + searchButton->setStyleSheet(dialogButtonsStyleSheet); closeButton->setStyleSheet(dialogButtonsStyleSheet); content = new QStackedWidget(this); @@ -39,7 +45,10 @@ void ComicVineDialog::doLayout() QHBoxLayout * buttonLayout = new QHBoxLayout; buttonLayout->addStretch(); + buttonLayout->addWidget(skipButton); + buttonLayout->addWidget(backButton); buttonLayout->addWidget(nextButton); + buttonLayout->addWidget(searchButton); buttonLayout->addWidget(closeButton); buttonLayout->setContentsMargins(0,0,0,0); @@ -60,13 +69,13 @@ void ComicVineDialog::doStackedWidgets() content->addWidget(seriesQuestion = new SeriesQuestion); content->addWidget(searchSingleComic = new SearchSingleComic); content->addWidget(searchVolume = new SearchVolume); - } void ComicVineDialog::doConnections() { - connect(closeButton,SIGNAL(pressed()),this,SLOT(close())); - connect(nextButton,SIGNAL(pressed()),this,SLOT(goNext())); + connect(closeButton,SIGNAL(clicked()),this,SLOT(close())); + connect(nextButton,SIGNAL(clicked()),this,SLOT(goNext())); + connect(searchButton,SIGNAL(clicked()),this,SLOT(search())); connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString))); } @@ -78,14 +87,28 @@ void ComicVineDialog::goNext() { if(seriesQuestion->getYes()) { - content->setCurrentWidget(searchVolume); + QString volumeSearchString = comics[0].getParentFolderName(); + + if(volumeSearchString.isEmpty()) + showSearchVolume(); + else + { + showLoading(); + comicVineClient->search(volumeSearchString); + } + + status = Volume; } else { ComicDB comic = comics[currentIndex]; QString title = comic.getTitleOrPath(); titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title)); - content->setCurrentWidget(searchSingleComic); + showLoading(); + + comicVineClient->search(title); + + status = SingleComicInSeries; } } else if (content->currentWidget() == searchSingleComic) { @@ -109,13 +132,15 @@ void ComicVineDialog::show() ComicDB singleComic = comics[0]; QString title = singleComic.getTitleOrPath(); titleHeader->setSubTitle(title); - content->setCurrentIndex(0); + showLoading(); comicVineClient->search(title); + + status = SingleComic; }else if(comics.length()>1) { titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length())); - content->setCurrentWidget(seriesQuestion); + showSeriesQuestion(); } } @@ -139,9 +164,76 @@ void ComicVineDialog::doLoading() void ComicVineDialog::debugClientResults(const QString & string) { - content->setCurrentWidget(searchSingleComic); - QMessageBox::information(0,"-Response-", string); + switch(status) + { + case SingleComic: + showSearchSingleComic(); + break; + case Volume: + showSearchVolume(); + break; + case SingleComicInSeries: + showSearchSingleComic(); + break; + } + QMessageBox::information(0,"-Response-", string); +} + +void ComicVineDialog::showSeriesQuestion() +{ + content->setCurrentWidget(seriesQuestion); + backButton->setHidden(true); + skipButton->setHidden(true); + nextButton->setVisible(true); + searchButton->setHidden(true); + closeButton->setVisible(true); +} + +void ComicVineDialog::showSearchSingleComic() +{ + content->setCurrentWidget(searchSingleComic); + backButton->setHidden(true); + skipButton->setHidden(true); + nextButton->setHidden(true); + searchButton->setVisible(true); + closeButton->setVisible(true); +} + +void ComicVineDialog::showSearchVolume() +{ + content->setCurrentWidget(searchVolume); + backButton->setHidden(true); + nextButton->setHidden(true); + searchButton->setVisible(true); + closeButton->setVisible(true); + + if (status == SingleComicInSeries) + skipButton->setVisible(true); + else + skipButton->setHidden(true); +} + +void ComicVineDialog::showLoading() +{ + content->setCurrentIndex(0); + backButton->setHidden(true); + skipButton->setHidden(true); + nextButton->setHidden(true); + searchButton->setHidden(true); + closeButton->setVisible(true); +} + +void ComicVineDialog::search() +{ + switch (status) { + case Volume: + showLoading(); + comicVineClient->search(searchVolume->getVolumeInfo()); + break; + default: + break; + } } //--------------------------------------- @@ -308,3 +400,21 @@ SearchVolume::SearchVolume(QWidget * parent) setLayout(l); setContentsMargins(0,0,0,0); } + +//--------------------------------------- +//SelectVolume +//--------------------------------------- +SelectVolume::SelectVolume(QWidget *parent) + :QWidget(parent) +{} + +SelectVolume::~SelectVolume() {} + +//--------------------------------------- +//SelectComic +//--------------------------------------- +SelectComic::SelectComic(QWidget *parent) + :QWidget(parent) +{} + +SelectComic::~SelectComic() {} diff --git a/YACReaderLibrary/comic_vine_dialog.h b/YACReaderLibrary/comic_vine_dialog.h index ab8a21ad..36af2ca8 100644 --- a/YACReaderLibrary/comic_vine_dialog.h +++ b/YACReaderLibrary/comic_vine_dialog.h @@ -62,16 +62,36 @@ private: ScrapperLineEdit * volumeEdit; }; -//---------------------------------------- +//--------------------------------------- class SearchVolume : public QWidget { Q_OBJECT public: SearchVolume(QWidget * parent = 0); +public slots: + QString getVolumeInfo() {return volumeEdit->text();} private: ScrapperLineEdit * volumeEdit; }; +//--------------------------------------- +class SelectComic : public QWidget +{ + Q_OBJECT +public: + SelectComic(QWidget * parent = 0); + virtual ~SelectComic(); +}; + +//--------------------------------------- +class SelectVolume : public QWidget +{ + Q_OBJECT +public: + SelectVolume(QWidget * parent = 0); + virtual ~SelectVolume(); +}; + //---------------------------------------- class ComicVineDialog : public QDialog { @@ -88,13 +108,33 @@ public slots: protected slots: void goNext(); void debugClientResults(const QString & string); + //show widget methods + void showSeriesQuestion(); + void showSearchSingleComic(); + void showSearchVolume(); + void showLoading(); + void search(); private: + + enum ScrapperStatus + { + SingleComic, + Volume, + SingleComicInSeries + }; + + ScrapperStatus status; + ComicVineClient * comicVineClient; int currentIndex; TitleHeader * titleHeader; - QPushButton * nextButton; + + QPushButton * skipButton; + QPushButton * backButton; + QPushButton * nextButton; + QPushButton * searchButton; QPushButton * closeButton; //stacked widgets diff --git a/common/comic_db.cpp b/common/comic_db.cpp index 10e4dc22..06093f05 100644 --- a/common/comic_db.cpp +++ b/common/comic_db.cpp @@ -116,6 +116,15 @@ QString ComicDB::getTitleOrPath() return QFileInfo(path).fileName(); } +QString ComicDB::getParentFolderName() +{ + QStringList paths = path.split('/'); + if(paths.length()<2) + return ""; + else + return paths[paths.length()-2]; +} + //----------------------------------------------------------------------------- //COMIC_INFO------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/common/comic_db.h b/common/comic_db.h index 7931258c..ffabc8e7 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -135,6 +135,9 @@ public: //returns comic title if it isn't null or empty, in other case returns fileName QString getTitleOrPath(); + //returns parent folder name + QString getParentFolderName(); + QString toTXT(); ComicInfo info; diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index 52c6dd45..e0f4f032 100644 --- a/common/pictureflow.cpp +++ b/common/pictureflow.cpp @@ -934,17 +934,8 @@ void PictureFlowSoftwareRenderer::render() renderSlides(); if(state->slideImages.size()>0) { - int x = buffer.width()/2; - int size = buffer.width() * 0.021; + int size = buffer.width() * 0.015; int start = buffer.width() * 0.010; - for(int j = start; jbackgroundColor); - for(int i = 0; ibackgroundColor); - buffer.setPixel(QPoint(x+i,j),QColor(255,255,255).rgb()-state->backgroundColor); - } - } QPainter painter(&buffer); painter.setPen(QColor(255,255,255).rgb()-state->backgroundColor); diff --git a/common/yacreader_flow_gl.cpp b/common/yacreader_flow_gl.cpp index a2114af2..cdd302e0 100644 --- a/common/yacreader_flow_gl.cpp +++ b/common/yacreader_flow_gl.cpp @@ -306,7 +306,7 @@ void YACReaderFlowGL::paintGL() void YACReaderFlowGL::resizeGL(int width, int height) { - fontSize = width * 0.02; + fontSize = width * 0.015; //int side = qMin(width, height); udpatePerspective(width,height); @@ -529,14 +529,7 @@ void YACReaderFlowGL::draw() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glBegin( GL_TRIANGLES ); - glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - glVertex2f( -0.03f, 0.98f); - glVertex2f( 0.03f, 0.98f); - glVertex2f( 0.f, 0.949f); - - glEnd(); renderText(10, fontSize + 10,QString("%1/%2").arg(currentSelected+1).arg(numObjects),QFont("Arial", fontSize)); @@ -1453,4 +1446,4 @@ QImage ImageLoaderByteArrayGL::result() // flow->cfImages[index].width = 0.5; // flow->cfImages[index].height = 0.5 * (float(image.height())/image.width()); // flow->cfImages[index].img = bindTexture(image, GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); -//} \ No newline at end of file +//}