From 1728f85cc0c8a99da129b3afe33e9f551eb08e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 17 Jul 2013 11:12:24 +0200 Subject: [PATCH] YACReaderLibrary opens now its own viewer windows --- YACReader/YACReader.pro | 103 +----------------- YACReader/main_window_viewer.cpp | 44 ++++++++ YACReader/main_window_viewer.h | 9 +- YACReader/{files.qrc => yacreader_files.qrc} | 0 .../{images.qrc => yacreader_images.qrc} | 0 ...mages_osx.qrc => yacreader_images_osx.qrc} | 0 ...mages_win.qrc => yacreader_images_win.qrc} | 0 YACReaderLibrary/YACReaderLibrary.pro | 2 + YACReaderLibrary/db/tablemodel.cpp | 19 ++++ YACReaderLibrary/db/tablemodel.h | 1 + YACReaderLibrary/library_window.cpp | 24 ++-- YACReaderLibrary/main.cpp | 5 + common/comic_db.h | 2 + 13 files changed, 98 insertions(+), 111 deletions(-) rename YACReader/{files.qrc => yacreader_files.qrc} (100%) rename YACReader/{images.qrc => yacreader_images.qrc} (100%) rename YACReader/{images_osx.qrc => yacreader_images_osx.qrc} (100%) rename YACReader/{images_win.qrc => yacreader_images_win.qrc} (100%) diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 33f2f3e6..4bcc2061 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -5,108 +5,9 @@ TEMPLATE = app TARGET = DEPENDPATH += . \ release -INCLUDEPATH += . -INCLUDEPATH += ../common \ - ../custom_widgets -win32 { -INCLUDEPATH += ../dependencies/poppler/include -LIBS += -L../dependencies/poppler/lib -lpoppler-qt4 -QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL -QMAKE_LFLAGS_RELEASE += /LTCG -CONFIG -= embed_manifest_exe -} - -unix:!macx{ -INCLUDEPATH += /usr/include/poppler/qt4 -LIBS += -L/usr/lib -lpoppler-qt4 -LIBS += -lGLU -} - -macx{ -#INCLUDEPATH += "/Volumes/Mac OS X Lion/usr/X11/include" -INCLUDEPATH += /usr/local/include/poppler/qt4 -LIBS += -L/usr/local/lib -lpoppler-qt4 -} - -QT += network phonon opengl -CONFIG += release -CONFIG -= flat - -# Input -HEADERS += comic.h \ - configuration.h \ - goto_dialog.h \ - magnifying_glass.h \ - main_window_viewer.h \ - viewer.h \ - goto_flow.h \ - options_dialog.h \ - bookmarks.h \ - bookmarks_dialog.h \ - render.h \ - shortcuts_dialog.h \ - translator.h \ - goto_flow_gl.h \ - goto_flow_widget.h \ - page_label_widget.h \ - goto_flow_toolbar.h \ - goto_flow_decorationbar.h \ - width_slider.h \ - notifications_label_widget.h \ - ../common/pictureflow.h \ - ../common/custom_widgets.h \ - ../common/check_new_version.h \ - ../common/qnaturalsorting.h \ - ../common/yacreader_flow_gl.h \ - ../common/yacreader_global.h \ - ../common/onstart_flow_selection_dialog.h \ - ../common/comic_db.h \ - ../common/folder.h \ - ../common/library_item.h \ - yacreader_local_client.h - -SOURCES += comic.cpp \ - configuration.cpp \ - goto_dialog.cpp \ - magnifying_glass.cpp \ - main.cpp \ - main_window_viewer.cpp \ - viewer.cpp \ - goto_flow.cpp \ - options_dialog.cpp \ - bookmarks.cpp \ - bookmarks_dialog.cpp \ - render.cpp \ - shortcuts_dialog.cpp \ - translator.cpp \ - goto_flow_gl.cpp \ - goto_flow_widget.cpp \ - page_label_widget.cpp \ - goto_flow_toolbar.cpp \ - goto_flow_decorationbar.cpp \ - width_slider.cpp \ - notifications_label_widget.cpp \ - ../common/pictureflow.cpp \ - ../common/custom_widgets.cpp \ - ../common/check_new_version.cpp \ - ../common/qnaturalsorting.cpp \ - ../common/yacreader_flow_gl.cpp \ - ../common/onstart_flow_selection_dialog.cpp \ - ../common/comic_db.cpp \ - ../common/folder.cpp \ - ../common/library_item.cpp \ - yacreader_local_client.cpp - -include(../custom_widgets/custom_widgets.pri) -include(../compressed_archive/wrapper.pri) - -RESOURCES += images.qrc \ - files.qrc - -win32:RESOURCES += images_win.qrc -unix:!macx:RESOURCES += images_win.qrc -macx:RESOURCES += images_osx.qrc +SOURCES += main.cpp +include(YACReader.pri) RC_FILE = icon.rc diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 300a8ead..540ff1c5 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -558,6 +558,34 @@ void MainWindowViewer::open() } } +void MainWindowViewer::open(QString path, ComicDB & comic, QList & siblings) +{ + currentComicDB = comic; + siblingComics = siblings; + + QFileInfo fi(path); + currentDirectory = fi.absoluteDir().path(); + + if(comic.info.title != 0 && !comic.info.title->isEmpty()) + setWindowTitle("YACReader - " + *comic.info.title); + else + setWindowTitle("YACReader - " + fi.fileName()); + + viewer->open(path); + enableActions(); + int index = siblings.indexOf(comic); + + if(index>0) + openPreviousComicAction->setDisabled(false); + else + openPreviousComicAction->setDisabled(true); + + if(index+1setDisabled(false); + else + openNextComicAction->setDisabled(true); +} + void MainWindowViewer::openComicFromPath(QString pathFile) { currentDirectory = pathFile; @@ -795,10 +823,19 @@ void MainWindowViewer::closeEvent ( QCloseEvent * event ) conf.setSize(size()); } conf.setMaximized(isMaximized()); + + emit (closed()); } void MainWindowViewer::openPreviousComic() { + if(!siblingComics.isEmpty()) + { + int currentIndex = siblingComics.indexOf(currentComicDB); + ComicDB previoiusComic = siblingComics.at(currentIndex-1); + open(currentDirectory+previoiusComic.path,previoiusComic,siblingComics); + return; + } if(!previousComicPath.isEmpty()) { viewer->open(previousComicPath); @@ -811,6 +848,13 @@ void MainWindowViewer::openPreviousComic() void MainWindowViewer::openNextComic() { + if(!siblingComics.isEmpty()) + { + int currentIndex = siblingComics.indexOf(currentComicDB); + ComicDB nextComic = siblingComics.at(currentIndex+1); + open(currentDirectory+nextComic.path,nextComic,siblingComics); + return; + } if(!nextComicPath.isEmpty()) { viewer->open(nextComicPath); diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index d509b559..5c790d8c 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -9,6 +9,8 @@ #include #include +#include "comic_db.h" + class Comic; class Viewer; class OptionsDialog; @@ -23,6 +25,7 @@ class YACReaderSliderAction; public slots: void open(); + void open(QString path, ComicDB & comic, QList & siblings); void openFolder(); void saveImage(); void toggleToolBars(); @@ -115,7 +118,11 @@ class YACReaderSliderAction; void dragEnterEvent(QDragEnterEvent *event); QSettings * settings; - + + ComicDB currentComicDB; + QList siblingComics; +signals: + void closed(); protected: virtual void closeEvent ( QCloseEvent * event ); public: diff --git a/YACReader/files.qrc b/YACReader/yacreader_files.qrc similarity index 100% rename from YACReader/files.qrc rename to YACReader/yacreader_files.qrc diff --git a/YACReader/images.qrc b/YACReader/yacreader_images.qrc similarity index 100% rename from YACReader/images.qrc rename to YACReader/yacreader_images.qrc diff --git a/YACReader/images_osx.qrc b/YACReader/yacreader_images_osx.qrc similarity index 100% rename from YACReader/images_osx.qrc rename to YACReader/yacreader_images_osx.qrc diff --git a/YACReader/images_win.qrc b/YACReader/yacreader_images_win.qrc similarity index 100% rename from YACReader/images_win.qrc rename to YACReader/yacreader_images_win.qrc diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 80a3e209..2fde29e3 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -127,6 +127,8 @@ win32:RESOURCES += images_win.qrc unix:!macx:RESOURCES += images_win.qrc macx:RESOURCES += images_osx.qrc +include(../YACReader/YACReader.pri) + RC_FILE = icon.rc macx { diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp index 7baf0763..3509f9b1 100644 --- a/YACReaderLibrary/db/tablemodel.cpp +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -394,6 +394,25 @@ QVector TableModel::setAllComicsRead(bool read) return readList; } +QList TableModel::getAllComics() +{ + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + db.transaction(); + + QList comics; + int numComics = _data.count(); + for(int i=0;idata(ID).toULongLong(),db)); + } + + db.commit(); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + + return comics; +} + QList TableModel::getComics(QList list) { QList comics; diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h index fe1cea32..cc081db2 100644 --- a/YACReaderLibrary/db/tablemodel.h +++ b/YACReaderLibrary/db/tablemodel.h @@ -41,6 +41,7 @@ public: QVector getReadList(); QVector setAllComicsRead(bool read); QList getComics(QList list); //--> recupera la información común a los comics seleccionados + QList getAllComics(); QModelIndex getIndexFromId(quint64 id); //setcomicInfo(QModelIndex & mi); --> inserta en la base datos //setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez. diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 5b166716..5811cbf4 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -55,7 +55,7 @@ #include "comics_remover.h" #include "yacreader_library_list_widget.h" #include "yacreader_treeview.h" - +#include "main_window_viewer.h" //#include "yacreader_social_dialog.h" // @@ -1006,19 +1006,25 @@ void LibraryWindow::openComic() { ComicDB comic = dmCV->getComic(comicView->currentIndex()); QString path = currentPath() + comic.path; + MainWindowViewer * viewer = new MainWindowViewer(); + QList siblings = dmCV->getAllComics(); + viewer->open(path,comic,siblings); + viewer->show(); + + connect(viewer,SIGNAL(closed()),viewer,SLOT(deleteLater())); /*quint64 comicId = comic.id; //TODO generate IDS for libraries... quint64 libraryId = selectedLibrary->currentIndex(); int page = *(comic.info.numPages) / 2;*/ -#ifdef Q_OS_MAC - - QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path /*<< comicId << libraryId << page*/);//,QStringList() << path); - //Comic is readed -#else - - QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\"").arg(path)/*.arg(comicId).arg(libraryId).arg(page)*/,QStringList()); -#endif +//#ifdef Q_OS_MAC +// +// QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path /*<< comicId << libraryId << page*/);//,QStringList() << path); +// //Comic is readed +//#else +// +// QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\"").arg(path)/*.arg(comicId).arg(libraryId).arg(page)*/,QStringList()); +//#endif //Comic is readed setCurrentComicReaded(); } diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index dbcff307..4dc5ba7d 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -8,6 +8,7 @@ #include "yacreader_global.h" #include "startup.h" #include "yacreader_local_server.h" + #define PICTUREFLOW_QT4 1 //interfaz al servidor @@ -21,6 +22,10 @@ int main( int argc, char ** argv ) QString sufix = QLocale::system().name(); translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix); app.installTranslator(&translator); + + QTranslator viewerTranslator; + viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix); + app.installTranslator(&viewerTranslator); app.setApplicationName("YACReaderLibrary"); #ifdef SERVER_RELEASE diff --git a/common/comic_db.h b/common/comic_db.h index b9fed60f..0df4abca 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -120,6 +120,8 @@ public: ComicInfo info; + bool operator==(const ComicDB & other){return id == other.id;}; + friend QDataStream &operator<<(QDataStream &, const ComicDB &); friend QDataStream &operator>>(QDataStream &, ComicDB &); };