From 6b5e4c5ec8fb2bfa8ca346a2470b6f4f38e5780c Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Sat, 12 Dec 2015 18:50:34 +0100 Subject: [PATCH] Merged luisangelsm/yacreader/headless_server into headless_server --- YACReader/YACReader.pro | 130 +++++------ YACReader/configuration.h | 2 +- YACReader/goto_flow.h | 2 + YACReader/goto_flow_widget.h | 2 +- YACReader/render.cpp | 2 +- YACReaderLibrary/YACReaderLibrary.pro | 2 + YACReaderLibrary/YACReaderLibraryServer.pro | 159 +++++++++++++ .../comic_vine/api_key_dialog.cpp | 2 +- .../comic_vine/comic_vine_client.cpp | 1 + YACReaderLibrary/comics_view_transition.cpp | 2 +- YACReaderLibrary/db/comic_model.h | 2 +- YACReaderLibrary/db/data_base_management.cpp | 1 - YACReaderLibrary/db/folder_model.cpp | 2 +- YACReaderLibrary/db/reading_list_item.h | 2 +- YACReaderLibrary/empty_label_widget.h | 2 +- YACReaderLibrary/grid_comics_view.cpp | 62 ++--- YACReaderLibrary/headless/main.cpp | 211 ++++++++++++++++++ YACReaderLibrary/library_creator.cpp | 6 +- YACReaderLibrary/library_window.cpp | 3 + YACReaderLibrary/library_window.h | 2 +- .../lib/bfHttpServer/staticfilecontroller.cpp | 6 +- .../lib/bfTemplateEngine/templateloader.cpp | 6 +- YACReaderLibrary/server/startup.cpp | 4 +- YACReaderLibrary/server_config_dialog.cpp | 2 +- common/bookmarks.cpp | 1 - common/check_new_version.cpp | 2 +- common/check_new_version.h | 1 - common/comic.cpp | 26 +-- common/http_worker.cpp | 2 +- common/http_worker.h | 1 - common/pictureflow.h | 2 +- common/yacreader_global.cpp | 53 +---- common/yacreader_global.h | 93 +------- common/yacreader_global_gui.cpp | 51 +++++ common/yacreader_global_gui.h | 98 ++++++++ custom_widgets/yacreader_sidebar.cpp | 2 +- 36 files changed, 656 insertions(+), 291 deletions(-) create mode 100644 YACReaderLibrary/YACReaderLibraryServer.pro create mode 100644 YACReaderLibrary/headless/main.cpp create mode 100644 common/yacreader_global_gui.cpp create mode 100644 common/yacreader_global_gui.h 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..da375155 --- /dev/null +++ b/YACReaderLibrary/YACReaderLibraryServer.pro @@ -0,0 +1,159 @@ +###################################################################### +# 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 + +#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 + + +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 + + +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 + + +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..9f307024 100644 --- a/YACReaderLibrary/db/data_base_management.cpp +++ b/YACReaderLibrary/db/data_base_management.cpp @@ -311,7 +311,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 770921a7..adf5f90f 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() @@ -206,7 +203,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); @@ -214,7 +210,6 @@ void GridComicsView::setCurrentIndex(const QModelIndex &index) QModelIndex GridComicsView::currentIndex() { - QLOG_INFO() << "currentIndex"; QModelIndexList indexes = _selectionModel->selectedRows(); if(indexes.length()>0) return indexes[0]; @@ -225,7 +220,6 @@ QModelIndex GridComicsView::currentIndex() QItemSelectionModel *GridComicsView::selectionModel() { - QLOG_INFO() << "selectionModel"; QModelIndexList indexes = _selectionModel->selectedRows(); if(indexes.length()==0) this->selectIndex(0); @@ -235,24 +229,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) @@ -262,7 +254,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); @@ -272,7 +263,6 @@ void GridComicsView::selectAll() void GridComicsView::rate(int index, int rating) { - QLOG_INFO() << "Comic "<< index << "rated" << rating; model->updateRating(rating,model->index(index,0)); } @@ -289,7 +279,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)); @@ -309,8 +298,7 @@ void GridComicsView::setCoversSize(int width) QSize GridComicsView::sizeHint() { - QLOG_INFO() << "sizeHint"; - return QSize(1280,768); + return QSize(1280,768); } QByteArray GridComicsView::getMimeDataFromSelection() @@ -327,7 +315,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 @@ -375,7 +362,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); @@ -409,7 +395,6 @@ bool GridComicsView::isSelectedIndex(int index) void GridComicsView::clear() { - QLOG_INFO() << "clear"; if(_selectionModel != NULL) { _selectionModel->clear(); @@ -439,7 +424,6 @@ int GridComicsView::lastSelectedIndex() { if(_selectionModel != NULL) { - QLOG_INFO() << "last selected index " << _selectionModel->selectedRows().last().row(); return _selectionModel->selectedRows().last().row(); } @@ -448,7 +432,6 @@ int GridComicsView::lastSelectedIndex() void GridComicsView::setShowMarks(bool show) { - QLOG_INFO() << "setShowMarks"; QQmlContext *ctxt = view->rootContext(); ctxt->setContextProperty("show_marks", show); } @@ -458,7 +441,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/main.cpp b/YACReaderLibrary/headless/main.cpp new file mode 100644 index 00000000..545a6d2f --- /dev/null +++ b/YACReaderLibrary/headless/main.cpp @@ -0,0 +1,211 @@ +#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 "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() << "--------------------------------------------"; +} + +QCoreApplication* createApplication(int &argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) + if (!qstrcmp(argv[i], "--no-gui")) + return new QCoreApplication(argc, argv); + return new QCoreApplication(argc, argv); +} + +int main( int argc, char ** argv ) +{ + QScopedPointer app(createApplication(argc, argv)); + + app->setApplicationName("YACReaderLibraryServer"); + app->setOrganizationName("YACReader"); + //simple command line parser + //will be replaced by QCommandLineParser in the future + //TODO: 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; + } + if (optlist.contains("--no-gui")) + { + parser << "You're running YACReaderLibrary in non-gui mode. Press Ctrl+C to exit." << endl; + } + } + + 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); + app->setApplicationName("YACReaderLibrary"); + + qRegisterMetaType("ComicDB"); + + + QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci�n del fichero de config con el servidor + 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; +} diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 8b5662f4..ec12222a 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(); 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/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..a9927c6e 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,7 +26,7 @@ void Startup::start() { // Initialize the core application - QCoreApplication* app = QApplication::instance(); + QCoreApplication* app = QCoreApplication::instance(); app->setApplicationName(APPNAME); app->setOrganizationName(ORGANISATION); QString configFileName=YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini"; 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/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 6454c980..f1f0eb71 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 240efe57..9d65259c 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" @@ -78,24 +20,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, @@ -114,12 +41,6 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/ SevenZNotFound = 700 }; - enum ComicsViewStatus - { - Flow, - Grid - }; - enum SearchModifiers{ NoModifiers = 0, OnlyRead, @@ -142,22 +63,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/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)