diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 5c39295a..5f26d395 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -99,38 +99,39 @@ CONFIG -= flat QT += multimedia # Input -HEADERS += ../common/comic.h \ - configuration.h \ - goto_dialog.h \ - magnifying_glass.h \ - main_window_viewer.h \ - viewer.h \ - goto_flow.h \ - options_dialog.h \ - ../common/bookmarks.h \ - bookmarks_dialog.h \ - render.h \ - shortcuts_dialog.h \ - translator.h \ - goto_flow_widget.h \ - page_label_widget.h \ - goto_flow_toolbar.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_global.h \ - ../common/onstart_flow_selection_dialog.h \ - ../common/comic_db.h \ - ../common/folder.h \ - ../common/library_item.h \ - yacreader_local_client.h \ - ../common/http_worker.h \ - ../common/exit_check.h \ - ../common/scroll_management.h \ - ../common/opengl_checker.h +HEADERS += ../common/comic.h \ + configuration.h \ + goto_dialog.h \ + magnifying_glass.h \ + main_window_viewer.h \ + viewer.h \ + goto_flow.h \ + options_dialog.h \ + ../common/bookmarks.h \ + bookmarks_dialog.h \ + render.h \ + shortcuts_dialog.h \ + translator.h \ + goto_flow_widget.h \ + page_label_widget.h \ + goto_flow_toolbar.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_global.h \ + ../common/yacreader_global_gui.h \ + ../common/onstart_flow_selection_dialog.h \ + ../common/comic_db.h \ + ../common/folder.h \ + ../common/library_item.h \ + yacreader_local_client.h \ + ../common/http_worker.h \ + ../common/exit_check.h \ + ../common/scroll_management.h \ + ../common/opengl_checker.h !CONFIG(no_opengl) { CONFIG(legacy_gl_widget) { @@ -142,38 +143,39 @@ HEADERS += ../common/comic.h \ HEADERS += goto_flow_gl.h } -SOURCES += ../common/comic.cpp \ - configuration.cpp \ - goto_dialog.cpp \ - magnifying_glass.cpp \ - main_window_viewer.cpp \ - viewer.cpp \ - goto_flow.cpp \ - options_dialog.cpp \ - ../common/bookmarks.cpp \ - bookmarks_dialog.cpp \ - render.cpp \ - shortcuts_dialog.cpp \ - translator.cpp \ - goto_flow_widget.cpp \ - page_label_widget.cpp \ - goto_flow_toolbar.cpp \ - width_slider.cpp \ - notifications_label_widget.cpp \ - ../common/pictureflow.cpp \ - ../common/custom_widgets.cpp \ - ../common/check_new_version.cpp \ - ../common/qnaturalsorting.cpp \ - ../common/onstart_flow_selection_dialog.cpp \ - ../common/comic_db.cpp \ - ../common/folder.cpp \ - ../common/library_item.cpp \ - yacreader_local_client.cpp \ - ../common/http_worker.cpp \ - ../common/yacreader_global.cpp \ - ../common/exit_check.cpp \ - ../common/scroll_management.cpp \ - ../common/opengl_checker.cpp +SOURCES += ../common/comic.cpp \ + configuration.cpp \ + goto_dialog.cpp \ + magnifying_glass.cpp \ + main_window_viewer.cpp \ + viewer.cpp \ + goto_flow.cpp \ + options_dialog.cpp \ + ../common/bookmarks.cpp \ + bookmarks_dialog.cpp \ + render.cpp \ + shortcuts_dialog.cpp \ + translator.cpp \ + goto_flow_widget.cpp \ + page_label_widget.cpp \ + goto_flow_toolbar.cpp \ + width_slider.cpp \ + notifications_label_widget.cpp \ + ../common/pictureflow.cpp \ + ../common/custom_widgets.cpp \ + ../common/check_new_version.cpp \ + ../common/qnaturalsorting.cpp \ + ../common/onstart_flow_selection_dialog.cpp \ + ../common/comic_db.cpp \ + ../common/folder.cpp \ + ../common/library_item.cpp \ + yacreader_local_client.cpp \ + ../common/http_worker.cpp \ + ../common/yacreader_global.cpp \ + ../common/yacreader_global_gui.cpp \ + ../common/exit_check.cpp \ + ../common/scroll_management.cpp \ + ../common/opengl_checker.cpp !CONFIG(no_opengl) { CONFIG(legacy_gl_widget) { diff --git a/YACReader/configuration.h b/YACReader/configuration.h index 384595dd..bc3a4be0 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -8,7 +8,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" #define CONF_FILE_PATH "." #define SLIDE_ASPECT_RATIO 1.585 diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h index 6609b854..53176d1c 100644 --- a/YACReader/goto_flow.h +++ b/YACReader/goto_flow.h @@ -2,6 +2,8 @@ #define __GOTO_FLOW_H #include "goto_flow_widget.h" +#include "yacreader_global_gui.h" + #include #include diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h index c7afbbef..fbb05028 100644 --- a/YACReader/goto_flow_widget.h +++ b/YACReader/goto_flow_widget.h @@ -3,7 +3,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" using namespace YACReader; diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 87cab589..fd8f636b 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -10,7 +10,7 @@ #include #include "comic_db.h" -#include "yacreader_global.h" +#include "yacreader_global_gui.h" template inline const T& kClamp( const T& x, const T& low, const T& high ) diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 917babd7..15d78d9f 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -118,6 +118,7 @@ HEADERS += comic_flow.h \ ../common/custom_widgets.h \ ../common/qnaturalsorting.h \ ../common/yacreader_global.h \ + ../common/yacreader_global_gui.h \ ../common/onstart_flow_selection_dialog.h \ no_libraries_widget.h \ import_widget.h \ @@ -194,6 +195,7 @@ SOURCES += comic_flow.cpp \ comics_remover.cpp \ ../common/http_worker.cpp \ ../common/yacreader_global.cpp \ + ../common/yacreader_global_gui.cpp \ yacreader_libraries.cpp \ ../common/exit_check.cpp \ comics_view.cpp \ diff --git a/YACReaderLibrary/YACReaderLibraryServer.pro b/YACReaderLibrary/YACReaderLibraryServer.pro new file mode 100644 index 00000000..bb5cf73c --- /dev/null +++ b/YACReaderLibrary/YACReaderLibraryServer.pro @@ -0,0 +1,164 @@ +###################################################################### +# Automatically generated by qmake (2.01a) dom 12. oct 20:47:48 2008 +###################################################################### + +TEMPLATE = app +TARGET = YACReaderLibraryServer +CONFIG += console +DEPENDPATH += . +INCLUDEPATH += . +INCLUDEPATH += ../common \ + ./server \ + ./db + +DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY QT_NO_DEBUG_OUTPUT + +#load default build flags +#TODO include (../config.pri) +!CONFIG(unarr):!CONFIG(7zip) { + unix { + !macx { + CONFIG+=unarr + } + else { + CONFIG+=7zip + } + + } + win32 { + CONFIG+=7zip + } +} + +win32 { + LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -luser32 + LIBS += -lpoppler-qt5 + INCLUDEPATH += ../dependencies/poppler/include/qt5 + + QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL + QMAKE_LFLAGS_RELEASE += /LTCG + CONFIG -= embed_manifest_exe +} + +unix:!macx{ +INCLUDEPATH += /usr/include/poppler/qt5 +LIBS += -L/usr/lib -lpoppler-qt5 +} + +macx{ +LIBS += -framework Foundation -framework ApplicationServices -framework AppKit + +OBJECTIVE_SOURCES += $$PWD/../common/pdf_comic.mm +HEADERS += $$PWD/../common/pdf_comic.h +CONFIG += objective_c +} + +unix{ +CONFIG += c++11 +} + +#CONFIG += release +CONFIG -= flat +QT += core sql network script + +# Input +HEADERS += library_creator.h \ + package_manager.h \ + bundle_creator.h \ + db_helper.h \ + ./db/data_base_management.h \ + ../common/comic_db.h \ + ../common/folder.h \ + ../common/library_item.h \ + ../common/comic.h \ + ../common/bookmarks.h \ + ../common/qnaturalsorting.h \ + ../common/yacreader_global.h \ + yacreader_local_server.h \ + comics_remover.h \ + ../common/http_worker.h \ + yacreader_libraries.h \ + comic_files_manager.h \ + headless/console_ui_library_creator.h + + +SOURCES += library_creator.cpp \ + .\headless\main.cpp \ + package_manager.cpp \ + bundle_creator.cpp \ + db_helper.cpp \ + ./db/data_base_management.cpp \ + ../common/comic_db.cpp \ + ../common/folder.cpp \ + ../common/library_item.cpp \ + ../common/comic.cpp \ + ../common/bookmarks.cpp \ + ../common/qnaturalsorting.cpp \ + yacreader_local_server.cpp \ + comics_remover.cpp \ + ../common/http_worker.cpp \ + ../common/yacreader_global.cpp \ + yacreader_libraries.cpp \ + comic_files_manager.cpp \ + headless/console_ui_library_creator.cpp + + +include(./server/server.pri) +CONFIG(7zip){ +include(../compressed_archive/wrapper.pri) +} else:CONFIG(unarr) { +include(../compressed_archive/unarr/unarr-wrapper.pri) +} else { + error(No compression backend specified. Did you mess with the build system?) +} +include(../QsLog/QsLog.pri) + + +TRANSLATIONS = yacreaderlibraryserver_es.ts \ + yacreaderlibraryserver_ru.ts \ + yacreaderlibraryserver_pt.ts \ + yacreaderlibraryserver_fr.ts \ + yacreaderlibraryserver_nl.ts \ + yacreaderlibraryserver_tr.ts \ + yacreaderlibraryserver_de.ts \ + yacreaderlibraryserver_source.ts + + +RESOURCES += headless/images.qrc + + +Release:DESTDIR = ../release +Debug:DESTDIR = ../debug + + +unix:!macx { +#set install prefix if it's empty +isEmpty(PREFIX) { + PREFIX = /usr +} + +BINDIR = $$PREFIX/bin +LIBDIR = $$PREFIX/lib +DATADIR = $$PREFIX/share + +DEFINES += "LIBDIR=\\\"$$LIBDIR\\\"" "DATADIR=\\\"$$DATADIR\\\"" "BINDIR=\\\"$$BINDIR\\\"" + +#MAKE INSTALL +INSTALLS += bin icon desktop server translation manpage + +bin.path = $$BINDIR +isEmpty(DESTDIR) { + bin.files = YACReaderLibrary +} else { + bin.files = $$DESTDIR/YACReaderLibrary +} + +server.path = $$DATADIR/yacreader +server.files = ../release/server + +translation.path = $$DATADIR/yacreader/languages +translation.files = ../release/languages/yacreaderlibrary_* + +manpage.path = $$DATADIR/man/man1 +manpage.files = ../YACReaderLibrary.1 +} diff --git a/YACReaderLibrary/comic_vine/api_key_dialog.cpp b/YACReaderLibrary/comic_vine/api_key_dialog.cpp index 355ecd0e..0e1b326b 100644 --- a/YACReaderLibrary/comic_vine/api_key_dialog.cpp +++ b/YACReaderLibrary/comic_vine/api_key_dialog.cpp @@ -7,7 +7,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" ApiKeyDialog::ApiKeyDialog(QWidget *parent) : QDialog(parent) diff --git a/YACReaderLibrary/comic_vine/comic_vine_client.cpp b/YACReaderLibrary/comic_vine/comic_vine_client.cpp index cb36d3ca..409ec8c3 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_client.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_client.cpp @@ -1,4 +1,5 @@ #include "comic_vine_client.h" +#include "yacreader_global_gui.h" //this is the API key used by YACReader to access Comic Vine //please, do not use it in your own software, get one for free at Comic Vine diff --git a/YACReaderLibrary/comics_view_transition.cpp b/YACReaderLibrary/comics_view_transition.cpp index 6734d479..a41e1070 100644 --- a/YACReaderLibrary/comics_view_transition.cpp +++ b/YACReaderLibrary/comics_view_transition.cpp @@ -8,7 +8,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" ComicsViewTransition::ComicsViewTransition(QWidget *parent) : QWidget(parent),movie(0) diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index bd48038b..ce0de290 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -7,7 +7,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" class ComicDB; diff --git a/YACReaderLibrary/db/data_base_management.cpp b/YACReaderLibrary/db/data_base_management.cpp index e8052aee..8d18d478 100644 --- a/YACReaderLibrary/db/data_base_management.cpp +++ b/YACReaderLibrary/db/data_base_management.cpp @@ -4,6 +4,7 @@ #include "library_creator.h" #include "check_new_version.h" + static QString fields = "title ," "coverPage," @@ -311,7 +312,6 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database) return success; } -#include void DataBaseManagement::exportComicsInfo(QString source, QString dest) { //QSqlDatabase sourceDB = loadDatabase(source); diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index 10420299..1df7b199 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -54,7 +54,7 @@ #include "folder.h" #include "db_helper.h" #include "qnaturalsorting.h" -#include "yacreader_global.h" +#include "yacreader_global_gui.h" #include "QsLog.h" #ifdef Q_OS_MAC diff --git a/YACReaderLibrary/db/reading_list_item.h b/YACReaderLibrary/db/reading_list_item.h index e79fea62..6acf898b 100644 --- a/YACReaderLibrary/db/reading_list_item.h +++ b/YACReaderLibrary/db/reading_list_item.h @@ -4,7 +4,7 @@ #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" #include "reading_list_model.h" //TODO add propper constructors, using QList is not safe diff --git a/YACReaderLibrary/empty_label_widget.h b/YACReaderLibrary/empty_label_widget.h index 0e877da6..8dce705c 100644 --- a/YACReaderLibrary/empty_label_widget.h +++ b/YACReaderLibrary/empty_label_widget.h @@ -3,7 +3,7 @@ #include #include "empty_container_info.h" -#include "yacreader_global.h" +#include "yacreader_global_gui.h" class EmptyLabelWidget : public EmptyContainerInfo { diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 5578ca1e..1b1e8932 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -127,7 +127,6 @@ void GridComicsView::createCoverSizeSliderWidget() void GridComicsView::setToolBar(QToolBar *toolBar) { - QLOG_INFO() << "setToolBar"; static_cast(this->layout())->insertWidget(1,toolBar); this->toolbar = toolBar; @@ -137,34 +136,32 @@ void GridComicsView::setToolBar(QToolBar *toolBar) void GridComicsView::setModel(ComicModel *model) { - QLOG_INFO() << "setModel"; + if(model == NULL) + return; + + ComicsView::setModel(model); QQmlContext *ctxt = view->rootContext(); - //there is only one mothel in the system - ComicsView::setModel(model); - if(this->model != NULL) - { - QLOG_INFO() << "xxx"; + if(_selectionModel != NULL) + delete _selectionModel; - if(_selectionModel != NULL) - delete _selectionModel; - _selectionModel = new QItemSelectionModel(this->model); + _selectionModel = new QItemSelectionModel(model); - ctxt->setContextProperty("comicsList", this->model); - ctxt->setContextProperty("comicsSelection", _selectionModel); - ctxt->setContextProperty("contextMenuHelper",this); - ctxt->setContextProperty("comicsSelectionHelper", this); - ctxt->setContextProperty("comicRatingHelper", this); - ctxt->setContextProperty("dummyValue", true); - ctxt->setContextProperty("dragManager", this); - ctxt->setContextProperty("dropManager", this); + //TODO fix crash in the following line on comics views switch + ctxt->setContextProperty("comicsList", model); + ctxt->setContextProperty("comicsSelection", _selectionModel); + ctxt->setContextProperty("contextMenuHelper",this); + ctxt->setContextProperty("comicsSelectionHelper", this); + ctxt->setContextProperty("comicRatingHelper", this); + ctxt->setContextProperty("dummyValue", true); + ctxt->setContextProperty("dragManager", this); + ctxt->setContextProperty("dropManager", this); - updateBackgroundConfig(); + updateBackgroundConfig(); - if(model->rowCount()>0) - setCurrentIndex(model->index(0,0)); - } + if(model->rowCount()>0) + setCurrentIndex(model->index(0,0)); } void GridComicsView::updateBackgroundConfig() @@ -208,7 +205,6 @@ void GridComicsView::updateBackgroundConfig() void GridComicsView::setCurrentIndex(const QModelIndex &index) { - QLOG_INFO() << "setCurrentIndex"; _selectionModel->clear(); _selectionModel->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); view->rootContext()->setContextProperty("dummyValue", true); @@ -219,7 +215,6 @@ void GridComicsView::setCurrentIndex(const QModelIndex &index) QModelIndex GridComicsView::currentIndex() { - QLOG_INFO() << "currentIndex"; if(!_selectionModel) return QModelIndex(); @@ -238,7 +233,6 @@ QModelIndex GridComicsView::currentIndex() QItemSelectionModel *GridComicsView::selectionModel() { - QLOG_INFO() << "selectionModel"; QModelIndexList indexes = _selectionModel->selectedRows(); if(indexes.length()==0) this->selectIndex(0); @@ -248,24 +242,22 @@ QItemSelectionModel *GridComicsView::selectionModel() void GridComicsView::scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint) { - QLOG_INFO() << "scrollTo"; + } void GridComicsView::toFullScreen() { - QLOG_INFO() << "toFullScreen"; toolbar->hide(); } void GridComicsView::toNormal() { - QLOG_INFO() << "toNormal"; toolbar->show(); } void GridComicsView::updateConfig(QSettings *settings) { - QLOG_INFO() << "updateConfig"; + } void GridComicsView::enableFilterMode(bool enabled) @@ -275,7 +267,6 @@ void GridComicsView::enableFilterMode(bool enabled) void GridComicsView::selectAll() { - QLOG_INFO() << "selectAll"; QModelIndex top = model->index(0, 0); QModelIndex bottom = model->index(model->rowCount()-1, 0); QItemSelection selection(top, bottom); @@ -285,7 +276,6 @@ void GridComicsView::selectAll() void GridComicsView::rate(int index, int rating) { - QLOG_INFO() << "Comic "<< index << "rated" << rating; model->updateRating(rating,model->index(index,0)); } @@ -302,7 +292,6 @@ void GridComicsView::setCoversSize(int width) if(grid != 0) { - QLOG_INFO() << "method invoked"; QVariant cellCustomWidth = (width * YACREADER_MIN_CELL_CUSTOM_WIDTH) / YACREADER_MIN_GRID_ZOOM_WIDTH; QMetaObject::invokeMethod(grid, "calculateCellWidths", Q_ARG(QVariant, cellCustomWidth)); @@ -322,8 +311,7 @@ void GridComicsView::setCoversSize(int width) QSize GridComicsView::sizeHint() { - QLOG_INFO() << "sizeHint"; - return QSize(1280,768); + return QSize(1280,768); } QByteArray GridComicsView::getMimeDataFromSelection() @@ -340,7 +328,6 @@ QByteArray GridComicsView::getMimeDataFromSelection() void GridComicsView::startDrag() { - QLOG_DEBUG() << "performDrag"; QDrag *drag = new QDrag(this); drag->setMimeData(model->mimeData(_selectionModel->selectedRows())); drag->setPixmap(QPixmap(":/images/comics_view_toolbar/openInYACReader.png")); //TODO add better image @@ -388,7 +375,6 @@ void GridComicsView::droppedComicsForResortingAt(const QString &data, int index) //helper void GridComicsView::selectIndex(int index) { - QLOG_INFO() << "selectIndex" << index; if(_selectionModel != NULL && model!=NULL) { _selectionModel->select(model->index(index,0),QItemSelectionModel::Select | QItemSelectionModel::Rows); @@ -422,7 +408,6 @@ bool GridComicsView::isSelectedIndex(int index) void GridComicsView::clear() { - QLOG_INFO() << "clear"; if(_selectionModel != NULL) { _selectionModel->clear(); @@ -452,7 +437,6 @@ int GridComicsView::lastSelectedIndex() { if(_selectionModel != NULL) { - QLOG_INFO() << "last selected index " << _selectionModel->selectedRows().last().row(); return _selectionModel->selectedRows().last().row(); } @@ -461,7 +445,6 @@ int GridComicsView::lastSelectedIndex() void GridComicsView::setShowMarks(bool show) { - QLOG_INFO() << "setShowMarks"; QQmlContext *ctxt = view->rootContext(); ctxt->setContextProperty("show_marks", show); } @@ -471,7 +454,6 @@ void GridComicsView::closeEvent(QCloseEvent *event) toolbar->removeAction(toolBarStretchAction); toolbar->removeAction(coverSizeSliderAction); - QLOG_INFO() << "closeEvent"; QObject *object = view->rootObject(); QMetaObject::invokeMethod(object, "exit"); container->close(); diff --git a/YACReaderLibrary/headless/console_ui_library_creator.cpp b/YACReaderLibrary/headless/console_ui_library_creator.cpp new file mode 100644 index 00000000..e7e6adf0 --- /dev/null +++ b/YACReaderLibrary/headless/console_ui_library_creator.cpp @@ -0,0 +1,103 @@ +#include "console_ui_library_creator.h" + +#include + +#include "library_creator.h" +#include "yacreader_libraries.h" + + +ConsoleUILibraryCreator::ConsoleUILibraryCreator(QObject *parent) : + QObject(parent), numComicsProcessed(0) +{ + +} + +void ConsoleUILibraryCreator::createLibrary(const QString & name, const QString & path) +{ + QEventLoop eventLoop; + LibraryCreator * libraryCreator = new LibraryCreator(); + + libraryCreator->createLibrary(QDir::cleanPath(path),QDir::cleanPath(path)+"/.yacreaderlibrary"); + + connect(libraryCreator, &LibraryCreator::finished, this, &ConsoleUILibraryCreator::done); + connect(libraryCreator, &LibraryCreator::comicAdded, this, &ConsoleUILibraryCreator::newComic); + connect(libraryCreator, &LibraryCreator::failedCreatingDB, this, &ConsoleUILibraryCreator::manageCreatingError); + + connect(libraryCreator, &LibraryCreator::finished, &eventLoop, &QEventLoop::quit); + + std::cout << "Processing comics"; + + libraryCreator->start(); + eventLoop.exec(); + + //TODO, at some point some checking is needed for avoiding duplicated libraries + YACReaderLibraries yacreaderLibraries; + yacreaderLibraries.load(); + yacreaderLibraries.addLibrary(name, path); + yacreaderLibraries.save(); +} + +void ConsoleUILibraryCreator::updateLibrary(const QString & path) +{ + QEventLoop eventLoop; + LibraryCreator * libraryCreator = new LibraryCreator(); + + libraryCreator->updateLibrary(QDir::cleanPath(path),QDir::cleanPath(path)+"/.yacreaderlibrary"); + + connect(libraryCreator, &LibraryCreator::finished, this, &ConsoleUILibraryCreator::done); + connect(libraryCreator, &LibraryCreator::comicAdded, this, &ConsoleUILibraryCreator::newComic); + connect(libraryCreator, &LibraryCreator::failedOpeningDB, this, &ConsoleUILibraryCreator::manageUpdatingError); + + connect(libraryCreator, &LibraryCreator::finished, &eventLoop, &QEventLoop::quit); + + std::cout << "Processing comics"; + + libraryCreator->start(); + eventLoop.exec(); +} + +void ConsoleUILibraryCreator::addExistingLibrary(const QString & name, const QString & path) +{ + //TODO add error handling + YACReaderLibraries yacreaderLibraries; + yacreaderLibraries.load(); + yacreaderLibraries.addLibrary(name, path); + yacreaderLibraries.save(); + + std::cout << "Library added : " << name.toUtf8().constData() << " at " << path.toUtf8().constData() << std::endl; +} + +void ConsoleUILibraryCreator::removeLibrary(const QString & name) +{ + //TODO add error handling + YACReaderLibraries yacreaderLibraries; + yacreaderLibraries.load(); + yacreaderLibraries.remove(name); + yacreaderLibraries.save(); + + std::cout << "Library removed : " << name.toUtf8().constData() << std::endl; +} + +void ConsoleUILibraryCreator::newComic(const QString & /*relativeComicPath*/, const QString & /*coverPath*/) +{ + numComicsProcessed++; + std::cout << "."; +} + +void ConsoleUILibraryCreator::manageCreatingError(const QString & error) +{ + std::cout << std::endl << "Error creating library! " << error.toUtf8().constData(); +} + +void ConsoleUILibraryCreator::manageUpdatingError(const QString & error) +{ + std::cout << std::endl << "Error updating library! " << error.toUtf8().constData(); +} + +void ConsoleUILibraryCreator::done() +{ + std::cout << "Done!" << std::endl; + + if(numComicsProcessed > 0) + std::cout << "Number of comis processed = " << numComicsProcessed << std::endl; +} diff --git a/YACReaderLibrary/headless/console_ui_library_creator.h b/YACReaderLibrary/headless/console_ui_library_creator.h new file mode 100644 index 00000000..8181314d --- /dev/null +++ b/YACReaderLibrary/headless/console_ui_library_creator.h @@ -0,0 +1,29 @@ +#ifndef CONSOLE_UI_LIBRARY_CREATOR_H +#define CONSOLE_UI_LIBRARY_CREATOR_H + +#include + +class ConsoleUILibraryCreator : public QObject +{ + Q_OBJECT +public: + explicit ConsoleUILibraryCreator(QObject *parent = 0); + void createLibrary(const QString & name, const QString & path); + void updateLibrary(const QString & path); + void addExistingLibrary(const QString & name, const QString & path); + void removeLibrary(const QString & name); + +private: + uint numComicsProcessed; +signals: + +public slots: + +protected slots: + void newComic(const QString & relativeComicPath, const QString & coverPath); + void manageCreatingError(const QString & error); + void manageUpdatingError(const QString & error); + void done(); +}; + +#endif // CONSOLE_UI_LIBRARY_CREATOR_H diff --git a/YACReaderLibrary/headless/images.qrc b/YACReaderLibrary/headless/images.qrc new file mode 100644 index 00000000..4d459557 --- /dev/null +++ b/YACReaderLibrary/headless/images.qrc @@ -0,0 +1,6 @@ + + + ../../images/f_overlayed.png + ../../images/f_overlayed_retina.png + + diff --git a/YACReaderLibrary/headless/main.cpp b/YACReaderLibrary/headless/main.cpp new file mode 100644 index 00000000..20fe8a6e --- /dev/null +++ b/YACReaderLibrary/headless/main.cpp @@ -0,0 +1,321 @@ +#include + +#include "comic_db.h" +#include "db_helper.h" +#include "startup.h" +#include "yacreader_global.h" +#include "yacreader_libraries.h" +#include "yacreader_local_server.h" + +#include "console_ui_library_creator.h" + +#include "QsLog.h" +#include "QsLogDest.h" + + + +using namespace QsLogging; + +void logSystemAndConfig() +{ + QLOG_INFO() << "---------- System & configuration ----------"; +#if defined(Q_OS_WIN) + switch (QSysInfo::windowsVersion()) + { + case QSysInfo::WV_NT: + QLOG_INFO() << "SO : Windows NT"; + break; + case QSysInfo::WV_2000: + QLOG_INFO() << "SO : Windows 2000"; + break; + case QSysInfo::WV_XP: + QLOG_INFO() << "SO : Windows XP"; + break; + case QSysInfo::WV_2003: + QLOG_INFO() << "SO : Windows 2003"; + break; + case QSysInfo::WV_VISTA: + QLOG_INFO() << "SO : Windows Vista"; + break; + case QSysInfo::WV_WINDOWS7: + QLOG_INFO() << "SO : Windows 7"; + break; + case QSysInfo::WV_WINDOWS8: + QLOG_INFO() << "SO : Windows 8"; + break; + default: + QLOG_INFO() << "Windows (unknown version)"; + break; + } + +#elif defined(Q_OS_MAC) + + switch (QSysInfo::MacVersion()) + { + case QSysInfo::MV_SNOWLEOPARD: + QLOG_INFO() << "SO : MacOSX Snow Leopard"; + break; + case QSysInfo::MV_LION: + QLOG_INFO() << "SO : MacOSX Lion"; + break; + case QSysInfo::MV_MOUNTAINLION: + QLOG_INFO() << "SO : MacOSX Mountain Lion"; + break; +#if QT_VERSION >= 0x050000 + case QSysInfo::MV_MAVERICKS: + QLOG_INFO() << "SO : MacOSX Maverics"; + break; +#endif + default: + QLOG_INFO() << "SO : MacOSX (unknown version)"; + break; + } + +#elif defined(Q_OS_LINUX) + QLOG_INFO() << "SO : Linux (unknown version)"; + +#else + QLOG_INFO() << "SO : Unknown"; +#endif + +#ifdef Q_OS_WIN + if(QLibrary::isLibrary(QCoreApplication::applicationDirPath()+"/utils/7z.dll")) +#elif defined Q_OS_UNIX && !defined Q_OS_MAC + if(QLibrary::isLibrary(QString(LIBDIR)+"/yacreader/7z.so") | QLibrary::isLibrary(QString(LIBDIR)+"/p7zip/7z.so")) +#else + if(QLibrary::isLibrary(QApplication::applicationDirPath()+"/utils/7z.so")) +#endif + QLOG_INFO() << "7z : found"; + else + QLOG_ERROR() << "7z : not found"; + + /* TODO: qrencode could be helpfull for showing a qr code in the web client for client devices +#if defined Q_OS_UNIX && !defined Q_OS_MAC + if(QFileInfo(QString(BINDIR)+"/qrencode").exists()) +#else + if(QFileInfo(QCoreApplication::applicationDirPath()+"/utils/qrencode.exe").exists() || QFileInfo("./util/qrencode").exists()) +#endif + QLOG_INFO() << "qrencode : found"; + else + QLOG_INFO() << "qrencode : not found"; + */ + + QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries(); + QLOG_INFO() << "--------------------------------------------"; +} + +int main( int argc, char ** argv ) +{ + QCoreApplication *app = new QCoreApplication(argc, argv); + + app->setApplicationName("YACReaderLibrary"); + app->setOrganizationName("YACReader"); + app->setApplicationVersion(VERSION); + + QTextStream qout(stdout); + + //general help + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::tr("\nYACReaderLibraryServer is the headless (no gui) version of YACReaderLibrary")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, add-library, remove-library, list-libraries]"); + + parser.parse(QCoreApplication::arguments()); + + const QStringList args = parser.positionalArguments(); + const QString command = args.isEmpty() ? QString() : args.first(); + + if(command == "start") + { + QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log"; + QDir().mkpath(YACReader::getSettingsPath()); + + Logger& logger = Logger::instance(); + logger.setLoggingLevel(QsLogging::TraceLevel); + + DestinationPtr fileDestination(DestinationFactory::MakeFileDestination( + destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2))); + DestinationPtr debugDestination(DestinationFactory::MakeDebugOutputDestination()); + logger.addDestination(debugDestination); + logger.addDestination(fileDestination); + + QTranslator translator; + QString sufix = QLocale::system().name(); + #if defined Q_OS_UNIX && !defined Q_OS_MAC + translator.load(QString(DATADIR)+"/yacreader/languages/yacreaderlibrary_"+sufix); + #else + translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix); + #endif + app->installTranslator(&translator); + + QTranslator viewerTranslator; + #if defined Q_OS_UNIX && !defined Q_OS_MAC + viewerTranslator.load(QString(DATADIR)+"/yacreader/languages/yacreader_"+sufix); + #else + viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix); + #endif + app->installTranslator(&viewerTranslator); + + qRegisterMetaType("ComicDB"); + + QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini",QSettings::IniFormat); + settings->beginGroup("libraryConfig"); + + //server + Startup *s = new Startup(); + s->start(); + + QLOG_INFO() << "YACReaderLibraryServer attempting to start"; + + logSystemAndConfig(); + + if(YACReaderLocalServer::isRunning()) //s�lo se permite una instancia de YACReaderLibrary + { + QLOG_WARN() << "another instance of YACReaderLibrary is running"; + QsLogging::Logger::destroyInstance(); + return 0; + } + QLOG_INFO() << "YACReaderLibrary starting"; + + YACReaderLocalServer * localServer = new YACReaderLocalServer(); + + int ret = app->exec(); + + QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret; + + //shutdown + s->stop(); + delete s; + localServer->close(); + delete localServer; + + QsLogging::Logger::destroyInstance(); + + return ret; + } + else if(command == "create-library") + { + QCommandLineParser parser; + + parser.addHelpOption(); + + parser.parse(QCoreApplication::arguments()); + + parser.clearPositionalArguments(); + parser.addPositionalArgument("create-library", "Creates a library named \"name\" in the specified destination "); + parser.addPositionalArgument("name", "Library name", "\"name\""); + parser.addPositionalArgument("path", "Path to the folder where the library will be created", ""); + parser.process(*app); + + const QStringList args = parser.positionalArguments(); + if(args.length() != 3) + { + parser.showHelp(); + return 0; + } + + const QStringList createArgs = parser.positionalArguments(); + + ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator; + libraryCreatorUI->createLibrary(createArgs.at(1), createArgs.at(2)); + + return 0; + } + else if(command == "update-library") + { + QCommandLineParser parser; + + parser.addHelpOption(); + + parser.parse(QCoreApplication::arguments()); + + parser.clearPositionalArguments(); + parser.addPositionalArgument("update-library", "Updates an existing library at "); + parser.addPositionalArgument("path", "Path to the library to be updated", ""); + parser.process(*app); + + const QStringList args = parser.positionalArguments(); + if(args.length() != 2) + { + parser.showHelp(); + return 0; + } + + const QStringList updateArgs = parser.positionalArguments(); + + ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator; + libraryCreatorUI->updateLibrary(updateArgs.at(1)); + + return 0; + } + else if(command == "add-library") + { + QCommandLineParser parser; + + parser.addHelpOption(); + + parser.parse(QCoreApplication::arguments()); + + parser.clearPositionalArguments(); + parser.addPositionalArgument("add-library", "Adds an exiting library named \"name\" at the specified origin "); + parser.addPositionalArgument("name", "Library name", "\"name\""); + parser.addPositionalArgument("path", "Path to the folder where the library is", ""); + parser.process(*app); + + const QStringList args = parser.positionalArguments(); + if(args.length() != 3) + { + parser.showHelp(); + return 0; + } + + const QStringList addArgs = parser.positionalArguments(); + + ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator; + libraryCreatorUI->addExistingLibrary(addArgs.at(1), addArgs.at(2)); + + return 0; + } + else if(command == "remove-library") + { + QCommandLineParser parser; + + parser.addHelpOption(); + + parser.parse(QCoreApplication::arguments()); + + parser.clearPositionalArguments(); + parser.addPositionalArgument("remove-library", "Removes a library named \"name\" from the list of libraries"); + parser.addPositionalArgument("name", "Library name", "\"name\""); + parser.process(*app); + + const QStringList args = parser.positionalArguments(); + if(args.length() != 2) + { + parser.showHelp(); + return 0; + } + + const QStringList removeArgs = parser.positionalArguments(); + + ConsoleUILibraryCreator * libraryCreatorUI = new ConsoleUILibraryCreator; + libraryCreatorUI->removeLibrary(removeArgs.at(1)); + + return 0; + } + else if(command == "list-libraries") + { + YACReaderLibraries libraries = DBHelper::getLibraries(); + for(QString libraryName : libraries.getNames()) + qout << libraryName << " : " << libraries.getPath(libraryName) << endl; + + return 0; + } + else //error + { + parser.showHelp(); + + return 0; + } +} diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 8b5662f4..9ff6c47b 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include "data_base_management.h" @@ -127,13 +127,13 @@ void LibraryCreator::run() #if defined Q_OS_UNIX && !defined Q_OS_MAC QLibrary *sevenzLib = new QLibrary(QString(LIBDIR)+"/p7zip/7z.so"); #else - QLibrary *sevenzLib = new QLibrary(QApplication::applicationDirPath()+"/utils/7z"); + QLibrary *sevenzLib = new QLibrary(QCoreApplication::applicationDirPath()+"/utils/7z"); #endif if(!sevenzLib->load()) { QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl; - QApplication::exit(YACReader::SevenZNotFound); + QCoreApplication::exit(YACReader::SevenZNotFound); exit(); } sevenzLib->deleteLater(); @@ -636,7 +636,7 @@ void ThumbnailCreator::create() #else QImage p = pdfComic->page(_coverPage-1)->renderToImage(72,72); #endif - _cover = QPixmap::fromImage(p); + _cover = p; if(_target!="") { QImage scaled; diff --git a/YACReaderLibrary/library_creator.h b/YACReaderLibrary/library_creator.h index 83c06164..ed37fdab 100644 --- a/YACReaderLibrary/library_creator.h +++ b/YACReaderLibrary/library_creator.h @@ -78,14 +78,14 @@ QString _target; QString _currentName; int _numPages; - QPixmap _cover; + QImage _cover; int _coverPage; static bool crash; public slots: void create(); - int getNumPages(){return _numPages;}; - QPixmap getCover(){return _cover;}; + int getNumPages(){return _numPages;} + QPixmap getCover(){return QPixmap::fromImage(_cover);} signals: void openingError(QProcess::ProcessError error); diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index e95ffc39..f89dfa23 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1325,6 +1325,9 @@ void LibraryWindow::loadLibrary(const QString & name) void LibraryWindow::loadCoversFromCurrentModel() { + //TODO this is a workaround for the crash in GridComicsView::setModel crash on views switching + if(typeid(*comicsView) == typeid(GridComicsView)) + comicsView->setModel(new ComicModel()); comicsView->setModel(comicsModel); } diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 26b218ac..29ca0232 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -5,7 +5,7 @@ #include #include #include -#include "yacreader_global.h" +#include "yacreader_global_gui.h" #include "yacreader_libraries.h" #include "yacreader_navigation_controller.h" diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 581fcfc3..db3c629f 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -155,31 +155,9 @@ int main( int argc, char ** argv ) app.setApplicationName("YACReaderLibrary"); app.setOrganizationName("YACReader"); + app.setApplicationVersion(VERSION); + app.setAttribute(Qt::AA_UseHighDpiPixmaps); -//simple command line parser -//will be replaced by QCommandLineParser in the future -//TODO: --headless, --server=[on|off], support for file and directory arguments - if (argc > 1) - { - QTextStream parser(stdout); - QStringList optlist = QCoreApplication::arguments().filter(QRegExp ("^-{1,2}")); - if (optlist.contains("--version") || optlist.contains("-v")) - { - parser << app.applicationName() << " " << QString(VERSION) << endl << "Copyright 2014 by Luis Angel San Martin Rodriguez" << endl; - return 0; - } - if (optlist.contains("--help") || optlist.contains("-h")) - { - parser << endl << "Usage:" << "\tYACReaderLibrary [Option]" << endl << endl; - parser << "Options:" << endl; - parser << " none\t\t\tStart YACReaderLibrary" << endl; - parser << " -h, --help\t\tDisplay help text and exit." << endl; - parser << " -v, --version\t\tDisplay version information and exit." << endl; - return 0; - } - parser << "Unsupported command line options. See YACReaderLibrary --help for further information." << endl; - return 0; - } QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log"; QDir().mkpath(YACReader::getSettingsPath()); @@ -209,7 +187,6 @@ int main( int argc, char ** argv ) viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix); #endif app.installTranslator(&viewerTranslator); - app.setApplicationName("YACReaderLibrary"); qRegisterMetaType("ComicDB"); diff --git a/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp index b2515e3c..c16a3c28 100644 --- a/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp +++ b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp @@ -9,7 +9,7 @@ #include #include "httpsession.h" #include "static.h" -#include +#include StaticFileController::StaticFileController(QSettings* settings, QObject* parent) @@ -29,8 +29,8 @@ StaticFileController::StaticFileController(QSettings* settings, QObject* parent) QFileInfo configFile(QString(DATADIR)+"/yacreader"); docroot=QFileInfo(QString(DATADIR)+"/yacreader",docroot).absoluteFilePath(); #else - QFileInfo configFile(QApplication::applicationDirPath()); - docroot=QFileInfo(QApplication::applicationDirPath(),docroot).absoluteFilePath(); + QFileInfo configFile(QCoreApplication::applicationDirPath()); + docroot=QFileInfo(QCoreApplication::applicationDirPath(),docroot).absoluteFilePath(); #endif } qDebug("StaticFileController: docroot=%s, encoding=%s, maxAge=%i",qPrintable(docroot),qPrintable(encoding),maxAge); diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp index ea3a2dd8..9ed9cf8f 100644 --- a/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent) : QObject(parent) @@ -26,8 +26,8 @@ TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent) QFileInfo configFile(QString(DATADIR)+"/yacreader"); templatePath=QFileInfo(QString(DATADIR)+"/yacreader",templatePath).absoluteFilePath(); #else - QFileInfo configFile(QApplication::applicationDirPath()); - templatePath=QFileInfo(QApplication::applicationDirPath(),templatePath).absoluteFilePath(); + QFileInfo configFile(QCoreApplication::applicationDirPath()); + templatePath=QFileInfo(QCoreApplication::applicationDirPath(),templatePath).absoluteFilePath(); #endif } fileNameSuffix=settings->value("suffix",".tpl").toString(); diff --git a/YACReaderLibrary/server/startup.cpp b/YACReaderLibrary/server/startup.cpp index 7166e402..fd1e982f 100644 --- a/YACReaderLibrary/server/startup.cpp +++ b/YACReaderLibrary/server/startup.cpp @@ -13,7 +13,7 @@ #include "yacreader_global.h" #include -#include +#include /** Name of this application */ #define APPNAME "YACReaderLibrary" @@ -26,9 +26,8 @@ void Startup::start() { // Initialize the core application - QCoreApplication* app = QApplication::instance(); - app->setApplicationName(APPNAME); - app->setOrganizationName(ORGANISATION); + QCoreApplication* app = QCoreApplication::instance(); + QString configFileName=YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini"; // Configure logging into files diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index 3e971668..e0fe3bc7 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -11,7 +11,7 @@ #include #include "startup.h" -#include "yacreader_global.h" +#include "yacreader_global_gui.h" #include "qnaturalsorting.h" diff --git a/YACReaderLibrary/yacreader_libraries.cpp b/YACReaderLibrary/yacreader_libraries.cpp index 2e5e3cd2..53a8a6b0 100644 --- a/YACReaderLibrary/yacreader_libraries.cpp +++ b/YACReaderLibrary/yacreader_libraries.cpp @@ -102,7 +102,7 @@ void YACReaderLibraries::addLibrary(const QString &name, const QString &path) void YACReaderLibraries::load() { - QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); + QSettings settings(YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini",QSettings::IniFormat); if(settings.value(LIBRARIES).isValid()) { @@ -136,7 +136,7 @@ void YACReaderLibraries::load() bool YACReaderLibraries::save() { - QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); + QSettings settings(YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini",QSettings::IniFormat); QByteArray data; QDataStream out(&data, QIODevice::WriteOnly); diff --git a/YACReaderLibrary/yacreader_local_server.cpp b/YACReaderLibrary/yacreader_local_server.cpp index 0e55078d..247cb4eb 100644 --- a/YACReaderLibrary/yacreader_local_server.cpp +++ b/YACReaderLibrary/yacreader_local_server.cpp @@ -127,10 +127,10 @@ void YACReaderClientConnectionWorker::run() tries = 0; QByteArray data; int dataRead = 0; - while(data.size() < totalSize && tries < 200) + while((quint32)data.size() < totalSize && tries < 200) { data.append(clientConnection->readAll()); - if(data.length() < totalSize) + if((quint32)data.length() < totalSize) clientConnection->waitForReadyRead(100); if(dataRead == data.length()) //no bytes were read tries++; diff --git a/common/bookmarks.cpp b/common/bookmarks.cpp index d60d8b60..1330c266 100644 --- a/common/bookmarks.cpp +++ b/common/bookmarks.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include "yacreader_global.h" diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index 56089a3d..dd6213d2 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -1,5 +1,5 @@ #include "check_new_version.h" -#include + #include #include #include diff --git a/common/check_new_version.h b/common/check_new_version.h index 5c5e2fb5..f8e6b146 100644 --- a/common/check_new_version.h +++ b/common/check_new_version.h @@ -4,7 +4,6 @@ #include "http_worker.h" #include "yacreader_global.h" -#include #include #include diff --git a/common/comic.cpp b/common/comic.cpp index e3dbc42f..f5d8734a 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "bookmarks.h" //TODO desacoplar la dependencia con bookmarks #include "qnaturalsorting.h" @@ -320,7 +320,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic) else { //QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path); - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return false; } @@ -487,14 +487,14 @@ void FileComic::process() CompressedArchive archive(_path); if(!archive.toolsLoaded()) { - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(tr("7z not found")); return; } if(!archive.isValid()) { - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(tr("Format not supported")); return; } @@ -506,7 +506,7 @@ void FileComic::process() if(_fileNames.size()==0) { //QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file")); - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return; } @@ -552,7 +552,7 @@ void FileComic::process() emit imageLoaded(sortedIndex); emit imageLoaded(sortedIndex,_pages[sortedIndex]); }*/ - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit imagesLoaded(); } @@ -612,7 +612,7 @@ void FolderComic::process() { //TODO emitir este mensaje en otro sitio //QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder")); - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); } else @@ -646,7 +646,7 @@ void FolderComic::process() count++; } } - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit imagesLoaded(); } @@ -689,7 +689,7 @@ bool PDFComic::load(const QString & path, int atPage) } else { - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return false; } @@ -712,7 +712,7 @@ bool PDFComic::load(const QString & path, const ComicDB & comic) else { //QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path); - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return false; } @@ -736,13 +736,13 @@ void PDFComic::process() { //delete pdfComic; //pdfComic = 0; - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return; } if (pdfComic->isLocked()) { - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit errorOpening(); return; } @@ -778,7 +778,7 @@ void PDFComic::process() renderPage(i); delete pdfComic; - moveToThread(QApplication::instance()->thread()); + moveToThread(QCoreApplication::instance()->thread()); emit imagesLoaded(); } diff --git a/common/http_worker.cpp b/common/http_worker.cpp index eabdcc6c..c64b7c90 100644 --- a/common/http_worker.cpp +++ b/common/http_worker.cpp @@ -1,5 +1,5 @@ #include "http_worker.h" -#include + #include #include #include diff --git a/common/http_worker.h b/common/http_worker.h index 10034717..0cc01136 100644 --- a/common/http_worker.h +++ b/common/http_worker.h @@ -1,7 +1,6 @@ #ifndef __HTTP_WORKER_H #define __HTTP_WORKER_H -#include #include #include #include diff --git a/common/pictureflow.h b/common/pictureflow.h index b746ef70..0ac197d4 100644 --- a/common/pictureflow.h +++ b/common/pictureflow.h @@ -28,7 +28,7 @@ #define PICTUREFLOW_H #include -#include "yacreader_global.h" //FlowType +#include "yacreader_global_gui.h" //FlowType class PictureFlowPrivate; diff --git a/common/yacreader_global.cpp b/common/yacreader_global.cpp index fbf2540e..7e2e8ef4 100644 --- a/common/yacreader_global.cpp +++ b/common/yacreader_global.cpp @@ -1,5 +1,5 @@ #include "yacreader_global.h" -#include + using namespace YACReader; @@ -13,22 +13,6 @@ QString YACReader::getSettingsPath() } -void YACReader::addSperator(QWidget *w) -{ - QAction * separator = new QAction(w); - separator->setSeparator(true); - w->addAction(separator); -} - - -QAction * YACReader::createSeparator() -{ - QAction * a = new QAction(0); - a->setSeparator(true); - return a; -} - - QString YACReader::colorToName(LabelColors colors) { switch(colors){ @@ -59,31 +43,6 @@ QString YACReader::colorToName(LabelColors colors) } } - -QIcon YACReader::noHighlightedIcon(const QString &path) -{ - QPixmap p(path); - - QIcon icon;//(path); - icon.addFile(path,p.size(),QIcon::Normal); - icon.addFile(path,p.size(),QIcon::Selected); - return icon; -} - - -void YACReader::colorize(QImage &img, QColor &col) -{ - QRgb *data = (QRgb *)img.bits(); - QRgb *end = data + img.width()*img.height(); - - int rcol = col.red(), gcol = col.green(), bcol = col.blue(); - while(data != end) { - *data = qRgba(rcol,gcol,bcol,qAlpha(*data)); - ++data; - } -} - - QString YACReader::labelColorToRGBString(LabelColors color) { switch (color) { @@ -129,13 +88,3 @@ QString YACReader::labelColorToRGBString(LabelColors color) } } - - -QList YACReader::mimeDataToComicsIds(const QMimeData *data) -{ - QList comicIds; - QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat); - QDataStream in(&rawData,QIODevice::ReadOnly); - in >> comicIds; //deserialize the list of indentifiers - return comicIds; -} diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 39ba4917..cd403e6e 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -7,66 +7,8 @@ #include #endif -#include -#include - #define VERSION "8.0.0" -//old fitmode defines -/* -#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE" -#define FIT "FIT" -#define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO" -*/ - -#define PATH "PATH" -#define MAG_GLASS_SIZE "MAG_GLASS_SIZE" -#define ZOOM_LEVEL "ZOOM_LEVEL" -#define SLIDE_SIZE "SLIDE_SIZE" -#define GO_TO_FLOW_SIZE "GO_TO_FLOW_SIZE" -#define FLOW_TYPE_SW "FLOW_TYPE_SW" -#define FITMODE "FITMODE" -#define FLOW_TYPE "FLOW_TYPE" -#define FULLSCREEN "FULLSCREEN" -#define Y_WINDOW_POS "POS" -#define Y_WINDOW_SIZE "SIZE" -#define MAXIMIZED "MAXIMIZED" -#define DOUBLE_PAGE "DOUBLE_PAGE" -#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" -#define BACKGROUND_COLOR "BACKGROUND_COLOR" -#define ALWAYS_ON_TOP "ALWAYS_ON_TOP" -#define SHOW_TOOLBARS "SHOW_TOOLBARS" -#define BRIGHTNESS "BRIGHTNESS" -#define CONTRAST "CONTRAST" -#define GAMMA "GAMMA" -#define SHOW_INFO "SHOW_INFO" - -#define FLOW_TYPE_GL "FLOW_TYPE_GL" -#define Y_POSITION "Y_POSITION" -#define COVER_DISTANCE "COVER_DISTANCE" -#define CENTRAL_DISTANCE "CENTRAL_DISTANCE" -#define ZOOM_LEVEL "ZOOM_LEVEL" -#define Z_COVER_OFFSET "Z_COVER_OFFSET" -#define COVER_ROTATION "COVER_ROTATION" -#define FADE_OUT_DIST "FADE_OUT_DIST" -#define LIGHT_STRENGTH "LIGHT_STRENGTH" -#define MAX_ANGLE "MAX_ANGLE" -#define PERFORMANCE "PERFORMANCE" -#define USE_OPEN_GL "USE_OPEN_GL" -#define X_ROTATION "X_ROTATION" -#define Y_COVER_OFFSET "Y_COVER_OFFSET" -#define V_SYNC "V_SYNC" -#define SERVER_ON "SERVER_ON" - -#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY" -#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE" -#define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS" -#define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY" -#define COMICS_VIEW_STATUS "COMICS_VIEW_STATUS" -#define COMICS_VIEW_FLOW_SPLITTER_STATUS "COMICS_VIEW_FLOW_SPLITTER_STATUS" -#define SIDEBAR_SPLITTER_STATUS "SIDEBAR_SPLITTER_STATUS" -#define COMICS_GRID_COVER_SIZES "COMICS_GRID_COVER_SIZES" - #define USE_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_BACKGROUND_IMAGE_IN_GRID_VIEW" #define OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW "OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW" #define BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW "BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW" @@ -79,24 +21,9 @@ #define LIBRARIES "LIBRARIES" -#define COMIC_VINE_API_KEY "COMIC_VINE_API_KEY" - namespace YACReader { -static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids"; -static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/yacreaderlibrary-sublist-rows"; - - enum FlowType - { - CoverFlowLike=0, - Strip, - StripOverlapped, - Modern, - Roulette, - Custom - }; - enum YACReaderIPCMessages { RequestComicInfo = 0, @@ -115,12 +42,6 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/ SevenZNotFound = 700 }; - enum ComicsViewStatus - { - Flow, - Grid - }; - enum SearchModifiers{ NoModifiers = 0, OnlyRead, @@ -143,22 +64,10 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/ YDark }; - enum FitMode{ - ToWidth=0x01, - ToHeight=0x02, - FullRes=0x03, - FullPage=0x04//, - //Text=0x05 - }; - QString getSettingsPath(); -void addSperator(QWidget * w); -QAction * createSeparator(); QString colorToName(LabelColors colors); -QIcon noHighlightedIcon(const QString & path); -void colorize(QImage &img, QColor &col); QString labelColorToRGBString(LabelColors color); -QList mimeDataToComicsIds(const QMimeData * data); + } #endif diff --git a/common/yacreader_global_gui.cpp b/common/yacreader_global_gui.cpp new file mode 100644 index 00000000..91d1d106 --- /dev/null +++ b/common/yacreader_global_gui.cpp @@ -0,0 +1,51 @@ +#include "yacreader_global_gui.h" + +#include +#include + +using namespace YACReader; + +void YACReader::addSperator(QWidget *w) +{ + QAction * separator = new QAction(w); + separator->setSeparator(true); + w->addAction(separator); +} + +QAction * YACReader::createSeparator() +{ + QAction * a = new QAction(0); + a->setSeparator(true); + return a; +} + +QIcon YACReader::noHighlightedIcon(const QString &path) +{ + QPixmap p(path); + + QIcon icon;//(path); + icon.addFile(path,p.size(),QIcon::Normal); + icon.addFile(path,p.size(),QIcon::Selected); + return icon; +} + +void YACReader::colorize(QImage &img, QColor &col) +{ + QRgb *data = (QRgb *)img.bits(); + QRgb *end = data + img.width()*img.height(); + + int rcol = col.red(), gcol = col.green(), bcol = col.blue(); + while(data != end) { + *data = qRgba(rcol,gcol,bcol,qAlpha(*data)); + ++data; + } +} + +QList YACReader::mimeDataToComicsIds(const QMimeData *data) +{ + QList comicIds; + QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat); + QDataStream in(&rawData,QIODevice::ReadOnly); + in >> comicIds; //deserialize the list of indentifiers + return comicIds; +} diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h new file mode 100644 index 00000000..f00dd563 --- /dev/null +++ b/common/yacreader_global_gui.h @@ -0,0 +1,98 @@ +#ifndef __YACREADER_GLOBAL_GUI_H +#define __YACREADER_GLOBAL_GUI_H + +#include "yacreader_global.h" + +#include +#include + +#define PATH "PATH" +#define MAG_GLASS_SIZE "MAG_GLASS_SIZE" +#define ZOOM_LEVEL "ZOOM_LEVEL" +#define SLIDE_SIZE "SLIDE_SIZE" +#define GO_TO_FLOW_SIZE "GO_TO_FLOW_SIZE" +#define FLOW_TYPE_SW "FLOW_TYPE_SW" +#define FITMODE "FITMODE" +#define FLOW_TYPE "FLOW_TYPE" +#define FULLSCREEN "FULLSCREEN" +#define Y_WINDOW_POS "POS" +#define Y_WINDOW_SIZE "SIZE" +#define MAXIMIZED "MAXIMIZED" +#define DOUBLE_PAGE "DOUBLE_PAGE" +#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" +#define BACKGROUND_COLOR "BACKGROUND_COLOR" +#define ALWAYS_ON_TOP "ALWAYS_ON_TOP" +#define SHOW_TOOLBARS "SHOW_TOOLBARS" +#define BRIGHTNESS "BRIGHTNESS" +#define CONTRAST "CONTRAST" +#define GAMMA "GAMMA" +#define SHOW_INFO "SHOW_INFO" + +#define FLOW_TYPE_GL "FLOW_TYPE_GL" +#define Y_POSITION "Y_POSITION" +#define COVER_DISTANCE "COVER_DISTANCE" +#define CENTRAL_DISTANCE "CENTRAL_DISTANCE" +#define ZOOM_LEVEL "ZOOM_LEVEL" +#define Z_COVER_OFFSET "Z_COVER_OFFSET" +#define COVER_ROTATION "COVER_ROTATION" +#define FADE_OUT_DIST "FADE_OUT_DIST" +#define LIGHT_STRENGTH "LIGHT_STRENGTH" +#define MAX_ANGLE "MAX_ANGLE" +#define PERFORMANCE "PERFORMANCE" +#define USE_OPEN_GL "USE_OPEN_GL" +#define X_ROTATION "X_ROTATION" +#define Y_COVER_OFFSET "Y_COVER_OFFSET" +#define V_SYNC "V_SYNC" +#define SERVER_ON "SERVER_ON" + +#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY" +#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE" +#define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS" +#define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY" +#define COMICS_VIEW_STATUS "COMICS_VIEW_STATUS" +#define COMICS_VIEW_FLOW_SPLITTER_STATUS "COMICS_VIEW_FLOW_SPLITTER_STATUS" +#define SIDEBAR_SPLITTER_STATUS "SIDEBAR_SPLITTER_STATUS" +#define COMICS_GRID_COVER_SIZES "COMICS_GRID_COVER_SIZES" + +#define COMIC_VINE_API_KEY "COMIC_VINE_API_KEY" + +namespace YACReader +{ + +static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids"; +static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/yacreaderlibrary-sublist-rows"; + + enum FlowType + { + CoverFlowLike=0, + Strip, + StripOverlapped, + Modern, + Roulette, + Custom + }; + + enum ComicsViewStatus + { + Flow, + Grid + }; + + enum FitMode{ + ToWidth=0x01, + ToHeight=0x02, + FullRes=0x03, + FullPage=0x04//, + //Text=0x05 + }; + + +void addSperator(QWidget * w); +QAction * createSeparator(); +QIcon noHighlightedIcon(const QString & path); +void colorize(QImage &img, QColor &col); +QList mimeDataToComicsIds(const QMimeData * data); + +} +#endif + diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index fe665cca..43412799 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -73,12 +73,12 @@ struct SevenZipInterface { //SevenZipInterface * szInterface; -const char rar[7]={static_cast(0x52), static_cast(0x61), static_cast(0x72), static_cast(0x21), static_cast(0x1A), static_cast(0x07), static_cast(0x00)}; -const char rar5[8]={static_cast(0x52), static_cast(0x61), static_cast(0x72), static_cast(0x21), static_cast(0x1A), static_cast(0x07), static_cast(0x01), static_cast(0x00)}; -const char zip[2]={static_cast(0x50), static_cast(0x4B)}; -const char sevenz[6]={static_cast(0x37), static_cast(0x7A), static_cast(0xBC), static_cast(0xAF), static_cast(0x27), static_cast(0x1C)}; -const char tar[6]="ustar"; -const char arj[2]={static_cast(0x60), static_cast(0xEA)}; +const unsigned char rar[7]={static_cast(0x52), static_cast(0x61), static_cast(0x72), static_cast(0x21), static_cast(0x1A), static_cast(0x07), static_cast(0x00)}; +const unsigned char rar5[8]={static_cast(0x52), static_cast(0x61), static_cast(0x72), static_cast(0x21), static_cast(0x1A), static_cast(0x07), static_cast(0x01), static_cast(0x00)}; +const unsigned char zip[2]={static_cast(0x50), static_cast(0x4B)}; +const unsigned char sevenz[6]={static_cast(0x37), static_cast(0x7A), static_cast(0xBC), static_cast(0xAF), static_cast(0x27), static_cast(0x1C)}; +const unsigned char tar[6]="ustar"; +const unsigned char arj[2]={static_cast(0x60), static_cast(0xEA)}; CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) : QObject(parent),sevenzLib(0),valid(false),tools(false) @@ -404,7 +404,7 @@ QVector CompressedArchive::translateIndexes(const QVector & in foreach(quint32 i, indexes) { - if(i < offsets.length()) + if(i < (quint32)offsets.length()) translatedIndexes.append(offsets.at(i)); } diff --git a/custom_widgets/yacreader_sidebar.cpp b/custom_widgets/yacreader_sidebar.cpp index 2d380e4e..44a796cc 100644 --- a/custom_widgets/yacreader_sidebar.cpp +++ b/custom_widgets/yacreader_sidebar.cpp @@ -8,7 +8,7 @@ #include "yacreader_library_list_widget.h" #include "yacreader_search_line_edit.h" #include "yacreader_titled_toolbar.h" - +#include "yacreader_global_gui.h" YACReaderSideBar::YACReaderSideBar(QWidget *parent) : QWidget(parent)