From e3ec56aa437b65e45d2b02258717f53339e99500 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?=
Date: Thu, 30 May 2019 19:46:37 +0200
Subject: [PATCH] Format code using clang-format
---
YACReader/bookmarks_dialog.cpp | 242 ++-
YACReader/bookmarks_dialog.h | 48 +-
YACReader/configuration.cpp | 85 +-
YACReader/configuration.h | 161 +-
YACReader/goto_dialog.cpp | 93 +-
YACReader/goto_dialog.h | 42 +-
YACReader/goto_flow.cpp | 340 ++--
YACReader/goto_flow.h | 80 +-
YACReader/goto_flow_gl.cpp | 203 +-
YACReader/goto_flow_gl.h | 31 +-
YACReader/goto_flow_toolbar.cpp | 155 +-
YACReader/goto_flow_toolbar.h | 42 +-
YACReader/goto_flow_widget.cpp | 69 +-
YACReader/goto_flow_widget.h | 36 +-
YACReader/magnifying_glass.cpp | 370 ++--
YACReader/magnifying_glass.h | 49 +-
YACReader/main.cpp | 187 +-
YACReader/main_window_viewer.cpp | 1430 +++++++-------
YACReader/main_window_viewer.h | 279 +--
YACReader/notifications_label_widget.cpp | 49 +-
YACReader/notifications_label_widget.h | 16 +-
YACReader/options_dialog.cpp | 398 ++--
YACReader/options_dialog.h | 80 +-
YACReader/page_label_widget.cpp | 83 +-
YACReader/page_label_widget.h | 16 +-
YACReader/render.cpp | 1502 +++++++-------
YACReader/render.h | 272 +--
YACReader/shortcuts_dialog.cpp | 64 +-
YACReader/shortcuts_dialog.h | 15 +-
YACReader/translator.cpp | 532 +++--
YACReader/translator.h | 111 +-
YACReader/viewer.cpp | 1515 +++++++-------
YACReader/viewer.h | 291 +--
YACReader/width_slider.cpp | 21 +-
YACReader/width_slider.h | 21 +-
YACReader/yacreader_local_client.cpp | 228 +--
YACReader/yacreader_local_client.h | 10 +-
YACReaderLibrary/add_label_dialog.cpp | 27 +-
YACReaderLibrary/add_label_dialog.h | 10 +-
YACReaderLibrary/add_library_dialog.cpp | 154 +-
YACReaderLibrary/add_library_dialog.h | 48 +-
YACReaderLibrary/bundle_creator.cpp | 5 +-
YACReaderLibrary/bundle_creator.h | 6 +-
YACReaderLibrary/classic_comics_view.cpp | 130 +-
YACReaderLibrary/classic_comics_view.h | 43 +-
YACReaderLibrary/comic_files_manager.cpp | 51 +-
YACReaderLibrary/comic_files_manager.h | 10 +-
YACReaderLibrary/comic_flow.cpp | 293 ++-
YACReaderLibrary/comic_flow.h | 76 +-
YACReaderLibrary/comic_flow_widget.cpp | 331 ++--
YACReaderLibrary/comic_flow_widget.h | 195 +-
.../comic_vine/api_key_dialog.cpp | 24 +-
YACReaderLibrary/comic_vine/api_key_dialog.h | 10 +-
...comic_vine_all_volume_comics_retriever.cpp | 32 +-
.../comic_vine_all_volume_comics_retriever.h | 1 +
.../comic_vine/comic_vine_client.cpp | 152 +-
.../comic_vine/comic_vine_client.h | 57 +-
.../comic_vine/comic_vine_dialog.cpp | 731 ++++---
.../comic_vine/comic_vine_dialog.h | 151 +-
.../comic_vine/model/comics_model.cpp | 4 +-
.../comic_vine/model/comics_model.h | 5 +-
.../comic_vine/model/json_model.cpp | 4 +-
.../comic_vine/model/json_model.h | 7 +-
.../model/local_comic_list_model.cpp | 154 +-
.../comic_vine/model/local_comic_list_model.h | 38 +-
.../comic_vine/model/response_parser.cpp | 66 +-
.../comic_vine/model/response_parser.h | 22 +-
.../comic_vine/model/volume_comics_model.cpp | 195 +-
.../comic_vine/model/volume_comics_model.h | 46 +-
.../comic_vine/model/volumes_model.cpp | 207 +-
.../comic_vine/model/volumes_model.h | 60 +-
.../comic_vine/scraper_lineedit.cpp | 21 +-
.../comic_vine/scraper_lineedit.h | 10 +-
.../comic_vine/scraper_results_paginator.cpp | 83 +-
.../comic_vine/scraper_results_paginator.h | 26 +-
.../comic_vine/scraper_scroll_label.cpp | 61 +-
.../comic_vine/scraper_scroll_label.h | 13 +-
.../comic_vine/scraper_selector.cpp | 18 +-
.../comic_vine/scraper_selector.h | 16 +-
.../comic_vine/scraper_tableview.cpp | 68 +-
.../comic_vine/scraper_tableview.h | 5 +-
.../comic_vine/search_single_comic.cpp | 60 +-
.../comic_vine/search_single_comic.h | 19 +-
YACReaderLibrary/comic_vine/search_volume.cpp | 30 +-
YACReaderLibrary/comic_vine/search_volume.h | 12 +-
YACReaderLibrary/comic_vine/select_comic.cpp | 163 +-
YACReaderLibrary/comic_vine/select_comic.h | 24 +-
YACReaderLibrary/comic_vine/select_volume.cpp | 178 +-
YACReaderLibrary/comic_vine/select_volume.h | 26 +-
.../comic_vine/series_question.cpp | 49 +-
YACReaderLibrary/comic_vine/series_question.h | 13 +-
.../comic_vine/sort_volume_comics.cpp | 210 +-
.../comic_vine/sort_volume_comics.h | 107 +-
YACReaderLibrary/comic_vine/title_header.cpp | 50 +-
YACReaderLibrary/comic_vine/title_header.h | 15 +-
YACReaderLibrary/comics_remover.cpp | 42 +-
YACReaderLibrary/comics_remover.h | 28 +-
YACReaderLibrary/comics_view.cpp | 55 +-
YACReaderLibrary/comics_view.h | 19 +-
YACReaderLibrary/comics_view_transition.cpp | 15 +-
YACReaderLibrary/create_library_dialog.cpp | 255 ++-
YACReaderLibrary/create_library_dialog.h | 94 +-
.../current_comic_view_helper.cpp | 3 +-
YACReaderLibrary/db/comic_item.cpp | 16 +-
YACReaderLibrary/db/comic_item.h | 18 +-
YACReaderLibrary/db/comic_model.cpp | 739 ++++---
YACReaderLibrary/db/comic_model.h | 101 +-
YACReaderLibrary/db/data_base_management.cpp | 832 ++++----
YACReaderLibrary/db/data_base_management.h | 65 +-
YACReaderLibrary/db/folder_item.cpp | 67 +-
YACReaderLibrary/db/folder_item.h | 23 +-
YACReaderLibrary/db/folder_model.cpp | 461 ++---
YACReaderLibrary/db/folder_model.h | 55 +-
YACReaderLibrary/db/reading_list.cpp | 7 +-
YACReaderLibrary/db/reading_list.h | 2 +-
YACReaderLibrary/db/reading_list_item.cpp | 76 +-
YACReaderLibrary/db/reading_list_item.h | 18 +-
YACReaderLibrary/db/reading_list_model.cpp | 437 ++---
YACReaderLibrary/db/reading_list_model.h | 39 +-
YACReaderLibrary/db_helper.cpp | 850 ++++----
YACReaderLibrary/db_helper.h | 120 +-
YACReaderLibrary/empty_container_info.cpp | 14 +-
YACReaderLibrary/empty_container_info.h | 8 +-
YACReaderLibrary/empty_folder_widget.cpp | 88 +-
YACReaderLibrary/empty_folder_widget.h | 14 +-
YACReaderLibrary/empty_label_widget.cpp | 6 +-
.../empty_reading_list_widget.cpp | 2 +-
YACReaderLibrary/empty_reading_list_widget.h | 2 +-
YACReaderLibrary/empty_special_list.cpp | 2 +-
YACReaderLibrary/empty_special_list.h | 2 +-
.../export_comics_info_dialog.cpp | 104 +-
YACReaderLibrary/export_comics_info_dialog.h | 29 +-
YACReaderLibrary/export_library_dialog.cpp | 124 +-
YACReaderLibrary/export_library_dialog.h | 31 +-
YACReaderLibrary/grid_comics_view.cpp | 145 +-
YACReaderLibrary/grid_comics_view.h | 43 +-
.../import_comics_info_dialog.cpp | 126 +-
YACReaderLibrary/import_comics_info_dialog.h | 49 +-
YACReaderLibrary/import_library_dialog.cpp | 194 +-
YACReaderLibrary/import_library_dialog.h | 65 +-
YACReaderLibrary/import_widget.cpp | 400 ++--
YACReaderLibrary/import_widget.h | 33 +-
YACReaderLibrary/info_comics_view.cpp | 76 +-
YACReaderLibrary/info_comics_view.h | 24 +-
YACReaderLibrary/library_creator.cpp | 1042 +++++-----
YACReaderLibrary/library_creator.h | 136 +-
YACReaderLibrary/library_window.cpp | 1633 ++++++++-------
YACReaderLibrary/library_window.h | 300 +--
YACReaderLibrary/main.cpp | 300 ++-
YACReaderLibrary/no_libraries_widget.cpp | 114 +-
YACReaderLibrary/no_libraries_widget.h | 11 +-
YACReaderLibrary/no_search_results_widget.cpp | 14 +-
YACReaderLibrary/no_search_results_widget.h | 5 +-
YACReaderLibrary/options_dialog.cpp | 56 +-
YACReaderLibrary/options_dialog.h | 42 +-
YACReaderLibrary/package_manager.cpp | 64 +-
YACReaderLibrary/package_manager.h | 21 +-
YACReaderLibrary/properties_dialog.cpp | 1201 ++++++------
YACReaderLibrary/properties_dialog.h | 189 +-
YACReaderLibrary/rename_library_dialog.cpp | 88 +-
YACReaderLibrary/rename_library_dialog.h | 36 +-
.../server/controllers/v1/comiccontroller.cpp | 58 +-
.../server/controllers/v1/comiccontroller.h | 18 +-
.../v1/comicdownloadinfocontroller.cpp | 5 +-
.../v1/comicdownloadinfocontroller.h | 6 +-
.../server/controllers/v1/covercontroller.cpp | 46 +-
.../server/controllers/v1/covercontroller.h | 7 +-
.../server/controllers/v1/errorcontroller.cpp | 32 +-
.../server/controllers/v1/errorcontroller.h | 18 +-
.../controllers/v1/foldercontroller.cpp | 407 ++--
.../server/controllers/v1/foldercontroller.h | 7 +-
.../controllers/v1/folderinfocontroller.cpp | 21 +-
.../controllers/v1/folderinfocontroller.h | 19 +-
.../controllers/v1/librariescontroller.cpp | 22 +-
.../controllers/v1/librariescontroller.h | 8 +-
.../server/controllers/v1/pagecontroller.cpp | 60 +-
.../server/controllers/v1/pagecontroller.h | 17 +-
.../controllers/v1/sessioncontroller.cpp | 12 +-
.../server/controllers/v1/synccontroller.cpp | 25 +-
.../server/controllers/v1/synccontroller.h | 5 +-
.../controllers/v1/updatecomiccontroller.cpp | 18 +-
.../controllers/v1/updatecomiccontroller.h | 4 +-
.../controllers/v2/comiccontroller_v2.cpp | 108 +-
.../controllers/v2/comiccontroller_v2.h | 11 +-
.../v2/comicdownloadinfocontroller_v2.cpp | 5 +-
.../v2/comicdownloadinfocontroller_v2.h | 5 +-
.../v2/comicfullinfocontroller_v2.cpp | 10 +-
.../v2/comicfullinfocontroller_v2.h | 9 +-
.../controllers/v2/covercontroller_v2.cpp | 33 +-
.../controllers/v2/covercontroller_v2.h | 6 +-
.../controllers/v2/errorcontroller_v2.cpp | 34 +-
.../controllers/v2/errorcontroller_v2.h | 15 +-
.../controllers/v2/favoritescontroller_v2.cpp | 13 +-
.../controllers/v2/favoritescontroller_v2.h | 6 +-
.../v2/foldercontentcontroller_v2.cpp | 37 +-
.../v2/foldercontentcontroller_v2.h | 11 +-
.../v2/folderinfocontroller_v2.cpp | 39 +-
.../controllers/v2/folderinfocontroller_v2.h | 16 +-
.../controllers/v2/librariescontroller_v2.cpp | 18 +-
.../controllers/v2/librariescontroller_v2.h | 7 +-
.../controllers/v2/pagecontroller_v2.cpp | 81 +-
.../server/controllers/v2/pagecontroller_v2.h | 12 +-
.../v2/readingcomicscontroller_v2.cpp | 8 +-
.../v2/readingcomicscontroller_v2.h | 5 +-
.../v2/readinglistcontentcontroller_v2.cpp | 6 +-
.../v2/readinglistcontentcontroller_v2.h | 5 +-
.../v2/readinglistinfocontroller_v2.cpp | 21 +-
.../v2/readinglistinfocontroller_v2.h | 11 +-
.../v2/readinglistscontroller_v2.cpp | 8 +-
.../v2/readinglistscontroller_v2.h | 5 +-
.../controllers/v2/synccontroller_v2.cpp | 29 +-
.../server/controllers/v2/synccontroller_v2.h | 5 +-
.../v2/tagcontentcontroller_v2.cpp | 14 +-
.../controllers/v2/tagcontentcontroller_v2.h | 5 +-
.../controllers/v2/taginfocontroller_v2.cpp | 19 +-
.../controllers/v2/taginfocontroller_v2.h | 9 +-
.../controllers/v2/tagscontroller_v2.cpp | 8 +-
.../server/controllers/v2/tagscontroller_v2.h | 8 +-
.../v2/updatecomiccontroller_v2.cpp | 18 +-
.../controllers/v2/updatecomiccontroller_v2.h | 4 +-
.../server/controllers/versioncontroller.cpp | 4 +-
.../server/controllers/versioncontroller.h | 12 +-
YACReaderLibrary/server/requestmapper.cpp | 264 +--
YACReaderLibrary/server/requestmapper.h | 19 +-
YACReaderLibrary/server/startup.cpp | 106 +-
YACReaderLibrary/server/startup.h | 19 +-
YACReaderLibrary/server/static.cpp | 53 +-
YACReaderLibrary/server/static.h | 11 +-
.../server/yacreader_http_session.cpp | 58 +-
.../server/yacreader_http_session.h | 36 +-
.../server/yacreader_http_session_store.cpp | 2 -
.../server/yacreader_http_session_store.h | 10 +-
.../server/yacreader_server_data_helper.cpp | 12 +-
.../server/yacreader_server_data_helper.h | 16 +-
YACReaderLibrary/server_config_dialog.cpp | 329 ++--
YACReaderLibrary/server_config_dialog.h | 67 +-
.../yacreader_comic_info_helper.cpp | 15 +-
.../yacreader_comic_info_helper.h | 2 -
.../yacreader_comics_selection_helper.cpp | 42 +-
.../yacreader_comics_selection_helper.h | 6 +-
.../yacreader_comics_views_manager.cpp | 85 +-
.../yacreader_comics_views_manager.h | 27 +-
YACReaderLibrary/yacreader_folders_view.cpp | 40 +-
YACReaderLibrary/yacreader_folders_view.h | 9 +-
.../yacreader_history_controller.cpp | 34 +-
.../yacreader_history_controller.h | 10 +-
YACReaderLibrary/yacreader_libraries.cpp | 139 +-
YACReaderLibrary/yacreader_libraries.h | 41 +-
YACReaderLibrary/yacreader_local_server.cpp | 234 +--
YACReaderLibrary/yacreader_local_server.h | 44 +-
YACReaderLibrary/yacreader_main_toolbar.cpp | 173 +-
YACReaderLibrary/yacreader_main_toolbar.h | 44 +-
.../yacreader_navigation_controller.cpp | 100 +-
.../yacreader_navigation_controller.h | 26 +-
.../yacreader_reading_lists_view.cpp | 17 +-
.../yacreader_reading_lists_view.h | 6 +-
.../console_ui_library_creator.cpp | 75 +-
.../console_ui_library_creator.h | 14 +-
YACReaderLibraryServer/libraries_updater.cpp | 16 +-
YACReaderLibraryServer/libraries_updater.h | 1 -
YACReaderLibraryServer/main.cpp | 174 +-
common/bookmarks.cpp | 179 +-
common/bookmarks.h | 113 +-
common/check_new_version.cpp | 78 +-
common/check_new_version.h | 28 +-
common/comic.cpp | 1467 +++++++-------
common/comic.h | 291 ++-
common/comic_db.cpp | 455 +++--
common/comic_db.h | 143 +-
common/custom_widgets.h | 2 -
common/exit_check.cpp | 17 +-
common/exit_check.h | 5 +-
common/folder.cpp | 38 +-
common/folder.h | 17 +-
common/gl/yacreader_flow_gl.cpp | 1595 +++++++--------
common/gl/yacreader_flow_gl.h | 495 ++---
common/http_worker.cpp | 57 +-
common/http_worker.h | 43 +-
common/library_item.h | 10 +-
common/onstart_flow_selection_dialog.cpp | 68 +-
common/onstart_flow_selection_dialog.h | 4 +-
common/opengl_checker.cpp | 16 +-
common/opengl_checker.h | 1 +
common/pdf_comic.cpp | 137 +-
common/pdf_comic.h | 52 +-
common/pdf_comic.mm | 30 +-
common/pictureflow.cpp | 1746 ++++++++---------
common/pictureflow.h | 194 +-
common/qnaturalsorting.cpp | 20 +-
common/qnaturalsorting.h | 10 +-
common/scroll_management.cpp | 18 +-
common/scroll_management.h | 6 +-
common/yacreader_global.cpp | 6 +-
common/yacreader_global.h | 70 +-
common/yacreader_global_gui.cpp | 22 +-
common/yacreader_global_gui.h | 63 +-
compressed_archive/7z_includes.h | 9 +-
compressed_archive/compressed_archive.cpp | 753 ++++---
compressed_archive/compressed_archive.h | 62 +-
compressed_archive/extract_callbacks.h | 403 ++--
compressed_archive/extract_delegate.h | 8 +-
compressed_archive/open_callbacks.h | 51 +-
.../unarr/compressed_archive.cpp | 164 +-
compressed_archive/unarr/compressed_archive.h | 40 +-
compressed_archive/unarr/extract_delegate.h | 10 +-
custom_widgets/help_about_dialog.cpp | 74 +-
custom_widgets/help_about_dialog.h | 21 +-
custom_widgets/yacreader_busy_widget.cpp | 213 +-
custom_widgets/yacreader_busy_widget.h | 44 +-
custom_widgets/yacreader_dark_menu.cpp | 32 +-
custom_widgets/yacreader_dark_menu.h | 7 +-
.../yacreader_deleting_progress.cpp | 133 +-
custom_widgets/yacreader_deleting_progress.h | 15 +-
custom_widgets/yacreader_field_edit.cpp | 39 +-
custom_widgets/yacreader_field_edit.h | 19 +-
.../yacreader_field_plain_text_edit.cpp | 47 +-
.../yacreader_field_plain_text_edit.h | 22 +-
custom_widgets/yacreader_flow.cpp | 13 +-
custom_widgets/yacreader_flow.h | 10 +-
.../yacreader_flow_config_widget.cpp | 70 +-
custom_widgets/yacreader_flow_config_widget.h | 10 +-
.../yacreader_gl_flow_config_widget.cpp | 353 ++--
.../yacreader_gl_flow_config_widget.h | 51 +-
.../yacreader_library_item_widget.cpp | 98 +-
.../yacreader_library_item_widget.h | 40 +-
.../yacreader_library_list_widget.cpp | 134 +-
.../yacreader_library_list_widget.h | 38 +-
custom_widgets/yacreader_macosx_toolbar.h | 28 +-
custom_widgets/yacreader_macosx_toolbar.mm | 157 +-
custom_widgets/yacreader_options_dialog.cpp | 429 ++--
custom_widgets/yacreader_options_dialog.h | 79 +-
custom_widgets/yacreader_search_line_edit.cpp | 98 +-
custom_widgets/yacreader_search_line_edit.h | 18 +-
custom_widgets/yacreader_sidebar.cpp | 89 +-
custom_widgets/yacreader_sidebar.h | 34 +-
custom_widgets/yacreader_social_dialog.cpp | 146 +-
custom_widgets/yacreader_social_dialog.h | 11 +-
.../yacreader_spin_slider_widget.cpp | 89 +-
custom_widgets/yacreader_spin_slider_widget.h | 38 +-
custom_widgets/yacreader_table_view.cpp | 414 ++--
custom_widgets/yacreader_table_view.h | 144 +-
custom_widgets/yacreader_titled_toolbar.cpp | 117 +-
custom_widgets/yacreader_titled_toolbar.h | 38 +-
custom_widgets/yacreader_tool_bar_stretch.h | 13 +-
custom_widgets/yacreader_treeview.cpp | 80 +-
shortcuts_management/actions_groups_model.cpp | 11 +-
shortcuts_management/actions_groups_model.h | 7 +-
.../actions_shortcuts_model.cpp | 28 +-
.../actions_shortcuts_model.h | 1 -
.../edit_shortcut_item_delegate.cpp | 54 +-
.../edit_shortcut_item_delegate.h | 3 +-
.../edit_shortcuts_dialog.cpp | 48 +-
shortcuts_management/edit_shortcuts_dialog.h | 16 +-
shortcuts_management/shortcuts_manager.cpp | 48 +-
shortcuts_management/shortcuts_manager.h | 13 +-
tests/compressed_archive_test/main.cpp | 39 +-
356 files changed, 19824 insertions(+), 21874 deletions(-)
diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp
index 7175fa33..33a1b939 100644
--- a/YACReader/bookmarks_dialog.cpp
+++ b/YACReader/bookmarks_dialog.cpp
@@ -9,174 +9,154 @@
#include "bookmarks.h"
-BookmarksDialog::BookmarksDialog(QWidget * parent)
- :QDialog(parent)
+BookmarksDialog::BookmarksDialog(QWidget *parent)
+ : QDialog(parent)
{
- setModal(true);
+ setModal(true);
- //animation = new QPropertyAnimation(this,"windowOpacity");
- //animation->setDuration(150);
+ //animation = new QPropertyAnimation(this,"windowOpacity");
+ //animation->setDuration(150);
- QHBoxLayout * layout = new QHBoxLayout();
+ QHBoxLayout *layout = new QHBoxLayout();
- //bookmarks
- QGridLayout * bookmarksL = new QGridLayout();
-
- pages.push_back(new QLabel(tr("Lastest Page")));
- for(int i=0;i<3;i++)
- pages.push_back(new QLabel("-"));
+ //bookmarks
+ QGridLayout *bookmarksL = new QGridLayout();
- QString labelsStyle = "QLabel {color:white;}";
+ pages.push_back(new QLabel(tr("Lastest Page")));
+ for (int i = 0; i < 3; i++)
+ pages.push_back(new QLabel("-"));
- foreach(QLabel * label,pages)
- {
- label->setStyleSheet(labelsStyle);
- }
-
- int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
- int height,width;
- height = heightDesktopResolution*0.50;
- width = height*0.65;
+ QString labelsStyle = "QLabel {color:white;}";
- coverSize = QSize(width,height);
+ foreach (QLabel *label, pages) {
+ label->setStyleSheet(labelsStyle);
+ }
- for(int i=0;i<4;i++)
- {
- QLabel * l = new QLabel();
- l->setFixedSize(coverSize);
- l->setScaledContents(false);
- //l->setPixmap(QPixmap(":/images/notCover.png"));
- l->installEventFilter(this);
- images.push_back(l);
- }
+ int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
+ int height, width;
+ height = heightDesktopResolution * 0.50;
+ width = height * 0.65;
- for(int i=0;i<3;i++)
- bookmarksL->addWidget(pages.at(i+1),0,i,Qt::AlignCenter);
+ coverSize = QSize(width, height);
- for(int i=0;i<3;i++)
- bookmarksL->addWidget(images.at(i+1),1,i,Qt::AlignCenter);
+ for (int i = 0; i < 4; i++) {
+ QLabel *l = new QLabel();
+ l->setFixedSize(coverSize);
+ l->setScaledContents(false);
+ //l->setPixmap(QPixmap(":/images/notCover.png"));
+ l->installEventFilter(this);
+ images.push_back(l);
+ }
+ for (int i = 0; i < 3; i++)
+ bookmarksL->addWidget(pages.at(i + 1), 0, i, Qt::AlignCenter);
- //last page
- QGridLayout * lp = new QGridLayout();
- lp->addWidget(pages.at(0),0,0,Qt::AlignCenter);
- lp->addWidget(images.at(0),1,0,Qt::AlignCenter);
+ for (int i = 0; i < 3; i++)
+ bookmarksL->addWidget(images.at(i + 1), 1, i, Qt::AlignCenter);
- layout->addLayout(bookmarksL);
- QFrame *f = new QFrame( this );
- f->setFrameStyle( QFrame::VLine | QFrame::Sunken );
- layout->addWidget(f);
- layout->addLayout(lp);
+ //last page
+ QGridLayout *lp = new QGridLayout();
+ lp->addWidget(pages.at(0), 0, 0, Qt::AlignCenter);
+ lp->addWidget(images.at(0), 1, 0, Qt::AlignCenter);
- QHBoxLayout * buttons = new QHBoxLayout();
+ layout->addLayout(bookmarksL);
+ QFrame *f = new QFrame(this);
+ f->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ layout->addWidget(f);
+ layout->addLayout(lp);
- cancel = new QPushButton(tr("Close"));
+ QHBoxLayout *buttons = new QHBoxLayout();
+
+ cancel = new QPushButton(tr("Close"));
cancel->setFlat(true);
- connect(cancel,SIGNAL(clicked()),this,SLOT(hide()));
- buttons->addStretch();
- buttons->addWidget(cancel);
+ connect(cancel, SIGNAL(clicked()), this, SLOT(hide()));
+ buttons->addStretch();
+ buttons->addWidget(cancel);
cancel->setStyleSheet("QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}");
- QVBoxLayout * l = new QVBoxLayout();
+ QVBoxLayout *l = new QVBoxLayout();
- l->addWidget(new QLabel(""+tr("Click on any image to go to the bookmark")+""),0,Qt::AlignCenter);
- l->addLayout(layout);
+ l->addWidget(new QLabel("" + tr("Click on any image to go to the bookmark") + ""), 0, Qt::AlignCenter);
+ l->addLayout(layout);
#ifdef Q_OS_MAC
l->addLayout(buttons);
#endif
- QPalette Pal(palette());
- // set black background
- Pal.setColor(QPalette::Background, QColor("#454545"));
- this->setAutoFillBackground(true);
- this->setPalette(Pal);
+ QPalette Pal(palette());
+ // set black background
+ Pal.setColor(QPalette::Background, QColor("#454545"));
+ this->setAutoFillBackground(true);
+ this->setPalette(Pal);
setLayout(l);
}
-void BookmarksDialog::setBookmarks(const Bookmarks & bm)
+void BookmarksDialog::setBookmarks(const Bookmarks &bm)
{
- lastPage = bm.getLastPage();
- if (lastPage > 0)
- {
- QPixmap p = QPixmap::fromImage(bm.getLastPagePixmap());
- if(p.isNull())
- {
- images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
- images.at(0)->setText(tr("Loading..."));
- }
- else
- {
- images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
- images.at(0)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
- }
- }
- else
- {
- images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
- images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
+ lastPage = bm.getLastPage();
+ if (lastPage > 0) {
+ QPixmap p = QPixmap::fromImage(bm.getLastPagePixmap());
+ if (p.isNull()) {
+ images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ images.at(0)->setText(tr("Loading..."));
+ } else {
+ images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
+ images.at(0)->setPixmap(p.scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
+ } else {
+ images.at(0)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
- }
-
- QList l = bm.getBookmarkPages();
- int s = l.count();
- for(int i=0;isetText(QString::number(l.at(i)+1));
- QPixmap p = QPixmap::fromImage(bm.getBookmarkPixmap(l.at(i)));
- if(p.isNull())
- {
- images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
- images.at(i+1)->setText(tr("Loading..."));
- }
- else
- {
- images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom);
- images.at(i+1)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
- }
- }
- for(int i=s;i<3;i++)
- {
- pages.at(i+1)->setText("-");
- images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
- images.at(i+1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation));
- }
+ QList l = bm.getBookmarkPages();
+ int s = l.count();
+ for (int i = 0; i < s; i++) {
+ pages.at(i + 1)->setText(QString::number(l.at(i) + 1));
+ QPixmap p = QPixmap::fromImage(bm.getBookmarkPixmap(l.at(i)));
+ if (p.isNull()) {
+ images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ images.at(i + 1)->setText(tr("Loading..."));
+ } else {
+ images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
+ images.at(i + 1)->setPixmap(p.scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
+ }
+ for (int i = s; i < 3; i++) {
+ pages.at(i + 1)->setText("-");
+ images.at(i + 1)->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ images.at(i + 1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ }
}
bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event)
{
- if(event->type() == QEvent::MouseButtonPress)
- {
- if (obj == images.at(0))
- {
- emit(goToPage(lastPage));
- close();
- event->accept();
- }
- for(int i=1;i<=3;i++)
- {
- if(obj == images.at(i))
- {
- bool b;
- int page = pages.at(i)->text().toInt(&b)-1;
- if(b)
- {
- emit(goToPage(page));
- close();
- }
- event->accept();
- }
- }
- }
- // pass the event on to the parent class
- return QDialog::eventFilter(obj, event);
+ if (event->type() == QEvent::MouseButtonPress) {
+ if (obj == images.at(0)) {
+ emit(goToPage(lastPage));
+ close();
+ event->accept();
+ }
+ for (int i = 1; i <= 3; i++) {
+ if (obj == images.at(i)) {
+ bool b;
+ int page = pages.at(i)->text().toInt(&b) - 1;
+ if (b) {
+ emit(goToPage(page));
+ close();
+ }
+ event->accept();
+ }
+ }
+ }
+ // pass the event on to the parent class
+ return QDialog::eventFilter(obj, event);
}
-void BookmarksDialog::keyPressEvent(QKeyEvent * event)
+void BookmarksDialog::keyPressEvent(QKeyEvent *event)
{
- if(event->key() == Qt::Key_M)
- hide();
+ if (event->key() == Qt::Key_M)
+ hide();
}
/*
void BookmarksDialog::show()
diff --git a/YACReader/bookmarks_dialog.h b/YACReader/bookmarks_dialog.h
index 4838ee75..2b520663 100644
--- a/YACReader/bookmarks_dialog.h
+++ b/YACReader/bookmarks_dialog.h
@@ -11,35 +11,35 @@
#include "bookmarks.h"
- class BookmarksDialog : public QDialog
- {
- Q_OBJECT
+class BookmarksDialog : public QDialog
+{
+ Q_OBJECT
- protected:
- QList pages;
- QList images;
+protected:
+ QList pages;
+ QList images;
- int lastPage;
+ int lastPage;
- QPushButton * accept;
- QPushButton * cancel;
+ QPushButton *accept;
+ QPushButton *cancel;
- QSize coverSize;
+ QSize coverSize;
- bool eventFilter(QObject *obj, QEvent *event);
- void keyPressEvent(QKeyEvent * event);
- //QPropertyAnimation * animation;
+ bool eventFilter(QObject *obj, QEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ //QPropertyAnimation * animation;
- public:
- BookmarksDialog(QWidget * parent = 0);
-
- public slots:
- void setBookmarks(const Bookmarks & bookmarks);
- //void show();
- //void hide();
-
- signals:
- void goToPage(unsigned int page);
- };
+public:
+ BookmarksDialog(QWidget *parent = 0);
+
+public slots:
+ void setBookmarks(const Bookmarks &bookmarks);
+ //void show();
+ //void hide();
+
+signals:
+ void goToPage(unsigned int page);
+};
#endif // BOOKMARKS_DIALOG_H
diff --git a/YACReader/configuration.cpp b/YACReader/configuration.cpp
index 36e9aeea..78476e50 100644
--- a/YACReader/configuration.cpp
+++ b/YACReader/configuration.cpp
@@ -11,7 +11,7 @@
Configuration::Configuration()
{
- //read configuration
+ //read configuration
//load("/YACReader.conf");
}
@@ -25,55 +25,54 @@ QSettings *Configuration::getSettings()
//nothing
}*/
-void Configuration::load(QSettings * settings)
+void Configuration::load(QSettings *settings)
{
- this->settings = settings;
+ this->settings = settings;
- //TODO set defaults
- if(!settings->contains(PATH))
- settings->setValue(PATH,".");
- if(!settings->contains(GO_TO_FLOW_SIZE))
- settings->setValue(GO_TO_FLOW_SIZE,QSize(126,200));
- if(!settings->contains(MAG_GLASS_SIZE))
- settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
- if(!settings->contains(ZOOM_LEVEL))
- settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
- if(!settings->contains(FLOW_TYPE))
- settings->setValue(FLOW_TYPE,0);
- if(!settings->contains(FULLSCREEN))
- settings->setValue(FULLSCREEN,false);
- if(!settings->contains(Y_WINDOW_SIZE))
- settings->setValue(Y_WINDOW_SIZE,QSize(0,0));
- if(!settings->contains(MAXIMIZED))
- settings->setValue(MAXIMIZED,false);
- if(!settings->contains(DOUBLE_PAGE))
- settings->setValue(DOUBLE_PAGE,false);
- if(!settings->contains(BACKGROUND_COLOR))
- settings->setValue(BACKGROUND_COLOR,QColor(40,40,40));
- if(!settings->contains(ALWAYS_ON_TOP))
- settings->setValue(ALWAYS_ON_TOP,false);
- if(!settings->contains(SHOW_TOOLBARS))
- settings->setValue(SHOW_TOOLBARS, true);
- if(!settings->contains(QUICK_NAVI_MODE))
+ //TODO set defaults
+ if (!settings->contains(PATH))
+ settings->setValue(PATH, ".");
+ if (!settings->contains(GO_TO_FLOW_SIZE))
+ settings->setValue(GO_TO_FLOW_SIZE, QSize(126, 200));
+ if (!settings->contains(MAG_GLASS_SIZE))
+ settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
+ if (!settings->contains(ZOOM_LEVEL))
+ settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
+ if (!settings->contains(FLOW_TYPE))
+ settings->setValue(FLOW_TYPE, 0);
+ if (!settings->contains(FULLSCREEN))
+ settings->setValue(FULLSCREEN, false);
+ if (!settings->contains(Y_WINDOW_SIZE))
+ settings->setValue(Y_WINDOW_SIZE, QSize(0, 0));
+ if (!settings->contains(MAXIMIZED))
+ settings->setValue(MAXIMIZED, false);
+ if (!settings->contains(DOUBLE_PAGE))
+ settings->setValue(DOUBLE_PAGE, false);
+ if (!settings->contains(BACKGROUND_COLOR))
+ settings->setValue(BACKGROUND_COLOR, QColor(40, 40, 40));
+ if (!settings->contains(ALWAYS_ON_TOP))
+ settings->setValue(ALWAYS_ON_TOP, false);
+ if (!settings->contains(SHOW_TOOLBARS))
+ settings->setValue(SHOW_TOOLBARS, true);
+ if (!settings->contains(QUICK_NAVI_MODE))
settings->setValue(QUICK_NAVI_MODE, false);
- //old fit stuff
- /*if(!settings->contains(FIT))
+ //old fit stuff
+ /*if(!settings->contains(FIT))
settings->setValue(FIT,false);
if(!settings->contains(FIT_TO_WIDTH_RATIO))
settings->setValue(FIT_TO_WIDTH_RATIO,1);
if(!settings->contains(ADJUST_TO_FULL_SIZE))
settings->setValue(ADJUST_TO_FULL_SIZE,false);
*/
- }
-void Configuration::updateOpenRecentList (QString path)
-{
- QStringList list = openRecentList();
- list.removeAll(path);
- list.prepend(path);
- //TODO: Make list lenght configurable
- while (list.length() > getOpenRecentSize())
- {
- list.removeLast();
- }
- settings->setValue("recentFiles", list);
+}
+void Configuration::updateOpenRecentList(QString path)
+{
+ QStringList list = openRecentList();
+ list.removeAll(path);
+ list.prepend(path);
+ //TODO: Make list lenght configurable
+ while (list.length() > getOpenRecentSize()) {
+ list.removeLast();
+ }
+ settings->setValue("recentFiles", list);
}
diff --git a/YACReader/configuration.h b/YACReader/configuration.h
index 93abfa0f..8dd0815f 100644
--- a/YACReader/configuration.h
+++ b/YACReader/configuration.h
@@ -15,65 +15,64 @@
using namespace YACReader;
- class Configuration : public QObject
- {
- Q_OBJECT
+class Configuration : public QObject
+{
+ Q_OBJECT
- private:
- QSettings * settings;
+private:
+ QSettings *settings;
- QString defaultPath;
- //configuration properties
- QSize magnifyingGlassSize;
- QSize gotoSlideSize;
- float zoomLevel;
- bool adjustToWidth;
- bool fullScreen;
- FlowType flowType;
- float fitToWidthRatio;
- QPoint windowPos;
- QSize windowSize;
- bool maximized;
- bool doublePage;
- bool doubleMangaPage;
- bool alwaysOnTop;
- bool adjustToFullSize;
- QColor backgroundColor;
+ QString defaultPath;
+ //configuration properties
+ QSize magnifyingGlassSize;
+ QSize gotoSlideSize;
+ float zoomLevel;
+ bool adjustToWidth;
+ bool fullScreen;
+ FlowType flowType;
+ float fitToWidthRatio;
+ QPoint windowPos;
+ QSize windowSize;
+ bool maximized;
+ bool doublePage;
+ bool doubleMangaPage;
+ bool alwaysOnTop;
+ bool adjustToFullSize;
+ QColor backgroundColor;
- Configuration();
- //Configuration(const Configuration & conf);
- void load(const QString & path = CONF_FILE_PATH);
+ Configuration();
+ //Configuration(const Configuration & conf);
+ void load(const QString &path = CONF_FILE_PATH);
+public:
+ static Configuration &getConfiguration()
+ {
+ static Configuration configuration;
+ return configuration;
+ };
+ QSettings *getSettings();
+ void load(QSettings *settings);
+ QString getDefaultPath() { return settings->value(PATH).toString(); }
+ void setDefaultPath(QString defaultPath) { settings->setValue(PATH, defaultPath); }
+ QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize(); }
+ void setMagnifyingGlassSize(const QSize &mgs) { settings->setValue(MAG_GLASS_SIZE, mgs); }
+ QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize(); }
+ void setGotoSlideSize(const QSize &gss) { settings->setValue(GO_TO_FLOW_SIZE, gss); }
+ float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat(); }
+ void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL, zl); }
- public:
- static Configuration & getConfiguration()
- {
- static Configuration configuration;
- return configuration;
- };
- QSettings *getSettings();
- void load(QSettings * settings);
- QString getDefaultPath() { return settings->value(PATH).toString(); }
- void setDefaultPath(QString defaultPath){settings->setValue(PATH,defaultPath);}
- QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize();}
- void setMagnifyingGlassSize(const QSize & mgs) { settings->setValue(MAG_GLASS_SIZE,mgs);}
- QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize();}
- void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);}
- float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();}
- void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);}
+ //Unified enum based fitmode
+ YACReader::FitMode getFitMode() { return static_cast(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); }
+ void setFitMode(YACReader::FitMode fitMode) { settings->setValue(FITMODE, static_cast(fitMode)); }
- //Unified enum based fitmode
- YACReader::FitMode getFitMode() { return static_cast(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); }
- void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast(fitMode)); }
+ //openRecent
+ int getOpenRecentSize() { return settings->value("recentSize", 25).toInt(); }
+ QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
+ void updateOpenRecentList(QString path);
+ void clearOpenRecentList() { settings->remove("recentFiles"); }
- //openRecent
- int getOpenRecentSize() { return settings->value("recentSize", 25).toInt();}
- QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
- void updateOpenRecentList (QString path);
- void clearOpenRecentList() { settings->remove("recentFiles"); }
-
- //Old fitmodes
- /*
+ //Old fitmodes
+ /*
bool getAdjustToWidth() {return settings->value(FIT).toBool();}
void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);}
float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();}
@@ -82,36 +81,36 @@ using namespace YACReader;
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
*/
- FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();}
- void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);}
- bool getFullScreen(){return settings->value(FULLSCREEN).toBool();}
- void setFullScreen(bool f){settings->setValue(FULLSCREEN,f);}
+ FlowType getFlowType() { return (FlowType)settings->value(FLOW_TYPE_SW).toInt(); }
+ void setFlowType(FlowType type) { settings->setValue(FLOW_TYPE_SW, type); }
+ bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); }
+ void setFullScreen(bool f) { settings->setValue(FULLSCREEN, f); }
- QPoint getPos(){return settings->value(Y_WINDOW_POS).toPoint();}
- void setPos(QPoint p){settings->setValue(Y_WINDOW_POS,p);}
- QSize getSize(){return settings->value(Y_WINDOW_SIZE).toSize();}
- void setSize(QSize s){settings->setValue(Y_WINDOW_SIZE,s);}
- bool getMaximized(){return settings->value(MAXIMIZED).toBool();}
- void setMaximized(bool b){settings->setValue(MAXIMIZED,b);}
- bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();}
- void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);}
- bool getDoubleMangaPage(){return settings->value(DOUBLE_MANGA_PAGE).toBool();}
- void setDoubleMangaPage(bool b){settings->setValue(DOUBLE_MANGA_PAGE,b);}
+ QPoint getPos() { return settings->value(Y_WINDOW_POS).toPoint(); }
+ void setPos(QPoint p) { settings->setValue(Y_WINDOW_POS, p); }
+ QSize getSize() { return settings->value(Y_WINDOW_SIZE).toSize(); }
+ void setSize(QSize s) { settings->setValue(Y_WINDOW_SIZE, s); }
+ bool getMaximized() { return settings->value(MAXIMIZED).toBool(); }
+ void setMaximized(bool b) { settings->setValue(MAXIMIZED, b); }
+ bool getDoublePage() { return settings->value(DOUBLE_PAGE).toBool(); }
+ void setDoublePage(bool b) { settings->setValue(DOUBLE_PAGE, b); }
+ bool getDoubleMangaPage() { return settings->value(DOUBLE_MANGA_PAGE).toBool(); }
+ void setDoubleMangaPage(bool b) { settings->setValue(DOUBLE_MANGA_PAGE, b); }
- QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value();}
- void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);}
- bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();}
- void setAlwaysOnTop(bool b){ settings->setValue(ALWAYS_ON_TOP,b);}
- bool getShowToolbars(){return settings->value(SHOW_TOOLBARS).toBool();}
- void setShowToolbars(bool b){settings->setValue(SHOW_TOOLBARS,b);}
- bool getShowInformation(){return settings->value(SHOW_INFO,false).toBool();}
- void setShowInformation(bool b){settings->setValue(SHOW_INFO,b);}
- QDate getLastVersionCheck(){return settings->value(LAST_VERSION_CHECK).toDate();}
- void setLastVersionCheck(const QDate & date){ settings->setValue(LAST_VERSION_CHECK,date);}
- int getNumDaysBetweenVersionChecks() {return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS,1).toInt();}
- void setNumDaysBetweenVersionChecks(int days) {return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS,days);}
- bool getQuickNaviMode(){return settings->value(QUICK_NAVI_MODE).toBool();}
- bool getDisableShowOnMouseOver(){return settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool();}
- };
+ QColor getBackgroundColor() { return settings->value(BACKGROUND_COLOR).value(); }
+ void setBackgroundColor(const QColor &color) { settings->value(BACKGROUND_COLOR, color); }
+ bool getAlwaysOnTop() { return settings->value(ALWAYS_ON_TOP).toBool(); }
+ void setAlwaysOnTop(bool b) { settings->setValue(ALWAYS_ON_TOP, b); }
+ bool getShowToolbars() { return settings->value(SHOW_TOOLBARS).toBool(); }
+ void setShowToolbars(bool b) { settings->setValue(SHOW_TOOLBARS, b); }
+ bool getShowInformation() { return settings->value(SHOW_INFO, false).toBool(); }
+ void setShowInformation(bool b) { settings->setValue(SHOW_INFO, b); }
+ QDate getLastVersionCheck() { return settings->value(LAST_VERSION_CHECK).toDate(); }
+ void setLastVersionCheck(const QDate &date) { settings->setValue(LAST_VERSION_CHECK, date); }
+ int getNumDaysBetweenVersionChecks() { return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS, 1).toInt(); }
+ void setNumDaysBetweenVersionChecks(int days) { return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS, days); }
+ bool getQuickNaviMode() { return settings->value(QUICK_NAVI_MODE).toBool(); }
+ bool getDisableShowOnMouseOver() { return settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool(); }
+};
#endif
diff --git a/YACReader/goto_dialog.cpp b/YACReader/goto_dialog.cpp
index 2b931583..7d0ce1af 100644
--- a/YACReader/goto_dialog.cpp
+++ b/YACReader/goto_dialog.cpp
@@ -4,81 +4,78 @@
#include
#include
-
-
-GoToDialog::GoToDialog(QWidget * parent)
-:QDialog(parent)
+GoToDialog::GoToDialog(QWidget *parent)
+ : QDialog(parent)
{
- setupUI();
+ setupUI();
}
void GoToDialog::setupUI()
{
- textLabel = new QLabel(tr("Page : "));
- pageNumber = new QLineEdit;
- v = new QIntValidator(this);
- v->setBottom(1);
- pageNumber->setValidator(v);
- textLabel->setBuddy(pageNumber);
- textLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ textLabel = new QLabel(tr("Page : "));
+ pageNumber = new QLineEdit;
+ v = new QIntValidator(this);
+ v->setBottom(1);
+ pageNumber->setValidator(v);
+ textLabel->setBuddy(pageNumber);
+ textLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
- accept = new QPushButton(tr("Go To"));
- connect(accept,SIGNAL(clicked()),this,SLOT(goTo()));
- cancel = new QPushButton(tr("Cancel"));
- connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
+ accept = new QPushButton(tr("Go To"));
+ connect(accept, SIGNAL(clicked()), this, SLOT(goTo()));
+ cancel = new QPushButton(tr("Cancel"));
+ connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
- QHBoxLayout *topLayout = new QHBoxLayout;
+ QHBoxLayout *topLayout = new QHBoxLayout;
- topLayout->addWidget(textLabel);
- topLayout->addWidget(pageNumber);
+ topLayout->addWidget(textLabel);
+ topLayout->addWidget(pageNumber);
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addStretch();
- bottomLayout->addWidget(accept);
- bottomLayout->addWidget(cancel);
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addWidget(accept);
+ bottomLayout->addWidget(cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(numPagesLabel = new QLabel(tr("Total pages : ")));
- mainLayout->addLayout(topLayout);
- mainLayout->addStretch();
- mainLayout->addLayout(bottomLayout);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(numPagesLabel = new QLabel(tr("Total pages : ")));
+ mainLayout->addLayout(topLayout);
+ mainLayout->addStretch();
+ mainLayout->addLayout(bottomLayout);
- QHBoxLayout *imgMainLayout = new QHBoxLayout;
- QLabel * imgLabel = new QLabel();
- QPixmap p(":/images/goto.png");
- imgLabel->setPixmap(p);
- imgMainLayout->addWidget(imgLabel);
- imgMainLayout->addLayout(mainLayout);
+ QHBoxLayout *imgMainLayout = new QHBoxLayout;
+ QLabel *imgLabel = new QLabel();
+ QPixmap p(":/images/goto.png");
+ imgLabel->setPixmap(p);
+ imgMainLayout->addWidget(imgLabel);
+ imgMainLayout->addLayout(mainLayout);
- setLayout(imgMainLayout);
+ setLayout(imgMainLayout);
- setWindowTitle(tr("Go to..."));
- setModal (true);
+ setWindowTitle(tr("Go to..."));
+ setModal(true);
- pageNumber->setFocusPolicy(Qt::StrongFocus);
- pageNumber->setFocus();
+ pageNumber->setFocusPolicy(Qt::StrongFocus);
+ pageNumber->setFocus();
}
void GoToDialog::goTo()
{
- unsigned int page = pageNumber->text().toInt();
- pageNumber->clear();
+ unsigned int page = pageNumber->text().toInt();
+ pageNumber->clear();
- if(page >= 1)
- emit(goToPage(page-1));
-
- close();
+ if (page >= 1)
+ emit(goToPage(page - 1));
+ close();
}
void GoToDialog::setNumPages(unsigned int numPages)
{
- numPagesLabel->setText(tr("Total pages : ")+QString::number(numPages));
- v->setTop(numPages);
+ numPagesLabel->setText(tr("Total pages : ") + QString::number(numPages));
+ v->setTop(numPages);
}
void GoToDialog::open()
{
- pageNumber->setFocus();
+ pageNumber->setFocus();
QDialog::open();
}
diff --git a/YACReader/goto_dialog.h b/YACReader/goto_dialog.h
index bf19444e..29f52b6d 100644
--- a/YACReader/goto_dialog.h
+++ b/YACReader/goto_dialog.h
@@ -7,26 +7,26 @@
#include
#include
- class GoToDialog : public QDialog
- {
- Q_OBJECT
- public:
- GoToDialog(QWidget * parent = 0);
- private:
- QLabel * numPagesLabel;
- QLabel * textLabel;
- QLineEdit * pageNumber;
- QIntValidator * v;
- QPushButton * accept;
- QPushButton * cancel;
- void setupUI();
- public slots:
- void goTo();
- void setNumPages(unsigned int numPages);
- void open();
- signals:
- void goToPage(unsigned int page);
- };
+class GoToDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ GoToDialog(QWidget *parent = 0);
+
+private:
+ QLabel *numPagesLabel;
+ QLabel *textLabel;
+ QLineEdit *pageNumber;
+ QIntValidator *v;
+ QPushButton *accept;
+ QPushButton *cancel;
+ void setupUI();
+public slots:
+ void goTo();
+ void setNumPages(unsigned int numPages);
+ void open();
+signals:
+ void goToPage(unsigned int page);
+};
#endif
-
diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp
index b8734a56..27c0c000 100644
--- a/YACReader/goto_flow.cpp
+++ b/YACReader/goto_flow.cpp
@@ -25,204 +25,197 @@
#include "goto_flow_toolbar.h"
-
-GoToFlow::GoToFlow(QWidget *parent,FlowType flowType)
- :GoToFlowWidget(parent),ready(false)
+GoToFlow::GoToFlow(QWidget *parent, FlowType flowType)
+ : GoToFlowWidget(parent), ready(false)
{
- updateTimer = new QTimer;
- connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
+ updateTimer = new QTimer;
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
- worker = new PageLoader(&mutexGoToFlow);
+ worker = new PageLoader(&mutexGoToFlow);
- flow = new YACReaderFlow(this,flowType);
- flow->setReflectionEffect(PictureFlow::PlainReflection);
- imageSize = Configuration::getConfiguration().getGotoSlideSize();
+ flow = new YACReaderFlow(this, flowType);
+ flow->setReflectionEffect(PictureFlow::PlainReflection);
+ imageSize = Configuration::getConfiguration().getGotoSlideSize();
- flow->setSlideSize(imageSize);
- connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
- connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
+ flow->setSlideSize(imageSize);
+ connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(setPageNumber(int)));
+ connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
- connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
- connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(showSlide(unsigned int)));
+ connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
+ connect(toolBar, SIGNAL(setCenter(unsigned int)), flow, SLOT(showSlide(unsigned int)));
- mainLayout->addWidget(flow);
- toolBar->raise();
+ mainLayout->addWidget(flow);
+ toolBar->raise();
- resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7));
+ resize(static_cast(5 * imageSize.width()), toolBar->height() + static_cast(imageSize.height() * 1.7));
- this->setCursor(QCursor(Qt::ArrowCursor));
+ this->setCursor(QCursor(Qt::ArrowCursor));
}
GoToFlow::~GoToFlow()
{
- delete flow;
- delete updateTimer;
- worker->deleteLater();
+ delete flow;
+ delete updateTimer;
+ worker->deleteLater();
}
void GoToFlow::keyPressEvent(QKeyEvent *event)
{
- switch (event->key())
- {
- case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
- QApplication::sendEvent(flow,event);
- return;
- default:
- break;
- }
+ switch (event->key()) {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ QApplication::sendEvent(flow, event);
+ return;
+ default:
+ break;
+ }
- GoToFlowWidget::keyPressEvent(event);
+ GoToFlowWidget::keyPressEvent(event);
}
void GoToFlow::resizeEvent(QResizeEvent *event)
{
- QWidget::resizeEvent(event);
+ QWidget::resizeEvent(event);
- toolBar->move(0, event->size().height() - toolBar->height());
- toolBar->setFixedWidth(width());
+ toolBar->move(0, event->size().height() - toolBar->height());
+ toolBar->setFixedWidth(width());
}
-
void GoToFlow::centerSlide(int slide)
{
- if(flow->centerIndex()!=slide)
- {
- flow->setCenterIndex(slide);
- if(ready)// load images if pages are loaded.
- {
- //worker->reset(); //BUG FIXED : image didn't load if worker was working
- preload();
- }
- }
+ if (flow->centerIndex() != slide) {
+ flow->setCenterIndex(slide);
+ if (ready) // load images if pages are loaded.
+ {
+ //worker->reset(); //BUG FIXED : image didn't load if worker was working
+ preload();
+ }
+ }
}
void GoToFlow::setNumSlides(unsigned int slides)
{
- // numPagesLabel->setText(tr("Total pages : ")+QString::number(slides));
- // numPagesLabel->adjustSize();
- imagesReady.clear();
- imagesReady.fill(false,slides);
+ // numPagesLabel->setText(tr("Total pages : ")+QString::number(slides));
+ // numPagesLabel->adjustSize();
+ imagesReady.clear();
+ imagesReady.fill(false, slides);
- rawImages.clear();
- rawImages.resize(slides);
+ rawImages.clear();
+ rawImages.resize(slides);
- toolBar->setTop(slides);
+ toolBar->setTop(slides);
- imagesLoaded.clear();
- imagesLoaded.fill(false,slides);
+ imagesLoaded.clear();
+ imagesLoaded.fill(false, slides);
- imagesSetted.clear();
- imagesSetted.fill(false,slides);
+ imagesSetted.clear();
+ imagesSetted.fill(false, slides);
- numImagesLoaded = 0;
+ numImagesLoaded = 0;
- connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
- connect(flow, SIGNAL(centerIndexChangedSilent(int)), this, SLOT(preload()));
+ connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
+ connect(flow, SIGNAL(centerIndexChangedSilent(int)), this, SLOT(preload()));
- ready = true;
- worker->reset();
+ ready = true;
+ worker->reset();
- flow->clear();
- for(unsigned int i=0;iaddSlide(QImage());
- flow->setCenterIndex(0);
+ flow->clear();
+ for (unsigned int i = 0; i < slides; i++)
+ flow->addSlide(QImage());
+ flow->setCenterIndex(0);
}
void GoToFlow::reset()
{
- updateTimer->stop();
- /*imagesLoaded.clear();
+ updateTimer->stop();
+ /*imagesLoaded.clear();
numImagesLoaded = 0;
imagesReady.clear();
rawImages.clear();*/
- ready = false;
+ ready = false;
}
-void GoToFlow::setImageReady(int index,const QByteArray & image)
+void GoToFlow::setImageReady(int index, const QByteArray &image)
{
- rawImages[index]=image;
- imagesReady[index]=true;
- preload();
+ rawImages[index] = image;
+ imagesReady[index] = true;
+ preload();
}
void GoToFlow::preload()
{
- if(numImagesLoaded < imagesLoaded.size())
- updateTimer->start(30); //TODO comprobar rendimiento, antes era 70
+ if (numImagesLoaded < imagesLoaded.size())
+ updateTimer->start(30); //TODO comprobar rendimiento, antes era 70
}
void GoToFlow::updateImageData()
{
- // can't do anything, wait for the next possibility
- if(worker->busy())
- return;
+ // can't do anything, wait for the next possibility
+ if (worker->busy())
+ return;
- // set image of last one
- int idx = worker->index();
- if( idx >= 0 && !worker->result().isNull())
- {
- if(!imagesSetted[idx])
- {
- flow->setSlide(idx, worker->result());
- imagesSetted[idx] = true;
- numImagesLoaded++;
- rawImages[idx].clear();; //release memory
- imagesLoaded[idx]=true;
- }
+ // set image of last one
+ int idx = worker->index();
+ if (idx >= 0 && !worker->result().isNull()) {
+ if (!imagesSetted[idx]) {
+ flow->setSlide(idx, worker->result());
+ imagesSetted[idx] = true;
+ numImagesLoaded++;
+ rawImages[idx].clear();
+ ; //release memory
+ imagesLoaded[idx] = true;
+ }
+ }
- }
-
- // try to load only few images on the left and right side
- // i.e. all visible ones plus some extra
+ // try to load only few images on the left and right side
+ // i.e. all visible ones plus some extra
#define COUNT 8
- int indexes[2*COUNT+1];
- int center = flow->centerIndex();
- indexes[0] = center;
- for(int j = 0; j < COUNT; j++)
- {
- indexes[j*2+1] = center+j+1;
- indexes[j*2+2] = center-j-1;
- }
- for(int c = 0; c < 2*COUNT+1; c++)
- {
- int i = indexes[c];
- if((i >= 0) && (i < flow->slideCount()))
- if(!imagesLoaded[i]&&imagesReady[i])//slide(i).isNull())
- {
- // schedule thumbnail generation
+ int indexes[2 * COUNT + 1];
+ int center = flow->centerIndex();
+ indexes[0] = center;
+ for (int j = 0; j < COUNT; j++) {
+ indexes[j * 2 + 1] = center + j + 1;
+ indexes[j * 2 + 2] = center - j - 1;
+ }
+ for (int c = 0; c < 2 * COUNT + 1; c++) {
+ int i = indexes[c];
+ if ((i >= 0) && (i < flow->slideCount()))
+ if (!imagesLoaded[i] && imagesReady[i]) //slide(i).isNull())
+ {
+ // schedule thumbnail generation
- worker->generate(i, flow->slideSize(),rawImages[i]);
- return;
- }
+ worker->generate(i, flow->slideSize(), rawImages[i]);
+ return;
+ }
+ }
- }
-
- // no need to generate anything? stop polling...
- updateTimer->stop();
+ // no need to generate anything? stop polling...
+ updateTimer->stop();
}
-void GoToFlow::wheelEvent(QWheelEvent * event)
+void GoToFlow::wheelEvent(QWheelEvent *event)
{
- if(event->delta()<0)
- flow->showNext();
- else
- flow->showPrevious();
- event->accept();
+ if (event->delta() < 0)
+ flow->showNext();
+ else
+ flow->showPrevious();
+ event->accept();
}
void GoToFlow::setFlowType(FlowType flowType)
{
- flow->setFlowType(flowType);
+ flow->setFlowType(flowType);
}
-void GoToFlow::updateConfig(QSettings * settings)
+void GoToFlow::updateConfig(QSettings *settings)
{
- GoToFlowWidget::updateConfig(settings);
+ GoToFlowWidget::updateConfig(settings);
- imageSize = Configuration::getConfiguration().getGotoSlideSize();
- flow->setFlowType(Configuration::getConfiguration().getFlowType());
- resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
- updateSize();
+ imageSize = Configuration::getConfiguration().getGotoSlideSize();
+ flow->setFlowType(Configuration::getConfiguration().getFlowType());
+ resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
+ updateSize();
}
void GoToFlow::setFlowRightToLeft(bool b)
@@ -234,74 +227,71 @@ void GoToFlow::setFlowRightToLeft(bool b)
//PageLoader
//-----------------------------------------------------------------------------
-PageLoader::PageLoader(QMutex * m):
- QThread(),mutex(m), restart(false), working(false), idx(-1)
+PageLoader::PageLoader(QMutex *m)
+ : QThread(), mutex(m), restart(false), working(false), idx(-1)
{
}
PageLoader::~PageLoader()
{
- //TODO this destructor never runs. If it is ever called, it will hang, because
- //the implementation is broken due to the absolutely endless loop in run().
- mutex->lock();
- condition.wakeOne();
- mutex->unlock();
- wait();
+ //TODO this destructor never runs. If it is ever called, it will hang, because
+ //the implementation is broken due to the absolutely endless loop in run().
+ mutex->lock();
+ condition.wakeOne();
+ mutex->unlock();
+ wait();
}
bool PageLoader::busy() const
{
- return isRunning() ? working : false;
+ return isRunning() ? working : false;
}
-void PageLoader::generate(int index, QSize size,const QByteArray & rImage)
+void PageLoader::generate(int index, QSize size, const QByteArray &rImage)
{
- mutex->lock();
- this->idx = index;
- //this->img = QImage();
- this->size = size;
- this->rawImage = rImage;
- mutex->unlock();
+ mutex->lock();
+ this->idx = index;
+ //this->img = QImage();
+ this->size = size;
+ this->rawImage = rImage;
+ mutex->unlock();
- if (!isRunning())
- start();
- else
- {
- mutex->lock();
- // already running, wake up whenever ready
- restart = true;
- condition.wakeOne();
- mutex->unlock();
- }
+ if (!isRunning())
+ start();
+ else {
+ mutex->lock();
+ // already running, wake up whenever ready
+ restart = true;
+ condition.wakeOne();
+ mutex->unlock();
+ }
}
void PageLoader::run()
{
- for(;;)
- {
- // copy necessary data
- mutex->lock();
- this->working = true;
- //int idx = this->idx;
+ for (;;) {
+ // copy necessary data
+ mutex->lock();
+ this->working = true;
+ //int idx = this->idx;
+ QImage image;
+ image.loadFromData(this->rawImage);
+ // let everyone knows it is ready
+ image = image.scaled(this->size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- QImage image;
- image.loadFromData(this->rawImage);
- // let everyone knows it is ready
- image = image.scaled(this->size,Qt::KeepAspectRatio,Qt::SmoothTransformation);
+ mutex->unlock();
- mutex->unlock();
+ mutex->lock();
+ this->working = false;
+ this->img = image;
+ mutex->unlock();
- mutex->lock();
- this->working = false;
- this->img = image;
- mutex->unlock();
-
- // put to sleep
- mutex->lock();
- while (!this->restart)
- condition.wait(mutex);
- restart = false;
- mutex->unlock();
- }
+ // put to sleep
+ mutex->lock();
+ while (!this->restart)
+ condition.wait(mutex);
+ restart = false;
+ mutex->unlock();
+ }
}
diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h
index a09a039f..db4aaeff 100644
--- a/YACReader/goto_flow.h
+++ b/YACReader/goto_flow.h
@@ -19,7 +19,6 @@ class QWaitCondition;
class QEvent;
class QLabel;
-
class Comic;
class PageLoader;
class YACReaderFlow;
@@ -28,44 +27,43 @@ class QKeyEvent;
class GoToFlow : public GoToFlowWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- GoToFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
- ~GoToFlow();
- bool ready; //comic is ready for read.
+ GoToFlow(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
+ ~GoToFlow();
+ bool ready; //comic is ready for read.
private:
- YACReaderFlow * flow;
- void keyPressEvent(QKeyEvent* event);
- //Comic * comic;
- QSize imageSize;
+ YACReaderFlow *flow;
+ void keyPressEvent(QKeyEvent *event);
+ //Comic * comic;
+ QSize imageSize;
- QVector imagesLoaded;
- QVector imagesSetted;
- int numImagesLoaded;
- QVector imagesReady;
- QVector rawImages;
- QTimer* updateTimer;
- PageLoader* worker;
- virtual void wheelEvent(QWheelEvent * event);
- QMutex mutexGoToFlow;
+ QVector imagesLoaded;
+ QVector imagesSetted;
+ int numImagesLoaded;
+ QVector imagesReady;
+ QVector rawImages;
+ QTimer *updateTimer;
+ PageLoader *worker;
+ virtual void wheelEvent(QWheelEvent *event);
+ QMutex mutexGoToFlow;
private slots:
void preload();
void updateImageData();
void resizeEvent(QResizeEvent *event);
- public slots:
- void centerSlide(int slide);
+public slots:
+ void centerSlide(int slide);
void reset();
void setNumSlides(unsigned int slides);
- void setImageReady(int index,const QByteArray & image);
+ void setImageReady(int index, const QByteArray &image);
void setFlowType(FlowType flowType);
- void updateConfig(QSettings * settings);
+ void updateConfig(QSettings *settings);
void setFlowRightToLeft(bool b);
signals:
void goToPage(unsigned int page);
-
};
//-----------------------------------------------------------------------------
@@ -74,27 +72,29 @@ signals:
class PageLoader : public QThread
{
public:
- PageLoader(QMutex * m);
- ~PageLoader();
- // returns FALSE if worker is still busy and can't take the task
- bool busy() const;
- void generate(int index, QSize size,const QByteArray & rImage);
- void reset(){idx = -1;};
- int index() const { return idx; }
- QImage result() const { return img; }
+ PageLoader(QMutex *m);
+ ~PageLoader();
+ // returns FALSE if worker is still busy and can't take the task
+ bool busy() const;
+ void generate(int index, QSize size, const QByteArray &rImage);
+ void reset() { idx = -1; };
+ int index() const { return idx; }
+ QImage result() const { return img; }
+
protected:
- void run();
+ void run();
+
private:
- QMutex * mutex;
- QWaitCondition condition;
+ QMutex *mutex;
+ QWaitCondition condition;
- bool restart;
- bool working;
- int idx;
+ bool restart;
+ bool working;
+ int idx;
- QSize size;
- QImage img;
- QByteArray rawImage;
+ QSize size;
+ QImage img;
+ QByteArray rawImage;
};
#endif
diff --git a/YACReader/goto_flow_gl.cpp b/YACReader/goto_flow_gl.cpp
index eca6ec5d..269671c2 100644
--- a/YACReader/goto_flow_gl.cpp
+++ b/YACReader/goto_flow_gl.cpp
@@ -11,154 +11,151 @@
#include "goto_flow_toolbar.h"
-
-GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType)
- :GoToFlowWidget(parent)
+GoToFlowGL::GoToFlowGL(QWidget *parent, FlowType flowType)
+ : GoToFlowWidget(parent)
{
- Q_UNUSED(flowType)
- flow = new YACReaderPageFlowGL(this);
- flow->setShowMarks(false);
+ Q_UNUSED(flowType)
+ flow = new YACReaderPageFlowGL(this);
+ flow->setShowMarks(false);
- imageSize = Configuration::getConfiguration().getGotoSlideSize();
+ imageSize = Configuration::getConfiguration().getGotoSlideSize();
- flow->setSlideSize(imageSize);
- connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int)));
- connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
+ flow->setSlideSize(imageSize);
+ connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(setPageNumber(int)));
+ connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
- connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int)));
- connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(setCenterIndex(unsigned int)));
+ connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int)));
+ connect(toolBar, SIGNAL(setCenter(unsigned int)), flow, SLOT(setCenterIndex(unsigned int)));
- mainLayout->addWidget(flow);
- toolBar->raise();
+ mainLayout->addWidget(flow);
+ toolBar->raise();
- resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7));
+ resize(static_cast(5 * imageSize.width()), toolBar->height() + static_cast(imageSize.height() * 1.7));
- this->setCursor(QCursor(Qt::ArrowCursor));
+ this->setCursor(QCursor(Qt::ArrowCursor));
}
GoToFlowGL::~GoToFlowGL()
{
- delete flow;
+ delete flow;
}
void GoToFlowGL::reset()
{
- flow->reset();
+ flow->reset();
}
void GoToFlowGL::centerSlide(int slide)
{
- if(flow->centerIndex()!=slide)
- {
- flow->setCenterIndex(slide);
- }
+ if (flow->centerIndex() != slide) {
+ flow->setCenterIndex(slide);
+ }
}
void GoToFlowGL::setFlowType(FlowType flowType)
{
- if(flowType == CoverFlowLike)
- flow->setPreset(presetYACReaderFlowClassicConfig);
- else if(flowType == Strip)
- flow->setPreset(presetYACReaderFlowStripeConfig);
- else if(flowType == StripOverlapped)
- flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
- else
- flow->setPreset(defaultYACReaderFlowConfig);
+ if (flowType == CoverFlowLike)
+ flow->setPreset(presetYACReaderFlowClassicConfig);
+ else if (flowType == Strip)
+ flow->setPreset(presetYACReaderFlowStripeConfig);
+ else if (flowType == StripOverlapped)
+ flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
+ else
+ flow->setPreset(defaultYACReaderFlowConfig);
}
void GoToFlowGL::setNumSlides(unsigned int slides)
{
- flow->populate(slides);
- toolBar->setTop(slides);
+ flow->populate(slides);
+ toolBar->setTop(slides);
}
-void GoToFlowGL::setImageReady(int index,const QByteArray & imageData)
+void GoToFlowGL::setImageReady(int index, const QByteArray &imageData)
{
- flow->rawImages[index] = imageData;
- flow->imagesReady[index] = true;
+ flow->rawImages[index] = imageData;
+ flow->imagesReady[index] = true;
}
-void GoToFlowGL::updateConfig(QSettings * settings)
+void GoToFlowGL::updateConfig(QSettings *settings)
{
- GoToFlowWidget::updateConfig(settings);
+ GoToFlowWidget::updateConfig(settings);
- Performance performance = medium;
- switch (settings->value(PERFORMANCE).toInt())
- {
- case 0:
- performance = low;
- break;
- case 1:
- performance = medium;
- break;
- case 2:
- performance = high;
- break;
- case 3:
- performance = ultraHigh;
- break;
- }
+ Performance performance = medium;
+ switch (settings->value(PERFORMANCE).toInt()) {
+ case 0:
+ performance = low;
+ break;
+ case 1:
+ performance = medium;
+ break;
+ case 2:
+ performance = high;
+ break;
+ case 3:
+ performance = ultraHigh;
+ break;
+ }
- imageSize = Configuration::getConfiguration().getGotoSlideSize();
- resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
- updateSize();
+ imageSize = Configuration::getConfiguration().getGotoSlideSize();
+ resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
+ updateSize();
- flow->setPerformance(performance);
+ flow->setPerformance(performance);
- switch (settings->value(FLOW_TYPE_GL).toInt())
- {
- case FlowType::CoverFlowLike:
- flow->setPreset(presetYACReaderFlowClassicConfig);
- break;
- case FlowType::Strip:
- flow->setPreset(presetYACReaderFlowStripeConfig);
- break;
- case FlowType::StripOverlapped:
- flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
- break;
- case FlowType::Modern:
- flow->setPreset(defaultYACReaderFlowConfig);
- break;
- case FlowType::Roulette:
- flow->setPreset(pressetYACReaderFlowDownConfig);
- break;
- case FlowType::Custom:
- flow->setCF_RX(settings->value(X_ROTATION).toInt());
- flow->setCF_Y(settings->value(Y_POSITION).toInt());
- flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
- flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
- flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
- flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
- flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
- flow->setRotation(settings->value(COVER_ROTATION).toInt());
- flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
- flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
- flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
- break;
- }
- if (Configuration::getConfiguration().getQuickNaviMode())
- flow->setFadeOutDist(20);
+ switch (settings->value(FLOW_TYPE_GL).toInt()) {
+ case FlowType::CoverFlowLike:
+ flow->setPreset(presetYACReaderFlowClassicConfig);
+ break;
+ case FlowType::Strip:
+ flow->setPreset(presetYACReaderFlowStripeConfig);
+ break;
+ case FlowType::StripOverlapped:
+ flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
+ break;
+ case FlowType::Modern:
+ flow->setPreset(defaultYACReaderFlowConfig);
+ break;
+ case FlowType::Roulette:
+ flow->setPreset(pressetYACReaderFlowDownConfig);
+ break;
+ case FlowType::Custom:
+ flow->setCF_RX(settings->value(X_ROTATION).toInt());
+ flow->setCF_Y(settings->value(Y_POSITION).toInt());
+ flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
+ flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
+ flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
+ flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
+ flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
+ flow->setRotation(settings->value(COVER_ROTATION).toInt());
+ flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
+ flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
+ flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
+ break;
+ }
+ if (Configuration::getConfiguration().getQuickNaviMode())
+ flow->setFadeOutDist(20);
}
-void GoToFlowGL::keyPressEvent(QKeyEvent* event)
+void GoToFlowGL::keyPressEvent(QKeyEvent *event)
{
- switch (event->key())
- {
- case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
- QApplication::sendEvent(flow,event);
- return;
- default:
- break;
- }
+ switch (event->key()) {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ QApplication::sendEvent(flow, event);
+ return;
+ default:
+ break;
+ }
- GoToFlowWidget::keyPressEvent(event);
+ GoToFlowWidget::keyPressEvent(event);
}
void GoToFlowGL::resizeEvent(QResizeEvent *event)
{
- QWidget::resizeEvent(event);
+ QWidget::resizeEvent(event);
- toolBar->move(0, event->size().height() - toolBar->height());
- toolBar->setFixedWidth(width());
+ toolBar->move(0, event->size().height() - toolBar->height());
+ toolBar->setFixedWidth(width());
}
void GoToFlowGL::setFlowRightToLeft(bool b)
diff --git a/YACReader/goto_flow_gl.h b/YACReader/goto_flow_gl.h
index c111bc40..ea3dbbce 100644
--- a/YACReader/goto_flow_gl.h
+++ b/YACReader/goto_flow_gl.h
@@ -14,27 +14,28 @@ class QKeyEvent;
class GoToFlowGL : public GoToFlowWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- GoToFlowGL(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
- ~GoToFlowGL();
- void reset();
- void centerSlide(int slide);
- void setFlowType(FlowType flowType);
- void setNumSlides(unsigned int slides);
- void setImageReady(int index,const QByteArray & image);
+ GoToFlowGL(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
+ ~GoToFlowGL();
+ void reset();
+ void centerSlide(int slide);
+ void setFlowType(FlowType flowType);
+ void setNumSlides(unsigned int slides);
+ void setImageReady(int index, const QByteArray &image);
- void updateConfig(QSettings * settings);
- void setFlowRightToLeft(bool b);
+ void updateConfig(QSettings *settings);
+ void setFlowRightToLeft(bool b);
signals:
- void goToPage(unsigned int page);
+ void goToPage(unsigned int page);
+
private:
- YACReaderPageFlowGL * flow;
- void keyPressEvent(QKeyEvent* event);
+ YACReaderPageFlowGL *flow;
+ void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
- //Comic * comic;
- QSize imageSize;
+ //Comic * comic;
+ QSize imageSize;
};
#endif
diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp
index 0a465fee..71df2ac0 100644
--- a/YACReader/goto_flow_toolbar.cpp
+++ b/YACReader/goto_flow_toolbar.cpp
@@ -4,87 +4,86 @@
#include "configuration.h"
-GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
- :QStackedWidget(parent)
+GoToFlowToolBar::GoToFlowToolBar(QWidget *parent)
+ : QStackedWidget(parent)
{
- //elementos interactivos
- QWidget * normal = new QWidget(this); // container widget
- QWidget * quickNavi = new QWidget(this); // container widget
- addWidget(normal);
- addWidget(quickNavi);
- QHBoxLayout * normalLayout = new QHBoxLayout(normal);
- QHBoxLayout * naviLayout = new QHBoxLayout(quickNavi);
- normal->setLayout(normalLayout);
- quickNavi->setLayout(naviLayout);
+ //elementos interactivos
+ QWidget *normal = new QWidget(this); // container widget
+ QWidget *quickNavi = new QWidget(this); // container widget
+ addWidget(normal);
+ addWidget(quickNavi);
+ QHBoxLayout *normalLayout = new QHBoxLayout(normal);
+ QHBoxLayout *naviLayout = new QHBoxLayout(quickNavi);
+ normal->setLayout(normalLayout);
+ quickNavi->setLayout(naviLayout);
- slider = new QSlider(Qt::Horizontal,this);
- slider->setStyleSheet(
- "QSlider::groove:horizontal {"
- " border: 1px solid #22FFFFFF;"
- " border-radius: 1px;"
- " background: #77000000;"
- " margin: 2px 0;"
- " padding: 1px;"
- "}"
- "QSlider::handle:horizontal {"
- " background: #55FFFFFF;"
- " width: 48px;"
- " border-radius: 1px;"
- "}"
- );
+ slider = new QSlider(Qt::Horizontal, this);
+ slider->setStyleSheet(
+ "QSlider::groove:horizontal {"
+ " border: 1px solid #22FFFFFF;"
+ " border-radius: 1px;"
+ " background: #77000000;"
+ " margin: 2px 0;"
+ " padding: 1px;"
+ "}"
+ "QSlider::handle:horizontal {"
+ " background: #55FFFFFF;"
+ " width: 48px;"
+ " border-radius: 1px;"
+ "}");
- connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); });
+ connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); });
- pageHint = new QLabel("" + tr("Page : ") + "",this);
- v = new QIntValidator(this);
- v->setBottom(1);
- edit = new QLineEdit(this);
- edit->setValidator(v);
- edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ pageHint = new QLabel("" + tr("Page : ") + "", this);
+ v = new QIntValidator(this);
+ v->setBottom(1);
+ edit = new QLineEdit(this);
+ edit->setValidator(v);
+ edit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}");
- QPixmap p(":/images/imgEdit.png");
- edit->setFixedSize(54,50);
- edit->setAttribute(Qt::WA_MacShowFocusRect,false);
+ QPixmap p(":/images/imgEdit.png");
+ edit->setFixedSize(54, 50);
+ edit->setAttribute(Qt::WA_MacShowFocusRect, false);
//edit->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
- //edit->resize(QSize(54,50));
- edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
+ //edit->resize(QSize(54,50));
+ edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
//edit->setAutoFillBackground(false);
- connect(edit,SIGNAL(returnPressed()),this,SLOT(goTo()));
+ connect(edit, SIGNAL(returnPressed()), this, SLOT(goTo()));
- QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
- "QPushButton:focus { border: none; outline: none;}"
- "QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
- centerButton = new QPushButton(this);
- //centerButton->setIcon(QIcon(":/images/center.png"));
- centerButton->setStyleSheet(centerButtonCSS);
- centerButton->setFixedSize(26,50);
- centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
- connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide()));
+ QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
+ "QPushButton:focus { border: none; outline: none;}"
+ "QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
+ centerButton = new QPushButton(this);
+ //centerButton->setIcon(QIcon(":/images/center.png"));
+ centerButton->setStyleSheet(centerButtonCSS);
+ centerButton->setFixedSize(26, 50);
+ centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
+ connect(centerButton, SIGNAL(clicked()), this, SLOT(centerSlide()));
- QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
- "QPushButton:focus { border: none; outline: none;}"
- "QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
- goToButton = new QPushButton(this);
- //goToButton->setIcon(QIcon(":/images/goto.png"));
- goToButton->setStyleSheet(goToButtonCSS);
- goToButton->setFixedSize(32,50);
- goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
+ QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
+ "QPushButton:focus { border: none; outline: none;}"
+ "QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
+ goToButton = new QPushButton(this);
+ //goToButton->setIcon(QIcon(":/images/goto.png"));
+ goToButton->setStyleSheet(goToButtonCSS);
+ goToButton->setFixedSize(32, 50);
+ goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
- connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
+ connect(goToButton, SIGNAL(clicked()), this, SLOT(goTo()));
- normalLayout->setMargin(0);
- normalLayout->setSpacing(0);
- normalLayout->addStretch();
- normalLayout->addWidget(pageHint);
- normalLayout->addWidget(edit);
- normalLayout->addWidget(centerButton);
- normalLayout->addWidget(goToButton);
- normalLayout->addStretch();
+ normalLayout->setMargin(0);
+ normalLayout->setSpacing(0);
+ normalLayout->addStretch();
+ normalLayout->addWidget(pageHint);
+ normalLayout->addWidget(edit);
+ normalLayout->addWidget(centerButton);
+ normalLayout->addWidget(goToButton);
+ normalLayout->addStretch();
- naviLayout->setContentsMargins(5, 0, 0, 0);
- naviLayout->setSpacing(2);
- naviLayout->addWidget(slider);
- naviLayout->addWidget(goToButton);
+ naviLayout->setContentsMargins(5, 0, 0, 0);
+ naviLayout->setSpacing(2);
+ naviLayout->addWidget(slider);
+ naviLayout->addWidget(goToButton);
updateOptions();
@@ -94,31 +93,31 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
void GoToFlowToolBar::paintEvent(QPaintEvent *)
{
QPainter painter(this);
- painter.fillRect(0,0,width(),height(),QColor("#99000000"));
+ painter.fillRect(0, 0, width(), height(), QColor("#99000000"));
}
void GoToFlowToolBar::setPage(int pageNumber)
{
- edit->setText(QString::number(pageNumber+1));
- slider->setValue(pageNumber);
+ edit->setText(QString::number(pageNumber + 1));
+ slider->setValue(pageNumber);
}
void GoToFlowToolBar::setTop(int numPages)
{
- v->setTop(numPages);
- slider->setMaximum(numPages-1); // min is 0
+ v->setTop(numPages);
+ slider->setMaximum(numPages - 1); // min is 0
}
void GoToFlowToolBar::goTo()
{
- if(edit->text().toInt()!=0)
- emit(goTo(edit->text().toInt()-1));
+ if (edit->text().toInt() != 0)
+ emit(goTo(edit->text().toInt() - 1));
}
void GoToFlowToolBar::centerSlide()
{
- if(edit->text().toInt()!=0)
- emit(setCenter(edit->text().toInt()-1));
+ if (edit->text().toInt() != 0)
+ emit(setCenter(edit->text().toInt() - 1));
}
void GoToFlowToolBar::updateOptions()
diff --git a/YACReader/goto_flow_toolbar.h b/YACReader/goto_flow_toolbar.h
index 2a772dc8..6656b243 100644
--- a/YACReader/goto_flow_toolbar.h
+++ b/YACReader/goto_flow_toolbar.h
@@ -12,29 +12,29 @@ class QLabel;
class GoToFlowToolBar : public QStackedWidget
{
- Q_OBJECT
- private:
- QLineEdit * edit;
- QSlider * slider;
- QIntValidator * v;
- QPushButton * centerButton;
- QPushButton * goToButton;
- QLabel * pageHint;
- QWidget * bar;
- void paintEvent(QPaintEvent *);
+ Q_OBJECT
+private:
+ QLineEdit *edit;
+ QSlider *slider;
+ QIntValidator *v;
+ QPushButton *centerButton;
+ QPushButton *goToButton;
+ QLabel *pageHint;
+ QWidget *bar;
+ void paintEvent(QPaintEvent *);
- public:
- GoToFlowToolBar(QWidget * parent = 0);
+public:
+ GoToFlowToolBar(QWidget *parent = 0);
- public slots:
- void setPage(int pageNumber);
- void setTop(int numPages);
- void goTo();
- void centerSlide();
- void updateOptions();
- signals:
- void setCenter(unsigned int);
- void goTo(unsigned int);
+public slots:
+ void setPage(int pageNumber);
+ void setTop(int numPages);
+ void goTo();
+ void centerSlide();
+ void updateOptions();
+signals:
+ void setCenter(unsigned int);
+ void goTo(unsigned int);
};
#endif
diff --git a/YACReader/goto_flow_widget.cpp b/YACReader/goto_flow_widget.cpp
index 2b31fa58..9b96efe6 100644
--- a/YACReader/goto_flow_widget.cpp
+++ b/YACReader/goto_flow_widget.cpp
@@ -8,62 +8,63 @@
#include "goto_flow_toolbar.h"
#include "configuration.h"
-GoToFlowWidget::GoToFlowWidget(QWidget * parent)
- :QWidget(parent)
+GoToFlowWidget::GoToFlowWidget(QWidget *parent)
+ : QWidget(parent)
{
- mainLayout = new QVBoxLayout;
- mainLayout->setMargin(0);
- mainLayout->setSpacing(0);
+ mainLayout = new QVBoxLayout;
+ mainLayout->setMargin(0);
+ mainLayout->setSpacing(0);
- toolBar = new GoToFlowToolBar(this);
+ toolBar = new GoToFlowToolBar(this);
- setLayout(mainLayout);
+ setLayout(mainLayout);
- //toolBar->installEventFilter(this);
+ //toolBar->installEventFilter(this);
}
-GoToFlowWidget::~GoToFlowWidget() {
- delete toolBar;
- delete mainLayout;
+GoToFlowWidget::~GoToFlowWidget()
+{
+ delete toolBar;
+ delete mainLayout;
}
void GoToFlowWidget::setPageNumber(int page)
{
- toolBar->setPage(page);
+ toolBar->setPage(page);
}
-void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
+void GoToFlowWidget::keyPressEvent(QKeyEvent *event)
{
- switch (event->key())
- {
- case Qt::Key_Return: case Qt::Key_Enter:
- toolBar->goTo();
- toolBar->centerSlide();
- break;
- case Qt::Key_Space:
- toolBar->centerSlide();
- break;
- case Qt::Key_S:
- QCoreApplication::sendEvent(this->parent(),event);
- break;
- }
+ switch (event->key()) {
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ toolBar->goTo();
+ toolBar->centerSlide();
+ break;
+ case Qt::Key_Space:
+ toolBar->centerSlide();
+ break;
+ case Qt::Key_S:
+ QCoreApplication::sendEvent(this->parent(), event);
+ break;
+ }
- event->accept();
+ event->accept();
}
-void GoToFlowWidget::updateConfig(QSettings * settings)
+void GoToFlowWidget::updateConfig(QSettings *settings)
{
- Q_UNUSED(settings)
+ Q_UNUSED(settings)
toolBar->updateOptions();
}
void GoToFlowWidget::updateSize()
{
- // called by parent in resizeEvent
- // no need to update width when QuickNaviMode disabled
- // height is set in updateConfig
- if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr)
- resize(parentWidget()->width(),height());
+ // called by parent in resizeEvent
+ // no need to update width when QuickNaviMode disabled
+ // height is set in updateConfig
+ if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr)
+ resize(parentWidget()->width(), height());
}
/*bool GoToFlowWidget::eventFilter(QObject * target, QEvent * event)
diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h
index 8e95f930..5d7c0a75 100644
--- a/YACReader/goto_flow_widget.h
+++ b/YACReader/goto_flow_widget.h
@@ -12,29 +12,29 @@ class GoToFlowToolBar;
class QVBoxLayout;
class GoToFlowWidget : public QWidget
-{
- Q_OBJECT
+{
+ Q_OBJECT
protected:
- QVBoxLayout * mainLayout;
- GoToFlowToolBar * toolBar;
+ QVBoxLayout *mainLayout;
+ GoToFlowToolBar *toolBar;
+
public:
- GoToFlowWidget(QWidget * paret = 0);
- virtual ~GoToFlowWidget() = 0;
+ GoToFlowWidget(QWidget *paret = 0);
+ virtual ~GoToFlowWidget() = 0;
public slots:
- virtual void reset() = 0;
- virtual void centerSlide(int slide) = 0;
- virtual void setPageNumber(int page);
- virtual void setFlowType(FlowType flowType) = 0;
- virtual void setNumSlides(unsigned int slides) = 0;
- virtual void setImageReady(int index,const QByteArray & image) = 0;
- virtual void updateSize();
- virtual void updateConfig(QSettings * settings);
- virtual void setFlowRightToLeft(bool b) = 0;
+ virtual void reset() = 0;
+ virtual void centerSlide(int slide) = 0;
+ virtual void setPageNumber(int page);
+ virtual void setFlowType(FlowType flowType) = 0;
+ virtual void setNumSlides(unsigned int slides) = 0;
+ virtual void setImageReady(int index, const QByteArray &image) = 0;
+ virtual void updateSize();
+ virtual void updateConfig(QSettings *settings);
+ virtual void setFlowRightToLeft(bool b) = 0;
protected:
- void keyPressEvent(QKeyEvent* event);
- //bool eventFilter(QObject *, QEvent *);
-
+ void keyPressEvent(QKeyEvent *event);
+ //bool eventFilter(QObject *, QEvent *);
};
#endif
diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp
index 1f0404fb..dfe9044f 100644
--- a/YACReader/magnifying_glass.cpp
+++ b/YACReader/magnifying_glass.cpp
@@ -5,251 +5,232 @@
#include
-MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent)
-:QLabel(parent),zoomLevel(0.5)
+MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget *parent)
+ : QLabel(parent), zoomLevel(0.5)
{
- setup(QSize(w,h));
+ setup(QSize(w, h));
}
-MagnifyingGlass::MagnifyingGlass(const QSize & size, QWidget * parent)
-:QLabel(parent),zoomLevel(0.5)
+MagnifyingGlass::MagnifyingGlass(const QSize &size, QWidget *parent)
+ : QLabel(parent), zoomLevel(0.5)
{
- setup(size);
+ setup(size);
}
-void MagnifyingGlass::setup(const QSize & size)
+void MagnifyingGlass::setup(const QSize &size)
{
- resize(size);
- setScaledContents(true);
- setMouseTracking(true);
- setCursor(QCursor(QBitmap(1,1),QBitmap(1,1)));
+ resize(size);
+ setScaledContents(true);
+ setMouseTracking(true);
+ setCursor(QCursor(QBitmap(1, 1), QBitmap(1, 1)));
}
-void MagnifyingGlass::mouseMoveEvent(QMouseEvent * event)
+void MagnifyingGlass::mouseMoveEvent(QMouseEvent *event)
{
- updateImage();
- event->accept();
+ updateImage();
+ event->accept();
}
void MagnifyingGlass::updateImage(int x, int y)
{
- //image section augmented
- int zoomWidth = static_cast(width() * zoomLevel);
- int zoomHeight = static_cast(height() * zoomLevel);
- Viewer * p = (Viewer *)parent();
- int currentPos = p->verticalScrollBar()->sliderPosition();
- const QPixmap * image = p->pixmap();
- int iWidth = image->width();
- int iHeight = image->height();
- float wFactor = static_cast(iWidth) / p->widget()->width();
- float hFactor = static_cast(iHeight) / p->widget()->height();
- zoomWidth *= wFactor;
- zoomHeight *= hFactor;
- if(p->verticalScrollBar()->minimum()==p->verticalScrollBar()->maximum())
- {
- int xp = static_cast(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
- int yp = static_cast((y-p->widget()->pos().y()+currentPos)*hFactor-zoomHeight/2);
- int xOffset=0;
- int yOffset=0;
- int zw=zoomWidth;
- int zh=zoomHeight;
- //int wOffset,hOffset=0;
- bool outImage = false;
- if(xp<0)
- {
- xOffset = -xp;
- xp=0;
- zw = zw - xOffset;
- outImage = true;
- }
- if(yp<0)
- {
- yOffset = -yp;
- yp=0;
- zh = zh - yOffset;
- outImage = true;
- }
-
- if(xp+zoomWidth >= image->width())
- {
- zw -= xp+zw - image->width();
- outImage = true;
- }
- if(yp+zoomHeight >= image->height())
- {
- zh -= yp+zh - image->height();
- outImage = true;
- }
- if(outImage)
- {
- QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
- img.fill(Configuration::getConfiguration().getBackgroundColor());
- if(zw>0&&zh>0)
- {
- QPainter painter(&img);
- painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
- }
- setPixmap(QPixmap().fromImage(img));
- }
- else
- setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
- }
- else
- {
- int xp = static_cast(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2);
- int yp = static_cast((y+currentPos)*hFactor-zoomHeight/2);
- int xOffset=0;
- int yOffset=0;
- int zw=zoomWidth;
- int zh=zoomHeight;
- //int wOffset,hOffset=0;
- bool outImage = false;
- if(xp<0)
- {
- xOffset = -xp;
- xp=0;
- zw = zw - xOffset;
- outImage = true;
- }
- if(yp<0)
- {
- yOffset = -yp;
- yp=0;
- zh = zh - yOffset;
- outImage = true;
- }
-
- if(xp+zoomWidth >= image->width())
- {
- zw -= xp+zw - image->width();
- outImage = true;
- }
- if(yp+zoomHeight >= image->height())
- {
- zh -= yp+zh - image->height();
- outImage = true;
- }
- if(outImage)
- {
- QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32);
- img.fill(Configuration::getConfiguration().getBackgroundColor());
- if(zw>0&&zh>0)
- {
- QPainter painter(&img);
- painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh));
- }
- setPixmap(QPixmap().fromImage(img));
- }
- else
- setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight));
- }
- move(static_cast(x-float(width())/2),static_cast(y-float(height())/2));
+ //image section augmented
+ int zoomWidth = static_cast(width() * zoomLevel);
+ int zoomHeight = static_cast(height() * zoomLevel);
+ Viewer *p = (Viewer *)parent();
+ int currentPos = p->verticalScrollBar()->sliderPosition();
+ const QPixmap *image = p->pixmap();
+ int iWidth = image->width();
+ int iHeight = image->height();
+ float wFactor = static_cast(iWidth) / p->widget()->width();
+ float hFactor = static_cast(iHeight) / p->widget()->height();
+ zoomWidth *= wFactor;
+ zoomHeight *= hFactor;
+ if (p->verticalScrollBar()->minimum() == p->verticalScrollBar()->maximum()) {
+ int xp = static_cast(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
+ int yp = static_cast((y - p->widget()->pos().y() + currentPos) * hFactor - zoomHeight / 2);
+ int xOffset = 0;
+ int yOffset = 0;
+ int zw = zoomWidth;
+ int zh = zoomHeight;
+ //int wOffset,hOffset=0;
+ bool outImage = false;
+ if (xp < 0) {
+ xOffset = -xp;
+ xp = 0;
+ zw = zw - xOffset;
+ outImage = true;
+ }
+ if (yp < 0) {
+ yOffset = -yp;
+ yp = 0;
+ zh = zh - yOffset;
+ outImage = true;
+ }
+
+ if (xp + zoomWidth >= image->width()) {
+ zw -= xp + zw - image->width();
+ outImage = true;
+ }
+ if (yp + zoomHeight >= image->height()) {
+ zh -= yp + zh - image->height();
+ outImage = true;
+ }
+ if (outImage) {
+ QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
+ img.fill(Configuration::getConfiguration().getBackgroundColor());
+ if (zw > 0 && zh > 0) {
+ QPainter painter(&img);
+ painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh));
+ }
+ setPixmap(QPixmap().fromImage(img));
+ } else
+ setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight));
+ } else {
+ int xp = static_cast(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2);
+ int yp = static_cast((y + currentPos) * hFactor - zoomHeight / 2);
+ int xOffset = 0;
+ int yOffset = 0;
+ int zw = zoomWidth;
+ int zh = zoomHeight;
+ //int wOffset,hOffset=0;
+ bool outImage = false;
+ if (xp < 0) {
+ xOffset = -xp;
+ xp = 0;
+ zw = zw - xOffset;
+ outImage = true;
+ }
+ if (yp < 0) {
+ yOffset = -yp;
+ yp = 0;
+ zh = zh - yOffset;
+ outImage = true;
+ }
+
+ if (xp + zoomWidth >= image->width()) {
+ zw -= xp + zw - image->width();
+ outImage = true;
+ }
+ if (yp + zoomHeight >= image->height()) {
+ zh -= yp + zh - image->height();
+ outImage = true;
+ }
+ if (outImage) {
+ QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32);
+ img.fill(Configuration::getConfiguration().getBackgroundColor());
+ if (zw > 0 && zh > 0) {
+ QPainter painter(&img);
+ painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh));
+ }
+ setPixmap(QPixmap().fromImage(img));
+ } else
+ setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight));
+ }
+ move(static_cast(x - float(width()) / 2), static_cast(y - float(height()) / 2));
}
void MagnifyingGlass::updateImage()
{
- if(isVisible())
- {
- QPoint p = QPoint(cursor().pos().x(),cursor().pos().y());
- p = this->parentWidget()->mapFromGlobal(p);
- updateImage(p.x(),p.y());
- }
+ if (isVisible()) {
+ QPoint p = QPoint(cursor().pos().x(), cursor().pos().y());
+ p = this->parentWidget()->mapFromGlobal(p);
+ updateImage(p.x(), p.y());
+ }
}
-void MagnifyingGlass::wheelEvent(QWheelEvent * event)
+void MagnifyingGlass::wheelEvent(QWheelEvent *event)
{
- switch(event->modifiers())
- {
- //size
- case Qt::NoModifier:
- if(event->delta()<0)
- sizeUp();
- else
- sizeDown();
- break;
- //size height
- case Qt::ControlModifier:
- if(event->delta()<0)
- heightUp();
- else
- heightDown();
- break;
- //size width
- case Qt::AltModifier:
- if(event->delta()<0)
- widthUp();
- else
- widthDown();
- break;
- //zoom level
- case Qt::ShiftModifier:
- if(event->delta()<0)
- zoomIn();
- else
- zoomOut();
- break;
- }
- updateImage();
- event->setAccepted(true);
+ switch (event->modifiers()) {
+ //size
+ case Qt::NoModifier:
+ if (event->delta() < 0)
+ sizeUp();
+ else
+ sizeDown();
+ break;
+ //size height
+ case Qt::ControlModifier:
+ if (event->delta() < 0)
+ heightUp();
+ else
+ heightDown();
+ break;
+ //size width
+ case Qt::AltModifier:
+ if (event->delta() < 0)
+ widthUp();
+ else
+ widthDown();
+ break;
+ //zoom level
+ case Qt::ShiftModifier:
+ if (event->delta() < 0)
+ zoomIn();
+ else
+ zoomOut();
+ break;
+ }
+ updateImage();
+ event->setAccepted(true);
}
void MagnifyingGlass::zoomIn()
{
- if(zoomLevel>0.2f)
- zoomLevel -= 0.025f;
+ if (zoomLevel > 0.2f)
+ zoomLevel -= 0.025f;
}
void MagnifyingGlass::zoomOut()
{
- if(zoomLevel<0.9f)
- zoomLevel += 0.025f;
+ if (zoomLevel < 0.9f)
+ zoomLevel += 0.025f;
}
void MagnifyingGlass::sizeUp()
{
- Viewer * p = (Viewer *)parent();
- if(width()<(p->width()*0.90f))
- resize(width()+30,height()+15);
+ Viewer *p = (Viewer *)parent();
+ if (width() < (p->width() * 0.90f))
+ resize(width() + 30, height() + 15);
}
void MagnifyingGlass::sizeDown()
{
- if(width()>175)
- resize(width()-30,height()-15);
+ if (width() > 175)
+ resize(width() - 30, height() - 15);
}
void MagnifyingGlass::heightUp()
{
- Viewer * p = (Viewer *)parent();
- if(height()<(p->height()*0.90f))
- resize(width(),height()+15);
+ Viewer *p = (Viewer *)parent();
+ if (height() < (p->height() * 0.90f))
+ resize(width(), height() + 15);
}
void MagnifyingGlass::heightDown()
{
- if(height()>80)
- resize(width(),height()-15);
+ if (height() > 80)
+ resize(width(), height() - 15);
}
void MagnifyingGlass::widthUp()
{
- Viewer * p = (Viewer *)parent();
- if(width()<(p->width()*0.90f))
- resize(width()+30,height());
+ Viewer *p = (Viewer *)parent();
+ if (width() < (p->width() * 0.90f))
+ resize(width() + 30, height());
}
void MagnifyingGlass::widthDown()
{
- if(width()>175)
- resize(width()-30,height());
+ if (width() > 175)
+ resize(width() - 30, height());
}
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
{
- bool validKey = false;
+ bool validKey = false;
int _key = event->key();
Qt::KeyboardModifiers modifiers = event->modifiers();
- if(modifiers & Qt::ShiftModifier)
+ if (modifiers & Qt::ShiftModifier)
_key |= Qt::SHIFT;
if (modifiers & Qt::ControlModifier)
_key |= Qt::CTRL;
@@ -260,33 +241,28 @@ void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
QKeySequence key(_key);
- if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y))
- {
+ if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y)) {
sizeUp();
validKey = true;
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y)) {
sizeDown();
validKey = true;
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y)) {
zoomIn();
validKey = true;
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y)) {
zoomOut();
validKey = true;
}
- if(validKey)
- {
+ if (validKey) {
updateImage();
- event->setAccepted(true);
+ event->setAccepted(true);
}
}
diff --git a/YACReader/magnifying_glass.h b/YACReader/magnifying_glass.h
index 024affb5..f7c951e8 100644
--- a/YACReader/magnifying_glass.h
+++ b/YACReader/magnifying_glass.h
@@ -6,29 +6,30 @@
#include
#include
- class MagnifyingGlass : public QLabel
- {
- Q_OBJECT
- private:
- float zoomLevel;
- void setup(const QSize & size);
- void keyPressEvent(QKeyEvent * event);
- public:
- MagnifyingGlass(int width,int height,QWidget * parent);
- MagnifyingGlass(const QSize & size, QWidget * parent);
- void mouseMoveEvent(QMouseEvent * event);
- public slots:
- void updateImage(int x, int y);
- void updateImage();
- void wheelEvent(QWheelEvent * event);
- void zoomIn();
- void zoomOut();
- void sizeUp();
- void sizeDown();
- void heightUp();
- void heightDown();
- void widthUp();
- void widthDown();
- };
+class MagnifyingGlass : public QLabel
+{
+ Q_OBJECT
+private:
+ float zoomLevel;
+ void setup(const QSize &size);
+ void keyPressEvent(QKeyEvent *event);
+
+public:
+ MagnifyingGlass(int width, int height, QWidget *parent);
+ MagnifyingGlass(const QSize &size, QWidget *parent);
+ void mouseMoveEvent(QMouseEvent *event);
+public slots:
+ void updateImage(int x, int y);
+ void updateImage();
+ void wheelEvent(QWheelEvent *event);
+ void zoomIn();
+ void zoomOut();
+ void sizeUp();
+ void sizeDown();
+ void heightUp();
+ void heightDown();
+ void widthUp();
+ void widthDown();
+};
#endif
diff --git a/YACReader/main.cpp b/YACReader/main.cpp
index c7b85513..8194b701 100644
--- a/YACReader/main.cpp
+++ b/YACReader/main.cpp
@@ -13,130 +13,129 @@
using namespace QsLogging;
#if defined(WIN32) && defined(_DEBUG)
- #define _CRTDBG_MAP_ALLOC
- #include
- #include
- #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
- #define new DEBUG_NEW
+#define _CRTDBG_MAP_ALLOC
+#include
+#include
+#define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
+#define new DEBUG_NEW
#endif
#ifdef Q_OS_MAC
#include
#include
-class YACReaderApplication: public QApplication
+class YACReaderApplication : public QApplication
{
- public:
- YACReaderApplication(int & argc, char ** argv) : QApplication(argc,argv)
- {}
+public:
+ YACReaderApplication(int &argc, char **argv)
+ : QApplication(argc, argv)
+ {
+ }
- void setWindow(MainWindowViewer * w)
- {
- window = w;
- }
+ void setWindow(MainWindowViewer *w)
+ {
+ window = w;
+ }
- protected:
- bool event(QEvent * event)
- {
- switch(event->type())
- {
- case QEvent::FileOpen:
- window->openComicFromPath(static_cast(event)->file());
- return true;
- default:
- return QApplication::event(event);
- }
+protected:
+ bool event(QEvent *event)
+ {
+ switch (event->type()) {
+ case QEvent::FileOpen:
+ window->openComicFromPath(static_cast(event)->file());
+ return true;
+ default:
+ return QApplication::event(event);
}
- private:
- MainWindowViewer * window;
+ }
+
+private:
+ MainWindowViewer *window;
};
#endif
-int main(int argc, char * argv[])
+int main(int argc, char *argv[])
{
#if defined(_MSC_VER) && defined(_DEBUG)
- _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef Q_OS_MAC
- YACReaderApplication app(argc,argv);
+ YACReaderApplication app(argc, argv);
#else
- QApplication app(argc, argv);
+ QApplication app(argc, argv);
#endif
#ifdef FORCE_ANGLE
- app.setAttribute(Qt::AA_UseOpenGLES);
+ app.setAttribute(Qt::AA_UseOpenGLES);
#endif
- app.setApplicationName("YACReader");
- app.setOrganizationName("YACReader");
- app.setAttribute(Qt::AA_UseHighDpiPixmaps);
- if (QIcon::hasThemeIcon("YACReader")) {
- app.setWindowIcon(QIcon::fromTheme("YACReader"));
- }
+ app.setApplicationName("YACReader");
+ app.setOrganizationName("YACReader");
+ app.setAttribute(Qt::AA_UseHighDpiPixmaps);
+ if (QIcon::hasThemeIcon("YACReader")) {
+ app.setWindowIcon(QIcon::fromTheme("YACReader"));
+ }
- // simple commandline parser
- QCommandLineParser parser;
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("[File|Directory]", "File or directory to open.");
- QCommandLineOption comicId("comicId", "", "comicId");
- QCommandLineOption libraryId("libraryId", "", "libraryId");
- // hide comicId and libraryId from help
- #if QT_VERSION >= 0x050800
- comicId.setFlags(QCommandLineOption::HiddenFromHelp);
- libraryId.setFlags(QCommandLineOption::HiddenFromHelp);
- #else
- comicId.setHidden(true);
- libraryId.setHidden(true);
- #endif
-
- // process
- parser.addOption(comicId);
- parser.addOption(libraryId);
- parser.process(app);
-
- QString destLog = YACReader::getSettingsPath()+"/yacreader.log";
- QDir().mkpath(YACReader::getSettingsPath());
-
- Logger& logger = Logger::instance();
- logger.setLoggingLevel(QsLogging::InfoLevel);
-
- 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/yacreader_"+sufix);
+ // simple commandline parser
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("[File|Directory]", "File or directory to open.");
+ QCommandLineOption comicId("comicId", "", "comicId");
+ QCommandLineOption libraryId("libraryId", "", "libraryId");
+// hide comicId and libraryId from help
+#if QT_VERSION >= 0x050800
+ comicId.setFlags(QCommandLineOption::HiddenFromHelp);
+ libraryId.setFlags(QCommandLineOption::HiddenFromHelp);
#else
- translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
+ comicId.setHidden(true);
+ libraryId.setHidden(true);
#endif
- app.installTranslator(&translator);
- MainWindowViewer * mwv = new MainWindowViewer();
- // some arguments need to be parsed after MainWindowViewer creation
- QStringList arglist = parser.positionalArguments();
- if (parser.isSet(comicId) && parser.isSet(libraryId) && arglist.count() >=1)
- {
- mwv->open(arglist.at(0), parser.value(comicId).toULongLong(), parser.value(libraryId).toULongLong());
- }
- else if (arglist.count() >= 1)
- {
- mwv->openComicFromPath(arglist.at(0));
- }
+ // process
+ parser.addOption(comicId);
+ parser.addOption(libraryId);
+ parser.process(app);
+
+ QString destLog = YACReader::getSettingsPath() + "/yacreader.log";
+ QDir().mkpath(YACReader::getSettingsPath());
+
+ Logger &logger = Logger::instance();
+ logger.setLoggingLevel(QsLogging::InfoLevel);
+
+ 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/yacreader_" + sufix);
+#else
+ translator.load(QCoreApplication::applicationDirPath() + "/languages/yacreader_" + sufix);
+#endif
+ app.installTranslator(&translator);
+ MainWindowViewer *mwv = new MainWindowViewer();
+
+ // some arguments need to be parsed after MainWindowViewer creation
+ QStringList arglist = parser.positionalArguments();
+ if (parser.isSet(comicId) && parser.isSet(libraryId) && arglist.count() >= 1) {
+ mwv->open(arglist.at(0), parser.value(comicId).toULongLong(), parser.value(libraryId).toULongLong());
+ } else if (arglist.count() >= 1) {
+ mwv->openComicFromPath(arglist.at(0));
+ }
#ifdef Q_OS_MAC
- app.setWindow(mwv);
+ app.setWindow(mwv);
#endif
- mwv->show();
- int ret = app.exec();
- delete mwv;
+ mwv->show();
+ int ret = app.exec();
+ delete mwv;
- //Configuration::getConfiguration().save();
- YACReader::exitCheck(ret);
- return ret;
+ //Configuration::getConfiguration().save();
+ YACReader::exitCheck(ret);
+ return ret;
}
diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp
index b4b2bbe7..062eb3da 100644
--- a/YACReader/main_window_viewer.cpp
+++ b/YACReader/main_window_viewer.cpp
@@ -69,152 +69,147 @@ public:
#endif*/
MainWindowViewer::MainWindowViewer()
-:QMainWindow(),fullscreen(false),toolbars(true),alwaysOnTop(false),currentDirectory("."),currentDirectoryImgDest("."),isClient(false)
+ : QMainWindow(), fullscreen(false), toolbars(true), alwaysOnTop(false), currentDirectory("."), currentDirectoryImgDest("."), isClient(false)
{
- loadConfiguration();
- setupUI();
+ loadConfiguration();
+ setupUI();
}
MainWindowViewer::~MainWindowViewer()
{
- delete settings;
- delete viewer;
- delete had;
+ delete settings;
+ delete viewer;
+ delete had;
- //delete sliderAction;
- delete openAction;
- delete openFolderAction;
+ //delete sliderAction;
+ delete openAction;
+ delete openFolderAction;
delete openLatestComicAction;
- delete saveImageAction;
- delete openPreviousComicAction;
- delete openNextComicAction;
- delete prevAction;
- delete nextAction;
+ delete saveImageAction;
+ delete openPreviousComicAction;
+ delete openNextComicAction;
+ delete prevAction;
+ delete nextAction;
delete adjustHeightAction;
delete adjustWidthAction;
- delete leftRotationAction;
- delete rightRotationAction;
- delete doublePageAction;
- delete doubleMangaPageAction;
- delete increasePageZoomAction;
- delete decreasePageZoomAction;
+ delete leftRotationAction;
+ delete rightRotationAction;
+ delete doublePageAction;
+ delete doubleMangaPageAction;
+ delete increasePageZoomAction;
+ delete decreasePageZoomAction;
delete resetZoomAction;
delete goToPageAction;
- delete optionsAction;
- delete helpAboutAction;
+ delete optionsAction;
+ delete helpAboutAction;
delete showMagnifyingGlassAction;
delete setBookmarkAction;
delete showBookmarksAction;
- delete showShorcutsAction;
+ delete showShorcutsAction;
delete showInfoAction;
- delete closeAction;
- delete showDictionaryAction;
- delete alwaysOnTopAction;
- delete adjustToFullSizeAction;
- delete fitToPageAction;
- delete showFlowAction;
-
+ delete closeAction;
+ delete showDictionaryAction;
+ delete alwaysOnTopAction;
+ delete adjustToFullSizeAction;
+ delete fitToPageAction;
+ delete showFlowAction;
}
void MainWindowViewer::loadConfiguration()
{
- settings = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
+ settings = new QSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
- Configuration & config = Configuration::getConfiguration();
- config.load(settings);
- currentDirectory = config.getDefaultPath();
- fullscreen = config.getFullScreen();
+ Configuration &config = Configuration::getConfiguration();
+ config.load(settings);
+ currentDirectory = config.getDefaultPath();
+ fullscreen = config.getFullScreen();
}
void MainWindowViewer::setupUI()
{
//setUnifiedTitleAndToolBarOnMac(true);
- viewer = new Viewer(this);
- connect(viewer,SIGNAL(reset()),this,SLOT(processReset()));
- //detected end of comic
- connect(viewer,SIGNAL(openNextComic()),this,SLOT(openNextComic()));
- //detected start of comic
- connect(viewer,SIGNAL(openPreviousComic()),this,SLOT(openPreviousComic()));
+ viewer = new Viewer(this);
+ connect(viewer, SIGNAL(reset()), this, SLOT(processReset()));
+ //detected end of comic
+ connect(viewer, SIGNAL(openNextComic()), this, SLOT(openNextComic()));
+ //detected start of comic
+ connect(viewer, SIGNAL(openPreviousComic()), this, SLOT(openPreviousComic()));
- setCentralWidget(viewer);
- int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
- int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
- int height,width;
- height = static_cast(heightDesktopResolution*0.84);
- width = static_cast(height*0.70);
- Configuration & conf = Configuration::getConfiguration();
- QPoint p = conf.getPos();
- QSize s = conf.getSize();
- if(s.width()!=0)
- {
- move(p);
- resize(s);
- }
- else
- {
- move(QPoint((widthDesktopResolution-width)/2,((heightDesktopResolution-height)-40)/2));
- resize(QSize(width,height));
- }
+ setCentralWidget(viewer);
+ int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
+ int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
+ int height, width;
+ height = static_cast(heightDesktopResolution * 0.84);
+ width = static_cast(height * 0.70);
+ Configuration &conf = Configuration::getConfiguration();
+ QPoint p = conf.getPos();
+ QSize s = conf.getSize();
+ if (s.width() != 0) {
+ move(p);
+ resize(s);
+ } else {
+ move(QPoint((widthDesktopResolution - width) / 2, ((heightDesktopResolution - height) - 40) / 2));
+ resize(QSize(width, height));
+ }
- had = new HelpAboutDialog(this); //TODO load data
+ had = new HelpAboutDialog(this); //TODO load data
- had->loadAboutInformation(":/files/about.html");
- had->loadHelp(":/files/helpYACReader.html");
+ had->loadAboutInformation(":/files/about.html");
+ had->loadHelp(":/files/helpYACReader.html");
- optionsDialog = new OptionsDialog(this);
- connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions()));
- connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions()));
- connect(optionsDialog,SIGNAL(changedFilters(int,int,int)),viewer,SLOT(updateFilters(int,int,int)));
+ optionsDialog = new OptionsDialog(this);
+ connect(optionsDialog, SIGNAL(accepted()), viewer, SLOT(updateOptions()));
+ connect(optionsDialog, SIGNAL(optionsChanged()), this, SLOT(reloadOptions()));
+ connect(optionsDialog, SIGNAL(changedFilters(int, int, int)), viewer, SLOT(updateFilters(int, int, int)));
- optionsDialog->restoreOptions(settings);
+ optionsDialog->restoreOptions(settings);
//shortcutsDialog = new ShortcutsDialog(this);
editShortcutsDialog = new EditShortcutsDialog(this);
- connect(optionsDialog,SIGNAL(editShortcuts()),editShortcutsDialog,SLOT(show()));
+ connect(optionsDialog, SIGNAL(editShortcuts()), editShortcutsDialog, SLOT(show()));
- createActions();
+ createActions();
setUpShortcutsManagement();
- createToolBars();
+ createToolBars();
- setWindowTitle("YACReader");
+ setWindowTitle("YACReader");
- checkNewVersion();
+ checkNewVersion();
- viewer->setFocusPolicy(Qt::StrongFocus);
+ viewer->setFocusPolicy(Qt::StrongFocus);
-
- //if(Configuration::getConfiguration().getAlwaysOnTop())
- //{
- // setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
- //}
+ //if(Configuration::getConfiguration().getAlwaysOnTop())
+ //{
+ // setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
+ //}
previousWindowFlags = windowFlags();
previousPos = pos();
previousSize = size();
- if(fullscreen)
- toFullScreen();
- if(conf.getMaximized())
- showMaximized();
+ if (fullscreen)
+ toFullScreen();
+ if (conf.getMaximized())
+ showMaximized();
- setAcceptDrops(true);
+ setAcceptDrops(true);
- if(Configuration::getConfiguration().getShowToolbars() && !Configuration::getConfiguration().getFullScreen())
- showToolBars();
- else
- hideToolBars();
+ if (Configuration::getConfiguration().getShowToolbars() && !Configuration::getConfiguration().getFullScreen())
+ showToolBars();
+ else
+ hideToolBars();
}
void MainWindowViewer::createActions()
{
- openAction = new QAction(tr("&Open"),this);
+ openAction = new QAction(tr("&Open"), this);
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.png"));
openAction->setToolTip(tr("Open a comic"));
openAction->setData(OPEN_ACTION_Y);
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
- openFolderAction = new QAction(tr("Open Folder"),this);
+ openFolderAction = new QAction(tr("Open Folder"), this);
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
openFolderAction->setToolTip(tr("Open image folder"));
openFolderAction->setData(OPEN_FOLDER_ACTION_Y);
@@ -227,100 +222,99 @@ void MainWindowViewer::createActions()
openLatestComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_LATEST_COMIC_Y));
connect(openLatestComicAction, SIGNAL(triggered()), this, SLOT(openLatestComic()));
- QAction* recentFileAction = nullptr;
+ QAction *recentFileAction = nullptr;
//TODO: Replace limit with a configurable value
- for (int i = 0; i < Configuration::getConfiguration().getOpenRecentSize(); i++)
- {
- recentFileAction = new QAction(this);
- recentFileAction->setVisible(false);
- QObject::connect(recentFileAction, &QAction::triggered, this, &MainWindowViewer::openRecent);
- recentFilesActionList.append(recentFileAction);
- }
+ for (int i = 0; i < Configuration::getConfiguration().getOpenRecentSize(); i++) {
+ recentFileAction = new QAction(this);
+ recentFileAction->setVisible(false);
+ QObject::connect(recentFileAction, &QAction::triggered, this, &MainWindowViewer::openRecent);
+ recentFilesActionList.append(recentFileAction);
+ }
- clearRecentFilesAction = new QAction(tr("Clear"),this);
+ clearRecentFilesAction = new QAction(tr("Clear"), this);
clearRecentFilesAction->setToolTip(tr("Clear open recent list"));
connect(clearRecentFilesAction, &QAction::triggered, this, &MainWindowViewer::clearRecentFiles);
- saveImageAction = new QAction(tr("Save"),this);
+ saveImageAction = new QAction(tr("Save"), this);
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
saveImageAction->setToolTip(tr("Save current page"));
saveImageAction->setDisabled(true);
saveImageAction->setData(SAVE_IMAGE_ACTION_Y);
saveImageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SAVE_IMAGE_ACTION_Y));
- connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage()));
+ connect(saveImageAction, SIGNAL(triggered()), this, SLOT(saveImage()));
- openPreviousComicAction = new QAction(tr("Previous Comic"),this);
+ openPreviousComicAction = new QAction(tr("Previous Comic"), this);
openPreviousComicAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
openPreviousComicAction->setToolTip(tr("Open previous comic"));
openPreviousComicAction->setDisabled(true);
openPreviousComicAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
openPreviousComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y));
- connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic()));
+ connect(openPreviousComicAction, SIGNAL(triggered()), this, SLOT(openPreviousComic()));
- openNextComicAction = new QAction(tr("Next Comic"),this);
+ openNextComicAction = new QAction(tr("Next Comic"), this);
openNextComicAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
openNextComicAction->setToolTip(tr("Open next comic"));
openNextComicAction->setDisabled(true);
openNextComicAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
openNextComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
- connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
+ connect(openNextComicAction, SIGNAL(triggered()), this, SLOT(openNextComic()));
- prevAction = new QAction(tr("&Previous"),this);
+ prevAction = new QAction(tr("&Previous"), this);
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
prevAction->setShortcutContext(Qt::WidgetShortcut);
prevAction->setToolTip(tr("Go to previous page"));
prevAction->setDisabled(true);
prevAction->setData(PREV_ACTION_Y);
prevAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y));
- connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
+ connect(prevAction, SIGNAL(triggered()), viewer, SLOT(prev()));
- nextAction = new QAction(tr("&Next"),this);
+ nextAction = new QAction(tr("&Next"), this);
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
nextAction->setShortcutContext(Qt::WidgetShortcut);
nextAction->setToolTip(tr("Go to next page"));
- nextAction->setDisabled(true);
+ nextAction->setDisabled(true);
nextAction->setData(NEXT_ACTION_Y);
nextAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y));
- connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
+ connect(nextAction, SIGNAL(triggered()), viewer, SLOT(next()));
- adjustHeightAction = new QAction(tr("Fit Height"),this);
+ adjustHeightAction = new QAction(tr("Fit Height"), this);
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
- //adjustWidth->setCheckable(true);
+ //adjustWidth->setCheckable(true);
adjustHeightAction->setDisabled(true);
adjustHeightAction->setToolTip(tr("Fit image to height"));
- //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
+ //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
adjustHeightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_HEIGHT_ACTION_Y));
adjustHeightAction->setCheckable(true);
- connect(adjustHeightAction, SIGNAL(triggered()),this,SLOT(fitToHeight()));
+ connect(adjustHeightAction, SIGNAL(triggered()), this, SLOT(fitToHeight()));
- adjustWidthAction = new QAction(tr("Fit Width"),this);
+ adjustWidthAction = new QAction(tr("Fit Width"), this);
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
- //adjustWidth->setCheckable(true);
+ //adjustWidth->setCheckable(true);
adjustWidthAction->setDisabled(true);
adjustWidthAction->setToolTip(tr("Fit image to width"));
- //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
+ //adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
adjustWidthAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_WIDTH_ACTION_Y));
adjustWidthAction->setCheckable(true);
- connect(adjustWidthAction, SIGNAL(triggered()),this,SLOT(fitToWidth()));
+ connect(adjustWidthAction, SIGNAL(triggered()), this, SLOT(fitToWidth()));
- adjustToFullSizeAction = new QAction(tr("Show full size"),this);
+ adjustToFullSizeAction = new QAction(tr("Show full size"), this);
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
adjustToFullSizeAction->setCheckable(false);
adjustToFullSizeAction->setDisabled(true);
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
adjustToFullSizeAction->setCheckable(true);
- connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
+ connect(adjustToFullSizeAction, SIGNAL(triggered()), this, SLOT(adjustToFullSizeSwitch()));
- fitToPageAction = new QAction(tr("Fit to page"),this);
+ fitToPageAction = new QAction(tr("Fit to page"), this);
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
fitToPageAction->setDisabled(true);
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
fitToPageAction->setCheckable(true);
- connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch()));
+ connect(fitToPageAction, SIGNAL(triggered()), this, SLOT(fitToPageSwitch()));
//fit modes have to be exclusive and checkable
QActionGroup *fitModes = new QActionGroup(this);
@@ -329,8 +323,7 @@ void MainWindowViewer::createActions()
fitModes->addAction(adjustToFullSizeAction);
fitModes->addAction(fitToPageAction);
- switch(Configuration::getConfiguration().getFitMode())
- {
+ switch (Configuration::getConfiguration().getFitMode()) {
case YACReader::FitMode::ToWidth:
adjustWidthAction->setChecked(true);
break;
@@ -351,159 +344,159 @@ void MainWindowViewer::createActions()
resetZoomAction->setDisabled(true);
resetZoomAction->setData(RESET_ZOOM_ACTION_Y);
resetZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_ZOOM_ACTION_Y));
- connect(resetZoomAction,SIGNAL(triggered()),this,SLOT(resetZoomLevel()));
+ connect(resetZoomAction, SIGNAL(triggered()), this, SLOT(resetZoomLevel()));
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
showZoomSliderlAction->setDisabled(true);
- increasePageZoomAction = new QAction(tr("Zoom+"),this);
+ increasePageZoomAction = new QAction(tr("Zoom+"), this);
increasePageZoomAction->setDisabled(true);
increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y);
increasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_PLUS_ACTION_Y));
- connect(increasePageZoomAction,SIGNAL(triggered()),this,SLOT(increasePageZoomLevel()));
+ connect(increasePageZoomAction, SIGNAL(triggered()), this, SLOT(increasePageZoomLevel()));
- decreasePageZoomAction = new QAction(tr("Zoom-"),this);
+ decreasePageZoomAction = new QAction(tr("Zoom-"), this);
decreasePageZoomAction->setDisabled(true);
decreasePageZoomAction->setData(ZOOM_MINUS_ACTION_Y);
decreasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_MINUS_ACTION_Y));
- connect(decreasePageZoomAction,SIGNAL(triggered()),this,SLOT(decreasePageZoomLevel()));
+ connect(decreasePageZoomAction, SIGNAL(triggered()), this, SLOT(decreasePageZoomLevel()));
- leftRotationAction = new QAction(tr("Rotate image to the left"),this);
- leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
- leftRotationAction->setDisabled(true);
+ leftRotationAction = new QAction(tr("Rotate image to the left"), this);
+ leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
+ leftRotationAction->setDisabled(true);
leftRotationAction->setData(LEFT_ROTATION_ACTION_Y);
leftRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(LEFT_ROTATION_ACTION_Y));
- connect(leftRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateLeft()));
+ connect(leftRotationAction, SIGNAL(triggered()), viewer, SLOT(rotateLeft()));
- rightRotationAction = new QAction(tr("Rotate image to the right"),this);
- rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
- rightRotationAction->setDisabled(true);
+ rightRotationAction = new QAction(tr("Rotate image to the right"), this);
+ rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
+ rightRotationAction->setDisabled(true);
rightRotationAction->setData(RIGHT_ROTATION_ACTION_Y);
rightRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RIGHT_ROTATION_ACTION_Y));
- connect(rightRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateRight()));
+ connect(rightRotationAction, SIGNAL(triggered()), viewer, SLOT(rotateRight()));
- doublePageAction = new QAction(tr("Double page mode"),this);
- doublePageAction->setToolTip(tr("Switch to double page mode"));
+ doublePageAction = new QAction(tr("Double page mode"), this);
+ doublePageAction->setToolTip(tr("Switch to double page mode"));
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
- doublePageAction->setDisabled(true);
- doublePageAction->setCheckable(true);
- doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
+ doublePageAction->setDisabled(true);
+ doublePageAction->setCheckable(true);
+ doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
doublePageAction->setData(DOUBLE_PAGE_ACTION_Y);
doublePageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_PAGE_ACTION_Y));
- connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
+ connect(doublePageAction, SIGNAL(triggered()), viewer, SLOT(doublePageSwitch()));
- //inversed pictures mode
- doubleMangaPageAction = new QAction(tr("Double page manga mode"),this);
- doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
- doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
- doubleMangaPageAction->setDisabled(true);
- doubleMangaPageAction->setCheckable(true);
- doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
+ //inversed pictures mode
+ doubleMangaPageAction = new QAction(tr("Double page manga mode"), this);
+ doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
+ doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
+ doubleMangaPageAction->setDisabled(true);
+ doubleMangaPageAction->setCheckable(true);
+ doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y));
- connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch()));
+ connect(doubleMangaPageAction, SIGNAL(triggered()), viewer, SLOT(doubleMangaPageSwitch()));
- goToPageAction = new QAction(tr("Go To"),this);
+ goToPageAction = new QAction(tr("Go To"), this);
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
goToPageAction->setDisabled(true);
goToPageAction->setToolTip(tr("Go to page ..."));
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
- connect(goToPageAction, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
+ connect(goToPageAction, SIGNAL(triggered()), viewer, SLOT(showGoToDialog()));
- optionsAction = new QAction(tr("Options"),this);
- optionsAction->setToolTip(tr("YACReader options"));
+ optionsAction = new QAction(tr("Options"), this);
+ optionsAction->setToolTip(tr("YACReader options"));
optionsAction->setData(OPTIONS_ACTION_Y);
optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_Y));
- optionsAction->setIcon(QIcon(":/images/viewer_toolbar/options.png"));
+ optionsAction->setIcon(QIcon(":/images/viewer_toolbar/options.png"));
- connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show()));
+ connect(optionsAction, SIGNAL(triggered()), optionsDialog, SLOT(show()));
- helpAboutAction = new QAction(tr("Help"),this);
- helpAboutAction->setToolTip(tr("Help, About YACReader"));
- helpAboutAction->setIcon(QIcon(":/images/viewer_toolbar/help.png"));
+ helpAboutAction = new QAction(tr("Help"), this);
+ helpAboutAction->setToolTip(tr("Help, About YACReader"));
+ helpAboutAction->setIcon(QIcon(":/images/viewer_toolbar/help.png"));
helpAboutAction->setData(HELP_ABOUT_ACTION_Y);
helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_Y));
- connect(helpAboutAction, SIGNAL(triggered()),had,SLOT(show()));
+ connect(helpAboutAction, SIGNAL(triggered()), had, SLOT(show()));
- showMagnifyingGlassAction = new QAction(tr("Magnifying glass"),this);
+ showMagnifyingGlassAction = new QAction(tr("Magnifying glass"), this);
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
showMagnifyingGlassAction->setDisabled(true);
showMagnifyingGlassAction->setCheckable(true);
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
- connect(showMagnifyingGlassAction, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
+ connect(showMagnifyingGlassAction, SIGNAL(triggered()), viewer, SLOT(magnifyingGlassSwitch()));
- setBookmarkAction = new QAction(tr("Set bookmark"),this);
+ setBookmarkAction = new QAction(tr("Set bookmark"), this);
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
setBookmarkAction->setDisabled(true);
setBookmarkAction->setCheckable(true);
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
- connect(setBookmarkAction,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool)));
- connect(viewer,SIGNAL(pageAvailable(bool)),setBookmarkAction,SLOT(setEnabled(bool)));
- connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmarkAction,SLOT(setChecked(bool)));
+ connect(setBookmarkAction, SIGNAL(triggered(bool)), viewer, SLOT(setBookmark(bool)));
+ connect(viewer, SIGNAL(pageAvailable(bool)), setBookmarkAction, SLOT(setEnabled(bool)));
+ connect(viewer, SIGNAL(pageIsBookmark(bool)), setBookmarkAction, SLOT(setChecked(bool)));
- showBookmarksAction = new QAction(tr("Show bookmarks"),this);
+ showBookmarksAction = new QAction(tr("Show bookmarks"), this);
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
showBookmarksAction->setDisabled(true);
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
showBookmarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_BOOKMARKS_ACTION_Y));
- connect(showBookmarksAction, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show()));
+ connect(showBookmarksAction, SIGNAL(triggered()), viewer->getBookmarksDialog(), SLOT(show()));
- showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this );
- showShorcutsAction->setIcon(QIcon(":/images/viewer_toolbar/shortcuts.png"));
+ showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this);
+ showShorcutsAction->setIcon(QIcon(":/images/viewer_toolbar/shortcuts.png"));
showShorcutsAction->setData(SHOW_SHORCUTS_ACTION_Y);
showShorcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_SHORCUTS_ACTION_Y));
//connect(showShorcutsAction, SIGNAL(triggered()),shortcutsDialog,SLOT(show()));
connect(showShorcutsAction, SIGNAL(triggered()), editShortcutsDialog, SLOT(show()));
- showInfoAction = new QAction(tr("Show Info"),this);
+ showInfoAction = new QAction(tr("Show Info"), this);
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
showInfoAction->setDisabled(true);
showInfoAction->setData(SHOW_INFO_ACTION_Y);
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
- connect(showInfoAction, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
+ connect(showInfoAction, SIGNAL(triggered()), viewer, SLOT(informationSwitch()));
- closeAction = new QAction(tr("Close"),this);
- closeAction->setIcon(QIcon(":/images/viewer_toolbar/close.png"));
+ closeAction = new QAction(tr("Close"), this);
+ closeAction->setIcon(QIcon(":/images/viewer_toolbar/close.png"));
closeAction->setData(CLOSE_ACTION_Y);
closeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CLOSE_ACTION_Y));
- connect(closeAction,SIGNAL(triggered()),this,SLOT(close()));
+ connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
- showDictionaryAction = new QAction(tr("Show Dictionary"),this);
- showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.png"));
- //showDictionaryAction->setCheckable(true);
- showDictionaryAction->setDisabled(true);
+ showDictionaryAction = new QAction(tr("Show Dictionary"), this);
+ showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.png"));
+ //showDictionaryAction->setCheckable(true);
+ showDictionaryAction->setDisabled(true);
showDictionaryAction->setData(SHOW_DICTIONARY_ACTION_Y);
showDictionaryAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_DICTIONARY_ACTION_Y));
- connect(showDictionaryAction,SIGNAL(triggered()),viewer,SLOT(translatorSwitch()));
+ connect(showDictionaryAction, SIGNAL(triggered()), viewer, SLOT(translatorSwitch()));
//deprecated
- alwaysOnTopAction = new QAction(tr("Always on top"),this);
- alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
- alwaysOnTopAction->setCheckable(true);
- alwaysOnTopAction->setDisabled(true);
- alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
+ alwaysOnTopAction = new QAction(tr("Always on top"), this);
+ alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
+ alwaysOnTopAction->setCheckable(true);
+ alwaysOnTopAction->setDisabled(true);
+ alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
alwaysOnTopAction->setData(ALWAYS_ON_TOP_ACTION_Y);
alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y));
- connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
+ connect(alwaysOnTopAction, SIGNAL(triggered()), this, SLOT(alwaysOnTopSwitch()));
- showFlowAction = new QAction(tr("Show go to flow"),this);
- showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
- showFlowAction->setDisabled(true);
+ showFlowAction = new QAction(tr("Show go to flow"), this);
+ showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
+ showFlowAction->setDisabled(true);
showFlowAction->setData(SHOW_FLOW_ACTION_Y);
showFlowAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_FLOW_ACTION_Y));
- connect(showFlowAction,SIGNAL(triggered()),viewer,SLOT(goToFlowSwitch()));
+ connect(showFlowAction, SIGNAL(triggered()), viewer, SLOT(goToFlowSwitch()));
- showEditShortcutsAction = new QAction(tr("Edit shortcuts"),this);
+ showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this);
showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_Y);
showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_Y));
- connect(showEditShortcutsAction,SIGNAL(triggered()),editShortcutsDialog,SLOT(show()));
+ connect(showEditShortcutsAction, SIGNAL(triggered()), editShortcutsDialog, SLOT(show()));
}
void MainWindowViewer::createToolBars()
@@ -511,13 +504,13 @@ void MainWindowViewer::createToolBars()
#ifdef Q_OS_MAC
comicToolBar = new YACReaderMacOSXToolbar(this);
#else
- comicToolBar = addToolBar(tr("&File"));
+ comicToolBar = addToolBar(tr("&File"));
#endif
#ifdef Q_OS_MAC
//comicToolBar->setIconSize(QSize(16,16));
#else
- comicToolBar->setIconSize(QSize(18,18));
+ comicToolBar->setIconSize(QSize(18, 18));
comicToolBar->setStyleSheet("QToolBar{border:none;}");
#endif
@@ -525,67 +518,67 @@ void MainWindowViewer::createToolBars()
comicToolBar->addAction(openAction);
comicToolBar->addAction(openFolderAction);
#else
- QMenu * recentmenu = new QMenu(tr("Open recent"));
- recentmenu->addActions(recentFilesActionList);
- recentmenu->addSeparator();
- recentmenu->addAction(clearRecentFilesAction);
- refreshRecentFilesActionList();
+ QMenu *recentmenu = new QMenu(tr("Open recent"));
+ recentmenu->addActions(recentFilesActionList);
+ recentmenu->addSeparator();
+ recentmenu->addAction(clearRecentFilesAction);
+ refreshRecentFilesActionList();
- QToolButton * tb = new QToolButton();
- tb->addAction(openAction);
+ QToolButton *tb = new QToolButton();
+ tb->addAction(openAction);
tb->addAction(openLatestComicAction);
- tb->addAction(openFolderAction);
- tb->addAction(recentmenu->menuAction());
- tb->setPopupMode(QToolButton::MenuButtonPopup);
- tb->setDefaultAction(openAction);
+ tb->addAction(openFolderAction);
+ tb->addAction(recentmenu->menuAction());
+ tb->setPopupMode(QToolButton::MenuButtonPopup);
+ tb->setDefaultAction(openAction);
- comicToolBar->addWidget(tb);
+ comicToolBar->addWidget(tb);
#endif
- comicToolBar->addAction(saveImageAction);
- comicToolBar->addAction(openPreviousComicAction);
- comicToolBar->addAction(openNextComicAction);
+ comicToolBar->addAction(saveImageAction);
+ comicToolBar->addAction(openPreviousComicAction);
+ comicToolBar->addAction(openNextComicAction);
- comicToolBar->addSeparator();
+ comicToolBar->addSeparator();
- comicToolBar->addAction(prevAction);
- comicToolBar->addAction(nextAction);
+ comicToolBar->addAction(prevAction);
+ comicToolBar->addAction(nextAction);
comicToolBar->addAction(goToPageAction);
- comicToolBar->addSeparator();
+ comicToolBar->addSeparator();
- comicToolBar->addAction(adjustWidthAction);
- comicToolBar->addAction(adjustHeightAction);
- comicToolBar->addAction(adjustToFullSizeAction);
- comicToolBar->addAction(fitToPageAction);
+ comicToolBar->addAction(adjustWidthAction);
+ comicToolBar->addAction(adjustHeightAction);
+ comicToolBar->addAction(adjustToFullSizeAction);
+ comicToolBar->addAction(fitToPageAction);
zoomSliderAction = new YACReaderSlider(this);
zoomSliderAction->hide();
comicToolBar->addAction(showZoomSliderlAction);
- connect(showZoomSliderlAction,SIGNAL(triggered()),this,SLOT(toggleFitToWidthSlider()));
- connect(zoomSliderAction, SIGNAL(zoomRatioChanged(int)),viewer,SLOT(updateZoomRatio(int)));
- connect(viewer,SIGNAL(zoomUpdated(int)),zoomSliderAction,SLOT(updateZoomRatio(int)));
+ connect(showZoomSliderlAction, SIGNAL(triggered()), this, SLOT(toggleFitToWidthSlider()));
+ connect(zoomSliderAction, SIGNAL(zoomRatioChanged(int)), viewer, SLOT(updateZoomRatio(int)));
+ connect(viewer, SIGNAL(zoomUpdated(int)), zoomSliderAction, SLOT(updateZoomRatio(int)));
- comicToolBar->addAction(leftRotationAction);
- comicToolBar->addAction(rightRotationAction);
- comicToolBar->addAction(doublePageAction);
- comicToolBar->addAction(doubleMangaPageAction);
+ comicToolBar->addAction(leftRotationAction);
+ comicToolBar->addAction(rightRotationAction);
+ comicToolBar->addAction(doublePageAction);
+ comicToolBar->addAction(doubleMangaPageAction);
comicToolBar->addSeparator();
comicToolBar->addAction(showMagnifyingGlassAction);
- comicToolBar->addSeparator();
+ comicToolBar->addSeparator();
comicToolBar->addAction(setBookmarkAction);
comicToolBar->addAction(showBookmarksAction);
- comicToolBar->addSeparator();
+ comicToolBar->addSeparator();
- comicToolBar->addAction(showDictionaryAction);
- comicToolBar->addAction(showFlowAction);
+ comicToolBar->addAction(showDictionaryAction);
+ comicToolBar->addAction(showFlowAction);
comicToolBar->addAction(showInfoAction);
#ifdef Q_OS_MAC
@@ -594,32 +587,31 @@ void MainWindowViewer::createToolBars()
comicToolBar->addWidget(new YACReaderToolBarStretch());
#endif
-
- comicToolBar->addAction(showShorcutsAction);
- comicToolBar->addAction(optionsAction);
- comicToolBar->addAction(helpAboutAction);
- //comicToolBar->addAction(closeAction);
+ comicToolBar->addAction(showShorcutsAction);
+ comicToolBar->addAction(optionsAction);
+ comicToolBar->addAction(helpAboutAction);
+ //comicToolBar->addAction(closeAction);
#ifndef Q_OS_MAC
- comicToolBar->setMovable(false);
+ comicToolBar->setMovable(false);
#endif
- viewer->addAction(openAction);
- viewer->addAction(openFolderAction);
- viewer->addAction(saveImageAction);
- viewer->addAction(openPreviousComicAction);
- viewer->addAction(openNextComicAction);
+ viewer->addAction(openAction);
+ viewer->addAction(openFolderAction);
+ viewer->addAction(saveImageAction);
+ viewer->addAction(openPreviousComicAction);
+ viewer->addAction(openNextComicAction);
YACReader::addSperator(viewer);
- viewer->addAction(prevAction);
- viewer->addAction(nextAction);
+ viewer->addAction(prevAction);
+ viewer->addAction(nextAction);
viewer->addAction(goToPageAction);
viewer->addAction(adjustHeightAction);
viewer->addAction(adjustWidthAction);
- viewer->addAction(adjustToFullSizeAction);
- viewer->addAction(fitToPageAction);
- viewer->addAction(leftRotationAction);
- viewer->addAction(rightRotationAction);
+ viewer->addAction(adjustToFullSizeAction);
+ viewer->addAction(fitToPageAction);
+ viewer->addAction(leftRotationAction);
+ viewer->addAction(rightRotationAction);
viewer->addAction(doublePageAction);
viewer->addAction(doubleMangaPageAction);
YACReader::addSperator(viewer);
@@ -634,29 +626,29 @@ void MainWindowViewer::createToolBars()
viewer->addAction(showBookmarksAction);
YACReader::addSperator(viewer);
- viewer->addAction(showDictionaryAction);
- viewer->addAction(showFlowAction);
+ viewer->addAction(showDictionaryAction);
+ viewer->addAction(showFlowAction);
viewer->addAction(showInfoAction);
YACReader::addSperator(viewer);
- viewer->addAction(showShorcutsAction);
+ viewer->addAction(showShorcutsAction);
viewer->addAction(showEditShortcutsAction);
- viewer->addAction(optionsAction);
- viewer->addAction(helpAboutAction);
+ viewer->addAction(optionsAction);
+ viewer->addAction(helpAboutAction);
YACReader::addSperator(viewer);
- viewer->addAction(closeAction);
+ viewer->addAction(closeAction);
- viewer->setContextMenuPolicy(Qt::ActionsContextMenu);
+ viewer->setContextMenuPolicy(Qt::ActionsContextMenu);
//MacOSX app menus
#ifdef Q_OS_MAC
- QMenuBar * menuBar = this->menuBar();
+ QMenuBar *menuBar = this->menuBar();
//about / preferences
//TODO
//file
- QMenu * fileMenu = new QMenu(tr("File"));
+ QMenu *fileMenu = new QMenu(tr("File"));
fileMenu->addAction(openAction);
fileMenu->addAction(openLatestComicAction);
@@ -665,21 +657,21 @@ void MainWindowViewer::createToolBars()
fileMenu->addAction(saveImageAction);
fileMenu->addSeparator();
- QMenu * recentmenu = new QMenu(tr("Open recent"));
- recentmenu->addActions(recentFilesActionList);
- recentmenu->addSeparator();
- recentmenu->addAction(clearRecentFilesAction);
- refreshRecentFilesActionList();
+ QMenu *recentmenu = new QMenu(tr("Open recent"));
+ recentmenu->addActions(recentFilesActionList);
+ recentmenu->addSeparator();
+ recentmenu->addAction(clearRecentFilesAction);
+ refreshRecentFilesActionList();
fileMenu->addMenu(recentmenu);
fileMenu->addSeparator();
fileMenu->addAction(closeAction);
- QMenu * editMenu = new QMenu(tr("Edit"));
+ QMenu *editMenu = new QMenu(tr("Edit"));
editMenu->addAction(leftRotationAction);
editMenu->addAction(rightRotationAction);
- QMenu * viewMenu = new QMenu(tr("View"));
+ QMenu *viewMenu = new QMenu(tr("View"));
viewMenu->addAction(adjustHeightAction);
viewMenu->addAction(adjustWidthAction);
viewMenu->addAction(fitToPageAction);
@@ -695,22 +687,22 @@ void MainWindowViewer::createToolBars()
viewMenu->addSeparator();
viewMenu->addAction(showMagnifyingGlassAction);
- QMenu * goMenu = new QMenu(tr("Go"));
+ QMenu *goMenu = new QMenu(tr("Go"));
goMenu->addAction(prevAction);
goMenu->addAction(nextAction);
goMenu->addAction(goToPageAction);
- goMenu->addSeparator();
+ goMenu->addSeparator();
goMenu->addAction(setBookmarkAction);
goMenu->addAction(showBookmarksAction);
- QMenu * windowMenu = new QMenu(tr("Window"));
+ QMenu *windowMenu = new QMenu(tr("Window"));
windowMenu->addAction(optionsAction); // this action goes to MacOS's Preference menu by Qt
windowMenu->addAction(showShorcutsAction);
windowMenu->addAction(showFlowAction);
windowMenu->addAction(showInfoAction);
windowMenu->addAction(showDictionaryAction);
- QMenu * helpMenu = new QMenu(tr("Help"));
+ QMenu *helpMenu = new QMenu(tr("Help"));
helpMenu->addAction(helpAboutAction);
menuBar->addMenu(fileMenu);
@@ -732,47 +724,44 @@ void MainWindowViewer::createToolBars()
comicToolBar->attachToWindow(this->windowHandle());
#endif
-
}
void MainWindowViewer::refreshRecentFilesActionList()
{
- QStringList recentFilePaths = Configuration::getConfiguration().openRecentList();
+ QStringList recentFilePaths = Configuration::getConfiguration().openRecentList();
- //TODO: Replace limit with something configurable
- int iteration = (recentFilePaths.size() < Configuration::getConfiguration().getOpenRecentSize())
- ? recentFilePaths.size() : Configuration::getConfiguration().getOpenRecentSize();
- for (int i = 0; i < iteration; i++)
- {
- QString strippedName = QFileInfo(recentFilePaths.at(i)).fileName();
- recentFilesActionList.at(i)->setText(strippedName);
- recentFilesActionList.at(i)->setData(recentFilePaths.at(i));
- recentFilesActionList.at(i)->setVisible(true);
- }
+ //TODO: Replace limit with something configurable
+ int iteration = (recentFilePaths.size() < Configuration::getConfiguration().getOpenRecentSize())
+ ? recentFilePaths.size()
+ : Configuration::getConfiguration().getOpenRecentSize();
+ for (int i = 0; i < iteration; i++) {
+ QString strippedName = QFileInfo(recentFilePaths.at(i)).fileName();
+ recentFilesActionList.at(i)->setText(strippedName);
+ recentFilesActionList.at(i)->setData(recentFilePaths.at(i));
+ recentFilesActionList.at(i)->setVisible(true);
+ }
- for (int i = iteration; i < Configuration::getConfiguration().getOpenRecentSize(); i++)
- {
- recentFilesActionList.at(i)->setVisible(false);
- }
+ for (int i = iteration; i < Configuration::getConfiguration().getOpenRecentSize(); i++) {
+ recentFilesActionList.at(i)->setVisible(false);
+ }
}
void MainWindowViewer::clearRecentFiles()
{
- Configuration::getConfiguration().clearOpenRecentList();
- refreshRecentFilesActionList();
+ Configuration::getConfiguration().clearOpenRecentList();
+ refreshRecentFilesActionList();
}
void MainWindowViewer::openRecent()
{
- QAction *action = qobject_cast(sender());
+ QAction *action = qobject_cast(sender());
openComicFromRecentAction(action);
}
void MainWindowViewer::openLatestComic()
{
- if (recentFilesActionList.isEmpty())
- {
+ if (recentFilesActionList.isEmpty()) {
return;
}
@@ -781,20 +770,15 @@ void MainWindowViewer::openLatestComic()
void MainWindowViewer::openComicFromRecentAction(QAction *action)
{
- if (action == nullptr)
- {
+ if (action == nullptr) {
return;
}
- QFileInfo info1 (action->data().toString());
- if (info1.exists())
- {
- if (info1.isFile())
- {
+ QFileInfo info1(action->data().toString());
+ if (info1.exists()) {
+ if (info1.isFile()) {
openComicFromPath(action->data().toString());
- }
- else if (info1.isDir())
- {
+ } else if (info1.isDir()) {
openFolderFromPath(action->data().toString());
}
}
@@ -802,83 +786,79 @@ void MainWindowViewer::openComicFromRecentAction(QAction *action)
void MainWindowViewer::reloadOptions()
{
- viewer->updateConfig(settings);
+ viewer->updateConfig(settings);
}
void MainWindowViewer::open()
{
- QFileDialog openDialog;
+ QFileDialog openDialog;
#ifndef use_unarr
- QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.7z *.cb7 *.arj *.cbt)");
+ QString pathFile = openDialog.getOpenFileName(this, tr("Open Comic"), currentDirectory, tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.7z *.cb7 *.arj *.cbt)");
#else
- QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.cbt)");
+ QString pathFile = openDialog.getOpenFileName(this, tr("Open Comic"), currentDirectory, tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.cbt)");
#endif
- if (!pathFile.isEmpty())
- {
- openComicFromPath(pathFile);
- }
+ if (!pathFile.isEmpty()) {
+ openComicFromPath(pathFile);
+ }
}
-void MainWindowViewer::open(QString path, ComicDB & comic, QList & siblings)
+void MainWindowViewer::open(QString path, ComicDB &comic, QList &siblings)
{
- //currentComicDB = comic;
- //siblingComics = siblings;
+ //currentComicDB = comic;
+ //siblingComics = siblings;
- QFileInfo fi(path);
+ QFileInfo fi(path);
- if(!comic.info.title.isNull() && !comic.info.title.toString().isEmpty())
+ if (!comic.info.title.isNull() && !comic.info.title.toString().isEmpty())
setWindowTitle("YACReader - " + comic.info.title.toString());
- else
- setWindowTitle("YACReader - " + fi.fileName());
+ else
+ setWindowTitle("YACReader - " + fi.fileName());
- viewer->open(path,comic);
- enableActions();
- int index = siblings.indexOf(comic);
+ viewer->open(path, comic);
+ enableActions();
+ int index = siblings.indexOf(comic);
- optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
+ optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
- if(index>0)
- openPreviousComicAction->setDisabled(false);
- else
- openPreviousComicAction->setDisabled(true);
+ if (index > 0)
+ openPreviousComicAction->setDisabled(false);
+ else
+ openPreviousComicAction->setDisabled(true);
- if(index+1setDisabled(false);
- else
- openNextComicAction->setDisabled(true);
+ if (index + 1 < siblings.count())
+ openNextComicAction->setDisabled(false);
+ else
+ openNextComicAction->setDisabled(true);
}
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId)
{
- //QString pathFile = QCoreApplication::arguments().at(1);
- currentDirectory = path;
- //quint64 comicId = QCoreApplication::arguments().at(2).split("=").at(1).toULongLong();
- //libraryId = QCoreApplication::arguments().at(3).split("=").at(1).toULongLong();
- this->libraryId=libraryId;
-// this->path=path;
+ //QString pathFile = QCoreApplication::arguments().at(1);
+ currentDirectory = path;
+ //quint64 comicId = QCoreApplication::arguments().at(2).split("=").at(1).toULongLong();
+ //libraryId = QCoreApplication::arguments().at(3).split("=").at(1).toULongLong();
+ this->libraryId = libraryId;
+ // this->path=path;
- enableActions();
+ enableActions();
- currentComicDB.id = comicId;
- YACReaderLocalClient client;
- int tries = 1;
- bool success = false;
- while(!(success = client.requestComicInfo(libraryId,currentComicDB,siblingComics)) && tries != 0)
- tries--;
+ currentComicDB.id = comicId;
+ YACReaderLocalClient client;
+ int tries = 1;
+ bool success = false;
+ while (!(success = client.requestComicInfo(libraryId, currentComicDB, siblingComics)) && tries != 0)
+ tries--;
- if(success)
- {
- isClient = true;
- open(path+currentComicDB.path,currentComicDB,siblingComics);
- }
- else
- {
- isClient = false;
- QMessageBox::information(this,"Connection Error", "Unable to connect to YACReaderLibrary");
- //error
- }
+ if (success) {
+ isClient = true;
+ open(path + currentComicDB.path, currentComicDB, siblingComics);
+ } else {
+ isClient = false;
+ QMessageBox::information(this, "Connection Error", "Unable to connect to YACReaderLibrary");
+ //error
+ }
- optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
+ optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
}
void MainWindowViewer::openComicFromPath(QString pathFile)
@@ -897,7 +877,7 @@ void MainWindowViewer::openComic(QString pathFile)
{
QFileInfo fi(pathFile);
currentDirectory = fi.dir().absolutePath();
- getSiblingComics(fi.absolutePath(),fi.fileName());
+ getSiblingComics(fi.absolutePath(), fi.fileName());
setWindowTitle("YACReader - " + fi.fileName());
@@ -906,106 +886,103 @@ void MainWindowViewer::openComic(QString pathFile)
viewer->open(pathFile);
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
refreshRecentFilesActionList();
- }
+}
void MainWindowViewer::openFolder()
{
- QFileDialog openDialog;
- QString pathDir = openDialog.getExistingDirectory(this,tr("Open folder"),currentDirectory);
- if (!pathDir.isEmpty())
- {
- openFolderFromPath(pathDir);
- isClient = false;
- }
+ QFileDialog openDialog;
+ QString pathDir = openDialog.getExistingDirectory(this, tr("Open folder"), currentDirectory);
+ if (!pathDir.isEmpty()) {
+ openFolderFromPath(pathDir);
+ isClient = false;
+ }
}
void MainWindowViewer::openFolderFromPath(QString pathDir)
{
- currentDirectory = pathDir; //TODO ??
- QFileInfo fi(pathDir);
- getSiblingComics(fi.absolutePath(),fi.fileName());
+ currentDirectory = pathDir; //TODO ??
+ QFileInfo fi(pathDir);
+ getSiblingComics(fi.absolutePath(), fi.fileName());
- setWindowTitle("YACReader - " + fi.fileName());
+ setWindowTitle("YACReader - " + fi.fileName());
- enableActions();
+ enableActions();
- viewer->open(pathDir);
- Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
- refreshRecentFilesActionList();
+ viewer->open(pathDir);
+ Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
+ refreshRecentFilesActionList();
}
void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName)
{
- currentDirectory = pathDir; //TODO ??
- QFileInfo fi(pathDir);
- getSiblingComics(fi.absolutePath(),fi.fileName());
+ currentDirectory = pathDir; //TODO ??
+ QFileInfo fi(pathDir);
+ getSiblingComics(fi.absolutePath(), fi.fileName());
- setWindowTitle("YACReader - " + fi.fileName());
+ setWindowTitle("YACReader - " + fi.fileName());
- enableActions();
+ enableActions();
- QDir d(pathDir);
- d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
- d.setNameFilters(Comic::getSupportedImageFormats());
- d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
- QStringList list = d.entryList();
+ QDir d(pathDir);
+ d.setFilter(QDir::Files | QDir::NoDotAndDotDot);
+ d.setNameFilters(Comic::getSupportedImageFormats());
+ d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
+ QStringList list = d.entryList();
- qSort(list.begin(),list.end(),naturalSortLessThanCI);
- int i = 0;
- foreach(QString path,list)
- {
- if(path.endsWith(atFileName))
- break;
- i++;
- }
+ qSort(list.begin(), list.end(), naturalSortLessThanCI);
+ int i = 0;
+ foreach (QString path, list) {
+ if (path.endsWith(atFileName))
+ break;
+ i++;
+ }
- int index = 0;
- if(i < list.count())
- index = i;
+ int index = 0;
+ if (i < list.count())
+ index = i;
- viewer->open(pathDir,index);
+ viewer->open(pathDir, index);
}
void MainWindowViewer::saveImage()
{
- QFileDialog saveDialog;
- QString pathFile = saveDialog.getSaveFileName(this,tr("Save current page"),currentDirectoryImgDest+"/"+tr("page_%1.jpg").arg(viewer->getIndex()),tr("Image files (*.jpg)"));
- if (!pathFile.isEmpty())
- {
- QFileInfo fi(pathFile);
- currentDirectoryImgDest = fi.absolutePath();
- const QPixmap * p = viewer->pixmap();
- if(p!=NULL)
- p->save(pathFile);
- }
+ QFileDialog saveDialog;
+ QString pathFile = saveDialog.getSaveFileName(this, tr("Save current page"), currentDirectoryImgDest + "/" + tr("page_%1.jpg").arg(viewer->getIndex()), tr("Image files (*.jpg)"));
+ if (!pathFile.isEmpty()) {
+ QFileInfo fi(pathFile);
+ currentDirectoryImgDest = fi.absolutePath();
+ const QPixmap *p = viewer->pixmap();
+ if (p != NULL)
+ p->save(pathFile);
+ }
}
void MainWindowViewer::enableActions()
{
- saveImageAction->setDisabled(false);
- prevAction->setDisabled(false);
- nextAction->setDisabled(false);
+ saveImageAction->setDisabled(false);
+ prevAction->setDisabled(false);
+ nextAction->setDisabled(false);
adjustHeightAction->setDisabled(false);
adjustWidthAction->setDisabled(false);
goToPageAction->setDisabled(false);
- //alwaysOnTopAction->setDisabled(false);
- leftRotationAction->setDisabled(false);
- rightRotationAction->setDisabled(false);
+ //alwaysOnTopAction->setDisabled(false);
+ leftRotationAction->setDisabled(false);
+ rightRotationAction->setDisabled(false);
showMagnifyingGlassAction->setDisabled(false);
- doublePageAction->setDisabled(false);
- doubleMangaPageAction->setDisabled(false);
- adjustToFullSizeAction->setDisabled(false);
- adjustToFullSizeAction->setDisabled(false);
- fitToPageAction->setDisabled(false);
+ doublePageAction->setDisabled(false);
+ doubleMangaPageAction->setDisabled(false);
+ adjustToFullSizeAction->setDisabled(false);
+ adjustToFullSizeAction->setDisabled(false);
+ fitToPageAction->setDisabled(false);
showZoomSliderlAction->setDisabled(false);
- increasePageZoomAction->setDisabled(false);
- decreasePageZoomAction->setDisabled(false);
+ increasePageZoomAction->setDisabled(false);
+ decreasePageZoomAction->setDisabled(false);
resetZoomAction->setDisabled(false);
- //setBookmark->setDisabled(false);
+ //setBookmark->setDisabled(false);
showBookmarksAction->setDisabled(false);
showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
- showDictionaryAction->setDisabled(false);
- showFlowAction->setDisabled(false);
+ showDictionaryAction->setDisabled(false);
+ showFlowAction->setDisabled(false);
#ifdef Q_OS_MAC
activateWindow();
@@ -1014,19 +991,19 @@ void MainWindowViewer::enableActions()
}
void MainWindowViewer::disableActions()
{
- saveImageAction->setDisabled(true);
- prevAction->setDisabled(true);
- nextAction->setDisabled(true);
+ saveImageAction->setDisabled(true);
+ prevAction->setDisabled(true);
+ nextAction->setDisabled(true);
adjustHeightAction->setDisabled(true);
adjustWidthAction->setDisabled(true);
goToPageAction->setDisabled(true);
- //alwaysOnTopAction->setDisabled(true);
- leftRotationAction->setDisabled(true);
- rightRotationAction->setDisabled(true);
+ //alwaysOnTopAction->setDisabled(true);
+ leftRotationAction->setDisabled(true);
+ rightRotationAction->setDisabled(true);
showMagnifyingGlassAction->setDisabled(true);
- doublePageAction->setDisabled(true);
- doubleMangaPageAction->setDisabled(true);
- adjustToFullSizeAction->setDisabled(true);
+ doublePageAction->setDisabled(true);
+ doubleMangaPageAction->setDisabled(true);
+ adjustToFullSizeAction->setDisabled(true);
fitToPageAction->setDisabled(true);
showZoomSliderlAction->setDisabled(true);
increasePageZoomAction->setDisabled(true);
@@ -1035,10 +1012,10 @@ void MainWindowViewer::disableActions()
setBookmarkAction->setDisabled(true);
showBookmarksAction->setDisabled(true);
showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
- openPreviousComicAction->setDisabled(true);
- openNextComicAction->setDisabled(true);
- showDictionaryAction->setDisabled(true);
- showFlowAction->setDisabled(true);
+ openPreviousComicAction->setDisabled(true);
+ openNextComicAction->setDisabled(true);
+ showDictionaryAction->setDisabled(true);
+ showFlowAction->setDisabled(true);
}
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
@@ -1047,7 +1024,7 @@ void MainWindowViewer::keyPressEvent(QKeyEvent *event)
int _key = event->key();
Qt::KeyboardModifiers modifiers = event->modifiers();
- if(modifiers & Qt::ShiftModifier)
+ if (modifiers & Qt::ShiftModifier)
_key |= Qt::SHIFT;
if (modifiers & Qt::ControlModifier)
_key |= Qt::CTRL;
@@ -1058,35 +1035,29 @@ void MainWindowViewer::keyPressEvent(QKeyEvent *event)
QKeySequence key(_key);
- if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y))
- {
+ if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y)) {
toggleFullScreen();
event->accept();
- }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y))
- {
+ } else if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y)) {
toggleToolBars();
event->accept();
- }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y))
- {
- toggleWidthHeight();
- event->accept();
- }
- else
+ } else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y)) {
+ toggleWidthHeight();
+ event->accept();
+ } else
QWidget::keyPressEvent(event);
}
-void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event )
+void MainWindowViewer::mouseDoubleClickEvent(QMouseEvent *event)
{
- toggleFullScreen();
- event->accept();
+ toggleFullScreen();
+ event->accept();
}
void MainWindowViewer::toggleFullScreen()
{
- fullscreen?toNormal():toFullScreen();
- Configuration::getConfiguration().setFullScreen(fullscreen = !fullscreen);
+ fullscreen ? toNormal() : toFullScreen();
+ Configuration::getConfiguration().setFullScreen(fullscreen = !fullscreen);
}
#ifdef Q_OS_WIN //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
@@ -1097,7 +1068,7 @@ void MainWindowViewer::toFullScreen()
hideToolBars();
viewer->hide();
- viewer->fullscreen = true;//TODO, change by the right use of windowState();
+ viewer->fullscreen = true; //TODO, change by the right use of windowState();
previousWindowFlags = windowFlags();
previousPos = pos();
@@ -1109,11 +1080,11 @@ void MainWindowViewer::toFullScreen()
const QRect r = windowHandle()->screen()->geometry();
move(r.x(), r.y());
- resize(r.width(),r.height()+1);
+ resize(r.width(), r.height() + 1);
show();
viewer->show();
- if(viewer->magnifyingGlassIsVisible())
+ if (viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
@@ -1121,7 +1092,7 @@ void MainWindowViewer::toNormal()
{
//show all
viewer->hide();
- viewer->fullscreen = false;//TODO, change by the right use of windowState();
+ viewer->fullscreen = false; //TODO, change by the right use of windowState();
//viewer->hideMagnifyingGlass();
setWindowFlags(previousWindowFlags);
@@ -1129,13 +1100,13 @@ void MainWindowViewer::toNormal()
resize(previousSize);
show();
- if(fromMaximized)
+ if (fromMaximized)
showMaximized();
- if(Configuration::getConfiguration().getShowToolbars())
+ if (Configuration::getConfiguration().getShowToolbars())
showToolBars();
viewer->show();
- if(viewer->magnifyingGlassIsVisible())
+ if (viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
@@ -1146,10 +1117,10 @@ void MainWindowViewer::toFullScreen()
hideToolBars();
viewer->hide();
- viewer->fullscreen = true;//TODO, change by the right use of windowState();
+ viewer->fullscreen = true; //TODO, change by the right use of windowState();
setWindowState(Qt::WindowFullScreen);
viewer->show();
- if(viewer->magnifyingGlassIsVisible())
+ if (viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
@@ -1157,272 +1128,263 @@ void MainWindowViewer::toNormal()
{
//show all
viewer->hide();
- viewer->fullscreen = false;//TODO, change by the right use of windowState();
+ viewer->fullscreen = false; //TODO, change by the right use of windowState();
//viewer->hideMagnifyingGlass();
- if(fromMaximized)
+ if (fromMaximized)
showMaximized();
else
showNormal();
- if(Configuration::getConfiguration().getShowToolbars())
+ if (Configuration::getConfiguration().getShowToolbars())
showToolBars();
viewer->show();
- if(viewer->magnifyingGlassIsVisible())
+ if (viewer->magnifyingGlassIsVisible())
viewer->showMagnifyingGlass();
}
#endif
void MainWindowViewer::toggleToolBars()
{
- toolbars?hideToolBars():showToolBars();
+ toolbars ? hideToolBars() : showToolBars();
- Configuration::getConfiguration().setShowToolbars(toolbars);
+ Configuration::getConfiguration().setShowToolbars(toolbars);
#ifndef Q_OS_MAC
- comicToolBar->setMovable(false);
+ comicToolBar->setMovable(false);
#endif
}
void MainWindowViewer::hideToolBars()
{
- //hide all
- this->comicToolBar->hide();
- toolbars = false;
+ //hide all
+ this->comicToolBar->hide();
+ toolbars = false;
}
void MainWindowViewer::showToolBars()
{
- this->comicToolBar->show();
- toolbars = true;
+ this->comicToolBar->show();
+ toolbars = true;
}
void MainWindowViewer::fitToWidth()
{
- Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToWidth);
+ Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToWidth);
viewer->setZoomFactor(100);
- viewer->updatePage();
+ viewer->updatePage();
}
void MainWindowViewer::fitToHeight()
{
- Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToHeight);
+ Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToHeight);
viewer->setZoomFactor(100);
- viewer->updatePage();
+ viewer->updatePage();
}
void MainWindowViewer::toggleWidthHeight()
{
- //Only switch to "Fit to height" when we're in "Fit to width"
- if (Configuration::getConfiguration().getFitMode() == YACReader::FitMode::ToWidth)
- {
- adjustHeightAction->trigger();
- }
- //Default to "Fit to width" in all other cases
- else
- {
- adjustWidthAction->trigger();
- }
+ //Only switch to "Fit to height" when we're in "Fit to width"
+ if (Configuration::getConfiguration().getFitMode() == YACReader::FitMode::ToWidth) {
+ adjustHeightAction->trigger();
+ }
+ //Default to "Fit to width" in all other cases
+ else {
+ adjustWidthAction->trigger();
+ }
}
void MainWindowViewer::checkNewVersion()
{
- Configuration & conf = Configuration::getConfiguration();
- QDate lastCheck = conf.getLastVersionCheck();
- QDate current = QDate::currentDate();
- if(lastCheck.isNull() || lastCheck.daysTo(current) >= conf.getNumDaysBetweenVersionChecks())
- {
- versionChecker = new HttpVersionChecker();
+ Configuration &conf = Configuration::getConfiguration();
+ QDate lastCheck = conf.getLastVersionCheck();
+ QDate current = QDate::currentDate();
+ if (lastCheck.isNull() || lastCheck.daysTo(current) >= conf.getNumDaysBetweenVersionChecks()) {
+ versionChecker = new HttpVersionChecker();
- connect(versionChecker,SIGNAL(newVersionDetected()),
- this,SLOT(newVersion()));
+ connect(versionChecker, SIGNAL(newVersionDetected()),
+ this, SLOT(newVersion()));
- QTimer * tT = new QTimer;
- tT->setSingleShot(true);
- connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
- //versionChecker->get(); //TOD�
- tT->start(100);
+ QTimer *tT = new QTimer;
+ tT->setSingleShot(true);
+ connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
+ //versionChecker->get(); //TOD�
+ tT->start(100);
- conf.setLastVersionCheck(current);
+ conf.setLastVersionCheck(current);
}
}
void MainWindowViewer::processReset()
{
- if(isClient)
- {
- if(siblingComics.count()>1)
- {
+ if (isClient) {
+ if (siblingComics.count() > 1) {
bool openNextB = openNextComicAction->isEnabled();
bool openPrevB = openPreviousComicAction->isEnabled();
disableActions();
openNextComicAction->setEnabled(openNextB);
openPreviousComicAction->setEnabled(openPrevB);
- }
- else
+ } else
disableActions();
- }
- else
+ } else
disableActions();
}
void MainWindowViewer::setUpShortcutsManagement()
{
//actions holder
- QObject * orphanActions = new QObject;
+ QObject *orphanActions = new QObject;
QList allActions;
QList tmpList;
-
- editShortcutsDialog->addActionsGroup(tr("Comics"),QIcon(":/images/shortcuts_group_comics.png"),
- tmpList = { openAction,
- openLatestComicAction,
- openFolderAction,
- saveImageAction,
- openPreviousComicAction,
- openNextComicAction });
+ editShortcutsDialog->addActionsGroup(tr("Comics"), QIcon(":/images/shortcuts_group_comics.png"),
+ tmpList = { openAction,
+ openLatestComicAction,
+ openFolderAction,
+ saveImageAction,
+ openPreviousComicAction,
+ openNextComicAction });
allActions << tmpList;
//keys without actions (General)
- QAction * toggleFullScreenAction = new QAction(tr("Toggle fullscreen mode"),orphanActions);
+ QAction *toggleFullScreenAction = new QAction(tr("Toggle fullscreen mode"), orphanActions);
toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_Y);
toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y));
- QAction * toggleToolbarsAction = new QAction(tr("Hide/show toolbar"),orphanActions);
+ QAction *toggleToolbarsAction = new QAction(tr("Hide/show toolbar"), orphanActions);
toggleToolbarsAction->setData(TOGGLE_TOOL_BARS_ACTION_Y);
toggleToolbarsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y));
- editShortcutsDialog->addActionsGroup(tr("General"),QIcon(":/images/shortcuts_group_general.png"),
+ editShortcutsDialog->addActionsGroup(tr("General"), QIcon(":/images/shortcuts_group_general.png"),
tmpList = QList()
- << optionsAction
- << helpAboutAction
- << showShorcutsAction
- << showInfoAction
- << closeAction
- << showDictionaryAction
- << showFlowAction
- << toggleFullScreenAction
- << toggleToolbarsAction
- << showEditShortcutsAction);
+ << optionsAction
+ << helpAboutAction
+ << showShorcutsAction
+ << showInfoAction
+ << closeAction
+ << showDictionaryAction
+ << showFlowAction
+ << toggleFullScreenAction
+ << toggleToolbarsAction
+ << showEditShortcutsAction);
allActions << tmpList;
//keys without actions (MGlass)
- QAction * sizeUpMglassAction = new QAction(tr("Size up magnifying glass"),orphanActions);
+ QAction *sizeUpMglassAction = new QAction(tr("Size up magnifying glass"), orphanActions);
sizeUpMglassAction->setData(SIZE_UP_MGLASS_ACTION_Y);
sizeUpMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y));
- QAction * sizeDownMglassAction = new QAction(tr("Size down magnifying glass"),orphanActions);
+ QAction *sizeDownMglassAction = new QAction(tr("Size down magnifying glass"), orphanActions);
sizeDownMglassAction->setData(SIZE_DOWN_MGLASS_ACTION_Y);
sizeDownMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y));
- QAction * zoomInMglassAction = new QAction(tr("Zoom in magnifying glass"),orphanActions);
+ QAction *zoomInMglassAction = new QAction(tr("Zoom in magnifying glass"), orphanActions);
zoomInMglassAction->setData(ZOOM_IN_MGLASS_ACTION_Y);
zoomInMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y));
- QAction * zoomOutMglassAction = new QAction(tr("Zoom out magnifying glass"),orphanActions);
+ QAction *zoomOutMglassAction = new QAction(tr("Zoom out magnifying glass"), orphanActions);
zoomOutMglassAction->setData(ZOOM_OUT_MGLASS_ACTION_Y);
zoomOutMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y));
- editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"),QIcon(":/images/shortcuts_group_mglass.png"),
+ editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), QIcon(":/images/shortcuts_group_mglass.png"),
tmpList = QList()
- << showMagnifyingGlassAction
- << sizeUpMglassAction
- << sizeDownMglassAction
- << zoomInMglassAction
- << zoomOutMglassAction);
+ << showMagnifyingGlassAction
+ << sizeUpMglassAction
+ << sizeDownMglassAction
+ << zoomInMglassAction
+ << zoomOutMglassAction);
allActions << tmpList;
//keys without actions
- QAction * toggleFitToScreenAction = new QAction(tr("Toggle between fit to width and fit to height"),orphanActions);
+ QAction *toggleFitToScreenAction = new QAction(tr("Toggle between fit to width and fit to height"), orphanActions);
toggleFitToScreenAction->setData(CHANGE_FIT_ACTION_Y);
toggleFitToScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y));
- editShortcutsDialog->addActionsGroup(tr("Page adjustement"),QIcon(":/images/shortcuts_group_page.png"),
+ editShortcutsDialog->addActionsGroup(tr("Page adjustement"), QIcon(":/images/shortcuts_group_page.png"),
tmpList = QList()
- << adjustHeightAction
- << adjustWidthAction
- << toggleFitToScreenAction
- << leftRotationAction
- << rightRotationAction
- << doublePageAction
- << doubleMangaPageAction
- << adjustToFullSizeAction
- << increasePageZoomAction
- << decreasePageZoomAction
- << resetZoomAction);
+ << adjustHeightAction
+ << adjustWidthAction
+ << toggleFitToScreenAction
+ << leftRotationAction
+ << rightRotationAction
+ << doublePageAction
+ << doubleMangaPageAction
+ << adjustToFullSizeAction
+ << increasePageZoomAction
+ << decreasePageZoomAction
+ << resetZoomAction);
allActions << tmpList;
- QAction * autoScrollForwardAction = new QAction(tr("Autoscroll down"),orphanActions);
+ QAction *autoScrollForwardAction = new QAction(tr("Autoscroll down"), orphanActions);
autoScrollForwardAction->setData(AUTO_SCROLL_FORWARD_ACTION_Y);
autoScrollForwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y));
- QAction * autoScrollBackwardAction = new QAction(tr("Autoscroll up"),orphanActions);
+ QAction *autoScrollBackwardAction = new QAction(tr("Autoscroll up"), orphanActions);
autoScrollBackwardAction->setData(AUTO_SCROLL_BACKWARD_ACTION_Y);
autoScrollBackwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y));
- QAction * autoScrollForwardHorizontalFirstAction = new QAction(tr("Autoscroll forward, horizontal first"),orphanActions);
+ QAction *autoScrollForwardHorizontalFirstAction = new QAction(tr("Autoscroll forward, horizontal first"), orphanActions);
autoScrollForwardHorizontalFirstAction->setData(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y);
autoScrollForwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y));
- QAction * autoScrollBackwardHorizontalFirstAction = new QAction(tr("Autoscroll backward, horizontal first"),orphanActions);
+ QAction *autoScrollBackwardHorizontalFirstAction = new QAction(tr("Autoscroll backward, horizontal first"), orphanActions);
autoScrollBackwardHorizontalFirstAction->setData(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y);
autoScrollBackwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y));
- QAction * autoScrollForwardVerticalFirstAction = new QAction(tr("Autoscroll forward, vertical first"),orphanActions);
+ QAction *autoScrollForwardVerticalFirstAction = new QAction(tr("Autoscroll forward, vertical first"), orphanActions);
autoScrollForwardVerticalFirstAction->setData(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y);
autoScrollForwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y));
- QAction * autoScrollBackwardVerticalFirstAction = new QAction(tr("Autoscroll backward, vertical first"),orphanActions);
+ QAction *autoScrollBackwardVerticalFirstAction = new QAction(tr("Autoscroll backward, vertical first"), orphanActions);
autoScrollBackwardVerticalFirstAction->setData(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y);
autoScrollBackwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y));
- QAction * moveDownAction = new QAction(tr("Move down"),orphanActions);
+ QAction *moveDownAction = new QAction(tr("Move down"), orphanActions);
moveDownAction->setData(MOVE_DOWN_ACTION_Y);
moveDownAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y));
- QAction * moveUpAction = new QAction(tr("Move up"),orphanActions);
+ QAction *moveUpAction = new QAction(tr("Move up"), orphanActions);
moveUpAction->setData(MOVE_UP_ACTION_Y);
moveUpAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y));
- QAction * moveLeftAction = new QAction(tr("Move left"),orphanActions);
+ QAction *moveLeftAction = new QAction(tr("Move left"), orphanActions);
moveLeftAction->setData(MOVE_LEFT_ACTION_Y);
moveLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y));
- QAction * moveRightAction = new QAction(tr("Move right"),orphanActions);
+ QAction *moveRightAction = new QAction(tr("Move right"), orphanActions);
moveRightAction->setData(MOVE_RIGHT_ACTION_Y);
moveRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y));
- QAction * goToFirstPageAction = new QAction(tr("Go to the first page"),orphanActions);
+ QAction *goToFirstPageAction = new QAction(tr("Go to the first page"), orphanActions);
goToFirstPageAction->setData(GO_TO_FIRST_PAGE_ACTION_Y);
goToFirstPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y));
- QAction * goToLastPageAction = new QAction(tr("Go to the last page"),orphanActions);
+ QAction *goToLastPageAction = new QAction(tr("Go to the last page"), orphanActions);
goToLastPageAction->setData(GO_TO_LAST_PAGE_ACTION_Y);
goToLastPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y));
- editShortcutsDialog->addActionsGroup(tr("Reading"),QIcon(":/images/shortcuts_group_reading.png"),
+ editShortcutsDialog->addActionsGroup(tr("Reading"), QIcon(":/images/shortcuts_group_reading.png"),
tmpList = QList()
- << nextAction
- << prevAction
- << setBookmarkAction
- << showBookmarksAction
- << autoScrollForwardAction
- << autoScrollBackwardAction
- << autoScrollForwardHorizontalFirstAction
- << autoScrollBackwardHorizontalFirstAction
- << autoScrollForwardVerticalFirstAction
- << autoScrollBackwardVerticalFirstAction
- << moveDownAction
- << moveUpAction
- << moveLeftAction
- << moveRightAction
- << goToFirstPageAction
- << goToLastPageAction
- << goToPageAction);
+ << nextAction
+ << prevAction
+ << setBookmarkAction
+ << showBookmarksAction
+ << autoScrollForwardAction
+ << autoScrollBackwardAction
+ << autoScrollForwardHorizontalFirstAction
+ << autoScrollBackwardHorizontalFirstAction
+ << autoScrollForwardVerticalFirstAction
+ << autoScrollBackwardVerticalFirstAction
+ << moveDownAction
+ << moveUpAction
+ << moveLeftAction
+ << moveRightAction
+ << goToFirstPageAction
+ << goToLastPageAction
+ << goToPageAction);
allActions << tmpList;
ShortcutsManager::getShortcutsManager().registerActions(allActions);
-
}
void MainWindowViewer::toggleFitToWidthSlider()
@@ -1435,12 +1397,9 @@ void MainWindowViewer::toggleFitToWidthSlider()
y = this->comicToolBar->frameSize().height();
#endif
- if(zoomSliderAction->isVisible())
- {
+ if (zoomSliderAction->isVisible()) {
zoomSliderAction->hide();
- }
- else
- {
+ } else {
zoomSliderAction->move(250, y);
zoomSliderAction->show();
}
@@ -1448,113 +1407,120 @@ void MainWindowViewer::toggleFitToWidthSlider()
void MainWindowViewer::newVersion()
{
- QMessageBox msgBox;
- msgBox.setText(tr("There is a new version available"));
- msgBox.setInformativeText(tr("Do you want to download the new version?"));
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Ignore | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
- msgBox.button(QMessageBox::Ignore)->setText(tr("Remind me in 14 days"));
- msgBox.button(QMessageBox::No)->setText(tr("Not now"));
- msgBox.setWindowFlags(Qt::WindowStaysOnTopHint);
- msgBox.setModal(true);
- int ret = msgBox.exec();
+ QMessageBox msgBox;
+ msgBox.setText(tr("There is a new version available"));
+ msgBox.setInformativeText(tr("Do you want to download the new version?"));
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Ignore | QMessageBox::No);
+ msgBox.setDefaultButton(QMessageBox::Yes);
+ msgBox.button(QMessageBox::Ignore)->setText(tr("Remind me in 14 days"));
+ msgBox.button(QMessageBox::No)->setText(tr("Not now"));
+ msgBox.setWindowFlags(Qt::WindowStaysOnTopHint);
+ msgBox.setModal(true);
+ int ret = msgBox.exec();
- switch(ret)
- {
- case QMessageBox::Yes:
- QDesktopServices::openUrl(QUrl("http://www.yacreader.com"));
- break;
- case QMessageBox::No:
- Configuration::getConfiguration().setNumDaysBetweenVersionChecks(1);
- break;
- case QMessageBox::Ignore:
- Configuration::getConfiguration().setNumDaysBetweenVersionChecks(14);
- break;
- }
+ switch (ret) {
+ case QMessageBox::Yes:
+ QDesktopServices::openUrl(QUrl("http://www.yacreader.com"));
+ break;
+ case QMessageBox::No:
+ Configuration::getConfiguration().setNumDaysBetweenVersionChecks(1);
+ break;
+ case QMessageBox::Ignore:
+ Configuration::getConfiguration().setNumDaysBetweenVersionChecks(14);
+ break;
+ }
}
-void MainWindowViewer::closeEvent ( QCloseEvent * event )
+void MainWindowViewer::closeEvent(QCloseEvent *event)
{
- Q_UNUSED(event)
+ Q_UNUSED(event)
- if(isClient)
- sendComic();
+ if (isClient)
+ sendComic();
- viewer->save();
- Configuration & conf = Configuration::getConfiguration();
- if(!fullscreen && !isMaximized())
- {
- conf.setPos(pos());
- conf.setSize(size());
- }
- conf.setMaximized(isMaximized());
+ viewer->save();
+ Configuration &conf = Configuration::getConfiguration();
+ if (!fullscreen && !isMaximized()) {
+ conf.setPos(pos());
+ conf.setSize(size());
+ }
+ conf.setMaximized(isMaximized());
- emit (closed());
+ emit(closed());
}
void MainWindowViewer::openPreviousComic()
{
- if(!siblingComics.isEmpty() && isClient)
- {
- sendComic();
+ if (!siblingComics.isEmpty() && isClient) {
+ sendComic();
- int currentIndex = siblingComics.indexOf(currentComicDB);
- if (currentIndex == -1)
- return;
- if(currentIndex-1 >= 0 && currentIndex-1 < siblingComics.count())
- {
- siblingComics[currentIndex] = currentComicDB; //updated
- currentComicDB = siblingComics.at(currentIndex-1);
- open(currentDirectory+currentComicDB.path,currentComicDB,siblingComics);
- }
- return;
- }
- if(!previousComicPath.isEmpty())
- {
+ int currentIndex = siblingComics.indexOf(currentComicDB);
+ if (currentIndex == -1)
+ return;
+ if (currentIndex - 1 >= 0 && currentIndex - 1 < siblingComics.count()) {
+ siblingComics[currentIndex] = currentComicDB; //updated
+ currentComicDB = siblingComics.at(currentIndex - 1);
+ open(currentDirectory + currentComicDB.path, currentComicDB, siblingComics);
+ }
+ return;
+ }
+ if (!previousComicPath.isEmpty()) {
openSiblingComic(previousComicPath);
- }
+ }
}
void MainWindowViewer::openNextComic()
{
- if(!siblingComics.isEmpty() && isClient)
- {
- sendComic();
+ if (!siblingComics.isEmpty() && isClient) {
+ sendComic();
- int currentIndex = siblingComics.indexOf(currentComicDB);
- if (currentIndex == -1)
- return;
- if(currentIndex+1 > 0 && currentIndex+1 < siblingComics.count())
- {
- siblingComics[currentIndex] = currentComicDB; //updated
- currentComicDB = siblingComics.at(currentIndex+1);
- open(currentDirectory+currentComicDB.path,currentComicDB,siblingComics);
- }
- return;
- }
- if(!nextComicPath.isEmpty())
- {
+ int currentIndex = siblingComics.indexOf(currentComicDB);
+ if (currentIndex == -1)
+ return;
+ if (currentIndex + 1 > 0 && currentIndex + 1 < siblingComics.count()) {
+ siblingComics[currentIndex] = currentComicDB; //updated
+ currentComicDB = siblingComics.at(currentIndex + 1);
+ open(currentDirectory + currentComicDB.path, currentComicDB, siblingComics);
+ }
+ return;
+ }
+ if (!nextComicPath.isEmpty()) {
openSiblingComic(nextComicPath);
- }
+ }
}
-void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
+void MainWindowViewer::getSiblingComics(QString path, QString currentComic)
{
- QDir d(path);
- d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
+ QDir d(path);
+ d.setFilter(QDir::Files | QDir::NoDotAndDotDot);
#ifndef use_unarr
- d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt");
+ d.setNameFilters(QStringList() << "*.cbr"
+ << "*.cbz"
+ << "*.rar"
+ << "*.zip"
+ << "*.tar"
+ << "*.pdf"
+ << "*.7z"
+ << "*.cb7"
+ << "*.arj"
+ << "*.cbt");
#else
- d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.cbt");
+ d.setNameFilters(QStringList() << "*.cbr"
+ << "*.cbz"
+ << "*.rar"
+ << "*.zip"
+ << "*.tar"
+ << "*.pdf"
+ << "*.cbt");
#endif
- d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
- QStringList list = d.entryList();
- qSort(list.begin(),list.end(),naturalSortLessThanCI);
- //std::sort(list.begin(),list.end(),naturalSortLessThanCI);
- int index = list.indexOf(currentComic);
- if(index == -1) //comic not found
- {
- /*QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
+ d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
+ QStringList list = d.entryList();
+ qSort(list.begin(), list.end(), naturalSortLessThanCI);
+ //std::sort(list.begin(),list.end(),naturalSortLessThanCI);
+ int index = list.indexOf(currentComic);
+ if (index == -1) //comic not found
+ {
+ /*QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
if(!f.open(QIODevice::WriteOnly))
{
QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder."));
@@ -1572,95 +1538,82 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
}
f.close();
}*/
- }
+ }
- previousComicPath = nextComicPath = "";
- if(index>0)
- {
- previousComicPath = path+"/"+list.at(index-1);
- openPreviousComicAction->setDisabled(false);
- }
- else
- openPreviousComicAction->setDisabled(true);
+ previousComicPath = nextComicPath = "";
+ if (index > 0) {
+ previousComicPath = path + "/" + list.at(index - 1);
+ openPreviousComicAction->setDisabled(false);
+ } else
+ openPreviousComicAction->setDisabled(true);
- if(index+1setDisabled(false);
- }
- else
- openNextComicAction->setDisabled(true);
+ if (index + 1 < list.count()) {
+ nextComicPath = path + "/" + list.at(index + 1);
+ openNextComicAction->setDisabled(false);
+ } else
+ openNextComicAction->setDisabled(true);
}
void MainWindowViewer::dropEvent(QDropEvent *event)
{
- QList urlList;
- QString fName;
- QFileInfo info;
+ QList urlList;
+ QString fName;
+ QFileInfo info;
- if (event->mimeData()->hasUrls())
- {
- urlList = event->mimeData()->urls();
+ if (event->mimeData()->hasUrls()) {
+ urlList = event->mimeData()->urls();
- if ( urlList.size() > 0 )
- {
- fName = urlList[0].toLocalFile(); // convert first QUrl to local path
- info.setFile( fName ); // information about file
- if (info.isFile())
- {
- QStringList imageSuffixs = Comic::getSupportedImageLiteralFormats();
- if(imageSuffixs.contains(info.suffix())) //image dropped
- openFolderFromPath(info.absoluteDir().absolutePath(),info.fileName());
- else
- openComicFromPath(fName); // if is file, setText
- }
- else
- if(info.isDir())
- openFolderFromPath(fName);
+ if (urlList.size() > 0) {
+ fName = urlList[0].toLocalFile(); // convert first QUrl to local path
+ info.setFile(fName); // information about file
+ if (info.isFile()) {
+ QStringList imageSuffixs = Comic::getSupportedImageLiteralFormats();
+ if (imageSuffixs.contains(info.suffix())) //image dropped
+ openFolderFromPath(info.absoluteDir().absolutePath(), info.fileName());
+ else
+ openComicFromPath(fName); // if is file, setText
+ } else if (info.isDir())
+ openFolderFromPath(fName);
- isClient = false;
- }
- }
+ isClient = false;
+ }
+ }
- event->acceptProposedAction();
+ event->acceptProposedAction();
}
void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event)
{
- // accept just text/uri-list mime format
- if (event->mimeData()->hasFormat("text/uri-list"))
- {
- event->acceptProposedAction();
- isClient = false;
- }
+ // accept just text/uri-list mime format
+ if (event->mimeData()->hasFormat("text/uri-list")) {
+ event->acceptProposedAction();
+ isClient = false;
+ }
}
void MainWindowViewer::alwaysOnTopSwitch()
{
- if(!Configuration::getConfiguration().getAlwaysOnTop())
- {
- setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); //always on top
- show();
- }
- else
- {
- setWindowFlags(this->windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
- show();
- }
- Configuration::getConfiguration().setAlwaysOnTop(!Configuration::getConfiguration().getAlwaysOnTop());
+ if (!Configuration::getConfiguration().getAlwaysOnTop()) {
+ setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); //always on top
+ show();
+ } else {
+ setWindowFlags(this->windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
+ show();
+ }
+ Configuration::getConfiguration().setAlwaysOnTop(!Configuration::getConfiguration().getAlwaysOnTop());
}
void MainWindowViewer::adjustToFullSizeSwitch()
{
- Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes);
+ Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes);
viewer->setZoomFactor(100);
- viewer->updatePage();
+ viewer->updatePage();
}
void MainWindowViewer::fitToPageSwitch()
{
- Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullPage);
+ Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullPage);
viewer->setZoomFactor(100);
- viewer->updatePage();
+ viewer->updatePage();
}
void MainWindowViewer::resetZoomLevel()
@@ -1671,36 +1624,35 @@ void MainWindowViewer::resetZoomLevel()
void MainWindowViewer::increasePageZoomLevel()
{
- viewer->increaseZoomFactor();
+ viewer->increaseZoomFactor();
}
void MainWindowViewer::decreasePageZoomLevel()
{
- viewer->decreaseZoomFactor();
+ viewer->decreaseZoomFactor();
}
void MainWindowViewer::sendComic()
{
- YACReaderLocalClient * client = new YACReaderLocalClient;
-
+ YACReaderLocalClient *client = new YACReaderLocalClient;
+
connect(client, &YACReaderLocalClient::finished, client, &YACReaderLocalClient::deleteLater);
currentComicDB.info.lastTimeOpened = QDateTime::currentMSecsSinceEpoch() / 1000;
viewer->updateComic(currentComicDB);
int currentIndex = siblingComics.indexOf(currentComicDB);
- bool sendNextComicInfo = (currentComicDB.info.currentPage == currentComicDB.info.numPages)
- && (currentIndex+1 > 0 && currentIndex+1 < siblingComics.count());
+ bool sendNextComicInfo = (currentComicDB.info.currentPage == currentComicDB.info.numPages) && (currentIndex + 1 > 0 && currentIndex + 1 < siblingComics.count());
if (sendNextComicInfo) {
- ComicDB & nextComic = siblingComics[currentIndex+1];
- nextComic.info.hasBeenOpened = true;
- int retries = 1;
- while(!client->sendComicInfo(libraryId, currentComicDB, nextComic.id) && retries!=0)
- retries--;
+ ComicDB &nextComic = siblingComics[currentIndex + 1];
+ nextComic.info.hasBeenOpened = true;
+ int retries = 1;
+ while (!client->sendComicInfo(libraryId, currentComicDB, nextComic.id) && retries != 0)
+ retries--;
} else {
int retries = 1;
- while(!client->sendComicInfo(libraryId, currentComicDB) && retries!=0)
+ while (!client->sendComicInfo(libraryId, currentComicDB) && retries != 0)
retries--;
}
}
diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h
index 074c8094..ee505c71 100644
--- a/YACReader/main_window_viewer.h
+++ b/YACReader/main_window_viewer.h
@@ -10,7 +10,7 @@
#include
#ifdef Q_OS_MAC
- #include "yacreader_macosx_toolbar.h"
+#include "yacreader_macosx_toolbar.h"
#endif
#include "comic_db.h"
@@ -25,163 +25,164 @@ class YACReaderSliderAction;
class YACReaderSlider;
class EditShortcutsDialog;
- class MainWindowViewer : public QMainWindow
- {
- Q_OBJECT
+class MainWindowViewer : public QMainWindow
+{
+ Q_OBJECT
- public slots:
- void open();
- void open(QString path, ComicDB & comic, QList & siblings);
- void open(QString path, qint64 comicId, qint64 libraryId);
- void openFolder();
- void openRecent();
- void openLatestComic();
- void openComicFromRecentAction(QAction *action);
- void saveImage();
- void toggleToolBars();
- void hideToolBars();
- void showToolBars();
- void enableActions();
- void disableActions();
- void toggleFullScreen();
- void toFullScreen();
- void toNormal();
- void loadConfiguration();
- void newVersion();
- void openPreviousComic();
- void openNextComic();
- void openComicFromPath(QString pathFile);
- void openSiblingComic(QString pathFile);
- void openComic(QString pathFile);
- void openFolderFromPath(QString pathDir);
- void openFolderFromPath(QString pathFile, QString atFileName);
- void alwaysOnTopSwitch();
- void adjustToFullSizeSwitch();
- void fitToPageSwitch();
- void resetZoomLevel();
- void increasePageZoomLevel();
- void decreasePageZoomLevel();
- void reloadOptions();
- void fitToWidth();
- void fitToHeight();
- void toggleWidthHeight();
- void checkNewVersion();
- void processReset();
- void setUpShortcutsManagement();
+public slots:
+ void open();
+ void open(QString path, ComicDB &comic, QList &siblings);
+ void open(QString path, qint64 comicId, qint64 libraryId);
+ void openFolder();
+ void openRecent();
+ void openLatestComic();
+ void openComicFromRecentAction(QAction *action);
+ void saveImage();
+ void toggleToolBars();
+ void hideToolBars();
+ void showToolBars();
+ void enableActions();
+ void disableActions();
+ void toggleFullScreen();
+ void toFullScreen();
+ void toNormal();
+ void loadConfiguration();
+ void newVersion();
+ void openPreviousComic();
+ void openNextComic();
+ void openComicFromPath(QString pathFile);
+ void openSiblingComic(QString pathFile);
+ void openComic(QString pathFile);
+ void openFolderFromPath(QString pathDir);
+ void openFolderFromPath(QString pathFile, QString atFileName);
+ void alwaysOnTopSwitch();
+ void adjustToFullSizeSwitch();
+ void fitToPageSwitch();
+ void resetZoomLevel();
+ void increasePageZoomLevel();
+ void decreasePageZoomLevel();
+ void reloadOptions();
+ void fitToWidth();
+ void fitToHeight();
+ void toggleWidthHeight();
+ void checkNewVersion();
+ void processReset();
+ void setUpShortcutsManagement();
- void toggleFitToWidthSlider();
+ void toggleFitToWidthSlider();
- /*void viewComic();
+ /*void viewComic();
void prev();
void next();
void updatePage();*/
+private:
+ //!State
+ bool fullscreen;
+ bool toolbars;
+ bool alwaysOnTop;
+ bool fromMaximized;
- private:
- //!State
- bool fullscreen;
- bool toolbars;
- bool alwaysOnTop;
- bool fromMaximized;
+ //QTBUG-41883
+ QSize _size;
+ QPoint _pos;
- //QTBUG-41883
- QSize _size;
- QPoint _pos;
-
- QString currentDirectory;
- QString currentDirectoryImgDest;
- //!Widgets
- Viewer * viewer;
- //GoToDialog * goToDialog;
- OptionsDialog * optionsDialog;
- HelpAboutDialog * had;
- //ShortcutsDialog * shortcutsDialog;
- EditShortcutsDialog * editShortcutsDialog;
+ QString currentDirectory;
+ QString currentDirectoryImgDest;
+ //!Widgets
+ Viewer *viewer;
+ //GoToDialog * goToDialog;
+ OptionsDialog *optionsDialog;
+ HelpAboutDialog *had;
+ //ShortcutsDialog * shortcutsDialog;
+ EditShortcutsDialog *editShortcutsDialog;
- //! ToolBars
- #ifdef Q_OS_MAC
- YACReaderMacOSXToolbar * comicToolBar;
+ //! ToolBars
+#ifdef Q_OS_MAC
+ YACReaderMacOSXToolbar *comicToolBar;
#else
- QToolBar * comicToolBar;
+ QToolBar *comicToolBar;
#endif
- //! Actions
- QAction *openAction;
- QAction *openFolderAction;
- QAction *openLatestComicAction;
- QList recentFilesActionList;
- QAction *clearRecentFilesAction;
- QAction *saveImageAction;
- QAction *openPreviousComicAction;
- QAction *openNextComicAction;
- QAction *nextAction;
- QAction *prevAction;
- QAction *adjustWidthAction;
- QAction *adjustHeightAction;
- QAction *goToPageAction;
- QAction *optionsAction;
- QAction *helpAboutAction;
- QAction *showMagnifyingGlassAction;
- QAction *setBookmarkAction;
- QAction *showBookmarksAction;
- QAction *leftRotationAction;
- QAction *rightRotationAction;
- QAction *showInfoAction;
- QAction *closeAction;
- QAction *doublePageAction;
- QAction *doubleMangaPageAction;
- QAction *showShorcutsAction;
- QAction *showDictionaryAction;
- QAction *alwaysOnTopAction;
- QAction *adjustToFullSizeAction;
- QAction *fitToPageAction;
- QAction *resetZoomAction;
- QAction *showZoomSliderlAction;
- QAction *increasePageZoomAction;
- QAction *decreasePageZoomAction;
- QAction *showFlowAction;
+ //! Actions
+ QAction *openAction;
+ QAction *openFolderAction;
+ QAction *openLatestComicAction;
+ QList recentFilesActionList;
+ QAction *clearRecentFilesAction;
+ QAction *saveImageAction;
+ QAction *openPreviousComicAction;
+ QAction *openNextComicAction;
+ QAction *nextAction;
+ QAction *prevAction;
+ QAction *adjustWidthAction;
+ QAction *adjustHeightAction;
+ QAction *goToPageAction;
+ QAction *optionsAction;
+ QAction *helpAboutAction;
+ QAction *showMagnifyingGlassAction;
+ QAction *setBookmarkAction;
+ QAction *showBookmarksAction;
+ QAction *leftRotationAction;
+ QAction *rightRotationAction;
+ QAction *showInfoAction;
+ QAction *closeAction;
+ QAction *doublePageAction;
+ QAction *doubleMangaPageAction;
+ QAction *showShorcutsAction;
+ QAction *showDictionaryAction;
+ QAction *alwaysOnTopAction;
+ QAction *adjustToFullSizeAction;
+ QAction *fitToPageAction;
+ QAction *resetZoomAction;
+ QAction *showZoomSliderlAction;
+ QAction *increasePageZoomAction;
+ QAction *decreasePageZoomAction;
+ QAction *showFlowAction;
- QAction *showEditShortcutsAction;
+ QAction *showEditShortcutsAction;
- YACReaderSlider * zoomSliderAction;
+ YACReaderSlider *zoomSliderAction;
- HttpVersionChecker * versionChecker;
- QString previousComicPath;
- QString nextComicPath;
- //! Método que inicializa el interfaz.
- void setupUI();
- void createActions();
- void createToolBars();
- void refreshRecentFilesActionList();
- void clearRecentFiles();
- void getSiblingComics(QString path,QString currentComic);
+ HttpVersionChecker *versionChecker;
+ QString previousComicPath;
+ QString nextComicPath;
+ //! Método que inicializa el interfaz.
+ void setupUI();
+ void createActions();
+ void createToolBars();
+ void refreshRecentFilesActionList();
+ void clearRecentFiles();
+ void getSiblingComics(QString path, QString currentComic);
- //! Manejadores de evento:
- void keyPressEvent(QKeyEvent *event);
- //void resizeEvent(QResizeEvent * event);
- void mouseDoubleClickEvent ( QMouseEvent * event );
- void dropEvent(QDropEvent *event);
- void dragEnterEvent(QDragEnterEvent *event);
+ //! Manejadores de evento:
+ void keyPressEvent(QKeyEvent *event);
+ //void resizeEvent(QResizeEvent * event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ void dropEvent(QDropEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
- QSettings * settings;
+ QSettings *settings;
- ComicDB currentComicDB;
- QList siblingComics;
- bool isClient;
- QString startComicPath;
- quint64 libraryId;
+ ComicDB currentComicDB;
+ QList siblingComics;
+ bool isClient;
+ QString startComicPath;
+ quint64 libraryId;
- //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
- Qt::WindowFlags previousWindowFlags;
- QPoint previousPos;
- QSize previousSize;
+ //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
+ Qt::WindowFlags previousWindowFlags;
+ QPoint previousPos;
+ QSize previousSize;
signals:
- void closed();
- protected:
- virtual void closeEvent ( QCloseEvent * event );
- void sendComic();
- public:
- MainWindowViewer();
- ~MainWindowViewer();
- };
+ void closed();
+
+protected:
+ virtual void closeEvent(QCloseEvent *event);
+ void sendComic();
+
+public:
+ MainWindowViewer();
+ ~MainWindowViewer();
+};
#endif
diff --git a/YACReader/notifications_label_widget.cpp b/YACReader/notifications_label_widget.cpp
index 999d0ca7..de535484 100644
--- a/YACReader/notifications_label_widget.cpp
+++ b/YACReader/notifications_label_widget.cpp
@@ -2,29 +2,29 @@
#include
-NotificationsLabelWidget::NotificationsLabelWidget(QWidget * parent)
- :QWidget(parent)
+NotificationsLabelWidget::NotificationsLabelWidget(QWidget *parent)
+ : QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
- setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
- effect = new QGraphicsOpacityEffect(this);
+ setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
+ effect = new QGraphicsOpacityEffect(this);
effect->setOpacity(1.0);
- anim = new QPropertyAnimation(effect,"opacity");
- anim->setDuration(500);
+ anim = new QPropertyAnimation(effect, "opacity");
+ anim->setDuration(500);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
- anim->setEasingCurve(QEasingCurve::InExpo);
+ anim->setEasingCurve(QEasingCurve::InExpo);
- connect(anim,SIGNAL(finished()),this,SLOT(hide()));
+ connect(anim, SIGNAL(finished()), this, SLOT(hide()));
- textLabel = new QLabel(this);
- textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
- textLabel->setStyleSheet("QLabel { color : white; font-size:24px; }");
- textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
+ textLabel = new QLabel(this);
+ textLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
+ textLabel->setStyleSheet("QLabel { color : white; font-size:24px; }");
+ textLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
textLabel->setFixedSize(200, 120);
@@ -37,7 +37,7 @@ NotificationsLabelWidget::NotificationsLabelWidget(QWidget * parent)
setLayout(layout);
setFixedSize(200, 120);
- updatePosition();
+ updatePosition();
}
void NotificationsLabelWidget::paintEvent(QPaintEvent *)
@@ -53,24 +53,23 @@ void NotificationsLabelWidget::paintEvent(QPaintEvent *)
void NotificationsLabelWidget::flash()
{
- updatePosition();
- anim->stop();
- anim->start();
+ updatePosition();
+ anim->stop();
+ anim->start();
- setVisible(true);
+ setVisible(true);
}
-void NotificationsLabelWidget::setText(const QString & text)
+void NotificationsLabelWidget::setText(const QString &text)
{
- textLabel->setText(text);
+ textLabel->setText(text);
}
void NotificationsLabelWidget::updatePosition()
{
- QWidget * parent = dynamic_cast(this->parent());
- if(parent == 0)
- {
- return;
- }
- move(QPoint((parent->geometry().size().width()-this->width())/2,(parent->geometry().size().height()-this->height())/2));
+ QWidget *parent = dynamic_cast(this->parent());
+ if (parent == 0) {
+ return;
+ }
+ move(QPoint((parent->geometry().size().width() - this->width()) / 2, (parent->geometry().size().height() - this->height()) / 2));
}
diff --git a/YACReader/notifications_label_widget.h b/YACReader/notifications_label_widget.h
index eeafe952..391b0934 100644
--- a/YACReader/notifications_label_widget.h
+++ b/YACReader/notifications_label_widget.h
@@ -9,22 +9,22 @@ class QGraphicsOpacityEffect;
class NotificationsLabelWidget : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
private:
- QLabel * textLabel;
- QPropertyAnimation * anim;
- QGraphicsOpacityEffect * effect;
+ QLabel *textLabel;
+ QPropertyAnimation *anim;
+ QGraphicsOpacityEffect *effect;
protected:
void paintEvent(QPaintEvent *);
public:
- NotificationsLabelWidget(QWidget * parent);
+ NotificationsLabelWidget(QWidget *parent);
public slots:
- void flash();
- void setText(const QString & text);
- void updatePosition();
+ void flash();
+ void setText(const QString &text);
+ void updatePosition();
};
#endif
diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp
index 88371980..7772d11a 100644
--- a/YACReader/options_dialog.cpp
+++ b/YACReader/options_dialog.cpp
@@ -19,44 +19,44 @@
#include "yacreader_gl_flow_config_widget.h"
#endif
-OptionsDialog::OptionsDialog(QWidget * parent)
- :YACReaderOptionsDialog(parent)
+OptionsDialog::OptionsDialog(QWidget *parent)
+ : YACReaderOptionsDialog(parent)
{
- QTabWidget * tabWidget = new QTabWidget();
+ QTabWidget *tabWidget = new QTabWidget();
- QVBoxLayout * layout = new QVBoxLayout(this);
+ QVBoxLayout *layout = new QVBoxLayout(this);
- QWidget * pageGeneral = new QWidget();
- QWidget * pageFlow = new QWidget();
- QWidget * pageImage = new QWidget();
- QVBoxLayout * layoutGeneral = new QVBoxLayout();
- QVBoxLayout * layoutFlow = new QVBoxLayout();
- QVBoxLayout * layoutImageV = new QVBoxLayout();
- QGridLayout * layoutImage = new QGridLayout();
+ QWidget *pageGeneral = new QWidget();
+ QWidget *pageFlow = new QWidget();
+ QWidget *pageImage = new QWidget();
+ QVBoxLayout *layoutGeneral = new QVBoxLayout();
+ QVBoxLayout *layoutFlow = new QVBoxLayout();
+ QVBoxLayout *layoutImageV = new QVBoxLayout();
+ QGridLayout *layoutImage = new QGridLayout();
- QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size"));
- //slideSizeLabel = new QLabel(,this);
- slideSize = new QSlider(this);
- slideSize->setMinimum(125);
- slideSize->setMaximum(350);
- slideSize->setPageStep(5);
- slideSize->setOrientation(Qt::Horizontal);
- QHBoxLayout * slideLayout = new QHBoxLayout();
- slideLayout->addWidget(slideSize);
- slideSizeBox->setLayout(slideLayout);
+ QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size"));
+ //slideSizeLabel = new QLabel(,this);
+ slideSize = new QSlider(this);
+ slideSize->setMinimum(125);
+ slideSize->setMaximum(350);
+ slideSize->setPageStep(5);
+ slideSize->setOrientation(Qt::Horizontal);
+ QHBoxLayout *slideLayout = new QHBoxLayout();
+ slideLayout->addWidget(slideSize);
+ slideSizeBox->setLayout(slideLayout);
- QGroupBox *pathBox = new QGroupBox(tr("My comics path"));
+ QGroupBox *pathBox = new QGroupBox(tr("My comics path"));
- QHBoxLayout * path = new QHBoxLayout();
- path->addWidget(pathEdit = new QLineEdit());
- path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"),""));
- pathBox->setLayout(path);
+ QHBoxLayout *path = new QHBoxLayout();
+ path->addWidget(pathEdit = new QLineEdit());
+ path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"), ""));
+ pathBox->setLayout(path);
- connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder()));
+ connect(pathFindButton, SIGNAL(clicked()), this, SLOT(findFolder()));
- //fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this);
- /*QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
+ //fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this);
+ /*QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
fitToWidthRatioS = new QSlider(this);
fitToWidthRatioS->setMinimum(50);
fitToWidthRatioS->setMaximum(100);
@@ -67,190 +67,185 @@ OptionsDialog::OptionsDialog(QWidget * parent)
fitLayout->addWidget(fitToWidthRatioS);
fitBox->setLayout(fitLayout);*/
- QHBoxLayout * colorSelection = new QHBoxLayout;
- backgroundColor = new QLabel();
- QPalette pal = backgroundColor->palette();
- pal.setColor(backgroundColor->backgroundRole(), Qt::black);
- backgroundColor->setPalette(pal);
- backgroundColor->setAutoFillBackground(true);
+ QHBoxLayout *colorSelection = new QHBoxLayout;
+ backgroundColor = new QLabel();
+ QPalette pal = backgroundColor->palette();
+ pal.setColor(backgroundColor->backgroundRole(), Qt::black);
+ backgroundColor->setPalette(pal);
+ backgroundColor->setAutoFillBackground(true);
- colorDialog = new QColorDialog(Qt::red,this);
- connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(updateColor(QColor)));
+ colorDialog = new QColorDialog(Qt::red, this);
+ connect(colorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateColor(QColor)));
- QGroupBox *colorBox = new QGroupBox(tr("Background color"));
- //backgroundColor->setMinimumWidth(100);
- colorSelection->addWidget(backgroundColor);
- colorSelection->addWidget(selectBackgroundColorButton = new QPushButton(tr("Choose")));
- colorSelection->setStretchFactor(backgroundColor,1);
- colorSelection->setStretchFactor(selectBackgroundColorButton,0);
- //colorSelection->addStretch();
- connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show()));
- colorBox->setLayout(colorSelection);
+ QGroupBox *colorBox = new QGroupBox(tr("Background color"));
+ //backgroundColor->setMinimumWidth(100);
+ colorSelection->addWidget(backgroundColor);
+ colorSelection->addWidget(selectBackgroundColorButton = new QPushButton(tr("Choose")));
+ colorSelection->setStretchFactor(backgroundColor, 1);
+ colorSelection->setStretchFactor(selectBackgroundColorButton, 0);
+ //colorSelection->addStretch();
+ connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show()));
+ colorBox->setLayout(colorSelection);
- brightnessS = new YACReaderSpinSliderWidget(this,true);
- brightnessS->setRange(0,100);
- //brightnessS->setText(tr("Brightness"));
- brightnessS->setTracking(false);
- connect(brightnessS,SIGNAL(valueChanged(int)),this,SLOT(brightnessChanged(int)));
+ brightnessS = new YACReaderSpinSliderWidget(this, true);
+ brightnessS->setRange(0, 100);
+ //brightnessS->setText(tr("Brightness"));
+ brightnessS->setTracking(false);
+ connect(brightnessS, SIGNAL(valueChanged(int)), this, SLOT(brightnessChanged(int)));
- contrastS = new YACReaderSpinSliderWidget(this,true);
- contrastS->setRange(0,250);
- //contrastS->setText(tr("Contrast"));
- contrastS->setTracking(false);
- connect(contrastS,SIGNAL(valueChanged(int)),this,SLOT(contrastChanged(int)));
+ contrastS = new YACReaderSpinSliderWidget(this, true);
+ contrastS->setRange(0, 250);
+ //contrastS->setText(tr("Contrast"));
+ contrastS->setTracking(false);
+ connect(contrastS, SIGNAL(valueChanged(int)), this, SLOT(contrastChanged(int)));
- gammaS = new YACReaderSpinSliderWidget(this,true);
- gammaS->setRange(0,250);
- //gammaS->setText(tr("Gamma"));
- gammaS->setTracking(false);
- connect(gammaS,SIGNAL(valueChanged(int)),this,SLOT(gammaChanged(int)));
- //connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions()));
+ gammaS = new YACReaderSpinSliderWidget(this, true);
+ gammaS->setRange(0, 250);
+ //gammaS->setText(tr("Gamma"));
+ gammaS->setTracking(false);
+ connect(gammaS, SIGNAL(valueChanged(int)), this, SLOT(gammaChanged(int)));
+ //connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions()));
quickNavi = new QCheckBox(tr("Quick Navigation Mode"));
disableShowOnMouseOver = new QCheckBox(tr("Disable mouse over activation"));
- QHBoxLayout * buttons = new QHBoxLayout();
- buttons->addStretch();
- buttons->addWidget(new QLabel(tr("Restart is needed")));
- buttons->addWidget(accept);
- buttons->addWidget(cancel);
+ QHBoxLayout *buttons = new QHBoxLayout();
+ buttons->addStretch();
+ buttons->addWidget(new QLabel(tr("Restart is needed")));
+ buttons->addWidget(accept);
+ buttons->addWidget(cancel);
- layoutGeneral->addWidget(pathBox);
- layoutGeneral->addWidget(slideSizeBox);
- //layoutGeneral->addWidget(fitBox);
- layoutGeneral->addWidget(colorBox);
- layoutGeneral->addWidget(shortcutsBox);
- layoutGeneral->addStretch();
+ layoutGeneral->addWidget(pathBox);
+ layoutGeneral->addWidget(slideSizeBox);
+ //layoutGeneral->addWidget(fitBox);
+ layoutGeneral->addWidget(colorBox);
+ layoutGeneral->addWidget(shortcutsBox);
+ layoutGeneral->addStretch();
- layoutFlow->addWidget(sw);
+ layoutFlow->addWidget(sw);
#ifndef NO_OPENGL
- layoutFlow->addWidget(gl);
- layoutFlow->addWidget(useGL);
+ layoutFlow->addWidget(gl);
+ layoutFlow->addWidget(useGL);
#endif
- layoutFlow->addWidget(quickNavi);
+ layoutFlow->addWidget(quickNavi);
layoutFlow->addWidget(disableShowOnMouseOver);
- layoutFlow->addStretch();
+ layoutFlow->addStretch();
- layoutImage->addWidget(new QLabel(tr("Brightness")),0,0);
- layoutImage->addWidget(new QLabel(tr("Contrast")),1,0);
- layoutImage->addWidget(new QLabel(tr("Gamma")),2,0);
- layoutImage->addWidget(brightnessS,0,1);
- layoutImage->addWidget(contrastS,1,1);
- layoutImage->addWidget(gammaS,2,1);
- QPushButton * pushButton = new QPushButton(tr("Reset"));
- connect(pushButton,SIGNAL(pressed()),this,SLOT(resetImageConfig()));
- layoutImage->addWidget(pushButton,3,0);
- layoutImage->setColumnStretch(1,1);
+ layoutImage->addWidget(new QLabel(tr("Brightness")), 0, 0);
+ layoutImage->addWidget(new QLabel(tr("Contrast")), 1, 0);
+ layoutImage->addWidget(new QLabel(tr("Gamma")), 2, 0);
+ layoutImage->addWidget(brightnessS, 0, 1);
+ layoutImage->addWidget(contrastS, 1, 1);
+ layoutImage->addWidget(gammaS, 2, 1);
+ QPushButton *pushButton = new QPushButton(tr("Reset"));
+ connect(pushButton, SIGNAL(pressed()), this, SLOT(resetImageConfig()));
+ layoutImage->addWidget(pushButton, 3, 0);
+ layoutImage->setColumnStretch(1, 1);
+ QGroupBox *imageBox = new QGroupBox(tr("Image options"));
+ imageBox->setLayout(layoutImage);
+ layoutImageV->addWidget(imageBox);
+ layoutImageV->addStretch();
- QGroupBox *imageBox = new QGroupBox(tr("Image options"));
- imageBox->setLayout(layoutImage);
- layoutImageV->addWidget(imageBox);
- layoutImageV->addStretch();
+ pageGeneral->setLayout(layoutGeneral);
+ pageFlow->setLayout(layoutFlow);
+ pageImage->setLayout(layoutImageV);
+ tabWidget->addTab(pageGeneral, tr("General"));
+ tabWidget->addTab(pageFlow, tr("Page Flow"));
+ tabWidget->addTab(pageImage, tr("Image adjustment"));
- pageGeneral->setLayout(layoutGeneral);
- pageFlow->setLayout(layoutFlow);
- pageImage->setLayout(layoutImageV);
+ layout->addWidget(tabWidget);
+ layout->addLayout(buttons);
- tabWidget->addTab(pageGeneral,tr("General"));
- tabWidget->addTab(pageFlow,tr("Page Flow"));
- tabWidget->addTab(pageImage,tr("Image adjustment"));
+ setLayout(layout);
- layout->addWidget(tabWidget);
- layout->addLayout(buttons);
-
- setLayout(layout);
-
- //disable vSyncCheck
+ //disable vSyncCheck
#ifndef NO_OPENGL
- gl->vSyncCheck->hide();
+ gl->vSyncCheck->hide();
#endif
- //restoreOptions(); //load options
- //resize(400,0);
- setModal (true);
- setWindowTitle(tr("Options"));
+ //restoreOptions(); //load options
+ //resize(400,0);
+ setModal(true);
+ setWindowTitle(tr("Options"));
- this->layout()->setSizeConstraint(QLayout::SetFixedSize);
+ this->layout()->setSizeConstraint(QLayout::SetFixedSize);
}
void OptionsDialog::findFolder()
{
- QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),".");
- if(!s.isEmpty())
- {
- pathEdit->setText(s);
- }
+ QString s = QFileDialog::getExistingDirectory(0, tr("Comics directory"), ".");
+ if (!s.isEmpty()) {
+ pathEdit->setText(s);
+ }
}
void OptionsDialog::saveOptions()
{
- settings->setValue(GO_TO_FLOW_SIZE,QSize(static_cast(slideSize->sliderPosition()/SLIDE_ASPECT_RATIO),slideSize->sliderPosition()));
+ settings->setValue(GO_TO_FLOW_SIZE, QSize(static_cast(slideSize->sliderPosition() / SLIDE_ASPECT_RATIO), slideSize->sliderPosition()));
- if(sw->radio1->isChecked())
- settings->setValue(FLOW_TYPE_SW,0);
- if(sw->radio2->isChecked())
- settings->setValue(FLOW_TYPE_SW,1);
- if(sw->radio3->isChecked())
- settings->setValue(FLOW_TYPE_SW,2);
+ if (sw->radio1->isChecked())
+ settings->setValue(FLOW_TYPE_SW, 0);
+ if (sw->radio2->isChecked())
+ settings->setValue(FLOW_TYPE_SW, 1);
+ if (sw->radio3->isChecked())
+ settings->setValue(FLOW_TYPE_SW, 2);
- settings->setValue(PATH,pathEdit->text());
+ settings->setValue(PATH, pathEdit->text());
- settings->setValue(BACKGROUND_COLOR,colorDialog->currentColor());
- //settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
- settings->setValue(QUICK_NAVI_MODE,quickNavi->isChecked());
- settings->setValue(DISABLE_MOUSE_OVER_GOTO_FLOW,disableShowOnMouseOver->isChecked());
+ settings->setValue(BACKGROUND_COLOR, colorDialog->currentColor());
+ //settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
+ settings->setValue(QUICK_NAVI_MODE, quickNavi->isChecked());
+ settings->setValue(DISABLE_MOUSE_OVER_GOTO_FLOW, disableShowOnMouseOver->isChecked());
- YACReaderOptionsDialog::saveOptions();
+ YACReaderOptionsDialog::saveOptions();
}
-void OptionsDialog::restoreOptions(QSettings * settings)
+void OptionsDialog::restoreOptions(QSettings *settings)
{
- YACReaderOptionsDialog::restoreOptions(settings);
+ YACReaderOptionsDialog::restoreOptions(settings);
- slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height());
- switch(settings->value(FLOW_TYPE_SW).toInt())
- {
- case 0:
- sw->radio1->setChecked(true);
- break;
- case 1:
- sw->radio2->setChecked(true);
- break;
- case 2:
- sw->radio3->setChecked(true);
- break;
- default:
- sw->radio1->setChecked(true);
- break;
- }
+ slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height());
+ switch (settings->value(FLOW_TYPE_SW).toInt()) {
+ case 0:
+ sw->radio1->setChecked(true);
+ break;
+ case 1:
+ sw->radio2->setChecked(true);
+ break;
+ case 2:
+ sw->radio3->setChecked(true);
+ break;
+ default:
+ sw->radio1->setChecked(true);
+ break;
+ }
- pathEdit->setText(settings->value(PATH).toString());
+ pathEdit->setText(settings->value(PATH).toString());
- updateColor(settings->value(BACKGROUND_COLOR).value());
- //fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
+ updateColor(settings->value(BACKGROUND_COLOR).value());
+ //fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
quickNavi->setChecked(settings->value(QUICK_NAVI_MODE).toBool());
disableShowOnMouseOver->setChecked(settings->value(DISABLE_MOUSE_OVER_GOTO_FLOW).toBool());
- brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt());
- contrastS->setValue(settings->value(CONTRAST,100).toInt());
- gammaS->setValue(settings->value(GAMMA,100).toInt());
+ brightnessS->setValue(settings->value(BRIGHTNESS, 0).toInt());
+ contrastS->setValue(settings->value(CONTRAST, 100).toInt());
+ gammaS->setValue(settings->value(GAMMA, 100).toInt());
}
-
-void OptionsDialog::updateColor(const QColor & color)
+void OptionsDialog::updateColor(const QColor &color)
{
- QPalette pal = backgroundColor->palette();
- pal.setColor(backgroundColor->backgroundRole(), color);
- backgroundColor->setPalette(pal);
- backgroundColor->setAutoFillBackground(true);
- colorDialog->setCurrentColor(color);
+ QPalette pal = backgroundColor->palette();
+ pal.setColor(backgroundColor->backgroundRole(), color);
+ backgroundColor->setPalette(pal);
+ backgroundColor->setAutoFillBackground(true);
+ colorDialog->setCurrentColor(color);
- settings->setValue(BACKGROUND_COLOR,color);
+ settings->setValue(BACKGROUND_COLOR, color);
- emit(changedOptions());
+ emit(changedOptions());
}
/*void OptionsDialog::fitToWidthRatio(int value)
@@ -261,65 +256,64 @@ void OptionsDialog::updateColor(const QColor & color)
void OptionsDialog::brightnessChanged(int value)
{
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- settings.setValue(BRIGHTNESS,value);
- emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
- //emit(changedImageOptions());
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ settings.setValue(BRIGHTNESS, value);
+ emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
+ //emit(changedImageOptions());
}
void OptionsDialog::contrastChanged(int value)
{
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- settings.setValue(CONTRAST,value);
- emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
- ///emit(changedImageOptions());
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ settings.setValue(CONTRAST, value);
+ emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
+ ///emit(changedImageOptions());
}
void OptionsDialog::gammaChanged(int value)
{
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- settings.setValue(GAMMA,value);
- emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
- //emit(changedImageOptions());
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ settings.setValue(GAMMA, value);
+ emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
+ //emit(changedImageOptions());
}
void OptionsDialog::resetImageConfig()
{
- brightnessS->setValue(0);
- contrastS->setValue(100);
- gammaS->setValue(100);
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- settings.setValue(BRIGHTNESS,0);
- settings.setValue(CONTRAST,100);
- settings.setValue(GAMMA,100);
- emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
- //emit(changedImageOptions());
+ brightnessS->setValue(0);
+ contrastS->setValue(100);
+ gammaS->setValue(100);
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ settings.setValue(BRIGHTNESS, 0);
+ settings.setValue(CONTRAST, 100);
+ settings.setValue(GAMMA, 100);
+ emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
+ //emit(changedImageOptions());
}
void OptionsDialog::show()
{
- //TODO solucionar el tema de las settings, esto sólo deberÃa aparecer en una única lÃnea de código
- QSettings *s = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- //fitToWidthRatioS->disconnect();
- //fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
- //connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
- QDialog::show();
- delete s;
+ //TODO solucionar el tema de las settings, esto sólo deberÃa aparecer en una única lÃnea de código
+ QSettings *s = new QSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ //fitToWidthRatioS->disconnect();
+ //fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
+ //connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
+ QDialog::show();
+ delete s;
}
void OptionsDialog::setFilters(int brightness, int contrast, int gamma)
{
- if(brightness != -1)
- brightnessS->setValue(brightness);
- else
- brightnessS->setValue(0);
- if(contrast != -1)
- contrastS->setValue(contrast);
- else
- contrastS->setValue(100);
- if(gamma != -1)
- gammaS->setValue(gamma);
- else
- gammaS->setValue(100);
-
+ if (brightness != -1)
+ brightnessS->setValue(brightness);
+ else
+ brightnessS->setValue(0);
+ if (contrast != -1)
+ contrastS->setValue(contrast);
+ else
+ contrastS->setValue(100);
+ if (gamma != -1)
+ gammaS->setValue(gamma);
+ else
+ gammaS->setValue(100);
}
diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h
index a80cd3cf..4cbfcd6a 100644
--- a/YACReader/options_dialog.h
+++ b/YACReader/options_dialog.h
@@ -13,60 +13,58 @@ class QRadioButton;
class QColorDialog;
class YACReaderSpinSliderWidget;
-
class OptionsDialog : public YACReaderOptionsDialog
{
-Q_OBJECT
- public:
- OptionsDialog(QWidget * parent = 0);
- private:
- //QLabel * pathLabel;
- QLineEdit * pathEdit;
- QPushButton * pathFindButton;
- QCheckBox * quickNavi;
- QCheckBox * disableShowOnMouseOver;
+ Q_OBJECT
+public:
+ OptionsDialog(QWidget *parent = 0);
- QLabel * magGlassSizeLabel;
+private:
+ //QLabel * pathLabel;
+ QLineEdit *pathEdit;
+ QPushButton *pathFindButton;
+ QCheckBox *quickNavi;
+ QCheckBox *disableShowOnMouseOver;
- QLabel * zoomLevel;
+ QLabel *magGlassSizeLabel;
- //QLabel * slideSizeLabel;
- QSlider * slideSize;
-
- //QLabel * fitToWidthRatioLabel;
- //QSlider * fitToWidthRatioS;
+ QLabel *zoomLevel;
- QLabel * backgroundColor;
- QPushButton * selectBackgroundColorButton;
+ //QLabel * slideSizeLabel;
+ QSlider *slideSize;
- QColorDialog * colorDialog;
+ //QLabel * fitToWidthRatioLabel;
+ //QSlider * fitToWidthRatioS;
- YACReaderSpinSliderWidget * brightnessS;
+ QLabel *backgroundColor;
+ QPushButton *selectBackgroundColorButton;
- YACReaderSpinSliderWidget * contrastS;
+ QColorDialog *colorDialog;
- YACReaderSpinSliderWidget * gammaS;
+ YACReaderSpinSliderWidget *brightnessS;
- public slots:
- void saveOptions();
- void restoreOptions(QSettings * settings);
- void findFolder();
- void updateColor(const QColor & color);
- //void fitToWidthRatio(int value);
- void brightnessChanged(int value);
- void contrastChanged(int value);
- void gammaChanged(int value);
- void resetImageConfig();
- void show();
- void setFilters(int brightness, int contrast, int gamma);
+ YACReaderSpinSliderWidget *contrastS;
+
+ YACReaderSpinSliderWidget *gammaS;
+
+public slots:
+ void saveOptions();
+ void restoreOptions(QSettings *settings);
+ void findFolder();
+ void updateColor(const QColor &color);
+ //void fitToWidthRatio(int value);
+ void brightnessChanged(int value);
+ void contrastChanged(int value);
+ void gammaChanged(int value);
+ void resetImageConfig();
+ void show();
+ void setFilters(int brightness, int contrast, int gamma);
signals:
- void changedOptions();
- void changedImageOptions();
- void changedFilters(int brightness, int contrast, int gamma);
- //void fitToWidthRatioChanged(float ratio);
-
+ void changedOptions();
+ void changedImageOptions();
+ void changedFilters(int brightness, int contrast, int gamma);
+ //void fitToWidthRatioChanged(float ratio);
};
-
#endif
diff --git a/YACReader/page_label_widget.cpp b/YACReader/page_label_widget.cpp
index 71fb7627..1fe23658 100644
--- a/YACReader/page_label_widget.cpp
+++ b/YACReader/page_label_widget.cpp
@@ -2,18 +2,18 @@
#include
-PageLabelWidget::PageLabelWidget(QWidget * parent)
- :QWidget(parent)
+PageLabelWidget::PageLabelWidget(QWidget *parent)
+ : QWidget(parent)
{
- animation = new QPropertyAnimation(this,"pos");
+ animation = new QPropertyAnimation(this, "pos");
animation->setDuration(150);
- animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
+ animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
int verticalRes = QApplication::desktop()->screenGeometry().height();
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(0);
- setContentsMargins(0,0,0,0);
+ setContentsMargins(0, 0, 0, 0);
QSize labelSize;
if (verticalRes <= 1024)
@@ -24,8 +24,8 @@ PageLabelWidget::PageLabelWidget(QWidget * parent)
labelSize = QSize(205, 45);
textLabel = new QLabel(this);
- textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
- if(verticalRes <= 1024)
+ textLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
+ if (verticalRes <= 1024)
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }");
else if (verticalRes <= 1200)
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}");
@@ -34,50 +34,46 @@ PageLabelWidget::PageLabelWidget(QWidget * parent)
setFixedSize(labelSize);
- if(parent != 0)
- move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
+ if (parent != 0)
+ move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
- layout->addWidget(textLabel, 0 , Qt::AlignCenter);
+ layout->addWidget(textLabel, 0, Qt::AlignCenter);
setLayout(layout);
}
void PageLabelWidget::show()
{
- if(this->pos().y() <= 0 && animation->state()!=QPropertyAnimation::Running)
- {
- QWidget * parent = dynamic_cast(this->parent());
- if(parent == 0)
- {
- return;
- }
+ if (this->pos().y() <= 0 && animation->state() != QPropertyAnimation::Running) {
+ QWidget *parent = dynamic_cast(this->parent());
+ if (parent == 0) {
+ return;
+ }
- QWidget::show();
- //connect(animation,SIGNAL(finished()),this,SLOT(QWidget::hide()));
- animation->disconnect();
+ QWidget::show();
+ //connect(animation,SIGNAL(finished()),this,SLOT(QWidget::hide()));
+ animation->disconnect();
- animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
- animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),0));
- animation->start();
- }
+ animation->setStartValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
+ animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), 0));
+ animation->start();
+ }
}
void PageLabelWidget::hide()
{
- if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
- {
- QWidget * parent = dynamic_cast(this->parent());
- if(parent == 0)
- {
- return;
- }
- //connect(animation,SIGNAL(finished()),this,SLOT(setHidden()));
- animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),0));
- animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
- animation->start();
- }
+ if (this->pos().y() >= 0 && animation->state() != QPropertyAnimation::Running) {
+ QWidget *parent = dynamic_cast(this->parent());
+ if (parent == 0) {
+ return;
+ }
+ //connect(animation,SIGNAL(finished()),this,SLOT(setHidden()));
+ animation->setStartValue(QPoint((parent->geometry().size().width() - this->width()), 0));
+ animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
+ animation->start();
+ }
}
-void PageLabelWidget::setText(const QString & text)
+void PageLabelWidget::setText(const QString &text)
{
textLabel->setText(text);
}
@@ -86,20 +82,19 @@ void PageLabelWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
- painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
+ painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
}
void PageLabelWidget::updatePosition()
{
- QWidget * parent = dynamic_cast(this->parent());
- if(parent == 0)
- {
+ QWidget *parent = dynamic_cast(this->parent());
+ if (parent == 0) {
return;
- }
+ }
animation->stop();
if (animation->endValue().toPoint().y() == 0)
- move(QPoint((parent->geometry().size().width()-this->width()),0));
+ move(QPoint((parent->geometry().size().width() - this->width()), 0));
else
- move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
+ move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
}
diff --git a/YACReader/page_label_widget.h b/YACReader/page_label_widget.h
index 188a72d8..bc19fc78 100644
--- a/YACReader/page_label_widget.h
+++ b/YACReader/page_label_widget.h
@@ -8,22 +8,22 @@ class QPropertyAnimation;
class PageLabelWidget : public QWidget
{
-Q_OBJECT
+ Q_OBJECT
private:
- QLabel * textLabel;
- QPropertyAnimation * animation;
+ QLabel *textLabel;
+ QPropertyAnimation *animation;
protected:
virtual void paintEvent(QPaintEvent *);
public:
- PageLabelWidget(QWidget * parent);
+ PageLabelWidget(QWidget *parent);
public slots:
- void show();
- void hide();
- void setText(const QString & text);
- void updatePosition();
+ void show();
+ void hide();
+ void setText(const QString &text);
+ void updatePosition();
};
#endif
diff --git a/YACReader/render.cpp b/YACReader/render.cpp
index 417194b2..785d4dc5 100644
--- a/YACReader/render.cpp
+++ b/YACReader/render.cpp
@@ -13,164 +13,148 @@
#include "yacreader_global_gui.h"
template
-inline const T& kClamp( const T& x, const T& low, const T& high )
+inline const T &kClamp(const T &x, const T &low, const T &high)
{
- if ( x < low ) return low;
- else if ( high < x ) return high;
- else return x;
+ if (x < low)
+ return low;
+ else if (high < x)
+ return high;
+ else
+ return x;
}
-inline
-int changeBrightness( int value, int brightness )
- {
- return kClamp( value + brightness * 255 / 100, 0, 255 );
- }
+inline int changeBrightness(int value, int brightness)
+{
+ return kClamp(value + brightness * 255 / 100, 0, 255);
+}
-inline
-int changeContrast( int value, int contrast )
- {
- return kClamp((( value - 127 ) * contrast / 100 ) + 127, 0, 255 );
- }
+inline int changeContrast(int value, int contrast)
+{
+ return kClamp(((value - 127) * contrast / 100) + 127, 0, 255);
+}
-inline
-int changeGamma( int value, int gamma )
- {
- return kClamp( int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 0, 255 );
- }
+inline int changeGamma(int value, int gamma)
+{
+ return kClamp(int(pow(value / 255.0, 100.0 / gamma) * 255), 0, 255);
+}
-inline
-int changeUsingTable( int value, const int table[] )
- {
- return table[ value ];
- }
-
-template< int operation( int, int ) >
-static
-QImage changeImage( const QImage& image, int value )
- {
- QImage im = image;
- im.detach();
- if( im.colorCount() == 0 ) /* truecolor */
- {
- if( im.format() != QImage::Format_RGB32 ) /* just in case */
- im = im.convertToFormat( QImage::Format_RGB32 );
- int table[ 256 ];
- for( int i = 0;
- i < 256;
- ++i )
- table[ i ] = operation( i, value );
- if( im.hasAlphaChannel() )
- {
- for( int y = 0;
- y < im.height();
- ++y )
- {
- QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
- for( int x = 0;
- x < im.width();
- ++x )
- line[ x ] = qRgba( changeUsingTable( qRed( line[ x ] ), table ),
- changeUsingTable( qGreen( line[ x ] ), table ),
- changeUsingTable( qBlue( line[ x ] ), table ),
- changeUsingTable( qAlpha( line[ x ] ), table ));
- }
- }
- else
- {
- for( int y = 0;
- y < im.height();
- ++y )
- {
- QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
- for( int x = 0;
- x < im.width();
- ++x )
- line[ x ] = qRgb( changeUsingTable( qRed( line[ x ] ), table ),
- changeUsingTable( qGreen( line[ x ] ), table ),
- changeUsingTable( qBlue( line[ x ] ), table ));
- }
- }
- }
- else
- {
- QVector colors = im.colorTable();
- for( int i = 0;
- i < im.colorCount();
- ++i )
- colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ),
- operation( qGreen( colors[ i ] ), value ),
- operation( qBlue( colors[ i ] ), value ));
- im.setColorTable(colors);
- }
- return im;
- }
+inline int changeUsingTable(int value, const int table[])
+{
+ return table[value];
+}
+template
+static QImage changeImage(const QImage &image, int value)
+{
+ QImage im = image;
+ im.detach();
+ if (im.colorCount() == 0) /* truecolor */
+ {
+ if (im.format() != QImage::Format_RGB32) /* just in case */
+ im = im.convertToFormat(QImage::Format_RGB32);
+ int table[256];
+ for (int i = 0;
+ i < 256;
+ ++i)
+ table[i] = operation(i, value);
+ if (im.hasAlphaChannel()) {
+ for (int y = 0;
+ y < im.height();
+ ++y) {
+ QRgb *line = reinterpret_cast(im.scanLine(y));
+ for (int x = 0;
+ x < im.width();
+ ++x)
+ line[x] = qRgba(changeUsingTable(qRed(line[x]), table),
+ changeUsingTable(qGreen(line[x]), table),
+ changeUsingTable(qBlue(line[x]), table),
+ changeUsingTable(qAlpha(line[x]), table));
+ }
+ } else {
+ for (int y = 0;
+ y < im.height();
+ ++y) {
+ QRgb *line = reinterpret_cast(im.scanLine(y));
+ for (int x = 0;
+ x < im.width();
+ ++x)
+ line[x] = qRgb(changeUsingTable(qRed(line[x]), table),
+ changeUsingTable(qGreen(line[x]), table),
+ changeUsingTable(qBlue(line[x]), table));
+ }
+ }
+ } else {
+ QVector colors = im.colorTable();
+ for (int i = 0;
+ i < im.colorCount();
+ ++i)
+ colors[i] = qRgb(operation(qRed(colors[i]), value),
+ operation(qGreen(colors[i]), value),
+ operation(qBlue(colors[i]), value));
+ im.setColorTable(colors);
+ }
+ return im;
+}
// brightness is multiplied by 100 in order to avoid floating point numbers
-QImage changeBrightness( const QImage& image, int brightness )
- {
- if( brightness == 0 ) // no change
- return image;
- return changeImage< changeBrightness >( image, brightness );
- }
-
+QImage changeBrightness(const QImage &image, int brightness)
+{
+ if (brightness == 0) // no change
+ return image;
+ return changeImage(image, brightness);
+}
// contrast is multiplied by 100 in order to avoid floating point numbers
-QImage changeContrast( const QImage& image, int contrast )
- {
- if( contrast == 100 ) // no change
- return image;
- return changeImage< changeContrast >( image, contrast );
- }
+QImage changeContrast(const QImage &image, int contrast)
+{
+ if (contrast == 100) // no change
+ return image;
+ return changeImage(image, contrast);
+}
// gamma is multiplied by 100 in order to avoid floating point numbers
-QImage changeGamma( const QImage& image, int gamma )
- {
- if( gamma == 100 ) // no change
- return image;
- return changeImage< changeGamma >( image, gamma );
- }
-
-
+QImage changeGamma(const QImage &image, int gamma)
+{
+ if (gamma == 100) // no change
+ return image;
+ return changeImage(image, gamma);
+}
//-----------------------------------------------------------------------------
// MeanNoiseReductionFilter
//-----------------------------------------------------------------------------
MeanNoiseReductionFilter::MeanNoiseReductionFilter(enum NeighborghoodSize ns)
-:neighborghoodSize(ns)
+ : neighborghoodSize(ns)
{
-
}
-QImage MeanNoiseReductionFilter::setFilter(const QImage & image)
+QImage MeanNoiseReductionFilter::setFilter(const QImage &image)
{
- int width = image.width();
- int height = image.height();
- QImage result(width,height,image.format());
- int filterSize = sqrt((float)neighborghoodSize);
- int bound = filterSize/2;
- QRgb pix;
- int r,g,b;
- for(int j=bound;j redChannel;
- QList greenChannel;
- QList blueChannel;
- for(int j=bound;j redChannel;
+ QList greenChannel;
+ QList blueChannel;
+ for (int j = bound; j < height - bound; j++) {
+ for (int i = bound; i < width - bound; i++) {
+ redChannel.clear();
+ greenChannel.clear();
+ blueChannel.clear();
+ for (int y = j - bound; y <= j + bound; y++) {
+ for (int x = i - bound; x <= i + bound; x++) {
+ pix = image.pixel(x, y);
+ redChannel.push_back(qRed(pix));
+ greenChannel.push_back(qGreen(pix));
+ blueChannel.push_back(qBlue(pix));
+ }
+ }
- std::sort(redChannel.begin(),redChannel.end());
- std::sort(greenChannel.begin(),greenChannel.end());
- std::sort(blueChannel.begin(),blueChannel.end());
- result.setPixel(i,j,QColor(redChannel.at(4),greenChannel.at(4),blueChannel.at(4)).rgb());
- }
- }
- return result;
+ std::sort(redChannel.begin(), redChannel.end());
+ std::sort(greenChannel.begin(), greenChannel.end());
+ std::sort(blueChannel.begin(), blueChannel.end());
+ result.setPixel(i, j, QColor(redChannel.at(4), greenChannel.at(4), blueChannel.at(4)).rgb());
+ }
+ }
+ return result;
}
-
//-----------------------------------------------------------------------------
// BrightnessFilter
//-----------------------------------------------------------------------------
BrightnessFilter::BrightnessFilter(int l)
- :ImageFilter()
+ : ImageFilter()
{
- level = l;
+ level = l;
}
-QImage BrightnessFilter::setFilter(const QImage & image)
+QImage BrightnessFilter::setFilter(const QImage &image)
{
- /*int width = image.width();
+ /*int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
@@ -241,29 +221,26 @@ QImage BrightnessFilter::setFilter(const QImage & image)
}
}
return result;*/
- if(level ==-1)
- {
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
- }
- else
- {
- return changeBrightness(image,level);
- }
+ if (level == -1) {
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ return changeBrightness(image, settings.value(BRIGHTNESS, 0).toInt());
+ } else {
+ return changeBrightness(image, level);
+ }
}
//-----------------------------------------------------------------------------
// ContrastFilter
//-----------------------------------------------------------------------------
ContrastFilter::ContrastFilter(int l)
- :ImageFilter()
+ : ImageFilter()
{
- level = l;
+ level = l;
}
-QImage ContrastFilter::setFilter(const QImage & image)
+QImage ContrastFilter::setFilter(const QImage &image)
{
- /*int width = image.width();
+ /*int width = image.width();
int height = image.height();
QImage result(width,height,image.format());
@@ -319,78 +296,68 @@ QImage ContrastFilter::setFilter(const QImage & image)
}
return result;*/
- if(level ==-1)
- {
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- return changeContrast(image,settings.value(CONTRAST,100).toInt());
- }
- else
- {
- return changeContrast(image,level);
- }
+ if (level == -1) {
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ return changeContrast(image, settings.value(CONTRAST, 100).toInt());
+ } else {
+ return changeContrast(image, level);
+ }
}
//-----------------------------------------------------------------------------
// ContrastFilter
//-----------------------------------------------------------------------------
GammaFilter::GammaFilter(int l)
- :ImageFilter()
+ : ImageFilter()
{
- level = l;
+ level = l;
}
-QImage GammaFilter::setFilter(const QImage & image)
+QImage GammaFilter::setFilter(const QImage &image)
{
- if(level ==-1)
- {
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- return changeGamma(image,settings.value(GAMMA,100).toInt());
- }
- else
- {
- return changeGamma(image,level);
- }
+ if (level == -1) {
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ return changeGamma(image, settings.value(GAMMA, 100).toInt());
+ } else {
+ return changeGamma(image, level);
+ }
}
//-----------------------------------------------------------------------------
// PageRender
//-----------------------------------------------------------------------------
PageRender::PageRender()
-:QThread()
+ : QThread()
{
-
}
-PageRender::PageRender(Render * r,int np, const QByteArray & rd, QImage * p,unsigned int d, QVector f)
-:QThread(),
-numPage(np),
-data(rd),
-page(p),
-degrees(d),
-filters(f),
-render(r)
+PageRender::PageRender(Render *r, int np, const QByteArray &rd, QImage *p, unsigned int d, QVector f)
+ : QThread(),
+ numPage(np),
+ data(rd),
+ page(p),
+ degrees(d),
+ filters(f),
+ render(r)
{
}
void PageRender::run()
{
- QMutexLocker locker(&(render->mutex));
+ QMutexLocker locker(&(render->mutex));
- QImage img;
- img.loadFromData(data);
- if(degrees > 0)
- {
- QMatrix m;
- m.rotate(degrees);
- img = img.transformed(m,Qt::SmoothTransformation);
- }
- for(int i=0;isetFilter(img);
- }
+ QImage img;
+ img.loadFromData(data);
+ if (degrees > 0) {
+ QMatrix m;
+ m.rotate(degrees);
+ img = img.transformed(m, Qt::SmoothTransformation);
+ }
+ for (int i = 0; i < filters.size(); i++) {
+ img = filters[i]->setFilter(img);
+ }
+ *page = img;
- *page = img;
-
- emit pageReady(numPage);
+ emit pageReady(numPage);
}
//-----------------------------------------------------------------------------
@@ -398,38 +365,35 @@ void PageRender::run()
//-----------------------------------------------------------------------------
Render::Render()
-:comic(0),doublePage(false),doubleMangaPage(false),currentIndex(0),numLeftPages(4),numRightPages(4),loadedComic(false),imageRotation(0)
+ : comic(0), doublePage(false), doubleMangaPage(false), currentIndex(0), numLeftPages(4), numRightPages(4), loadedComic(false), imageRotation(0)
{
- int size = numLeftPages+numRightPages+1;
- currentPageBufferedIndex = numLeftPages;
- for(int i = 0; imoveToThread(QApplication::instance()->thread());
- comic->deleteLater();
- }
+ if (comic != 0) {
+ comic->moveToThread(QApplication::instance()->thread());
+ comic->deleteLater();
+ }
- foreach(PageRender * pr,pageRenders)
- if(pr !=0)
- {
- if(pr->wait())
- delete pr;
- }
+ foreach (PageRender *pr, pageRenders)
+ if (pr != 0) {
+ if (pr->wait())
+ delete pr;
+ }
//TODO move to share_ptr
- foreach(ImageFilter * filter, filters)
+ foreach (ImageFilter *filter, filters)
delete filter;
}
//Este método se encarga de forzar el renderizado de las páginas.
@@ -437,516 +401,454 @@ Render::~Render()
//si la pagina actual no está renderizada, se lanza un hilo que la renderize (double or single page mode) y se emite una señal que indica que se está renderizando.
void Render::render()
{
- updateBuffer();
- if(buffer[currentPageBufferedIndex]->isNull())
- {
- if(pagesReady.size()>0)
- {
- if(pagesReady[currentIndex])
- {
- pageRenders[currentPageBufferedIndex] = new PageRender(this,currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters);
- }
- else
- //las páginas no están listas, y se están cargando en el cómic
- emit processingPage(); //para evitar confusiones esta señal deberÃa llamarse de otra forma
+ updateBuffer();
+ if (buffer[currentPageBufferedIndex]->isNull()) {
+ if (pagesReady.size() > 0) {
+ if (pagesReady[currentIndex]) {
+ pageRenders[currentPageBufferedIndex] = new PageRender(this, currentIndex, comic->getRawData()->at(currentIndex), buffer[currentPageBufferedIndex], imageRotation, filters);
+ } else
+ //las páginas no están listas, y se están cargando en el cómic
+ emit processingPage(); //para evitar confusiones esta señal deberÃa llamarse de otra forma
- //si se ha creado un hilo para renderizar la página actual, se arranca
- if(pageRenders[currentPageBufferedIndex]!=0)
- {
- //se conecta la señal pageReady del hilo, con el SLOT prepareAvailablePage
- connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
- //se emite la señal de procesando, debido a que los hilos se arrancan aquÃ
- if(filters.size()>0)
- emit processingPage();
- pageRenders[currentPageBufferedIndex]->start();
- pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
- }
- else
- //en qué caso serÃa necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario.
- emit processingPage();
- }
- else
- //no hay ninguna página lista para ser renderizada, es necesario esperar.
- emit processingPage();
- }
- else
- // la página actual está lista
- {
- //emit currentPageReady();
- //make prepareAvailablePage the only function that emits currentPageReady()
- prepareAvailablePage(currentIndex);
- }
- fillBuffer();
+ //si se ha creado un hilo para renderizar la página actual, se arranca
+ if (pageRenders[currentPageBufferedIndex] != 0) {
+ //se conecta la señal pageReady del hilo, con el SLOT prepareAvailablePage
+ connect(pageRenders[currentPageBufferedIndex], SIGNAL(pageReady(int)), this, SLOT(prepareAvailablePage(int)));
+ //se emite la señal de procesando, debido a que los hilos se arrancan aquÃ
+ if (filters.size() > 0)
+ emit processingPage();
+ pageRenders[currentPageBufferedIndex]->start();
+ pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
+ } else
+ //en qué caso serÃa necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario.
+ emit processingPage();
+ } else
+ //no hay ninguna página lista para ser renderizada, es necesario esperar.
+ emit processingPage();
+ } else
+ // la página actual está lista
+ {
+ //emit currentPageReady();
+ //make prepareAvailablePage the only function that emits currentPageReady()
+ prepareAvailablePage(currentIndex);
+ }
+ fillBuffer();
}
-QPixmap * Render::getCurrentPage()
+QPixmap *Render::getCurrentPage()
{
- QPixmap * page = new QPixmap();
- *page = page->fromImage(*buffer[currentPageBufferedIndex]);
- return page;
+ QPixmap *page = new QPixmap();
+ *page = page->fromImage(*buffer[currentPageBufferedIndex]);
+ return page;
}
-QPixmap * Render::getCurrentDoublePage()
+QPixmap *Render::getCurrentDoublePage()
{
- if (currentPageIsDoublePage())
- {
- QPoint leftpage(0,0);
- QPoint rightpage(0,0);
- QSize leftsize = buffer[currentPageBufferedIndex]->size();
- QSize rightsize = buffer[currentPageBufferedIndex+1]->size();
- int totalWidth,totalHeight;
- switch (imageRotation)
- {
- case 0:
- totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
- leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- totalWidth = leftsize.rwidth() + rightsize.rwidth();
- rightpage.setX(leftsize.rwidth());
- break;
- case 90:
- totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
- leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
- rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
- totalHeight = leftsize.rheight() + rightsize.rheight();
- rightpage.setY(leftsize.rheight());
- break;
- case 180:
- totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
- leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- totalWidth = leftsize.rwidth() + rightsize.rwidth();
- leftpage.setX(rightsize.rwidth());
- break;
- case 270:
- totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
- leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
- rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
- totalHeight = leftsize.rheight() + rightsize.rheight();
- leftpage.setY(rightsize.rheight());
- break;
- default:
- return NULL;
- }
- QPixmap * page = new QPixmap(totalWidth, totalHeight);
- QPainter painter(page);
- painter.drawImage(QRect(leftpage,leftsize), *buffer[currentPageBufferedIndex]);
- painter.drawImage(QRect(rightpage,rightsize), *buffer[currentPageBufferedIndex+1]);
- return page;
- }
- else
- {
- return NULL;
- }
+ if (currentPageIsDoublePage()) {
+ QPoint leftpage(0, 0);
+ QPoint rightpage(0, 0);
+ QSize leftsize = buffer[currentPageBufferedIndex]->size();
+ QSize rightsize = buffer[currentPageBufferedIndex + 1]->size();
+ int totalWidth, totalHeight;
+ switch (imageRotation) {
+ case 0:
+ totalHeight = qMax(leftsize.rheight(), rightsize.rheight());
+ leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ totalWidth = leftsize.rwidth() + rightsize.rwidth();
+ rightpage.setX(leftsize.rwidth());
+ break;
+ case 90:
+ totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
+ leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ totalHeight = leftsize.rheight() + rightsize.rheight();
+ rightpage.setY(leftsize.rheight());
+ break;
+ case 180:
+ totalHeight = qMax(leftsize.rheight(), rightsize.rheight());
+ leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ totalWidth = leftsize.rwidth() + rightsize.rwidth();
+ leftpage.setX(rightsize.rwidth());
+ break;
+ case 270:
+ totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
+ leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ totalHeight = leftsize.rheight() + rightsize.rheight();
+ leftpage.setY(rightsize.rheight());
+ break;
+ default:
+ return NULL;
+ }
+ QPixmap *page = new QPixmap(totalWidth, totalHeight);
+ QPainter painter(page);
+ painter.drawImage(QRect(leftpage, leftsize), *buffer[currentPageBufferedIndex]);
+ painter.drawImage(QRect(rightpage, rightsize), *buffer[currentPageBufferedIndex + 1]);
+ return page;
+ } else {
+ return NULL;
+ }
}
-QPixmap * Render::getCurrentDoubleMangaPage()
+QPixmap *Render::getCurrentDoubleMangaPage()
{
- if (currentPageIsDoublePage())
- {
- QPoint leftpage(0,0);
- QPoint rightpage(0,0);
- QSize leftsize = buffer[currentPageBufferedIndex+1]->size();
- QSize rightsize = buffer[currentPageBufferedIndex]->size();
- int totalWidth,totalHeight;
- switch (imageRotation)
- {
- case 0:
- totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
- leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- totalWidth = leftsize.rwidth() + rightsize.rwidth();
- rightpage.setX(leftsize.rwidth());
- break;
- case 90:
- totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
- leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
- rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
- totalHeight = leftsize.rheight() + rightsize.rheight();
- rightpage.setY(leftsize.rheight());
- break;
- case 180:
- totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
- leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
- totalWidth = leftsize.rwidth() + rightsize.rwidth();
- leftpage.setX(rightsize.rwidth());
- break;
- case 270:
- totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
- leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
- rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
- totalHeight = leftsize.rheight() + rightsize.rheight();
- leftpage.setY(rightsize.rheight());
- break;
- default:
- return NULL;
- }
- QPixmap * page = new QPixmap(totalWidth, totalHeight);
- QPainter painter(page);
- painter.drawImage(QRect(rightpage, rightsize), *buffer[currentPageBufferedIndex]);
- painter.drawImage(QRect(leftpage, leftsize), *buffer[currentPageBufferedIndex+1]);
- return page;
- }
- else
- {
- return NULL;
- }
+ if (currentPageIsDoublePage()) {
+ QPoint leftpage(0, 0);
+ QPoint rightpage(0, 0);
+ QSize leftsize = buffer[currentPageBufferedIndex + 1]->size();
+ QSize rightsize = buffer[currentPageBufferedIndex]->size();
+ int totalWidth, totalHeight;
+ switch (imageRotation) {
+ case 0:
+ totalHeight = qMax(leftsize.rheight(), rightsize.rheight());
+ leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ totalWidth = leftsize.rwidth() + rightsize.rwidth();
+ rightpage.setX(leftsize.rwidth());
+ break;
+ case 90:
+ totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
+ leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ totalHeight = leftsize.rheight() + rightsize.rheight();
+ rightpage.setY(leftsize.rheight());
+ break;
+ case 180:
+ totalHeight = qMax(leftsize.rheight(), rightsize.rheight());
+ leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
+ totalWidth = leftsize.rwidth() + rightsize.rwidth();
+ leftpage.setX(rightsize.rwidth());
+ break;
+ case 270:
+ totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
+ leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
+ totalHeight = leftsize.rheight() + rightsize.rheight();
+ leftpage.setY(rightsize.rheight());
+ break;
+ default:
+ return NULL;
+ }
+ QPixmap *page = new QPixmap(totalWidth, totalHeight);
+ QPainter painter(page);
+ painter.drawImage(QRect(rightpage, rightsize), *buffer[currentPageBufferedIndex]);
+ painter.drawImage(QRect(leftpage, leftsize), *buffer[currentPageBufferedIndex + 1]);
+ return page;
+ } else {
+ return NULL;
+ }
}
bool Render::currentPageIsDoublePage()
{
- if (buffer[currentPageBufferedIndex]->isNull() || buffer[currentPageBufferedIndex+1]->isNull())
- {
- return false;
- }
- if (imageRotation == 0 || imageRotation == 180)
- {
- if (buffer[currentPageBufferedIndex]->height() > buffer[currentPageBufferedIndex]->width() &&
- buffer[currentPageBufferedIndex+1]->height() > buffer[currentPageBufferedIndex+1]->width())
- {
- return true;
- }
- }
- else if (imageRotation == 90 || imageRotation == 270)
- {
- if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
- buffer[currentPageBufferedIndex+1]->width() > buffer[currentPageBufferedIndex+1]->height())
- {
- return true;
- }
- }
- return false;
+ if (buffer[currentPageBufferedIndex]->isNull() || buffer[currentPageBufferedIndex + 1]->isNull()) {
+ return false;
+ }
+ if (imageRotation == 0 || imageRotation == 180) {
+ if (buffer[currentPageBufferedIndex]->height() > buffer[currentPageBufferedIndex]->width() &&
+ buffer[currentPageBufferedIndex + 1]->height() > buffer[currentPageBufferedIndex + 1]->width()) {
+ return true;
+ }
+ } else if (imageRotation == 90 || imageRotation == 270) {
+ if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
+ buffer[currentPageBufferedIndex + 1]->width() > buffer[currentPageBufferedIndex + 1]->height()) {
+ return true;
+ }
+ }
+ return false;
}
bool Render::nextPageIsDoublePage()
{
- //this function is not used right now
- if (buffer[currentPageBufferedIndex+2]->isNull() || buffer[currentPageBufferedIndex+3]->isNull())
- {
- return false;
- }
- if (imageRotation == 0 || imageRotation == 180)
- {
- if (buffer[currentPageBufferedIndex+2]->height() > buffer[currentPageBufferedIndex+2]->width() &&
- buffer[currentPageBufferedIndex+3]->height() > buffer[currentPageBufferedIndex+3]->width())
- {
- return true;
- }
- }
- else if (imageRotation == 90 || imageRotation == 270)
- {
- if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
- buffer[currentPageBufferedIndex+1]->width() > buffer[currentPageBufferedIndex+1]->height())
- {
- return true;
- }
- }
- return false;
+ //this function is not used right now
+ if (buffer[currentPageBufferedIndex + 2]->isNull() || buffer[currentPageBufferedIndex + 3]->isNull()) {
+ return false;
+ }
+ if (imageRotation == 0 || imageRotation == 180) {
+ if (buffer[currentPageBufferedIndex + 2]->height() > buffer[currentPageBufferedIndex + 2]->width() &&
+ buffer[currentPageBufferedIndex + 3]->height() > buffer[currentPageBufferedIndex + 3]->width()) {
+ return true;
+ }
+ } else if (imageRotation == 90 || imageRotation == 270) {
+ if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
+ buffer[currentPageBufferedIndex + 1]->width() > buffer[currentPageBufferedIndex + 1]->height()) {
+ return true;
+ }
+ }
+ return false;
}
bool Render::previousPageIsDoublePage()
{
- if (buffer[currentPageBufferedIndex-1]->isNull() || buffer[currentPageBufferedIndex-2]->isNull())
- {
- return false;
- }
- if (imageRotation == 0 || imageRotation == 180)
- {
- if (buffer[currentPageBufferedIndex-1]->height() > buffer[currentPageBufferedIndex-1]->width() &&
- buffer[currentPageBufferedIndex-2]->height() > buffer[currentPageBufferedIndex-2]->width())
- {
- return true;
- }
- }
- else if (imageRotation == 90 || imageRotation == 270)
- {
- if (buffer[currentPageBufferedIndex-1]->width() > buffer[currentPageBufferedIndex-1]->height() &&
- buffer[currentPageBufferedIndex-2]->width() > buffer[currentPageBufferedIndex-2]->height())
- {
- return true;
- }
- }
- return false;
+ if (buffer[currentPageBufferedIndex - 1]->isNull() || buffer[currentPageBufferedIndex - 2]->isNull()) {
+ return false;
+ }
+ if (imageRotation == 0 || imageRotation == 180) {
+ if (buffer[currentPageBufferedIndex - 1]->height() > buffer[currentPageBufferedIndex - 1]->width() &&
+ buffer[currentPageBufferedIndex - 2]->height() > buffer[currentPageBufferedIndex - 2]->width()) {
+ return true;
+ }
+ } else if (imageRotation == 90 || imageRotation == 270) {
+ if (buffer[currentPageBufferedIndex - 1]->width() > buffer[currentPageBufferedIndex - 1]->height() &&
+ buffer[currentPageBufferedIndex - 2]->width() > buffer[currentPageBufferedIndex - 2]->height()) {
+ return true;
+ }
+ }
+ return false;
}
void Render::setRotation(int degrees)
{
- Q_UNUSED(degrees)
+ Q_UNUSED(degrees)
}
-void Render::setComic(Comic * c)
+void Render::setComic(Comic *c)
{
- if(comic !=0)
- {
- comic->moveToThread(QApplication::instance()->thread());
- comic->disconnect();
- comic->deleteLater();
- }
- comic = c;
+ if (comic != 0) {
+ comic->moveToThread(QApplication::instance()->thread());
+ comic->disconnect();
+ comic->deleteLater();
+ }
+ comic = c;
}
void Render::prepareAvailablePage(int page)
{
- if(!doublePage)
- {
- if (currentIndex == page)
- {
- emit currentPageReady();
- }
- }
- else
- {
- //check for last page in double page mode
- if ((currentIndex == page) && (currentIndex + 1) >= (int)comic->numPages())
- {
- emit currentPageReady();
- }
- else if ((currentIndex == page && !buffer[currentPageBufferedIndex+1]->isNull()) ||
- (currentIndex+1 == page && !buffer[currentPageBufferedIndex]->isNull()))
- {
- emit currentPageReady();
- }
- }
+ if (!doublePage) {
+ if (currentIndex == page) {
+ emit currentPageReady();
+ }
+ } else {
+ //check for last page in double page mode
+ if ((currentIndex == page) && (currentIndex + 1) >= (int)comic->numPages()) {
+ emit currentPageReady();
+ } else if ((currentIndex == page && !buffer[currentPageBufferedIndex + 1]->isNull()) ||
+ (currentIndex + 1 == page && !buffer[currentPageBufferedIndex]->isNull())) {
+ emit currentPageReady();
+ }
+ }
}
void Render::update()
{
- render();
+ render();
}
//-----------------------------------------------------------------------------
// Comic interface
//-----------------------------------------------------------------------------
-void Render::load(const QString & path, int atPage)
+void Render::load(const QString &path, int atPage)
{
- createComic(path);
- if (comic !=0)
- {
- loadComic(path,atPage);
- startLoad();
- }
+ createComic(path);
+ if (comic != 0) {
+ loadComic(path, atPage);
+ startLoad();
+ }
}
//-----------------------------------------------------------------------------
-void Render::load(const QString & path, const ComicDB & comicDB)
+void Render::load(const QString &path, const ComicDB &comicDB)
{
- //TODO prepare filters
- for(int i = 0; i < filters.count(); i++)
- {
- if(typeid(*filters[i]) == typeid(BrightnessFilter))
- {
- if(comicDB.info.brightness == -1)
- filters[i]->setLevel(0);
- else
- filters[i]->setLevel(comicDB.info.brightness);
- }
- if(typeid(*filters[i]) == typeid(ContrastFilter))
- {
- if(comicDB.info.contrast == -1)
- filters[i]->setLevel(100);
- else
- filters[i]->setLevel(comicDB.info.contrast);
- }
- if(typeid(*filters[i]) == typeid(GammaFilter))
- {
- if(comicDB.info.gamma == -1)
- filters[i]->setLevel(100);
- else
- filters[i]->setLevel(comicDB.info.gamma);
- }
- }
- createComic(path);
- if (comic!=0)
- {
- loadComic(path,comicDB);
- startLoad();
- }
+ //TODO prepare filters
+ for (int i = 0; i < filters.count(); i++) {
+ if (typeid(*filters[i]) == typeid(BrightnessFilter)) {
+ if (comicDB.info.brightness == -1)
+ filters[i]->setLevel(0);
+ else
+ filters[i]->setLevel(comicDB.info.brightness);
+ }
+ if (typeid(*filters[i]) == typeid(ContrastFilter)) {
+ if (comicDB.info.contrast == -1)
+ filters[i]->setLevel(100);
+ else
+ filters[i]->setLevel(comicDB.info.contrast);
+ }
+ if (typeid(*filters[i]) == typeid(GammaFilter)) {
+ if (comicDB.info.gamma == -1)
+ filters[i]->setLevel(100);
+ else
+ filters[i]->setLevel(comicDB.info.gamma);
+ }
+ }
+ createComic(path);
+ if (comic != 0) {
+ loadComic(path, comicDB);
+ startLoad();
+ }
}
-void Render::createComic(const QString & path)
+void Render::createComic(const QString &path)
{
previousIndex = currentIndex = 0;
pagesEmited.clear();
- if(comic!=0)
- {
- //comic->moveToThread(QApplication::instance()->thread());
+ if (comic != 0) {
+ //comic->moveToThread(QApplication::instance()->thread());
comic->invalidate();
- comic->disconnect();
- comic->deleteLater();
- }
- //comic->moveToThread(QApplication::instance()->thread());
- comic = FactoryComic::newComic(path);
+ comic->disconnect();
+ comic->deleteLater();
+ }
+ //comic->moveToThread(QApplication::instance()->thread());
+ comic = FactoryComic::newComic(path);
- if(comic == NULL)//archivo no encontrado o no válido
- {
- emit errorOpening();
- reset();
- return;
- }
+ if (comic == NULL) //archivo no encontrado o no válido
+ {
+ emit errorOpening();
+ reset();
+ return;
+ }
- connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()), Qt::QueuedConnection);
- connect(comic,SIGNAL(errorOpening(QString)),this,SIGNAL(errorOpening(QString)), Qt::QueuedConnection);
- connect(comic,SIGNAL(crcErrorFound(QString)),this,SIGNAL(crcError(QString)), Qt::QueuedConnection);
- connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()), Qt::QueuedConnection);
- connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int)), Qt::QueuedConnection);
- connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int)), Qt::QueuedConnection);
- connect(comic,SIGNAL(openAt(int)),this,SLOT(renderAt(int)), Qt::QueuedConnection);
- connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)), Qt::QueuedConnection);
- connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)), Qt::QueuedConnection);
- connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)), Qt::QueuedConnection);
- connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(errorOpening()), this, SIGNAL(errorOpening()), Qt::QueuedConnection);
+ connect(comic, SIGNAL(errorOpening(QString)), this, SIGNAL(errorOpening(QString)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(crcErrorFound(QString)), this, SIGNAL(crcError(QString)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(errorOpening()), this, SLOT(reset()), Qt::QueuedConnection);
+ connect(comic, SIGNAL(imageLoaded(int)), this, SLOT(pageRawDataReady(int)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(imageLoaded(int)), this, SIGNAL(imageLoaded(int)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(openAt(int)), this, SLOT(renderAt(int)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(numPages(unsigned int)), this, SIGNAL(numPages(unsigned int)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(numPages(unsigned int)), this, SLOT(setNumPages(unsigned int)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(imageLoaded(int, QByteArray)), this, SIGNAL(imageLoaded(int, QByteArray)), Qt::QueuedConnection);
+ connect(comic, SIGNAL(isBookmark(bool)), this, SIGNAL(currentPageIsBookmark(bool)), Qt::QueuedConnection);
- connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated()), Qt::QueuedConnection);
+ connect(comic, SIGNAL(bookmarksUpdated()), this, SIGNAL(bookmarksUpdated()), Qt::QueuedConnection);
- //connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast()));
- //connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover()));
+ //connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast()));
+ //connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover()));
- pagesReady.clear();
+ pagesReady.clear();
}
-void Render::loadComic(const QString & path,const ComicDB & comicDB)
+void Render::loadComic(const QString &path, const ComicDB &comicDB)
{
- comic->load(path,comicDB);
+ comic->load(path, comicDB);
}
-void Render::loadComic(const QString & path, int atPage)
+void Render::loadComic(const QString &path, int atPage)
{
- comic->load(path,atPage);
+ comic->load(path, atPage);
}
void Render::startLoad()
{
- QThread * thread = nullptr;
+ QThread *thread = nullptr;
- thread = new QThread();
+ thread = new QThread();
- comic->moveToThread(thread);
+ comic->moveToThread(thread);
connect(comic, SIGNAL(errorOpening()), thread, SLOT(quit()), Qt::QueuedConnection);
connect(comic, SIGNAL(errorOpening(QString)), thread, SLOT(quit()), Qt::QueuedConnection);
connect(comic, SIGNAL(imagesLoaded()), thread, SLOT(quit()), Qt::QueuedConnection);
connect(comic, SIGNAL(destroyed()), thread, SLOT(quit()), Qt::QueuedConnection);
connect(comic, SIGNAL(invalidated()), thread, SLOT(quit()), Qt::QueuedConnection);
- connect(thread, SIGNAL(started()), comic, SLOT(process()));
- connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ connect(thread, SIGNAL(started()), comic, SLOT(process()));
+ connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
- if(thread != nullptr)
- thread->start();
+ if (thread != nullptr)
+ thread->start();
- invalidate();
- loadedComic = true;
- update();
+ invalidate();
+ loadedComic = true;
+ update();
}
void Render::renderAt(int page)
{
- previousIndex = currentIndex = page;
- emit pageChanged(page);
+ previousIndex = currentIndex = page;
+ emit pageChanged(page);
}
void Render::reset()
{
- loadedComic = false;
- invalidate();
+ loadedComic = false;
+ invalidate();
}
//si se solicita la siguiente página, se calcula cuál debe ser en función de si se lee en modo a doble página o no.
//la página sólo se renderiza, si realmente ha cambiado.
void Render::nextPage()
{
- int nextPage; //indica cuál será la próxima página
- nextPage = comic->nextPage();
- //se fuerza renderizado si la página ha cambiado
- if(currentIndex != nextPage)
- {
- previousIndex = currentIndex;
- currentIndex = nextPage;
- update();
- emit pageChanged(currentIndex);
- }
- else if (hasLoadedComic() && ((unsigned int)currentIndex == numPages()-1))
- {
- emit isLast();
- }
+ int nextPage; //indica cuál será la próxima página
+ nextPage = comic->nextPage();
+ //se fuerza renderizado si la página ha cambiado
+ if (currentIndex != nextPage) {
+ previousIndex = currentIndex;
+ currentIndex = nextPage;
+ update();
+ emit pageChanged(currentIndex);
+ } else if (hasLoadedComic() && ((unsigned int)currentIndex == numPages() - 1)) {
+ emit isLast();
+ }
}
void Render::nextDoublePage()
{
- int nextPage;
- if (currentIndex +2 < (int)comic->numPages())
- {
- nextPage = currentIndex+2;
- }
- else
- {
- nextPage = currentIndex;
- }
- if(currentIndex != nextPage)
- {
- comic->setIndex(nextPage);
- previousIndex = currentIndex;
- currentIndex = nextPage;
- update();
- emit pageChanged(currentIndex);
- }
- else if (hasLoadedComic() && ((unsigned int)currentIndex >= numPages()-2))
- {
- emit isLast();
- }
+ int nextPage;
+ if (currentIndex + 2 < (int)comic->numPages()) {
+ nextPage = currentIndex + 2;
+ } else {
+ nextPage = currentIndex;
+ }
+ if (currentIndex != nextPage) {
+ comic->setIndex(nextPage);
+ previousIndex = currentIndex;
+ currentIndex = nextPage;
+ update();
+ emit pageChanged(currentIndex);
+ } else if (hasLoadedComic() && ((unsigned int)currentIndex >= numPages() - 2)) {
+ emit isLast();
+ }
}
//si se solicita la página anterior, se calcula cuál debe ser en función de si se lee en modo a doble página o no.
//la página sólo se renderiza, si realmente ha cambiado.
void Render::previousPage()
{
- int previousPage; //indica cuál será la próxima página
- previousPage = comic->previousPage();
+ int previousPage; //indica cuál será la próxima página
+ previousPage = comic->previousPage();
- //se fuerza renderizado si la página ha cambiado
- if(currentIndex != previousPage)
- {
- previousIndex = currentIndex;
- currentIndex = previousPage;
- update();
- emit pageChanged(currentIndex);
- }
- else if (hasLoadedComic() && (currentIndex == 0))
- {
- emit isCover();
- }
+ //se fuerza renderizado si la página ha cambiado
+ if (currentIndex != previousPage) {
+ previousIndex = currentIndex;
+ currentIndex = previousPage;
+ update();
+ emit pageChanged(currentIndex);
+ } else if (hasLoadedComic() && (currentIndex == 0)) {
+ emit isCover();
+ }
}
void Render::previousDoublePage()
{
- int previousPage; //indica cuál será la próxima página
- previousPage = qMax(currentIndex-2,0);
- if(currentIndex != previousPage)
- {
- comic->setIndex(previousPage);
- previousIndex = currentIndex;
- currentIndex = previousPage;
- update();
- emit pageChanged(currentIndex);
- }
+ int previousPage; //indica cuál será la próxima página
+ previousPage = qMax(currentIndex - 2, 0);
+ if (currentIndex != previousPage) {
+ comic->setIndex(previousPage);
+ previousIndex = currentIndex;
+ currentIndex = previousPage;
+ update();
+ emit pageChanged(currentIndex);
+ }
}
unsigned int Render::getIndex()
{
- return comic->getIndex();
+ return comic->getIndex();
}
unsigned int Render::numPages()
{
- return comic->numPages();
+ return comic->numPages();
}
bool Render::hasLoadedComic()
{
- if(comic!=0)
- return comic->loaded();
- return false;
+ if (comic != 0)
+ return comic->loaded();
+ return false;
}
void Render::setNumPages(unsigned int numPages)
{
- pagesReady.fill(false,numPages);
+ pagesReady.fill(false, numPages);
}
void Render::pageRawDataReady(int page)
@@ -955,24 +857,19 @@ void Render::pageRawDataReady(int page)
return;
pagesEmited.push_back(page);
- if(pageRenders.size()>0)
- {
- for(int i=0;i= pagesReady.size())
- {
+ if (pageRenders.size() > 0) {
+ for (int i = 0; i < pagesEmited.size(); i++) {
+ if (pagesEmited.at(i) >= pagesReady.size()) {
pagesEmited.clear();
return; //Oooops, something went wrong
}
pagesReady[pagesEmited.at(i)] = true;
- if(pagesEmited.at(i) == currentIndex)
+ if (pagesEmited.at(i) == currentIndex)
update();
- else
- {
- if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-numLeftPages)) ||
- ((pagesEmited.at(i) > currentIndex) && (pagesEmited.at(i) < currentIndex+numRightPages)) )
- {
+ else {
+ if (((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex - numLeftPages)) ||
+ ((pagesEmited.at(i) > currentIndex) && (pagesEmited.at(i) < currentIndex + numRightPages))) {
fillBuffer();
}
}
@@ -985,28 +882,27 @@ void Render::pageRawDataReady(int page)
void Render::goTo(int index)
{
- if(currentIndex != index)
- {
- comic->setIndex(index);
- previousIndex = currentIndex;
- currentIndex = index;
- update();
- emit pageChanged(currentIndex);
- }
+ if (currentIndex != index) {
+ comic->setIndex(index);
+ previousIndex = currentIndex;
+ currentIndex = index;
+ update();
+ emit pageChanged(currentIndex);
+ }
}
void Render::rotateRight()
{
- imageRotation = (imageRotation+90) % 360;
- reload();
+ imageRotation = (imageRotation + 90) % 360;
+ reload();
}
void Render::rotateLeft()
{
- if(imageRotation == 0)
- imageRotation = 270;
- else
- imageRotation = imageRotation - 90;
- reload();
+ if (imageRotation == 0)
+ imageRotation = 270;
+ else
+ imageRotation = imageRotation - 90;
+ reload();
}
//Actualiza el buffer, añadiendo las imágenes (vacÃas) necesarias para su posterior renderizado y
@@ -1014,194 +910,176 @@ void Render::rotateLeft()
//Calcula el número de nuevas páginas que hay que buferear y si debe hacerlo por la izquierda o la derecha (según sea el sentido de la lectura)
void Render::updateBuffer()
{
- QMutexLocker locker(&mutex);
- int windowSize = currentIndex - previousIndex;
+ QMutexLocker locker(&mutex);
+ int windowSize = currentIndex - previousIndex;
- if(windowSize > 0)//add pages to right pages and remove on the left
- {
- windowSize = qMin(windowSize,buffer.size());
- for(int i = 0; i < windowSize; i++)
- {
- //renders
- PageRender * pr = pageRenders.front();
- pageRenders.pop_front();
- if(pr !=0)
- {
- if(pr->wait())
- delete pr;
- }
- pageRenders.push_back(0);
+ if (windowSize > 0) //add pages to right pages and remove on the left
+ {
+ windowSize = qMin(windowSize, buffer.size());
+ for (int i = 0; i < windowSize; i++) {
+ //renders
+ PageRender *pr = pageRenders.front();
+ pageRenders.pop_front();
+ if (pr != 0) {
+ if (pr->wait())
+ delete pr;
+ }
+ pageRenders.push_back(0);
- //images
+ //images
- if(buffer.front()!=0)
- delete buffer.front();
- buffer.pop_front();
- buffer.push_back(new QImage());
- }
- }
- else //add pages to left pages and remove on the right
- {
- if(windowSize<0)
- {
- windowSize = -windowSize;
- windowSize = qMin(windowSize,buffer.size());
- for(int i = 0; i < windowSize; i++)
- {
- //renders
- PageRender * pr = pageRenders.back();
- pageRenders.pop_back();
- if(pr !=0)
- {
- if(pr->wait())
- delete pr;
- }
- pageRenders.push_front(0);
+ if (buffer.front() != 0)
+ delete buffer.front();
+ buffer.pop_front();
+ buffer.push_back(new QImage());
+ }
+ } else //add pages to left pages and remove on the right
+ {
+ if (windowSize < 0) {
+ windowSize = -windowSize;
+ windowSize = qMin(windowSize, buffer.size());
+ for (int i = 0; i < windowSize; i++) {
+ //renders
+ PageRender *pr = pageRenders.back();
+ pageRenders.pop_back();
+ if (pr != 0) {
+ if (pr->wait())
+ delete pr;
+ }
+ pageRenders.push_front(0);
- //images
- buffer.push_front(new QImage());
- QImage * p = buffer.back();
- if(p!=0)
- delete p;
- buffer.pop_back();
- }
- }
- }
- previousIndex = currentIndex;
+ //images
+ buffer.push_front(new QImage());
+ QImage *p = buffer.back();
+ if (p != 0)
+ delete p;
+ buffer.pop_back();
+ }
+ }
+ }
+ previousIndex = currentIndex;
}
void Render::fillBuffer()
{
- if (pagesReady.size() < 1)
- {
- return;
- }
+ if (pagesReady.size() < 1) {
+ return;
+ }
- for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++)
- {
- if ((currentIndex+i < (int)comic->numPages()) &&
- buffer[currentPageBufferedIndex+i]->isNull() &&
- i <= numRightPages &&
- pageRenders[currentPageBufferedIndex+i]==0 &&
- pagesReady[currentIndex+i]) //preload next pages
- {
- pageRenders[currentPageBufferedIndex+i] = new PageRender(this,currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation,filters);
- connect(pageRenders[currentPageBufferedIndex+i],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
- pageRenders[currentPageBufferedIndex+i]->start();
- }
+ for (int i = 1; i <= qMax(numLeftPages, numRightPages); i++) {
+ if ((currentIndex + i < (int)comic->numPages()) &&
+ buffer[currentPageBufferedIndex + i]->isNull() &&
+ i <= numRightPages &&
+ pageRenders[currentPageBufferedIndex + i] == 0 &&
+ pagesReady[currentIndex + i]) //preload next pages
+ {
+ pageRenders[currentPageBufferedIndex + i] = new PageRender(this, currentIndex + i, comic->getRawData()->at(currentIndex + i), buffer[currentPageBufferedIndex + i], imageRotation, filters);
+ connect(pageRenders[currentPageBufferedIndex + i], SIGNAL(pageReady(int)), this, SLOT(prepareAvailablePage(int)));
+ pageRenders[currentPageBufferedIndex + i]->start();
+ }
- if ((currentIndex-i > 0) &&
- buffer[currentPageBufferedIndex-i]->isNull() &&
- i <= numLeftPages &&
- pageRenders[currentPageBufferedIndex-i]==0 &&
- pagesReady[currentIndex-i]) //preload previous pages
- {
- pageRenders[currentPageBufferedIndex-i] = new PageRender(this,currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation,filters);
- connect(pageRenders[currentPageBufferedIndex-i],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
- pageRenders[currentPageBufferedIndex-i]->start();
- }
- }
+ if ((currentIndex - i > 0) &&
+ buffer[currentPageBufferedIndex - i]->isNull() &&
+ i <= numLeftPages &&
+ pageRenders[currentPageBufferedIndex - i] == 0 &&
+ pagesReady[currentIndex - i]) //preload previous pages
+ {
+ pageRenders[currentPageBufferedIndex - i] = new PageRender(this, currentIndex - i, comic->getRawData()->at(currentIndex - i), buffer[currentPageBufferedIndex - i], imageRotation, filters);
+ connect(pageRenders[currentPageBufferedIndex - i], SIGNAL(pageReady(int)), this, SLOT(prepareAvailablePage(int)));
+ pageRenders[currentPageBufferedIndex - i]->start();
+ }
+ }
}
-
//Método que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual.
//se terminan todos los hilos en ejecución y se libera la memoria (de hilos e imágenes)
void Render::invalidate()
{
- for(int i=0;iwait();
- delete pageRenders[i];
- pageRenders[i] = 0;
- }
- }
+ for (int i = 0; i < pageRenders.size(); i++) {
+ if (pageRenders[i] != 0) {
+ pageRenders[i]->wait();
+ delete pageRenders[i];
+ pageRenders[i] = 0;
+ }
+ }
- for(int i=0;inumPages()))
- {
- if (currentPageIsDoublePage())
- {
- if (doubleMangaPage)
- s = QString::number(currentIndex+2) + "-" + s;
- else
- s += "-"+QString::number(currentIndex+2);
- }
- }
- s += "/"+QString::number(comic->numPages());
- return s;
+ QString s = QString::number(currentIndex + 1);
+ if (doublePage && (currentIndex + 1 < (int)comic->numPages())) {
+ if (currentPageIsDoublePage()) {
+ if (doubleMangaPage)
+ s = QString::number(currentIndex + 2) + "-" + s;
+ else
+ s += "-" + QString::number(currentIndex + 2);
+ }
+ }
+ s += "/" + QString::number(comic->numPages());
+ return s;
}
void Render::setBookmark()
{
- comic->setBookmark();
+ comic->setBookmark();
}
void Render::removeBookmark()
{
- comic->removeBookmark();
+ comic->removeBookmark();
}
void Render::save()
{
- comic->saveBookmarks();
+ comic->saveBookmarks();
}
-Bookmarks * Render::getBookmarks()
+Bookmarks *Render::getBookmarks()
{
- return comic->bm;
+ return comic->bm;
}
void Render::reload()
{
- if(comic)
- {
- invalidate();
- update();
- }
+ if (comic) {
+ invalidate();
+ update();
+ }
}
void Render::updateFilters(int brightness, int contrast, int gamma)
{
- for(int i = 0; i < filters.count(); i++)
- {
- if(typeid(*filters[i]) == typeid(BrightnessFilter))
- filters[i]->setLevel(brightness);
- if(typeid(*filters[i]) == typeid(ContrastFilter))
- filters[i]->setLevel(contrast);
- if(typeid(*filters[i]) == typeid(GammaFilter))
- filters[i]->setLevel(gamma);
- }
+ for (int i = 0; i < filters.count(); i++) {
+ if (typeid(*filters[i]) == typeid(BrightnessFilter))
+ filters[i]->setLevel(brightness);
+ if (typeid(*filters[i]) == typeid(ContrastFilter))
+ filters[i]->setLevel(contrast);
+ if (typeid(*filters[i]) == typeid(GammaFilter))
+ filters[i]->setLevel(gamma);
+ }
- reload();
+ reload();
}
diff --git a/YACReader/render.h b/YACReader/render.h
index 786bcd49..af65629c 100644
--- a/YACReader/render.h
+++ b/YACReader/render.h
@@ -1,4 +1,4 @@
- #ifndef RENDER_H
+#ifndef RENDER_H
#define RENDER_H
#include
@@ -18,51 +18,62 @@ class Comic;
class ComicDB;
class Render;
-class ImageFilter {
+class ImageFilter
+{
public:
- ImageFilter(){};
- virtual ~ImageFilter() {};
- virtual QImage setFilter(const QImage & image) = 0;
- inline int getLevel() {return level;};
- inline void setLevel(int l) {level = l;};
+ ImageFilter() {};
+ virtual ~ImageFilter() {};
+ virtual QImage setFilter(const QImage &image) = 0;
+ inline int getLevel() { return level; };
+ inline void setLevel(int l) { level = l; };
+
protected:
- int level;
+ int level;
};
-class MeanNoiseReductionFilter : public ImageFilter {
+class MeanNoiseReductionFilter : public ImageFilter
+{
public:
- enum NeighborghoodSize{SMALL=9, LARGE=25 };
- MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
- virtual QImage setFilter(const QImage & image);
+ enum NeighborghoodSize { SMALL = 9,
+ LARGE = 25 };
+ MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
+ virtual QImage setFilter(const QImage &image);
+
private:
- enum NeighborghoodSize neighborghoodSize;
+ enum NeighborghoodSize neighborghoodSize;
};
-class MedianNoiseReductionFilter : public ImageFilter {
+class MedianNoiseReductionFilter : public ImageFilter
+{
public:
- enum NeighborghoodSize{SMALL=9, LARGE=25 };
- MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
- virtual QImage setFilter(const QImage & image);
+ enum NeighborghoodSize { SMALL = 9,
+ LARGE = 25 };
+ MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
+ virtual QImage setFilter(const QImage &image);
+
private:
- enum NeighborghoodSize neighborghoodSize;
+ enum NeighborghoodSize neighborghoodSize;
};
-class BrightnessFilter : public ImageFilter {
+class BrightnessFilter : public ImageFilter
+{
public:
- BrightnessFilter(int l=-1);
- virtual QImage setFilter(const QImage & image);
+ BrightnessFilter(int l = -1);
+ virtual QImage setFilter(const QImage &image);
};
-class ContrastFilter : public ImageFilter {
+class ContrastFilter : public ImageFilter
+{
public:
- ContrastFilter(int l=-1);
- virtual QImage setFilter(const QImage & image);
+ ContrastFilter(int l = -1);
+ virtual QImage setFilter(const QImage &image);
};
-class GammaFilter : public ImageFilter {
+class GammaFilter : public ImageFilter
+{
public:
- GammaFilter(int l=-1);
- virtual QImage setFilter(const QImage & image);
+ GammaFilter(int l = -1);
+ virtual QImage setFilter(const QImage &image);
};
//-----------------------------------------------------------------------------
@@ -71,26 +82,26 @@ public:
class PageRender : public QThread
{
- Q_OBJECT
+ Q_OBJECT
public:
- PageRender();
- PageRender(Render * render,int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector filters = QVector());
- int getNumPage(){return numPage;};
- void setData(const QByteArray & rawData){data = rawData;};
- void setPage(QImage * p){page = p;};
- void setRotation(unsigned int d){degrees = d;};
- void setFilters(QVector f){filters = f;};
-private:
- int numPage;
- QByteArray data;
- QImage * page;
- unsigned int degrees;
- QVector filters;
- void run();
- Render * render;
-signals:
- void pageReady(int);
+ PageRender();
+ PageRender(Render *render, int numPage, const QByteArray &rawData, QImage *page, unsigned int degrees = 0, QVector filters = QVector());
+ int getNumPage() { return numPage; };
+ void setData(const QByteArray &rawData) { data = rawData; };
+ void setPage(QImage *p) { page = p; };
+ void setRotation(unsigned int d) { degrees = d; };
+ void setFilters(QVector f) { filters = f; };
+private:
+ int numPage;
+ QByteArray data;
+ QImage *page;
+ unsigned int degrees;
+ QVector filters;
+ void run();
+ Render *render;
+signals:
+ void pageReady(int);
};
//-----------------------------------------------------------------------------
// RENDER
@@ -116,101 +127,100 @@ signals:
};
*/
-class Render : public QObject {
-Q_OBJECT
+class Render : public QObject
+{
+ Q_OBJECT
public:
- Render();
- ~Render();
+ Render();
+ ~Render();
public slots:
- void render();
- QPixmap * getCurrentPage();
- QPixmap * getCurrentDoublePage();
- QPixmap * getCurrentDoubleMangaPage();
- bool currentPageIsDoublePage();
- bool nextPageIsDoublePage();
- bool previousPageIsDoublePage();
- void goTo(int index);
- void doublePageSwitch();
- void doubleMangaPageSwitch();
- void setRotation(int degrees);
- void setComic(Comic * c);
- void prepareAvailablePage(int page);
- void update();
- void setNumPages(unsigned int numPages);
- void pageRawDataReady(int page);
- //--comic interface
- void nextPage();
- void previousPage();
- void nextDoublePage();
- void previousDoublePage();
- void load(const QString & path, const ComicDB & comic);
- void load(const QString & path, int atPage);
- void createComic(const QString & path);
- void loadComic(const QString & path,const ComicDB & comic);
- void loadComic(const QString & path, int atPage);
- void startLoad();
- void rotateRight();
- void rotateLeft();
- unsigned int getIndex();
- unsigned int numPages();
- bool hasLoadedComic();
- void updateBuffer();
- void fillBuffer();
- void invalidate();
- QString getCurrentPagesInformation();
- void setBookmark();
- void removeBookmark();
- void save();
- void reset();
- void reload();
- void updateFilters(int brightness, int contrast, int gamma);
- Bookmarks * getBookmarks();
- //sets the firt page to render
- void renderAt(int page);
+ void render();
+ QPixmap *getCurrentPage();
+ QPixmap *getCurrentDoublePage();
+ QPixmap *getCurrentDoubleMangaPage();
+ bool currentPageIsDoublePage();
+ bool nextPageIsDoublePage();
+ bool previousPageIsDoublePage();
+ void goTo(int index);
+ void doublePageSwitch();
+ void doubleMangaPageSwitch();
+ void setRotation(int degrees);
+ void setComic(Comic *c);
+ void prepareAvailablePage(int page);
+ void update();
+ void setNumPages(unsigned int numPages);
+ void pageRawDataReady(int page);
+ //--comic interface
+ void nextPage();
+ void previousPage();
+ void nextDoublePage();
+ void previousDoublePage();
+ void load(const QString &path, const ComicDB &comic);
+ void load(const QString &path, int atPage);
+ void createComic(const QString &path);
+ void loadComic(const QString &path, const ComicDB &comic);
+ void loadComic(const QString &path, int atPage);
+ void startLoad();
+ void rotateRight();
+ void rotateLeft();
+ unsigned int getIndex();
+ unsigned int numPages();
+ bool hasLoadedComic();
+ void updateBuffer();
+ void fillBuffer();
+ void invalidate();
+ QString getCurrentPagesInformation();
+ void setBookmark();
+ void removeBookmark();
+ void save();
+ void reset();
+ void reload();
+ void updateFilters(int brightness, int contrast, int gamma);
+ Bookmarks *getBookmarks();
+ //sets the firt page to render
+ void renderAt(int page);
signals:
- void currentPageReady();
- void processingPage();
- void imagesLoaded();
- void imageLoaded(int index);
- void imageLoaded(int index,const QByteArray & image);
- void pageChanged(int index);
- void numPages(unsigned int numPages);
- void errorOpening();
- void errorOpening(QString);
- void crcError(QString);
- void currentPageIsBookmark(bool);
- void isLast();
- void isCover();
-
- void bookmarksUpdated();
+ void currentPageReady();
+ void processingPage();
+ void imagesLoaded();
+ void imageLoaded(int index);
+ void imageLoaded(int index, const QByteArray &image);
+ void pageChanged(int index);
+ void numPages(unsigned int numPages);
+ void errorOpening();
+ void errorOpening(QString);
+ void crcError(QString);
+ void currentPageIsBookmark(bool);
+ void isLast();
+ void isCover();
+ void bookmarksUpdated();
private:
- Comic * comic;
- bool doublePage;
- bool doubleMangaPage;
- int previousIndex;
- int currentIndex;
- //QPixmap * currentPage;
- int currentPageBufferedIndex;
- int numLeftPages;
- int numRightPages;
- QList pageRenders;
- QList buffer;
- void loadAll();
- void updateRightPages();
- void updateLeftPages();
- bool loadedComic;
- QList pagesEmited;
- QVector pagesReady;
- int imageRotation;
- QVector filters;
- QMutex mutex;
+ Comic *comic;
+ bool doublePage;
+ bool doubleMangaPage;
+ int previousIndex;
+ int currentIndex;
+ //QPixmap * currentPage;
+ int currentPageBufferedIndex;
+ int numLeftPages;
+ int numRightPages;
+ QList pageRenders;
+ QList buffer;
+ void loadAll();
+ void updateRightPages();
+ void updateLeftPages();
+ bool loadedComic;
+ QList pagesEmited;
+ QVector pagesReady;
+ int imageRotation;
+ QVector filters;
+ QMutex mutex;
- friend class PageRender;
+ friend class PageRender;
};
-
#endif // RENDER_H
diff --git a/YACReader/shortcuts_dialog.cpp b/YACReader/shortcuts_dialog.cpp
index 2c66bef6..9e5afb67 100644
--- a/YACReader/shortcuts_dialog.cpp
+++ b/YACReader/shortcuts_dialog.cpp
@@ -8,48 +8,48 @@
#include
#include
-ShortcutsDialog::ShortcutsDialog(QWidget * parent)
- :QDialog(parent)//,Qt::FramelessWindowHint)
+ShortcutsDialog::ShortcutsDialog(QWidget *parent)
+ : QDialog(parent) //,Qt::FramelessWindowHint)
{
- setModal(true);
- setWindowIcon(QIcon(":/images/shortcuts.png"));
- setWindowTitle(tr("YACReader keyboard shortcuts"));
+ setModal(true);
+ setWindowIcon(QIcon(":/images/shortcuts.png"));
+ setWindowTitle(tr("YACReader keyboard shortcuts"));
- QVBoxLayout * mainLayout = new QVBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout;
- close = new QPushButton(tr("Close"));
- connect(close,SIGNAL(clicked()),this,SLOT(close()));
+ close = new QPushButton(tr("Close"));
+ connect(close, SIGNAL(clicked()), this, SLOT(close()));
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addStretch();
- bottomLayout->addWidget(close);
-
- QHBoxLayout * shortcutsLayout = new QHBoxLayout;
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addWidget(close);
- shortcuts = new QTextEdit();
- shortcuts->setFrameStyle(QFrame::NoFrame);
-
- //"General functions:
O : Open comic
Esc : Exit
"
- shortcuts->setReadOnly(true);
- shortcutsLayout->addWidget(shortcuts);
- //shortcutsLayout->addWidget(shortcuts2);
- shortcutsLayout->setSpacing(0);
- mainLayout->addLayout(shortcutsLayout);
- mainLayout->addLayout(bottomLayout);
+ QHBoxLayout *shortcutsLayout = new QHBoxLayout;
+
+ shortcuts = new QTextEdit();
+ shortcuts->setFrameStyle(QFrame::NoFrame);
+
+ //"General functions:
O : Open comic
Esc : Exit"
+ shortcuts->setReadOnly(true);
+ shortcutsLayout->addWidget(shortcuts);
+ //shortcutsLayout->addWidget(shortcuts2);
+ shortcutsLayout->setSpacing(0);
+ mainLayout->addLayout(shortcutsLayout);
+ mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
- setFixedSize(QSize(700,500));
+ setFixedSize(QSize(700, 500));
- QFile f(":/files/shortcuts.html");
- f.open(QIODevice::ReadOnly);
- QTextStream txtS(&f);
- txtS.setCodec(QTextCodec::codecForName("UTF-8"));
- QString content = txtS.readAll();
+ QFile f(":/files/shortcuts.html");
+ f.open(QIODevice::ReadOnly);
+ QTextStream txtS(&f);
+ txtS.setCodec(QTextCodec::codecForName("UTF-8"));
+ QString content = txtS.readAll();
- f.close();
+ f.close();
- shortcuts->setHtml(content);
+ shortcuts->setHtml(content);
- setWindowTitle(tr("Keyboard Shortcuts"));
+ setWindowTitle(tr("Keyboard Shortcuts"));
}
diff --git a/YACReader/shortcuts_dialog.h b/YACReader/shortcuts_dialog.h
index 1d93c62e..876868b9 100644
--- a/YACReader/shortcuts_dialog.h
+++ b/YACReader/shortcuts_dialog.h
@@ -7,13 +7,14 @@
class ShortcutsDialog : public QDialog
{
-Q_OBJECT
- public:
- ShortcutsDialog(QWidget * parent = 0);
- private:
- QTextEdit * shortcuts;
- QPushButton * close;
- public slots:
+ Q_OBJECT
+public:
+ ShortcutsDialog(QWidget *parent = 0);
+
+private:
+ QTextEdit *shortcuts;
+ QPushButton *close;
+public slots:
};
#endif // SHORTCUTS_DIALOG_H
diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp
index af86d1ec..5ab8308d 100644
--- a/YACReader/translator.cpp
+++ b/YACReader/translator.cpp
@@ -33,275 +33,272 @@
#define APPID "417CEAD93449502CC3C9B69FED26C54118E62BCC"
-YACReaderTranslator::YACReaderTranslator(QWidget * parent)
-:QWidget(parent),drag(false)
+YACReaderTranslator::YACReaderTranslator(QWidget *parent)
+ : QWidget(parent), drag(false)
{
- QString scrollBarStyle = "QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
- "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
- "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ QString scrollBarStyle = "QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
+ "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
+ "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
- "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
+ "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
+ "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
- "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }";
+ "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }";
- this->setCursor(QCursor(Qt::ArrowCursor));
- this->setAutoFillBackground(true);
- this->setBackgroundRole(QPalette::Window);
- QPalette p(this->palette());
- p.setColor(QPalette::Window, QColor("#404040"));
- this->setPalette(p);
+ this->setCursor(QCursor(Qt::ArrowCursor));
+ this->setAutoFillBackground(true);
+ this->setBackgroundRole(QPalette::Window);
+ QPalette p(this->palette());
+ p.setColor(QPalette::Window, QColor("#404040"));
+ this->setPalette(p);
- QVBoxLayout *layout = new QVBoxLayout(this);
+ QVBoxLayout *layout = new QVBoxLayout(this);
- //TITLE BAR
- QHBoxLayout * titleBar = new QHBoxLayout();
- QPushButton * close = new QPushButton(QIcon(QPixmap(":/images/close.png")),"");
- close->setFlat(true);
- QLabel * title = new QLabel(tr("YACReader translator"));
- title->setStyleSheet("QLabel {font-size:18px; font-family:Arial; color:white;}");
- titleBar->addWidget(title);
- titleBar->addStretch();
- close->resize(14,14);
- close->setStyleSheet("QPushButton {margin:0;padding:0;border:none;}");
- titleBar->addWidget(close);
- titleBar->setContentsMargins(0,0,0,0);
- titleBar->setSpacing(0);
- connect(close,SIGNAL(clicked()),this->parent(),SLOT(animateHideTranslator()));
+ //TITLE BAR
+ QHBoxLayout *titleBar = new QHBoxLayout();
+ QPushButton *close = new QPushButton(QIcon(QPixmap(":/images/close.png")), "");
+ close->setFlat(true);
+ QLabel *title = new QLabel(tr("YACReader translator"));
+ title->setStyleSheet("QLabel {font-size:18px; font-family:Arial; color:white;}");
+ titleBar->addWidget(title);
+ titleBar->addStretch();
+ close->resize(14, 14);
+ close->setStyleSheet("QPushButton {margin:0;padding:0;border:none;}");
+ titleBar->addWidget(close);
+ titleBar->setContentsMargins(0, 0, 0, 0);
+ titleBar->setSpacing(0);
+ connect(close, SIGNAL(clicked()), this->parent(), SLOT(animateHideTranslator()));
- layout->addLayout(titleBar);
+ layout->addLayout(titleBar);
- //INPUT TEXT
- text = new QTextEdit(this);
- text->setMinimumHeight(110);
- text->setMaximumHeight(110);
- layout->addSpacing(12);
- layout->addWidget(text);
- text->setStyleSheet("QTextEdit{border:none;background:#2a2a2a;color:white; font-size:12px; padding:6px;}"+scrollBarStyle);
+ //INPUT TEXT
+ text = new QTextEdit(this);
+ text->setMinimumHeight(110);
+ text->setMaximumHeight(110);
+ layout->addSpacing(12);
+ layout->addWidget(text);
+ text->setStyleSheet("QTextEdit{border:none;background:#2a2a2a;color:white; font-size:12px; padding:6px;}" + scrollBarStyle);
- //COMBOBOXES
- QHBoxLayout * combos = new QHBoxLayout();
- from = new QComboBox(this);
- to = new QComboBox(this);
- QString comboBoxStyle = "QComboBox {border:none;background:#2a2a2a;color:white;font-size:12px;font-family:Arial;padding-left:8px;}"
- "QComboBox::down-arrow {image: url(:/images/dropDownArrow.png);}"
- "QComboBox::drop-down {border:none; padding-right:10px;}"
- "QComboBox QAbstractItemView {border: none; background:#272727; color:white; selection-background-color: #202020; outline:none;}"
- "QComboBox QAbstractItemView::item {padding-left:8px;}" + scrollBarStyle
- ;
- from->setStyleSheet(comboBoxStyle);
- to->setStyleSheet(comboBoxStyle);
- from->setFixedHeight(22);
- to->setFixedHeight(22);
- QLabel * arrow = new QLabel(this);
- QPixmap arrowPixmap(":/images/fromTo.png");
- arrow->setPixmap(arrowPixmap);
- QPushButton * searchButton = new QPushButton(this);
- searchButton->setIcon(QIcon(":/images/translatorSearch.png"));
- searchButton->setStyleSheet("QPushButton {border:none; background:#2a2a2a;}");
- searchButton->setFixedSize(22,22);
- combos->addWidget(from,1);
- combos->addSpacing(9);
- combos->addWidget(arrow,0);
- combos->addSpacing(9);
- combos->addWidget(to,1);
- combos->addSpacing(9);
- combos->addWidget(searchButton,0);
- layout->addSpacing(12);
- layout->addLayout(combos);
+ //COMBOBOXES
+ QHBoxLayout *combos = new QHBoxLayout();
+ from = new QComboBox(this);
+ to = new QComboBox(this);
+ QString comboBoxStyle = "QComboBox {border:none;background:#2a2a2a;color:white;font-size:12px;font-family:Arial;padding-left:8px;}"
+ "QComboBox::down-arrow {image: url(:/images/dropDownArrow.png);}"
+ "QComboBox::drop-down {border:none; padding-right:10px;}"
+ "QComboBox QAbstractItemView {border: none; background:#272727; color:white; selection-background-color: #202020; outline:none;}"
+ "QComboBox QAbstractItemView::item {padding-left:8px;}" +
+ scrollBarStyle;
+ from->setStyleSheet(comboBoxStyle);
+ to->setStyleSheet(comboBoxStyle);
+ from->setFixedHeight(22);
+ to->setFixedHeight(22);
+ QLabel *arrow = new QLabel(this);
+ QPixmap arrowPixmap(":/images/fromTo.png");
+ arrow->setPixmap(arrowPixmap);
+ QPushButton *searchButton = new QPushButton(this);
+ searchButton->setIcon(QIcon(":/images/translatorSearch.png"));
+ searchButton->setStyleSheet("QPushButton {border:none; background:#2a2a2a;}");
+ searchButton->setFixedSize(22, 22);
+ combos->addWidget(from, 1);
+ combos->addSpacing(9);
+ combos->addWidget(arrow, 0);
+ combos->addSpacing(9);
+ combos->addWidget(to, 1);
+ combos->addSpacing(9);
+ combos->addWidget(searchButton, 0);
+ layout->addSpacing(12);
+ layout->addLayout(combos);
+ //RESULTS
+ QHBoxLayout *resultsTitleLayout = new QHBoxLayout();
+ resultsTitle = new QLabel(tr("Translation"));
+ resultsTitle->setStyleSheet("QLabel {font-family:Arial;font-size:14px;color:#e3e3e3;}");
+ speakButton = new QPushButton(this);
+ speakButton->setStyleSheet("QPushButton {border:none;}");
+ speakButton->setIcon(QIcon(":/images/speaker.png"));
+ resultsTitleLayout->addWidget(resultsTitle, 0, Qt::AlignVCenter);
+ resultsTitleLayout->addSpacing(10);
+ resultsTitleLayout->addWidget(speakButton, 0, Qt::AlignVCenter);
+ resultsTitleLayout->addStretch();
- //RESULTS
- QHBoxLayout * resultsTitleLayout = new QHBoxLayout();
- resultsTitle = new QLabel(tr("Translation"));
- resultsTitle->setStyleSheet("QLabel {font-family:Arial;font-size:14px;color:#e3e3e3;}");
- speakButton = new QPushButton(this);
- speakButton->setStyleSheet("QPushButton {border:none;}");
- speakButton->setIcon(QIcon(":/images/speaker.png"));
- resultsTitleLayout->addWidget(resultsTitle,0,Qt::AlignVCenter);
- resultsTitleLayout->addSpacing(10);
- resultsTitleLayout->addWidget(speakButton,0,Qt::AlignVCenter);
- resultsTitleLayout->addStretch();
+ layout->addSpacing(15);
+ layout->addLayout(resultsTitleLayout);
+ layout->addSpacing(12);
- layout->addSpacing(15);
- layout->addLayout(resultsTitleLayout);
- layout->addSpacing(12);
+ resultText = new QLabel();
+ resultText->setWordWrap(true);
+ resultText->setStyleSheet("QLabel {color:white;font-size:12px;}");
+ resultText->setText("ñlkas lakj dflkaj lasd jflie lkajd fie kljads ijef lasei afsliej ljse f");
+ layout->addWidget(resultText);
- resultText = new QLabel();
- resultText->setWordWrap(true);
- resultText->setStyleSheet("QLabel {color:white;font-size:12px;}");
- resultText->setText("ñlkas lakj dflkaj lasd jflie lkajd fie kljads ijef lasei afsliej ljse f");
- layout->addWidget(resultText);
+ layout->addStretch();
- layout->addStretch();
+ //CLEAR BUTTON
+ clearButton = new QPushButton(tr("clear"));
+ layout->addWidget(clearButton, 0, Qt::AlignRight);
+ clearButton->setMinimumWidth(95);
+ clearButton->setStyleSheet("QPushButton {border:1px solid #212121; background:#2a2a2a; color:white; font-family:Arial; font-size:12px; padding-top:5px; padding-bottom:5px;}");
- //CLEAR BUTTON
- clearButton = new QPushButton(tr("clear"));
- layout->addWidget(clearButton,0,Qt::AlignRight);
- clearButton->setMinimumWidth(95);
- clearButton->setStyleSheet("QPushButton {border:1px solid #212121; background:#2a2a2a; color:white; font-family:Arial; font-size:12px; padding-top:5px; padding-bottom:5px;}");
+ resize(400, 479);
- resize(400,479);
+ layout->setMargin(0);
+ layout->setContentsMargins(18, 12, 18, 12);
+ setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
- layout->setMargin(0);
- layout->setContentsMargins(18,12,18,12);
- setContentsMargins(0,0,0,0);
- layout->setSpacing(0);
+ hideResults();
+ populateCombos();
- hideResults();
- populateCombos();
+ busyIndicator = new YACReaderBusyWidget(this);
+ busyIndicator->move((this->width() - busyIndicator->width()) / 2, (this->height() - busyIndicator->height()) * 2 / 3);
+ busyIndicator->hide();
- busyIndicator = new YACReaderBusyWidget(this);
- busyIndicator->move((this->width()-busyIndicator->width())/2,(this->height()-busyIndicator->height())*2/3);
- busyIndicator->hide();
+ show();
- show();
+ connect(searchButton, SIGNAL(pressed()), this, SLOT(translate()));
+ connect(speakButton, SIGNAL(pressed()), this, SLOT(play()));
+ connect(clearButton, SIGNAL(pressed()), this, SLOT(clear()));
- connect(searchButton,SIGNAL(pressed()),this,SLOT(translate()));
- connect(speakButton,SIGNAL(pressed()),this,SLOT(play()));
- connect(clearButton,SIGNAL(pressed()),this,SLOT(clear()));
-
- //multimedia/phonon
+ //multimedia/phonon
#if QT_VERSION >= 0x050000
- player = new QMediaPlayer;
+ player = new QMediaPlayer;
#else
- music = createPlayer(MusicCategory);
+ music = createPlayer(MusicCategory);
#endif
-
}
void YACReaderTranslator::hideResults()
{
- resultsTitle->setHidden(true);
- speakButton->setHidden(true);
- resultText->setHidden(true);
+ resultsTitle->setHidden(true);
+ speakButton->setHidden(true);
+ resultText->setHidden(true);
}
void YACReaderTranslator::clear()
{
- hideResults();
- text->clear();
+ hideResults();
+ text->clear();
}
void YACReaderTranslator::translate()
{
- QString text = this->text->toPlainText();
- if(text.isEmpty())
- return;
- QString from = this->from->itemData(this->from->currentIndex()).toString();
- QString to = this->to->itemData(this->to->currentIndex()).toString();
+ QString text = this->text->toPlainText();
+ if (text.isEmpty())
+ return;
+ QString from = this->from->itemData(this->from->currentIndex()).toString();
+ QString to = this->to->itemData(this->to->currentIndex()).toString();
- TranslationLoader * translationLoader = new TranslationLoader(text,from,to);
- connect(translationLoader,SIGNAL(requestFinished(QString)),this,SLOT(setTranslation(QString)));
- connect(translationLoader,SIGNAL(error()),this,SLOT(error()));
- connect(translationLoader,SIGNAL(timeOut()),this,SLOT(error()));
- connect(translationLoader,SIGNAL(finished()),translationLoader,SLOT(deleteLater()));
+ TranslationLoader *translationLoader = new TranslationLoader(text, from, to);
+ connect(translationLoader, SIGNAL(requestFinished(QString)), this, SLOT(setTranslation(QString)));
+ connect(translationLoader, SIGNAL(error()), this, SLOT(error()));
+ connect(translationLoader, SIGNAL(timeOut()), this, SLOT(error()));
+ connect(translationLoader, SIGNAL(finished()), translationLoader, SLOT(deleteLater()));
- TextToSpeachLoader * tts = new TextToSpeachLoader(text,from);
- connect(tts,SIGNAL(requestFinished(QUrl)),this,SLOT(setSpeak(QUrl)));
- connect(tts,SIGNAL(error()),this,SLOT(error()));
- connect(tts,SIGNAL(timeOut()),this,SLOT(error()));
- connect(tts,SIGNAL(finished()),tts,SLOT(deleteLater()));
+ TextToSpeachLoader *tts = new TextToSpeachLoader(text, from);
+ connect(tts, SIGNAL(requestFinished(QUrl)), this, SLOT(setSpeak(QUrl)));
+ connect(tts, SIGNAL(error()), this, SLOT(error()));
+ connect(tts, SIGNAL(timeOut()), this, SLOT(error()));
+ connect(tts, SIGNAL(finished()), tts, SLOT(deleteLater()));
- translationLoader->start();
- tts->start();
+ translationLoader->start();
+ tts->start();
- resultsTitle->setText(tr("Translation"));
+ resultsTitle->setText(tr("Translation"));
- hideResults();
+ hideResults();
- busyIndicator->show();
+ busyIndicator->show();
}
void YACReaderTranslator::error()
{
- resultsTitle->setText(tr("Service not available"));
- resultsTitle->setHidden(false);
- busyIndicator->hide();
+ resultsTitle->setText(tr("Service not available"));
+ resultsTitle->setHidden(false);
+ busyIndicator->hide();
}
-void YACReaderTranslator::setSpeak(const QUrl & url)
+void YACReaderTranslator::setSpeak(const QUrl &url)
{
- resultsTitle->setHidden(false);
- speakButton->setHidden(false);
+ resultsTitle->setHidden(false);
+ speakButton->setHidden(false);
- ttsSource = url;
+ ttsSource = url;
}
-void YACReaderTranslator::setTranslation(const QString & string)
+void YACReaderTranslator::setTranslation(const QString &string)
{
- resultText->setText(string);
+ resultText->setText(string);
- resultsTitle->setHidden(false);
- resultText->setHidden(false);
- busyIndicator->hide();
+ resultsTitle->setHidden(false);
+ resultText->setHidden(false);
+ busyIndicator->hide();
}
void YACReaderTranslator::populateCombos()
{
- QList combos;
- combos.append(from);
- combos.append(to);
+ QList combos;
+ combos.append(from);
+ combos.append(to);
- for(int i=0;iaddItem("Arabic","ar");
- combo->addItem("Bulgarian","bg");
- combo->addItem("Catalan","ca");
- combo->addItem("Chinese Simplified","zh-CHS");
- combo->addItem("Chinese Traditional","zh-CHT");
- combo->addItem("Czech","cs");
- combo->addItem("Danish","da");
- combo->addItem("Dutch","nl");
- combo->addItem("English","en");
- combo->addItem("Estonian","et");
- combo->addItem("Finnish","fi");
- combo->addItem("French","fr");
- combo->addItem("German","de");
- combo->addItem("Greek","el");
- combo->addItem("Haitian Creole","ht");
- combo->addItem("Hebrew","he");
- combo->addItem("Hindi","hi");
- combo->addItem("Hungarian","hu");
- combo->addItem("Indonesian","id");
- combo->addItem("Italian","it");
- combo->addItem("Japanese","ja");
- combo->addItem("Korean","ko");
- combo->addItem("Latvian","lv");
- combo->addItem("Lithuanian","lt");
- combo->addItem("Norwegian","no");
- combo->addItem("Polish","pl");
- combo->addItem("Portuguese","pt");
- combo->addItem("Romanian","ro");
- combo->addItem("Russian","ru");
- combo->addItem("Slovak","sk");
- combo->addItem("Slovenian","sl");
- combo->addItem("Spanish","es");
- combo->addItem("Swedish","sv");
- combo->addItem("Thai","th");
- combo->addItem("Turkish","tr");
- combo->addItem("Ukrainian","uk");
- combo->addItem("Vietnamese","vi");
- }
- from->setCurrentIndex(from->findText("English"));
- to->setCurrentIndex(from->findText("Spanish"));
+ for (int i = 0; i < combos.count(); i++) {
+ QComboBox *combo = combos.at(i);
+ combo->addItem("Arabic", "ar");
+ combo->addItem("Bulgarian", "bg");
+ combo->addItem("Catalan", "ca");
+ combo->addItem("Chinese Simplified", "zh-CHS");
+ combo->addItem("Chinese Traditional", "zh-CHT");
+ combo->addItem("Czech", "cs");
+ combo->addItem("Danish", "da");
+ combo->addItem("Dutch", "nl");
+ combo->addItem("English", "en");
+ combo->addItem("Estonian", "et");
+ combo->addItem("Finnish", "fi");
+ combo->addItem("French", "fr");
+ combo->addItem("German", "de");
+ combo->addItem("Greek", "el");
+ combo->addItem("Haitian Creole", "ht");
+ combo->addItem("Hebrew", "he");
+ combo->addItem("Hindi", "hi");
+ combo->addItem("Hungarian", "hu");
+ combo->addItem("Indonesian", "id");
+ combo->addItem("Italian", "it");
+ combo->addItem("Japanese", "ja");
+ combo->addItem("Korean", "ko");
+ combo->addItem("Latvian", "lv");
+ combo->addItem("Lithuanian", "lt");
+ combo->addItem("Norwegian", "no");
+ combo->addItem("Polish", "pl");
+ combo->addItem("Portuguese", "pt");
+ combo->addItem("Romanian", "ro");
+ combo->addItem("Russian", "ru");
+ combo->addItem("Slovak", "sk");
+ combo->addItem("Slovenian", "sl");
+ combo->addItem("Spanish", "es");
+ combo->addItem("Swedish", "sv");
+ combo->addItem("Thai", "th");
+ combo->addItem("Turkish", "tr");
+ combo->addItem("Ukrainian", "uk");
+ combo->addItem("Vietnamese", "vi");
+ }
+ from->setCurrentIndex(from->findText("English"));
+ to->setCurrentIndex(from->findText("Spanish"));
}
void YACReaderTranslator::play()
{
- //QMessageBox::question(this,"xxx",ttsSource.toString());
+ //QMessageBox::question(this,"xxx",ttsSource.toString());
#if QT_VERSION >= 0x050000
- player->setMedia(ttsSource);
- player->play();
+ player->setMedia(ttsSource);
+ player->play();
#else
- MediaSource src(ttsSource);
- src.setAutoDelete(true);
- music->setCurrentSource(src);
- music->play();
+ MediaSource src(ttsSource);
+ src.setAutoDelete(true);
+ music->setCurrentSource(src);
+ music->play();
#endif
}
@@ -309,31 +306,30 @@ YACReaderTranslator::~YACReaderTranslator()
{
#if QT_VERSION >= 0x050000
#else
- delete music;
+ delete music;
#endif
}
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
{
- QPoint p = mapTo(this,event->pos());
- if(p.y() < 40)
- {
- drag = true;
- click = event->pos();
- }
+ QPoint p = mapTo(this, event->pos());
+ if (p.y() < 40) {
+ drag = true;
+ click = event->pos();
+ }
}
void YACReaderTranslator::mouseReleaseEvent(QMouseEvent *event)
{
- drag = false;
- event->accept();
+ drag = false;
+ event->accept();
}
-void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event)
+void YACReaderTranslator::mouseMoveEvent(QMouseEvent *event)
{
- if(drag)
- this->move(QPoint(mapToParent(event->pos())-click));
- event->accept();
+ if (drag)
+ this->move(QPoint(mapToParent(event->pos()) - click));
+ event->accept();
}
//---------------------------------------------------------------------------
@@ -341,89 +337,83 @@ void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event)
//---------------------------------------------------------------------------
TranslationLoader::TranslationLoader(QString text, QString from, QString to)
- :QThread(),text(text),from(from),to(to)
+ : QThread(), text(text), from(from), to(to)
{
}
void TranslationLoader::run()
{
- QNetworkAccessManager manager;
- QEventLoop q;
- QTimer tT;
+ QNetworkAccessManager manager;
+ QEventLoop q;
+ QTimer tT;
- tT.setSingleShot(true);
- connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
- connect(&manager, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
+ tT.setSingleShot(true);
+ connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
+ connect(&manager, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit()));
- QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appid=%1&from=%2&to=%3&text=%4&contentType=text/plain";
- url = url.arg(APPID).arg(from).arg(to).arg(text);
+ QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appid=%1&from=%2&to=%3&text=%4&contentType=text/plain";
+ url = url.arg(APPID).arg(from).arg(to).arg(text);
- QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
+ QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
- tT.start(5000); // 5s timeout
- q.exec();
+ tT.start(5000); // 5s timeout
+ q.exec();
- if(tT.isActive()){
- // download complete
- if(reply->error() == QNetworkReply::NoError)
- {
- QString utf8 = QString::fromUtf8(reply->readAll());
- utf8 = utf8.remove(0,1);
- utf8 = utf8.remove(utf8.count()-1,1);
+ if (tT.isActive()) {
+ // download complete
+ if (reply->error() == QNetworkReply::NoError) {
+ QString utf8 = QString::fromUtf8(reply->readAll());
+ utf8 = utf8.remove(0, 1);
+ utf8 = utf8.remove(utf8.count() - 1, 1);
- QString translated(utf8);
- emit(requestFinished(translated));
- }
- else
- emit(error());
- } else {
- emit(timeOut());
- }
+ QString translated(utf8);
+ emit(requestFinished(translated));
+ } else
+ emit(error());
+ } else {
+ emit(timeOut());
+ }
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-
TextToSpeachLoader::TextToSpeachLoader(QString text, QString language)
- :QThread(),text(text),language(language)
+ : QThread(), text(text), language(language)
{
}
-
void TextToSpeachLoader::run()
{
- QNetworkAccessManager manager;
- QEventLoop q;
- QTimer tT;
+ QNetworkAccessManager manager;
+ QEventLoop q;
+ QTimer tT;
- tT.setSingleShot(true);
- connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
- connect(&manager, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
+ tT.setSingleShot(true);
+ connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
+ connect(&manager, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit()));
- QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appid=%1&language=%2&text=%3&contentType=text/plain";
- url = url.arg(APPID).arg(language).arg(text);
+ QString url = "http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appid=%1&language=%2&text=%3&contentType=text/plain";
+ url = url.arg(APPID).arg(language).arg(text);
- QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
+ QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));
- tT.start(5000); // 5s timeout
- q.exec();
+ tT.start(5000); // 5s timeout
+ q.exec();
- if(tT.isActive()){
- // download complete
- if(reply->error() == QNetworkReply::NoError)
- {
- QString utf8 = QString::fromUtf8(reply->readAll());
- utf8 = utf8.remove(0,1);
- utf8 = utf8.remove(utf8.count()-1,1);
- utf8 = utf8.replace("\\","");
+ if (tT.isActive()) {
+ // download complete
+ if (reply->error() == QNetworkReply::NoError) {
+ QString utf8 = QString::fromUtf8(reply->readAll());
+ utf8 = utf8.remove(0, 1);
+ utf8 = utf8.remove(utf8.count() - 1, 1);
+ utf8 = utf8.replace("\\", "");
- emit(requestFinished(QUrl(utf8)));
- }
- else
- emit(error());
- } else {
- emit(timeOut());
- }
+ emit(requestFinished(QUrl(utf8)));
+ } else
+ emit(error());
+ } else {
+ emit(timeOut());
+ }
}
diff --git a/YACReader/translator.h b/YACReader/translator.h
index c6acaea5..50596283 100644
--- a/YACReader/translator.h
+++ b/YACReader/translator.h
@@ -1,7 +1,7 @@
#ifndef __TRANSLATOR_H
#define __TRANSLATOR_H
-
-class QUrl;
+
+class QUrl;
class QMouseEvent;
class QPoint;
class QTextEdit;
@@ -15,88 +15,87 @@ class YACReaderBusyWidget;
#include
#if QT_VERSION >= 0x050000
- class QMediaPlayer;
+class QMediaPlayer;
#else
- #include
- using namespace Phonon;
+#include
+using namespace Phonon;
#endif
-
-
class YACReaderTranslator : public QWidget
{
- Q_OBJECT
- public:
- YACReaderTranslator(QWidget * parent = 0);
- ~YACReaderTranslator();
+ Q_OBJECT
+public:
+ YACReaderTranslator(QWidget *parent = 0);
+ ~YACReaderTranslator();
- public slots:
- void play();
+public slots:
+ void play();
- protected slots:
- void translate();
- void setSpeak(const QUrl & url);
- void setTranslation(const QString & string);
- void error();
- void clear();
+protected slots:
+ void translate();
+ void setSpeak(const QUrl &url);
+ void setTranslation(const QString &string);
+ void error();
+ void clear();
protected:
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent ( QMouseEvent * event );
- void hideResults();
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void hideResults();
+
+ void populateCombos();
+ bool drag;
+ QPoint click;
- void populateCombos();
- bool drag;
- QPoint click;
private:
-
#if QT_VERSION >= 0x050000
- QMediaPlayer *player;
+ QMediaPlayer *player;
#else
- MediaObject * music;
+ MediaObject *music;
#endif
- QTextEdit * text;
- QComboBox * from;
- QComboBox * to;
- QLabel * resultsTitle;
- QPushButton * speakButton;
- QLabel * resultText;
- YACReaderBusyWidget * busyIndicator;
- QUrl ttsSource;
- QPushButton * clearButton;
-
+ QTextEdit *text;
+ QComboBox *from;
+ QComboBox *to;
+ QLabel *resultsTitle;
+ QPushButton *speakButton;
+ QLabel *resultText;
+ YACReaderBusyWidget *busyIndicator;
+ QUrl ttsSource;
+ QPushButton *clearButton;
};
class TranslationLoader : public QThread
{
- Q_OBJECT
+ Q_OBJECT
public:
- TranslationLoader(QString text, QString from, QString to);
+ TranslationLoader(QString text, QString from, QString to);
signals:
- void requestFinished(QString);
- void timeOut();
- void error();
+ void requestFinished(QString);
+ void timeOut();
+ void error();
+
private:
- QString text;
- QString from;
- QString to;
- void run();
+ QString text;
+ QString from;
+ QString to;
+ void run();
};
class TextToSpeachLoader : public QThread
{
- Q_OBJECT
+ Q_OBJECT
public:
- TextToSpeachLoader(QString text, QString language);
+ TextToSpeachLoader(QString text, QString language);
signals:
- void requestFinished(QUrl);
- void timeOut();
- void error();
+ void requestFinished(QUrl);
+ void timeOut();
+ void error();
+
private:
- QString text;
- QString language;
- void run();
+ QString text;
+ QString language;
+ void run();
};
#endif
diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp
index 599bd201..30839bef 100644
--- a/YACReader/viewer.cpp
+++ b/YACReader/viewer.cpp
@@ -22,768 +22,692 @@
#include
-Viewer::Viewer(QWidget * parent)
- :QScrollArea(parent),
- fullscreen(false),
- information(false),
- doublePage(false),
- doubleMangaPage(false),
- zoom(100),
- currentPage(0),
- wheelStop(false),
- direction(1),
- drag(false),
- numScrollSteps(22),
- shouldOpenNext(false),
- shouldOpenPrevious(false),
- magnifyingGlassShowed(false),
- restoreMagnifyingGlass(false)
+Viewer::Viewer(QWidget *parent)
+ : QScrollArea(parent),
+ fullscreen(false),
+ information(false),
+ doublePage(false),
+ doubleMangaPage(false),
+ zoom(100),
+ currentPage(0),
+ wheelStop(false),
+ direction(1),
+ drag(false),
+ numScrollSteps(22),
+ shouldOpenNext(false),
+ shouldOpenPrevious(false),
+ magnifyingGlassShowed(false),
+ restoreMagnifyingGlass(false)
{
- translator = new YACReaderTranslator(this);
- translator->hide();
- translatorAnimation = new QPropertyAnimation(translator,"pos");
- translatorAnimation->setDuration(150);
- translatorXPos = -10000;
- translator->move(-translator->width(),10);
- //current comic page
- content = new QLabel(this);
- configureContent(tr("Press 'O' to open comic."));
- //scroll area configuration
- setBackgroundRole(QPalette::Dark);
- setWidget(content);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setFrameStyle(QFrame::NoFrame);
- setAlignment(Qt::AlignCenter);
+ translator = new YACReaderTranslator(this);
+ translator->hide();
+ translatorAnimation = new QPropertyAnimation(translator, "pos");
+ translatorAnimation->setDuration(150);
+ translatorXPos = -10000;
+ translator->move(-translator->width(), 10);
+ //current comic page
+ content = new QLabel(this);
+ configureContent(tr("Press 'O' to open comic."));
+ //scroll area configuration
+ setBackgroundRole(QPalette::Dark);
+ setWidget(content);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setFrameStyle(QFrame::NoFrame);
+ setAlignment(Qt::AlignCenter);
- QPalette palette;
- palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
- setPalette(palette);
- //---------------------------------------
- mglass = new MagnifyingGlass(Configuration::getConfiguration().getMagnifyingGlassSize(),this);
- mglass->hide();
- content->setMouseTracking(true);
- setMouseTracking(true);
+ QPalette palette;
+ palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
+ setPalette(palette);
+ //---------------------------------------
+ mglass = new MagnifyingGlass(Configuration::getConfiguration().getMagnifyingGlassSize(), this);
+ mglass->hide();
+ content->setMouseTracking(true);
+ setMouseTracking(true);
- showCursor();
+ showCursor();
- goToDialog = new GoToDialog(this);
+ goToDialog = new GoToDialog(this);
- QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
+ QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
- //CONFIG GOTO_FLOW--------------------------------------------------------
+ //CONFIG GOTO_FLOW--------------------------------------------------------
#ifndef NO_OPENGL
- OpenGLChecker openGLChecker;
- bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
+ OpenGLChecker openGLChecker;
+ bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
- if(openGLAvailable && !settings->contains(USE_OPEN_GL))
- settings->setValue(USE_OPEN_GL,2);
- else
- if(!openGLAvailable)
- settings->setValue(USE_OPEN_GL,0);
+ if (openGLAvailable && !settings->contains(USE_OPEN_GL))
+ settings->setValue(USE_OPEN_GL, 2);
+ else if (!openGLAvailable)
+ settings->setValue(USE_OPEN_GL, 0);
- if((settings->value(USE_OPEN_GL).toBool() == true))
- goToFlow = new GoToFlowGL(this,Configuration::getConfiguration().getFlowType());
- else
- goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType());
+ if ((settings->value(USE_OPEN_GL).toBool() == true))
+ goToFlow = new GoToFlowGL(this, Configuration::getConfiguration().getFlowType());
+ else
+ goToFlow = new GoToFlow(this, Configuration::getConfiguration().getFlowType());
#else
- goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType());
+ goToFlow = new GoToFlow(this, Configuration::getConfiguration().getFlowType());
#endif
- goToFlow->setFocusPolicy(Qt::StrongFocus);
- goToFlow->hide();
- showGoToFlowAnimation = new QPropertyAnimation(goToFlow,"pos");
- showGoToFlowAnimation->setDuration(150);
+ goToFlow->setFocusPolicy(Qt::StrongFocus);
+ goToFlow->hide();
+ showGoToFlowAnimation = new QPropertyAnimation(goToFlow, "pos");
+ showGoToFlowAnimation->setDuration(150);
- bd = new BookmarksDialog(this->parentWidget());
+ bd = new BookmarksDialog(this->parentWidget());
- render = new Render();
+ render = new Render();
- hideCursorTimer = new QTimer();
- hideCursorTimer->setSingleShot(true);
+ hideCursorTimer = new QTimer();
+ hideCursorTimer->setSingleShot(true);
- if(Configuration::getConfiguration().getDoublePage())
- doublePageSwitch();
+ if (Configuration::getConfiguration().getDoublePage())
+ doublePageSwitch();
- if(Configuration::getConfiguration().getDoubleMangaPage())
- doubleMangaPageSwitch();
+ if (Configuration::getConfiguration().getDoubleMangaPage())
+ doubleMangaPageSwitch();
- createConnections();
+ createConnections();
- hideCursorTimer->start(2500);
+ hideCursorTimer->start(2500);
- setMouseTracking(true);
+ setMouseTracking(true);
- //animations
- verticalScroller = new QPropertyAnimation(verticalScrollBar(), "sliderPosition");
- connect(verticalScroller,SIGNAL(valueChanged (const QVariant &)),this,SIGNAL(backgroundChanges()));
- horizontalScroller = new QPropertyAnimation(horizontalScrollBar(), "sliderPosition");
- connect(horizontalScroller,SIGNAL(valueChanged (const QVariant &)),this,SIGNAL(backgroundChanges()));
- groupScroller = new QParallelAnimationGroup();
- groupScroller->addAnimation(verticalScroller);
- groupScroller->addAnimation(horizontalScroller);
+ //animations
+ verticalScroller = new QPropertyAnimation(verticalScrollBar(), "sliderPosition");
+ connect(verticalScroller, SIGNAL(valueChanged(const QVariant &)), this, SIGNAL(backgroundChanges()));
+ horizontalScroller = new QPropertyAnimation(horizontalScrollBar(), "sliderPosition");
+ connect(horizontalScroller, SIGNAL(valueChanged(const QVariant &)), this, SIGNAL(backgroundChanges()));
+ groupScroller = new QParallelAnimationGroup();
+ groupScroller->addAnimation(verticalScroller);
+ groupScroller->addAnimation(horizontalScroller);
- notificationsLabel = new NotificationsLabelWidget(this);
- notificationsLabel->hide();
+ notificationsLabel = new NotificationsLabelWidget(this);
+ notificationsLabel->hide();
- informationLabel = new PageLabelWidget(this);
+ informationLabel = new PageLabelWidget(this);
- setAcceptDrops(true);
+ setAcceptDrops(true);
}
Viewer::~Viewer()
{
- delete render;
- delete goToFlow;
- delete translator;
- delete translatorAnimation;
- delete content;
- delete hideCursorTimer;
- delete informationLabel;
- delete verticalScroller;
- delete horizontalScroller;
- delete groupScroller;
- delete bd;
- delete notificationsLabel;
- delete mglass;
- if(currentPage != 0)
- delete currentPage;
+ delete render;
+ delete goToFlow;
+ delete translator;
+ delete translatorAnimation;
+ delete content;
+ delete hideCursorTimer;
+ delete informationLabel;
+ delete verticalScroller;
+ delete horizontalScroller;
+ delete groupScroller;
+ delete bd;
+ delete notificationsLabel;
+ delete mglass;
+ if (currentPage != 0)
+ delete currentPage;
}
void Viewer::createConnections()
{
- //magnifyingGlass (update mg after a background change
- connect(this,SIGNAL(backgroundChanges()),mglass,SLOT(updateImage()));
+ //magnifyingGlass (update mg after a background change
+ connect(this, SIGNAL(backgroundChanges()), mglass, SLOT(updateImage()));
- //goToDialog
- connect(goToDialog,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
+ //goToDialog
+ connect(goToDialog, SIGNAL(goToPage(unsigned int)), this, SLOT(goTo(unsigned int)));
- //goToFlow goTo
- connect(goToFlow,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
+ //goToFlow goTo
+ connect(goToFlow, SIGNAL(goToPage(unsigned int)), this, SLOT(goTo(unsigned int)));
- //current time
- QTimer * t = new QTimer();
- connect(t,SIGNAL(timeout()),this,SLOT(updateInformation()));
- t->start(1000);
+ //current time
+ QTimer *t = new QTimer();
+ connect(t, SIGNAL(timeout()), this, SLOT(updateInformation()));
+ t->start(1000);
- //hide cursor
- connect(hideCursorTimer,SIGNAL(timeout()),this,SLOT(hideCursor()));
+ //hide cursor
+ connect(hideCursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor()));
- //bookmarks
- connect(bd,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int)));
+ //bookmarks
+ connect(bd, SIGNAL(goToPage(unsigned int)), this, SLOT(goTo(unsigned int)));
- //render
- connect(render,SIGNAL(errorOpening()),this,SLOT(resetContent()));
- connect(render,SIGNAL(errorOpening()),this,SLOT(showMessageErrorOpening()));
- connect(render,SIGNAL(errorOpening(QString)),this,SLOT(showMessageErrorOpening(QString)));
- connect(render,SIGNAL(crcError(QString)),this,SLOT(processCRCError(QString)));
- connect(render,SIGNAL(numPages(unsigned int)),goToFlow,SLOT(setNumSlides(unsigned int)));
- connect(render,SIGNAL(numPages(unsigned int)),goToDialog,SLOT(setNumPages(unsigned int)));
- //connect(render,SIGNAL(numPages(unsigned int)),this,SLOT(updateInformation()));
- connect(render,SIGNAL(imageLoaded(int,QByteArray)),goToFlow,SLOT(setImageReady(int,QByteArray)));
- connect(render,SIGNAL(currentPageReady()),this,SLOT(updatePage()));
- connect(render,SIGNAL(processingPage()),this,SLOT(setLoadingMessage()));
- connect(render,SIGNAL(currentPageIsBookmark(bool)),this,SIGNAL(pageIsBookmark(bool)));
- connect(render,SIGNAL(pageChanged(int)),this,SLOT(updateInformation()));
- //connect(render,SIGNAL(bookmarksLoaded(Bookmarks)),this,SLOT(setBookmarks(Bookmarks)));
+ //render
+ connect(render, SIGNAL(errorOpening()), this, SLOT(resetContent()));
+ connect(render, SIGNAL(errorOpening()), this, SLOT(showMessageErrorOpening()));
+ connect(render, SIGNAL(errorOpening(QString)), this, SLOT(showMessageErrorOpening(QString)));
+ connect(render, SIGNAL(crcError(QString)), this, SLOT(processCRCError(QString)));
+ connect(render, SIGNAL(numPages(unsigned int)), goToFlow, SLOT(setNumSlides(unsigned int)));
+ connect(render, SIGNAL(numPages(unsigned int)), goToDialog, SLOT(setNumPages(unsigned int)));
+ //connect(render,SIGNAL(numPages(unsigned int)),this,SLOT(updateInformation()));
+ connect(render, SIGNAL(imageLoaded(int, QByteArray)), goToFlow, SLOT(setImageReady(int, QByteArray)));
+ connect(render, SIGNAL(currentPageReady()), this, SLOT(updatePage()));
+ connect(render, SIGNAL(processingPage()), this, SLOT(setLoadingMessage()));
+ connect(render, SIGNAL(currentPageIsBookmark(bool)), this, SIGNAL(pageIsBookmark(bool)));
+ connect(render, SIGNAL(pageChanged(int)), this, SLOT(updateInformation()));
+ //connect(render,SIGNAL(bookmarksLoaded(Bookmarks)),this,SLOT(setBookmarks(Bookmarks)));
- connect(render,SIGNAL(isLast()),this,SLOT(showIsLastMessage()));
- connect(render,SIGNAL(isCover()),this,SLOT(showIsCoverMessage()));
+ connect(render, SIGNAL(isLast()), this, SLOT(showIsLastMessage()));
+ connect(render, SIGNAL(isCover()), this, SLOT(showIsCoverMessage()));
- connect(render,SIGNAL(bookmarksUpdated()),this,SLOT(setBookmarks()));
+ connect(render, SIGNAL(bookmarksUpdated()), this, SLOT(setBookmarks()));
}
//Deprecated
void Viewer::prepareForOpening()
{
- if(render->hasLoadedComic())
- save();
- //bd->setBookmarks(*bm);
+ if (render->hasLoadedComic())
+ save();
+ //bd->setBookmarks(*bm);
- goToFlow->reset();
+ goToFlow->reset();
- //render->update();
+ //render->update();
- verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
+ verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
- if(Configuration::getConfiguration().getShowInformation() && !information)
- {
- QTimer * timer = new QTimer();
- connect(timer,SIGNAL(timeout()),this,SLOT(informationSwitch()));
- connect(timer,SIGNAL(timeout()),timer,SLOT(deleteLater()));
- timer->start();
- }
+ if (Configuration::getConfiguration().getShowInformation() && !information) {
+ QTimer *timer = new QTimer();
+ connect(timer, SIGNAL(timeout()), this, SLOT(informationSwitch()));
+ connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
+ timer->start();
+ }
- informationLabel->setText("...");
+ informationLabel->setText("...");
}
void Viewer::open(QString pathFile, int atPage)
{
- prepareForOpening();
- render->load(pathFile, atPage);
+ prepareForOpening();
+ render->load(pathFile, atPage);
}
-void Viewer::open(QString pathFile, const ComicDB & comic)
+void Viewer::open(QString pathFile, const ComicDB &comic)
{
- prepareForOpening();
- render->load(pathFile, comic);
+ prepareForOpening();
+ render->load(pathFile, comic);
}
void Viewer::showMessageErrorOpening()
{
- QMessageBox::critical(this,tr("Not found"),tr("Comic not found"));
- //resetContent(); --> not needed
+ QMessageBox::critical(this, tr("Not found"), tr("Comic not found"));
+ //resetContent(); --> not needed
}
void Viewer::showMessageErrorOpening(QString message)
{
- QMessageBox::critical(this,tr("Error opening comic"),message);
- resetContent();
+ QMessageBox::critical(this, tr("Error opening comic"), message);
+ resetContent();
}
void Viewer::processCRCError(QString message)
{
- QMessageBox::critical(this,tr("CRC Error"),message);
+ QMessageBox::critical(this, tr("CRC Error"), message);
}
void Viewer::next()
{
- direction = 1;
- if (doublePage && render->currentPageIsDoublePage())
- {
- render->nextDoublePage();
- }
- else
- {
- render->nextPage();
- }
- updateInformation();
- shouldOpenPrevious = false;
+ direction = 1;
+ if (doublePage && render->currentPageIsDoublePage()) {
+ render->nextDoublePage();
+ } else {
+ render->nextPage();
+ }
+ updateInformation();
+ shouldOpenPrevious = false;
}
void Viewer::prev()
{
- direction = -1;
- if (doublePage && render->previousPageIsDoublePage())
- {
- render->previousDoublePage();
- }
- else
- {
- render->previousPage();
- }
- updateInformation();
- shouldOpenNext = false;
+ direction = -1;
+ if (doublePage && render->previousPageIsDoublePage()) {
+ render->previousDoublePage();
+ } else {
+ render->previousPage();
+ }
+ updateInformation();
+ shouldOpenNext = false;
}
void Viewer::showGoToDialog()
{
- goToDialog->open();
+ goToDialog->open();
}
void Viewer::goTo(unsigned int page)
{
- direction = 1; //in "go to" direction is always fordward
- render->goTo(page);
+ direction = 1; //in "go to" direction is always fordward
+ render->goTo(page);
}
void Viewer::updatePage()
{
- QPixmap * previousPage = currentPage;
- if (doublePage)
- {
- if (!doubleMangaPage)
- currentPage = render->getCurrentDoublePage();
- else
- {
- currentPage = render->getCurrentDoubleMangaPage();
- }
- if (currentPage == NULL)
- {
- currentPage = render->getCurrentPage();
- }
- }
- else
- {
- currentPage = render->getCurrentPage();
- }
- content->setPixmap(*currentPage);
- updateContentSize();
- updateVerticalScrollBar();
+ QPixmap *previousPage = currentPage;
+ if (doublePage) {
+ if (!doubleMangaPage)
+ currentPage = render->getCurrentDoublePage();
+ else {
+ currentPage = render->getCurrentDoubleMangaPage();
+ }
+ if (currentPage == NULL) {
+ currentPage = render->getCurrentPage();
+ }
+ } else {
+ currentPage = render->getCurrentPage();
+ }
+ content->setPixmap(*currentPage);
+ updateContentSize();
+ updateVerticalScrollBar();
- if(goToFlow->isHidden())
- setFocus(Qt::ShortcutFocusReason);
- else
- goToFlow->setFocus(Qt::OtherFocusReason);
- delete previousPage;
+ if (goToFlow->isHidden())
+ setFocus(Qt::ShortcutFocusReason);
+ else
+ goToFlow->setFocus(Qt::OtherFocusReason);
+ delete previousPage;
- if(currentPage->isNull())
- setPageUnavailableMessage();
+ if (currentPage->isNull())
+ setPageUnavailableMessage();
else
emit(pageAvailable(true));
emit backgroundChanges();
- if(restoreMagnifyingGlass)
- {
- restoreMagnifyingGlass = false;
- showMagnifyingGlass();
- }
-
+ if (restoreMagnifyingGlass) {
+ restoreMagnifyingGlass = false;
+ showMagnifyingGlass();
+ }
}
void Viewer::updateContentSize()
{
- //there is an image to resize
- if(currentPage !=0 && !currentPage->isNull())
- {
- QSize pagefit;
- YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode();
- switch (fitmode)
- {
- case YACReader::FitMode::FullRes:
- pagefit=currentPage->size();
- break;
- case YACReader::FitMode::ToWidth:
- pagefit=currentPage->size();
- pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding);
- break;
- case YACReader::FitMode::ToHeight:
- pagefit=currentPage->size();
- pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
- break;
- //if everything fails showing the full page is a good idea
- case YACReader::FitMode::FullPage:
- default:
- pagefit=currentPage->size();
- pagefit.scale(size(), Qt::KeepAspectRatio);
- break;
- }
+ //there is an image to resize
+ if (currentPage != 0 && !currentPage->isNull()) {
+ QSize pagefit;
+ YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode();
+ switch (fitmode) {
+ case YACReader::FitMode::FullRes:
+ pagefit = currentPage->size();
+ break;
+ case YACReader::FitMode::ToWidth:
+ pagefit = currentPage->size();
+ pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding);
+ break;
+ case YACReader::FitMode::ToHeight:
+ pagefit = currentPage->size();
+ pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
+ break;
+ //if everything fails showing the full page is a good idea
+ case YACReader::FitMode::FullPage:
+ default:
+ pagefit = currentPage->size();
+ pagefit.scale(size(), Qt::KeepAspectRatio);
+ break;
+ }
- if(zoom != 100)
- {
- pagefit.scale(floor(pagefit.width()*zoom/100.0f), 0, Qt::KeepAspectRatioByExpanding);
- }
- //apply scaling
- content->resize(pagefit);
+ if (zoom != 100) {
+ pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding);
+ }
+ //apply scaling
+ content->resize(pagefit);
- //TODO: updtateContentSize should only scale the pixmap once
- if(devicePixelRatio()>1)//only in retina display
- {
- QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
- page.setDevicePixelRatio(devicePixelRatio());
- content->setPixmap(page);
- }
+ //TODO: updtateContentSize should only scale the pixmap once
+ if (devicePixelRatio() > 1) //only in retina display
+ {
+ QPixmap page = currentPage->scaled(content->width() * devicePixelRatio(), content->height() * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ page.setDevicePixelRatio(devicePixelRatio());
+ content->setPixmap(page);
+ }
- emit backgroundChanges();
- }
- content->update(); //TODO, it shouldn't be neccesary
+ emit backgroundChanges();
+ }
+ content->update(); //TODO, it shouldn't be neccesary
}
void Viewer::increaseZoomFactor()
{
- zoom = std::min(zoom + 10, 500);
+ zoom = std::min(zoom + 10, 500);
- updateContentSize();
- notificationsLabel->setText(QString::number(getZoomFactor())+"%");
- notificationsLabel->flash();
+ updateContentSize();
+ notificationsLabel->setText(QString::number(getZoomFactor()) + "%");
+ notificationsLabel->flash();
- emit zoomUpdated(zoom);
+ emit zoomUpdated(zoom);
}
void Viewer::decreaseZoomFactor()
{
- zoom = std::max(zoom - 10, 30);
+ zoom = std::max(zoom - 10, 30);
- updateContentSize();
- notificationsLabel->setText(QString::number(getZoomFactor())+"%");
- notificationsLabel->flash();
+ updateContentSize();
+ notificationsLabel->setText(QString::number(getZoomFactor()) + "%");
+ notificationsLabel->flash();
- emit zoomUpdated(zoom);
+ emit zoomUpdated(zoom);
}
int Viewer::getZoomFactor()
{
- //this function is a placeholder for future refactoring work
- return zoom;
+ //this function is a placeholder for future refactoring work
+ return zoom;
}
void Viewer::setZoomFactor(int z)
{
- //this function is mostly used to reset the zoom after a fitmode switch
- if (z > 500)
- zoom = 500;
- else if (z < 30)
- zoom = 30;
- else
- zoom = z;
+ //this function is mostly used to reset the zoom after a fitmode switch
+ if (z > 500)
+ zoom = 500;
+ else if (z < 30)
+ zoom = 30;
+ else
+ zoom = z;
- emit zoomUpdated(zoom);
+ emit zoomUpdated(zoom);
}
void Viewer::updateVerticalScrollBar()
{
- if(direction > 0)
- verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
- else
- verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum());
+ if (direction > 0)
+ verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
+ else
+ verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum());
}
void Viewer::scrollDown()
{
- if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())
- {
- next();
- }
- else
- {
- int currentPos = verticalScrollBar()->sliderPosition();
- verticalScroller->setDuration(250);
- verticalScroller->setStartValue(currentPos);
- verticalScroller->setEndValue(nextPos);
+ if (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum()) {
+ next();
+ } else {
+ int currentPos = verticalScrollBar()->sliderPosition();
+ verticalScroller->setDuration(250);
+ verticalScroller->setStartValue(currentPos);
+ verticalScroller->setEndValue(nextPos);
- verticalScroller->start();
+ verticalScroller->start();
- emit backgroundChanges();
- }
+ emit backgroundChanges();
+ }
}
void Viewer::scrollUp()
{
- if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())
- {
- prev();
- }
- else
- {
- int currentPos = verticalScrollBar()->sliderPosition();
- verticalScroller->setDuration(250);
- verticalScroller->setStartValue(currentPos);
- verticalScroller->setEndValue(nextPos);
+ if (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum()) {
+ prev();
+ } else {
+ int currentPos = verticalScrollBar()->sliderPosition();
+ verticalScroller->setDuration(250);
+ verticalScroller->setStartValue(currentPos);
+ verticalScroller->setEndValue(nextPos);
- verticalScroller->start();
+ verticalScroller->start();
- emit backgroundChanges();
- }
+ emit backgroundChanges();
+ }
}
void Viewer::scrollForwardHorizontalFirst()
{
- if (!doubleMangaPage)
- {
- scrollZigzag(RIGHT, DOWN, true); // right->right->lower left->right->...->next page
- }
- else
- {
- scrollZigzag(LEFT, DOWN, true); // left->left->lower right->left->...->next page
- }
+ if (!doubleMangaPage) {
+ scrollZigzag(RIGHT, DOWN, true); // right->right->lower left->right->...->next page
+ } else {
+ scrollZigzag(LEFT, DOWN, true); // left->left->lower right->left->...->next page
+ }
}
void Viewer::scrollBackwardHorizontalFirst()
{
- if (!doubleMangaPage)
- {
- scrollZigzag(LEFT, UP, false); // left->left->upper right->left->...->prev page
- }
- else
- {
- scrollZigzag(RIGHT, UP, false); // right->right->upper left->right->...->prev page
- }
+ if (!doubleMangaPage) {
+ scrollZigzag(LEFT, UP, false); // left->left->upper right->left->...->prev page
+ } else {
+ scrollZigzag(RIGHT, UP, false); // right->right->upper left->right->...->prev page
+ }
}
void Viewer::scrollForwardVerticalFirst()
{
- if (!doubleMangaPage)
- {
- scrollZigzag(DOWN, RIGHT, true); // down->down->upper right->down->...->next page
- }
- else
- {
- scrollZigzag(DOWN, LEFT, true); // down->down->upper left->down->...->next page
- }
+ if (!doubleMangaPage) {
+ scrollZigzag(DOWN, RIGHT, true); // down->down->upper right->down->...->next page
+ } else {
+ scrollZigzag(DOWN, LEFT, true); // down->down->upper left->down->...->next page
+ }
}
void Viewer::scrollBackwardVerticalFirst()
{
- if (!doubleMangaPage)
- {
- scrollZigzag(UP, LEFT, false); // up->up->lower left->up->...->prev page
- }
- else
- {
- scrollZigzag(UP, RIGHT, false); // up->up->lower right->up->...->prev page
- }
+ if (!doubleMangaPage) {
+ scrollZigzag(UP, LEFT, false); // up->up->lower left->up->...->prev page
+ } else {
+ scrollZigzag(UP, RIGHT, false); // up->up->lower right->up->...->prev page
+ }
}
bool Viewer::isEdge(scrollDirection d)
{
- if(d == UP)
- return verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum();
- else if(d == DOWN)
- return verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum();
- else if(d == LEFT)
- return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->minimum();
- else // d == RIGHT
- return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->maximum();
+ if (d == UP)
+ return verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum();
+ else if (d == DOWN)
+ return verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum();
+ else if (d == LEFT)
+ return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->minimum();
+ else // d == RIGHT
+ return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->maximum();
}
void Viewer::scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward)
{
- if(!isEdge(d1))
- {
- if(d1 == UP)
- scrollTo(horizontalScrollBar()->sliderPosition(),
- verticalScrollBar()->sliderPosition()-static_cast((height()*0.80)));
- else if(d1 == DOWN)
- scrollTo(horizontalScrollBar()->sliderPosition(),
- verticalScrollBar()->sliderPosition()+static_cast((height()*0.80)));
- else if(d1 == LEFT)
- scrollTo(horizontalScrollBar()->sliderPosition()-static_cast((width()*0.80)),
- verticalScrollBar()->sliderPosition());
- else // d1 == RIGHT
- scrollTo(horizontalScrollBar()->sliderPosition()+static_cast((width()*0.80)),
- verticalScrollBar()->sliderPosition());
- }
- else if(!isEdge(d2))
- {
- int x = 0;
- int y = 0;
-
- if(d1 == UP)
- y = verticalScrollBar()->maximum();
- else if(d1 == DOWN)
- y = verticalScrollBar()->minimum();
- else if(d1 == LEFT)
- x = horizontalScrollBar()->maximum();
- else // d1 == RIGHT
- x = horizontalScrollBar()->minimum();
-
- if(d2 == UP)
- y = std::max(verticalScrollBar()->sliderPosition()-static_cast((height()*0.80)), verticalScrollBar()->minimum());
- else if(d2 == DOWN)
- y = std::min(verticalScrollBar()->sliderPosition()+static_cast((height()*0.80)), verticalScrollBar()->maximum());
- else if(d2 == LEFT)
- x = std::max(horizontalScrollBar()->sliderPosition()-static_cast((width()*0.80)), horizontalScrollBar()->minimum());
- else // d2 == RIGHT
- x = std::min(horizontalScrollBar()->sliderPosition()+static_cast((width()*0.80)), horizontalScrollBar()->maximum());
-
- scrollTo(x, y);
- }
- else
- {
- // next or prev page's corner
- int savedPageNumber = getCurrentPageNumber();
+ if (!isEdge(d1)) {
+ if (d1 == UP)
+ scrollTo(horizontalScrollBar()->sliderPosition(),
+ verticalScrollBar()->sliderPosition() - static_cast((height() * 0.80)));
+ else if (d1 == DOWN)
+ scrollTo(horizontalScrollBar()->sliderPosition(),
+ verticalScrollBar()->sliderPosition() + static_cast((height() * 0.80)));
+ else if (d1 == LEFT)
+ scrollTo(horizontalScrollBar()->sliderPosition() - static_cast((width() * 0.80)),
+ verticalScrollBar()->sliderPosition());
+ else // d1 == RIGHT
+ scrollTo(horizontalScrollBar()->sliderPosition() + static_cast((width() * 0.80)),
+ verticalScrollBar()->sliderPosition());
+ } else if (!isEdge(d2)) {
+ int x = 0;
+ int y = 0;
- if(forward)
- next();
- else
- prev();
+ if (d1 == UP)
+ y = verticalScrollBar()->maximum();
+ else if (d1 == DOWN)
+ y = verticalScrollBar()->minimum();
+ else if (d1 == LEFT)
+ x = horizontalScrollBar()->maximum();
+ else // d1 == RIGHT
+ x = horizontalScrollBar()->minimum();
- if(savedPageNumber != getCurrentPageNumber()){
- if(d1 == LEFT || d2 == LEFT)
- horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->maximum());
- else
- horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->minimum());
- emit backgroundChanges();
- }
- }
+ if (d2 == UP)
+ y = std::max(verticalScrollBar()->sliderPosition() - static_cast((height() * 0.80)), verticalScrollBar()->minimum());
+ else if (d2 == DOWN)
+ y = std::min(verticalScrollBar()->sliderPosition() + static_cast((height() * 0.80)), verticalScrollBar()->maximum());
+ else if (d2 == LEFT)
+ x = std::max(horizontalScrollBar()->sliderPosition() - static_cast((width() * 0.80)), horizontalScrollBar()->minimum());
+ else // d2 == RIGHT
+ x = std::min(horizontalScrollBar()->sliderPosition() + static_cast((width() * 0.80)), horizontalScrollBar()->maximum());
+
+ scrollTo(x, y);
+ } else {
+ // next or prev page's corner
+ int savedPageNumber = getCurrentPageNumber();
+
+ if (forward)
+ next();
+ else
+ prev();
+
+ if (savedPageNumber != getCurrentPageNumber()) {
+ if (d1 == LEFT || d2 == LEFT)
+ horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->maximum());
+ else
+ horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->minimum());
+ emit backgroundChanges();
+ }
+ }
}
void Viewer::scrollTo(int x, int y)
{
- if(groupScroller->state() == QAbstractAnimation::Running)
- return;
- horizontalScroller->setDuration(250);
- horizontalScroller->setStartValue(horizontalScrollBar()->sliderPosition());
- horizontalScroller->setEndValue(x);
- verticalScroller->setDuration(250);
- verticalScroller->setStartValue(verticalScrollBar()->sliderPosition());
- verticalScroller->setEndValue(y);
- groupScroller->start();
- emit backgroundChanges();
+ if (groupScroller->state() == QAbstractAnimation::Running)
+ return;
+ horizontalScroller->setDuration(250);
+ horizontalScroller->setStartValue(horizontalScrollBar()->sliderPosition());
+ horizontalScroller->setEndValue(x);
+ verticalScroller->setDuration(250);
+ verticalScroller->setStartValue(verticalScrollBar()->sliderPosition());
+ verticalScroller->setEndValue(y);
+ groupScroller->start();
+ emit backgroundChanges();
}
void Viewer::keyPressEvent(QKeyEvent *event)
{
- if(render->hasLoadedComic())
- {
- int _key = event->key();
- Qt::KeyboardModifiers modifiers = event->modifiers();
+ if (render->hasLoadedComic()) {
+ int _key = event->key();
+ Qt::KeyboardModifiers modifiers = event->modifiers();
- if(modifiers & Qt::ShiftModifier)
- _key |= Qt::SHIFT;
- if (modifiers & Qt::ControlModifier)
- _key |= Qt::CTRL;
- if (modifiers & Qt::MetaModifier)
- _key |= Qt::META;
- if (modifiers & Qt::AltModifier)
- _key |= Qt::ALT;
+ if (modifiers & Qt::ShiftModifier)
+ _key |= Qt::SHIFT;
+ if (modifiers & Qt::ControlModifier)
+ _key |= Qt::CTRL;
+ if (modifiers & Qt::MetaModifier)
+ _key |= Qt::META;
+ if (modifiers & Qt::AltModifier)
+ _key |= Qt::ALT;
- QKeySequence key(_key);
- /*if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
+ QKeySequence key(_key);
+ /*if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
QCoreApplication::sendEvent(goToFlow,event);
else*/
- if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y))
- {
- posByStep = height()/numScrollSteps;
- nextPos=verticalScrollBar()->sliderPosition()+static_cast((height()*0.80));
- scrollDown();
- }
+ if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y)) {
+ posByStep = height() / numScrollSteps;
+ nextPos = verticalScrollBar()->sliderPosition() + static_cast((height() * 0.80));
+ scrollDown();
+ }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y))
- {
- posByStep = height()/numScrollSteps;
- nextPos=verticalScrollBar()->sliderPosition()-static_cast((height()*0.80));
- scrollUp();
- }
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y)) {
+ posByStep = height() / numScrollSteps;
+ nextPos = verticalScrollBar()->sliderPosition() - static_cast((height() * 0.80));
+ scrollUp();
+ }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y)) {
scrollForwardHorizontalFirst();
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y)) {
scrollBackwardHorizontalFirst();
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y)) {
scrollForwardVerticalFirst();
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y))
- {
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y)) {
scrollBackwardVerticalFirst();
}
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y))
- {
- QAbstractScrollArea::keyPressEvent(event);
- emit backgroundChanges();
- }
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) ||
+ key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) ||
+ key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) ||
+ key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y)) {
+ QAbstractScrollArea::keyPressEvent(event);
+ emit backgroundChanges();
+ }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y))
- {
- goTo(0);
- }
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y)) {
+ goTo(0);
+ }
- else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y))
- {
- goTo(this->render->numPages()-1);
- }
+ else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y)) {
+ goTo(this->render->numPages() - 1);
+ }
- else
- QAbstractScrollArea::keyPressEvent(event);
+ else
+ QAbstractScrollArea::keyPressEvent(event);
- if(mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) ||
- key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y)))
- {
- QCoreApplication::sendEvent(mglass,event);
- }
+ if (mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))) {
+ QCoreApplication::sendEvent(mglass, event);
+ }
- }
- else
- QAbstractScrollArea::keyPressEvent(event);
+ } else
+ QAbstractScrollArea::keyPressEvent(event);
}
-void Viewer::wheelEvent(QWheelEvent * event)
+void Viewer::wheelEvent(QWheelEvent *event)
{
- if(render->hasLoadedComic())
- {
- if((event->delta()<0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum()))
- {
- if(wheelStop)
- {
- if(getMovement(event) == Forward)
- {
- next();
- verticalScroller->stop();
- event->accept();
- wheelStop = false;
- }
- return;
- }
- else
- wheelStop = true;
- }
- else
- {
- if((event->delta()>0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum()))
- {
- if(wheelStop)
- {
- if(getMovement(event) == Backward)
- {
- prev();
- verticalScroller->stop();
- event->accept();
- wheelStop = false;
- }
- return;
- }
- else
- wheelStop = true;
- }
- }
+ if (render->hasLoadedComic()) {
+ if ((event->delta() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) {
+ if (wheelStop) {
+ if (getMovement(event) == Forward) {
+ next();
+ verticalScroller->stop();
+ event->accept();
+ wheelStop = false;
+ }
+ return;
+ } else
+ wheelStop = true;
+ } else {
+ if ((event->delta() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) {
+ if (wheelStop) {
+ if (getMovement(event) == Backward) {
+ prev();
+ verticalScroller->stop();
+ event->accept();
+ wheelStop = false;
+ }
+ return;
+ } else
+ wheelStop = true;
+ }
+ }
- int deltaNotFinished = 0;
- if(verticalScroller->state() == QAbstractAnimation::Running)
- {
- deltaNotFinished = verticalScroller->startValue().toInt() - verticalScroller->endValue().toInt();
- verticalScroller->stop();
- }
+ int deltaNotFinished = 0;
+ if (verticalScroller->state() == QAbstractAnimation::Running) {
+ deltaNotFinished = verticalScroller->startValue().toInt() - verticalScroller->endValue().toInt();
+ verticalScroller->stop();
+ }
+ int currentPos = verticalScrollBar()->sliderPosition();
+ verticalScroller->setDuration(250);
+ verticalScroller->setStartValue(currentPos);
+ verticalScroller->setEndValue(currentPos - event->delta() - deltaNotFinished);
- int currentPos = verticalScrollBar()->sliderPosition();
- verticalScroller->setDuration(250);
- verticalScroller->setStartValue(currentPos);
- verticalScroller->setEndValue(currentPos - event->delta() - deltaNotFinished);
+ verticalScroller->start();
- verticalScroller->start();
-
- //QAbstractScrollArea::wheelEvent(event);
- }
+ //QAbstractScrollArea::wheelEvent(event);
+ }
}
-void Viewer::resizeEvent(QResizeEvent * event)
+void Viewer::resizeEvent(QResizeEvent *event)
{
- updateContentSize();
- goToFlow->updateSize();
- goToFlow->move((width()-goToFlow->width())/2,height()-goToFlow->height());
- informationLabel->updatePosition();
- QScrollArea::resizeEvent(event);
+ updateContentSize();
+ goToFlow->updateSize();
+ goToFlow->move((width() - goToFlow->width()) / 2, height() - goToFlow->height());
+ informationLabel->updatePosition();
+ QScrollArea::resizeEvent(event);
}
-void Viewer::mouseMoveEvent(QMouseEvent * event)
+void Viewer::mouseMoveEvent(QMouseEvent *event)
{
- showCursor();
- hideCursorTimer->start(2500);
+ showCursor();
+ hideCursorTimer->start(2500);
- if(magnifyingGlassShowed)
- mglass->move(static_cast(event->x()-float(mglass->width())/2),static_cast(event->y()-float(mglass->height())/2));
+ if (magnifyingGlassShowed)
+ mglass->move(static_cast(event->x() - float(mglass->width()) / 2), static_cast(event->y() - float(mglass->height()) / 2));
- if(render->hasLoadedComic())
- {
- if(showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
- {
- if(Configuration::getConfiguration().getDisableShowOnMouseOver() == false)
- {
- if(goToFlow->isVisible())
- {
- QPoint gtfPos = goToFlow->mapFrom(this,event->pos());
- if(gtfPos.y() < 0 || gtfPos.x()<0 || gtfPos.x()>goToFlow->width())//TODO this extra check is for Mavericks (mouseMove over goToFlowGL seems to be broken)
+ if (render->hasLoadedComic()) {
+ if (showGoToFlowAnimation->state() != QPropertyAnimation::Running) {
+ if (Configuration::getConfiguration().getDisableShowOnMouseOver() == false) {
+ if (goToFlow->isVisible()) {
+ QPoint gtfPos = goToFlow->mapFrom(this, event->pos());
+ if (gtfPos.y() < 0 || gtfPos.x() < 0 || gtfPos.x() > goToFlow->width()) //TODO this extra check is for Mavericks (mouseMove over goToFlowGL seems to be broken)
animateHideGoToFlow();
//goToFlow->hide();
- }
- else
- {
- int umbral = (width()-goToFlow->width())/2;
- if((event->y()>height()-15)&&(event->x()>umbral)&&(event->x()width()) / 2;
+ if ((event->y() > height() - 15) && (event->x() > umbral) && (event->x() < width() - umbral)) {
animateShowGoToFlow();
hideCursorTimer->stop();
@@ -792,433 +716,402 @@ void Viewer::mouseMoveEvent(QMouseEvent * event)
}
}
- if(drag)
- {
- int currentPosY = verticalScrollBar()->sliderPosition();
- int currentPosX = horizontalScrollBar()->sliderPosition();
- verticalScrollBar()->setSliderPosition(currentPosY=currentPosY+(yDragOrigin-event->y()));
- horizontalScrollBar()->setSliderPosition(currentPosX=currentPosX+(xDragOrigin-event->x()));
- yDragOrigin = event->y();
- xDragOrigin = event->x();
- }
- }
-
-
+ if (drag) {
+ int currentPosY = verticalScrollBar()->sliderPosition();
+ int currentPosX = horizontalScrollBar()->sliderPosition();
+ verticalScrollBar()->setSliderPosition(currentPosY = currentPosY + (yDragOrigin - event->y()));
+ horizontalScrollBar()->setSliderPosition(currentPosX = currentPosX + (xDragOrigin - event->x()));
+ yDragOrigin = event->y();
+ xDragOrigin = event->x();
+ }
+ }
}
-const QPixmap * Viewer::pixmap()
+const QPixmap *Viewer::pixmap()
{
- return content->pixmap();
+ return content->pixmap();
}
void Viewer::magnifyingGlassSwitch()
{
- magnifyingGlassShowed?hideMagnifyingGlass():showMagnifyingGlass();
+ magnifyingGlassShowed ? hideMagnifyingGlass() : showMagnifyingGlass();
}
void Viewer::showMagnifyingGlass()
{
- if(render->hasLoadedComic())
- {
- QPoint p = QPoint(cursor().pos().x(),cursor().pos().y());
- p = this->parentWidget()->mapFromGlobal(p);
- mglass->move(static_cast(p.x()-float(mglass->width())/2)
- ,static_cast(p.y()-float(mglass->height())/2));
- mglass->show();
- mglass->updateImage(mglass->x()+mglass->width()/2,mglass->y()+mglass->height()/2);
- magnifyingGlassShowed = true;
- }
+ if (render->hasLoadedComic()) {
+ QPoint p = QPoint(cursor().pos().x(), cursor().pos().y());
+ p = this->parentWidget()->mapFromGlobal(p);
+ mglass->move(static_cast(p.x() - float(mglass->width()) / 2), static_cast(p.y() - float(mglass->height()) / 2));
+ mglass->show();
+ mglass->updateImage(mglass->x() + mglass->width() / 2, mglass->y() + mglass->height() / 2);
+ magnifyingGlassShowed = true;
+ }
}
void Viewer::hideMagnifyingGlass()
{
- mglass->hide();
- magnifyingGlassShowed = false;
+ mglass->hide();
+ magnifyingGlassShowed = false;
}
void Viewer::informationSwitch()
{
- information?informationLabel->hide():informationLabel->show();
- //informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
- information=!information;
- Configuration::getConfiguration().setShowInformation(information);
- //TODO it shouldn't be neccesary
- informationLabel->adjustSize();
- informationLabel->update();
+ information ? informationLabel->hide() : informationLabel->show();
+ //informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
+ information = !information;
+ Configuration::getConfiguration().setShowInformation(information);
+ //TODO it shouldn't be neccesary
+ informationLabel->adjustSize();
+ informationLabel->update();
}
void Viewer::updateInformation()
{
- if(render->hasLoadedComic())
- {
- informationLabel->setText(render->getCurrentPagesInformation()+" - "+QTime::currentTime().toString("HH:mm"));
- informationLabel->adjustSize();
- informationLabel->update(); //TODO it shouldn't be neccesary
- }
+ if (render->hasLoadedComic()) {
+ informationLabel->setText(render->getCurrentPagesInformation() + " - " + QTime::currentTime().toString("HH:mm"));
+ informationLabel->adjustSize();
+ informationLabel->update(); //TODO it shouldn't be neccesary
+ }
}
void Viewer::goToFlowSwitch()
{
- goToFlow->isVisible()?animateHideGoToFlow():showGoToFlow();
+ goToFlow->isVisible() ? animateHideGoToFlow() : showGoToFlow();
}
void Viewer::translatorSwitch()
{
- translator->isVisible()?animateHideTranslator():animateShowTranslator();
+ translator->isVisible() ? animateHideTranslator() : animateShowTranslator();
}
void Viewer::showGoToFlow()
{
- if(render->hasLoadedComic())
- {
- animateShowGoToFlow();
- }
+ if (render->hasLoadedComic()) {
+ animateShowGoToFlow();
+ }
}
void Viewer::animateShowGoToFlow()
{
- if(goToFlow->isHidden() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
- {
- disconnect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide()));
- connect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow()));
- showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-10));
- showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
- showGoToFlowAnimation->start();
- goToFlow->centerSlide(render->getIndex());
- goToFlow->setPageNumber(render->getIndex());
- goToFlow->show();
- goToFlow->setFocus(Qt::OtherFocusReason);
- }
+ if (goToFlow->isHidden() && showGoToFlowAnimation->state() != QPropertyAnimation::Running) {
+ disconnect(showGoToFlowAnimation, SIGNAL(finished()), goToFlow, SLOT(hide()));
+ connect(showGoToFlowAnimation, SIGNAL(finished()), this, SLOT(moveCursoToGoToFlow()));
+ showGoToFlowAnimation->setStartValue(QPoint((width() - goToFlow->width()) / 2, height() - 10));
+ showGoToFlowAnimation->setEndValue(QPoint((width() - goToFlow->width()) / 2, height() - goToFlow->height()));
+ showGoToFlowAnimation->start();
+ goToFlow->centerSlide(render->getIndex());
+ goToFlow->setPageNumber(render->getIndex());
+ goToFlow->show();
+ goToFlow->setFocus(Qt::OtherFocusReason);
+ }
}
void Viewer::animateHideGoToFlow()
{
- if(goToFlow->isVisible() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running)
- {
- connect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide()));
- disconnect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow()));
- showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
- showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height()));
- showGoToFlowAnimation->start();
- goToFlow->centerSlide(render->getIndex());
- goToFlow->setPageNumber(render->getIndex());
- this->setFocus(Qt::OtherFocusReason);
- }
+ if (goToFlow->isVisible() && showGoToFlowAnimation->state() != QPropertyAnimation::Running) {
+ connect(showGoToFlowAnimation, SIGNAL(finished()), goToFlow, SLOT(hide()));
+ disconnect(showGoToFlowAnimation, SIGNAL(finished()), this, SLOT(moveCursoToGoToFlow()));
+ showGoToFlowAnimation->setStartValue(QPoint((width() - goToFlow->width()) / 2, height() - goToFlow->height()));
+ showGoToFlowAnimation->setEndValue(QPoint((width() - goToFlow->width()) / 2, height()));
+ showGoToFlowAnimation->start();
+ goToFlow->centerSlide(render->getIndex());
+ goToFlow->setPageNumber(render->getIndex());
+ this->setFocus(Qt::OtherFocusReason);
+ }
}
void Viewer::moveCursoToGoToFlow()
{
- if(Configuration::getConfiguration().getDisableShowOnMouseOver())
- {
+ if (Configuration::getConfiguration().getDisableShowOnMouseOver()) {
return;
}
- //Move cursor to goToFlow widget on show (this avoid hide when mouse is moved)
- int y = goToFlow->pos().y();
- int x1 = goToFlow->pos().x();
- int x2 = x1 + goToFlow->width();
- QPoint cursorPos = mapFromGlobal(cursor().pos());
- int cursorX = cursorPos.x();
- int cursorY = cursorPos.y();
+ //Move cursor to goToFlow widget on show (this avoid hide when mouse is moved)
+ int y = goToFlow->pos().y();
+ int x1 = goToFlow->pos().x();
+ int x2 = x1 + goToFlow->width();
+ QPoint cursorPos = mapFromGlobal(cursor().pos());
+ int cursorX = cursorPos.x();
+ int cursorY = cursorPos.y();
- if(cursorY <= y)
- cursorY = y + 10;
- if(cursorX <= x1)
- cursorX = x1 + 10;
- if(cursorX >= x2)
- cursorX = x2 - 10;
- cursor().setPos(mapToGlobal(QPoint(cursorX,cursorY)));
- hideCursorTimer->stop();
- showCursor();
+ if (cursorY <= y)
+ cursorY = y + 10;
+ if (cursorX <= x1)
+ cursorX = x1 + 10;
+ if (cursorX >= x2)
+ cursorX = x2 - 10;
+ cursor().setPos(mapToGlobal(QPoint(cursorX, cursorY)));
+ hideCursorTimer->stop();
+ showCursor();
}
void Viewer::rotateLeft()
{
- render->rotateLeft();
+ render->rotateLeft();
}
void Viewer::rotateRight()
{
- render->rotateRight();
+ render->rotateRight();
}
//TODO
void Viewer::setBookmark(bool set)
{
- render->setBookmark();
- if(set) //add bookmark
- {
- render->setBookmark();
- }
- else //remove bookmark
- {
- render->removeBookmark();
- }
+ render->setBookmark();
+ if (set) //add bookmark
+ {
+ render->setBookmark();
+ } else //remove bookmark
+ {
+ render->removeBookmark();
+ }
}
-void Viewer::save ()
+void Viewer::save()
{
- if(render->hasLoadedComic())
- render->save();
+ if (render->hasLoadedComic())
+ render->save();
}
void Viewer::doublePageSwitch()
{
- doublePage = !doublePage;
- render->doublePageSwitch();
- Configuration::getConfiguration().setDoublePage(doublePage);
+ doublePage = !doublePage;
+ render->doublePageSwitch();
+ Configuration::getConfiguration().setDoublePage(doublePage);
}
void Viewer::doubleMangaPageSwitch()
{
- doubleMangaPage = !doubleMangaPage;
- render->doubleMangaPageSwitch();
+ doubleMangaPage = !doubleMangaPage;
+ render->doubleMangaPageSwitch();
Configuration &config = Configuration::getConfiguration();
config.setDoubleMangaPage(doubleMangaPage);
- goToFlow->setFlowRightToLeft(doubleMangaPage);
+ goToFlow->setFlowRightToLeft(doubleMangaPage);
goToFlow->updateConfig(config.getSettings());
}
void Viewer::resetContent()
{
- configureContent(tr("Press 'O' to open comic."));
- goToFlow->reset();
- emit reset();
+ configureContent(tr("Press 'O' to open comic."));
+ goToFlow->reset();
+ emit reset();
}
void Viewer::setLoadingMessage()
{
- if(magnifyingGlassShowed)
- {
- hideMagnifyingGlass();
- restoreMagnifyingGlass = true;
- }
- emit(pageAvailable(false));
- configureContent(tr("Loading...please wait!"));
+ if (magnifyingGlassShowed) {
+ hideMagnifyingGlass();
+ restoreMagnifyingGlass = true;
+ }
+ emit(pageAvailable(false));
+ configureContent(tr("Loading...please wait!"));
}
void Viewer::setPageUnavailableMessage()
{
- if(magnifyingGlassShowed)
- {
- hideMagnifyingGlass();
- restoreMagnifyingGlass = true;
- }
- emit(pageAvailable(false));
- configureContent(tr("Page not available!"));
+ if (magnifyingGlassShowed) {
+ hideMagnifyingGlass();
+ restoreMagnifyingGlass = true;
+ }
+ emit(pageAvailable(false));
+ configureContent(tr("Page not available!"));
}
void Viewer::configureContent(QString msg)
{
- content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
- if(!(devicePixelRatio()>1))
- content->setScaledContents(true);
- content->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
- content->setText(msg);
- content->setFont(QFont("courier new", 12));
- content->adjustSize();
- setFocus(Qt::ShortcutFocusReason);
- //emit showingText();
+ content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+ if (!(devicePixelRatio() > 1))
+ content->setScaledContents(true);
+ content->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
+ content->setText(msg);
+ content->setFont(QFont("courier new", 12));
+ content->adjustSize();
+ setFocus(Qt::ShortcutFocusReason);
+ //emit showingText();
}
void Viewer::hideCursor()
{
#ifdef Q_OS_MAC
- setCursor(QCursor(QBitmap(1,1),QBitmap(1,1)));
+ setCursor(QCursor(QBitmap(1, 1), QBitmap(1, 1)));
#else
- setCursor(Qt::BlankCursor);
+ setCursor(Qt::BlankCursor);
#endif
}
void Viewer::showCursor()
{
- if(drag)
- setCursor(Qt::ClosedHandCursor);
- else
- setCursor(Qt::OpenHandCursor);
+ if (drag)
+ setCursor(Qt::ClosedHandCursor);
+ else
+ setCursor(Qt::OpenHandCursor);
}
void Viewer::updateOptions()
{
- goToFlow->setFlowType(Configuration::getConfiguration().getFlowType());
- updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor());
- updateContentSize();
+ goToFlow->setFlowType(Configuration::getConfiguration().getFlowType());
+ updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor());
+ updateContentSize();
}
-void Viewer::updateBackgroundColor(const QColor & color)
+void Viewer::updateBackgroundColor(const QColor &color)
{
- QPalette palette;
- palette.setColor(backgroundRole(), color);
- setPalette(palette);
+ QPalette palette;
+ palette.setColor(backgroundRole(), color);
+ setPalette(palette);
}
void Viewer::animateShowTranslator()
{
- if(translator->isHidden() && translatorAnimation->state()!=QPropertyAnimation::Running)
- {
- disconnect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide()));
- if(translatorXPos == -10000)
- translatorXPos = (width()-translator->width())/2;
- int x = qMax(0,qMin(translatorXPos,width()-translator->width()));
- if(translator->pos().x()<0)
- {
- translatorAnimation->setStartValue(QPoint(-translator->width(),translator->pos().y()));
- }
- else
- {
- translatorAnimation->setStartValue(QPoint(width()+translator->width(),translator->pos().y()));
- }
- translatorAnimation->setEndValue(QPoint(x,translator->pos().y()));
- translatorAnimation->start();
- translator->show();
- translator->setFocus(Qt::OtherFocusReason);
- }
+ if (translator->isHidden() && translatorAnimation->state() != QPropertyAnimation::Running) {
+ disconnect(translatorAnimation, SIGNAL(finished()), translator, SLOT(hide()));
+ if (translatorXPos == -10000)
+ translatorXPos = (width() - translator->width()) / 2;
+ int x = qMax(0, qMin(translatorXPos, width() - translator->width()));
+ if (translator->pos().x() < 0) {
+ translatorAnimation->setStartValue(QPoint(-translator->width(), translator->pos().y()));
+ } else {
+ translatorAnimation->setStartValue(QPoint(width() + translator->width(), translator->pos().y()));
+ }
+ translatorAnimation->setEndValue(QPoint(x, translator->pos().y()));
+ translatorAnimation->start();
+ translator->show();
+ translator->setFocus(Qt::OtherFocusReason);
+ }
}
void Viewer::animateHideTranslator()
{
- if(translator->isVisible() && translatorAnimation->state()!=QPropertyAnimation::Running)
- {
- connect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide()));
- translatorAnimation->setStartValue(QPoint(translatorXPos = translator->pos().x(),translator->pos().y()));
- if((translator->width()/2)+translator->pos().x() <= width()/2)
- translatorAnimation->setEndValue(QPoint(-translator->width(),translator->pos().y()));
- else
- translatorAnimation->setEndValue(QPoint(width()+translator->width(),translator->pos().y()));
- translatorAnimation->start();
- this->setFocus(Qt::OtherFocusReason);
- }
+ if (translator->isVisible() && translatorAnimation->state() != QPropertyAnimation::Running) {
+ connect(translatorAnimation, SIGNAL(finished()), translator, SLOT(hide()));
+ translatorAnimation->setStartValue(QPoint(translatorXPos = translator->pos().x(), translator->pos().y()));
+ if ((translator->width() / 2) + translator->pos().x() <= width() / 2)
+ translatorAnimation->setEndValue(QPoint(-translator->width(), translator->pos().y()));
+ else
+ translatorAnimation->setEndValue(QPoint(width() + translator->width(), translator->pos().y()));
+ translatorAnimation->start();
+ this->setFocus(Qt::OtherFocusReason);
+ }
}
-void Viewer::mousePressEvent ( QMouseEvent * event )
+void Viewer::mousePressEvent(QMouseEvent *event)
{
- if (event->button() == Qt::LeftButton)
- {
- drag = true;
- yDragOrigin = event->y();
- xDragOrigin = event->x();
- setCursor(Qt::ClosedHandCursor);
- event->accept();
- }
+ if (event->button() == Qt::LeftButton) {
+ drag = true;
+ yDragOrigin = event->y();
+ xDragOrigin = event->x();
+ setCursor(Qt::ClosedHandCursor);
+ event->accept();
+ }
}
-void Viewer::mouseReleaseEvent ( QMouseEvent * event )
+void Viewer::mouseReleaseEvent(QMouseEvent *event)
{
- drag = false;
- setCursor(Qt::OpenHandCursor);
- event->accept();
+ drag = false;
+ setCursor(Qt::OpenHandCursor);
+ event->accept();
}
void Viewer::updateZoomRatio(int ratio)
{
- zoom = ratio;
- updateContentSize();
+ zoom = ratio;
+ updateContentSize();
}
-void Viewer::updateConfig(QSettings * settings)
+void Viewer::updateConfig(QSettings *settings)
{
- goToFlow->updateConfig(settings);
+ goToFlow->updateConfig(settings);
- QPalette palette;
- palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
- setPalette(palette);
+ QPalette palette;
+ palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
+ setPalette(palette);
}
//deprecated
void Viewer::updateImageOptions()
{
- render->reload();
+ render->reload();
}
-void Viewer::updateFilters(int brightness, int contrast,int gamma)
+void Viewer::updateFilters(int brightness, int contrast, int gamma)
{
- render->updateFilters(brightness,contrast,gamma);
+ render->updateFilters(brightness, contrast, gamma);
}
void Viewer::setBookmarks()
{
- bd->setBookmarks(*render->getBookmarks());
+ bd->setBookmarks(*render->getBookmarks());
}
void Viewer::showIsCoverMessage()
{
- if(!shouldOpenPrevious)
- {
- notificationsLabel->setText(tr("Cover!"));
- notificationsLabel->flash();
- shouldOpenPrevious = true;
- }
- else
- {
- shouldOpenPrevious = false;
- emit (openPreviousComic());
- }
+ if (!shouldOpenPrevious) {
+ notificationsLabel->setText(tr("Cover!"));
+ notificationsLabel->flash();
+ shouldOpenPrevious = true;
+ } else {
+ shouldOpenPrevious = false;
+ emit(openPreviousComic());
+ }
- shouldOpenNext = false; //single page comic
+ shouldOpenNext = false; //single page comic
}
void Viewer::showIsLastMessage()
{
- if(!shouldOpenNext)
- {
- notificationsLabel->setText(tr("Last page!"));
- notificationsLabel->flash();
- shouldOpenNext = true;
- }
- else
- {
- shouldOpenNext = false;
- emit (openNextComic());
- }
+ if (!shouldOpenNext) {
+ notificationsLabel->setText(tr("Last page!"));
+ notificationsLabel->flash();
+ shouldOpenNext = true;
+ } else {
+ shouldOpenNext = false;
+ emit(openNextComic());
+ }
- shouldOpenPrevious = false; //single page comic
+ shouldOpenPrevious = false; //single page comic
}
unsigned int Viewer::getIndex()
{
- return render->getIndex()+1;
+ return render->getIndex() + 1;
}
int Viewer::getCurrentPageNumber()
{
- return render->getIndex();
+ return render->getIndex();
}
-void Viewer::updateComic(ComicDB & comic)
+void Viewer::updateComic(ComicDB &comic)
{
- if(render->hasLoadedComic())
- {
+ if (render->hasLoadedComic()) {
//set currentPage
- if(!doublePage || (doublePage && render->currentPageIsDoublePage() == false))
- {
- comic.info.currentPage = render->getIndex()+1;
+ if (!doublePage || (doublePage && render->currentPageIsDoublePage() == false)) {
+ comic.info.currentPage = render->getIndex() + 1;
+ } else {
+ comic.info.currentPage = std::min(render->numPages(), render->getIndex() + 2);
}
- else
- {
- comic.info.currentPage = std::min(render->numPages(), render->getIndex()+2);
- }
- //set bookmarks
- Bookmarks * boomarks = render->getBookmarks();
- QList boomarksList = boomarks->getBookmarkPages();
- int numBookmarks = boomarksList.size();
- if(numBookmarks > 0)
- comic.info.bookmark1 = boomarksList[0];
- if(numBookmarks > 1)
- comic.info.bookmark2 = boomarksList[1];
- if(numBookmarks > 2)
- comic.info.bookmark3 = boomarksList[2];
- //set filters
- //TODO: avoid use settings for this...
- QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
- int brightness = settings.value(BRIGHTNESS,0).toInt();
- int contrast = settings.value(CONTRAST,100).toInt();
- int gamma = settings.value(GAMMA,100).toInt();
-
- if(brightness != 0 || comic.info.brightness!=-1)
- comic.info.brightness = brightness;
- if(contrast != 100 || comic.info.contrast!=-1)
- comic.info.contrast = contrast;
- if(gamma != 100 || comic.info.gamma!=-1)
- comic.info.gamma = gamma;
- }
-
+ //set bookmarks
+ Bookmarks *boomarks = render->getBookmarks();
+ QList boomarksList = boomarks->getBookmarkPages();
+ int numBookmarks = boomarksList.size();
+ if (numBookmarks > 0)
+ comic.info.bookmark1 = boomarksList[0];
+ if (numBookmarks > 1)
+ comic.info.bookmark2 = boomarksList[1];
+ if (numBookmarks > 2)
+ comic.info.bookmark3 = boomarksList[2];
+ //set filters
+ //TODO: avoid use settings for this...
+ QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
+ int brightness = settings.value(BRIGHTNESS, 0).toInt();
+ int contrast = settings.value(CONTRAST, 100).toInt();
+ int gamma = settings.value(GAMMA, 100).toInt();
+ if (brightness != 0 || comic.info.brightness != -1)
+ comic.info.brightness = brightness;
+ if (contrast != 100 || comic.info.contrast != -1)
+ comic.info.contrast = contrast;
+ if (gamma != 100 || comic.info.gamma != -1)
+ comic.info.gamma = gamma;
+ }
}
diff --git a/YACReader/viewer.h b/YACReader/viewer.h
index a6bd315b..1edfa13d 100644
--- a/YACReader/viewer.h
+++ b/YACReader/viewer.h
@@ -29,161 +29,164 @@ class GoToDialog;
class YACReaderTranslator;
class GoToFlowWidget;
class Bookmarks;
-class PageLabelWidget;
+class PageLabelWidget;
class NotificationsLabelWidget;
- class Viewer : public QScrollArea, public ScrollManagement
- {
- Q_OBJECT
- public:
- bool fullscreen; //TODO, change by the right use of windowState();
- public slots:
- void increaseZoomFactor();
- void decreaseZoomFactor();
- void setZoomFactor(int);
- int getZoomFactor();
-
- void prepareForOpening();
- void open(QString pathFile, int atPage = -1);
- void open(QString pathFile, const ComicDB & comic);
- void prev();
- void next();
- void showGoToDialog();
- void goTo(unsigned int page);
- void updatePage();
- void updateContentSize();
- void updateVerticalScrollBar();
- void updateOptions();
- void scrollDown();
- void scrollUp();
- void scrollForwardHorizontalFirst();
- void scrollBackwardHorizontalFirst();
- void scrollForwardVerticalFirst();
- void scrollBackwardVerticalFirst();
- void magnifyingGlassSwitch();
- void showMagnifyingGlass();
- void hideMagnifyingGlass();
- void informationSwitch();
- void updateInformation();
- void goToFlowSwitch();
- void showGoToFlow();
- void moveCursoToGoToFlow();
- void animateShowGoToFlow();
- void animateHideGoToFlow();
- void rotateLeft();
- void rotateRight();
- bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;}
- void setBookmark(bool);
- void save();
- void doublePageSwitch();
- void doubleMangaPageSwitch();
- void resetContent();
- void setLoadingMessage();
- void setPageUnavailableMessage();
- void configureContent(QString msg);
- void hideCursor();
- void showCursor();
- void createConnections();
- void translatorSwitch();
- void animateShowTranslator();
- void animateHideTranslator();
-virtual void mousePressEvent ( QMouseEvent * event );
-virtual void mouseReleaseEvent ( QMouseEvent * event );
- void updateBackgroundColor(const QColor & color);
- void updateConfig(QSettings * settings);
- void showMessageErrorOpening();
- void showMessageErrorOpening(QString);
- void processCRCError(QString message);
- void setBookmarks();
- //deprecated
- void updateImageOptions();
- void updateFilters(int brightness, int contrast,int gamma);
- void showIsCoverMessage();
- void showIsLastMessage();
- int getCurrentPageNumber();
- void updateZoomRatio(int ratio);
+class Viewer : public QScrollArea, public ScrollManagement
+{
+ Q_OBJECT
+public:
+ bool fullscreen; //TODO, change by the right use of windowState();
+public slots:
+ void increaseZoomFactor();
+ void decreaseZoomFactor();
+ void setZoomFactor(int);
+ int getZoomFactor();
- private:
- bool information;
- bool doublePage;
- bool doubleMangaPage;
-
- int zoom;
-
- PageLabelWidget * informationLabel;
- //QTimer * scroller;
- QPropertyAnimation * verticalScroller;
- QPropertyAnimation * horizontalScroller;
- QParallelAnimationGroup * groupScroller;
- int posByStep;
- int nextPos;
- GoToFlowWidget * goToFlow;
- QPropertyAnimation * showGoToFlowAnimation;
- GoToDialog * goToDialog;
- //!Image properties
- //! Comic
- //Comic * comic;
- int index;
- QPixmap *currentPage;
- BookmarksDialog * bd;
- bool wheelStop;
- Render * render;
- QTimer * hideCursorTimer;
- int direction;
- bool drag;
- int numScrollSteps;
+ void prepareForOpening();
+ void open(QString pathFile, int atPage = -1);
+ void open(QString pathFile, const ComicDB &comic);
+ void prev();
+ void next();
+ void showGoToDialog();
+ void goTo(unsigned int page);
+ void updatePage();
+ void updateContentSize();
+ void updateVerticalScrollBar();
+ void updateOptions();
+ void scrollDown();
+ void scrollUp();
+ void scrollForwardHorizontalFirst();
+ void scrollBackwardHorizontalFirst();
+ void scrollForwardVerticalFirst();
+ void scrollBackwardVerticalFirst();
+ void magnifyingGlassSwitch();
+ void showMagnifyingGlass();
+ void hideMagnifyingGlass();
+ void informationSwitch();
+ void updateInformation();
+ void goToFlowSwitch();
+ void showGoToFlow();
+ void moveCursoToGoToFlow();
+ void animateShowGoToFlow();
+ void animateHideGoToFlow();
+ void rotateLeft();
+ void rotateRight();
+ bool magnifyingGlassIsVisible() { return magnifyingGlassShowed; }
+ void setBookmark(bool);
+ void save();
+ void doublePageSwitch();
+ void doubleMangaPageSwitch();
+ void resetContent();
+ void setLoadingMessage();
+ void setPageUnavailableMessage();
+ void configureContent(QString msg);
+ void hideCursor();
+ void showCursor();
+ void createConnections();
+ void translatorSwitch();
+ void animateShowTranslator();
+ void animateHideTranslator();
+ virtual void mousePressEvent(QMouseEvent *event);
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+ void updateBackgroundColor(const QColor &color);
+ void updateConfig(QSettings *settings);
+ void showMessageErrorOpening();
+ void showMessageErrorOpening(QString);
+ void processCRCError(QString message);
+ void setBookmarks();
+ //deprecated
+ void updateImageOptions();
+ void updateFilters(int brightness, int contrast, int gamma);
+ void showIsCoverMessage();
+ void showIsLastMessage();
+ int getCurrentPageNumber();
+ void updateZoomRatio(int ratio);
- //!Widgets
- QLabel *content;
+private:
+ bool information;
+ bool doublePage;
+ bool doubleMangaPage;
- YACReaderTranslator * translator;
- int translatorXPos;
- QPropertyAnimation * translatorAnimation;
+ int zoom;
- int yDragOrigin;
- int xDragOrigin;
+ PageLabelWidget *informationLabel;
+ //QTimer * scroller;
+ QPropertyAnimation *verticalScroller;
+ QPropertyAnimation *horizontalScroller;
+ QParallelAnimationGroup *groupScroller;
+ int posByStep;
+ int nextPos;
+ GoToFlowWidget *goToFlow;
+ QPropertyAnimation *showGoToFlowAnimation;
+ GoToDialog *goToDialog;
+ //!Image properties
+ //! Comic
+ //Comic * comic;
+ int index;
+ QPixmap *currentPage;
+ BookmarksDialog *bd;
+ bool wheelStop;
+ Render *render;
+ QTimer *hideCursorTimer;
+ int direction;
+ bool drag;
+ int numScrollSteps;
- NotificationsLabelWidget * notificationsLabel;
+ //!Widgets
+ QLabel *content;
- bool shouldOpenNext;
- bool shouldOpenPrevious;
+ YACReaderTranslator *translator;
+ int translatorXPos;
+ QPropertyAnimation *translatorAnimation;
- private:
- //!Magnifying glass
- MagnifyingGlass *mglass;
- bool magnifyingGlassShowed;
- bool restoreMagnifyingGlass;
+ int yDragOrigin;
+ int xDragOrigin;
- //! Manejadores de evento:
- void keyPressEvent(QKeyEvent * event);
- void resizeEvent(QResizeEvent * event);
- void wheelEvent(QWheelEvent * event);
- void mouseMoveEvent(QMouseEvent * event);
+ NotificationsLabelWidget *notificationsLabel;
- //!ZigzagScroll
- enum scrollDirection{ UP, DOWN, LEFT, RIGHT };
- bool isEdge(scrollDirection d);
- void scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward);
- void scrollTo(int x, int y);
+ bool shouldOpenNext;
+ bool shouldOpenPrevious;
- public:
- Viewer(QWidget * parent = 0);
- ~Viewer();
- void toggleFullScreen();
- const QPixmap * pixmap();
- //Comic * getComic(){return comic;}
- const BookmarksDialog * getBookmarksDialog(){return bd;}
- //returns the current index starting in 1 [1,nPages]
- unsigned int getIndex();
- void updateComic(ComicDB & comic);
- signals:
- void backgroundChanges();
- void pageAvailable(bool);
- void pageIsBookmark(bool);
- void reset();
- void openNextComic();
- void openPreviousComic();
- void zoomUpdated(int);
- };
+private:
+ //!Magnifying glass
+ MagnifyingGlass *mglass;
+ bool magnifyingGlassShowed;
+ bool restoreMagnifyingGlass;
+
+ //! Manejadores de evento:
+ void keyPressEvent(QKeyEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void wheelEvent(QWheelEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ //!ZigzagScroll
+ enum scrollDirection { UP,
+ DOWN,
+ LEFT,
+ RIGHT };
+ bool isEdge(scrollDirection d);
+ void scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward);
+ void scrollTo(int x, int y);
+
+public:
+ Viewer(QWidget *parent = 0);
+ ~Viewer();
+ void toggleFullScreen();
+ const QPixmap *pixmap();
+ //Comic * getComic(){return comic;}
+ const BookmarksDialog *getBookmarksDialog() { return bd; }
+ //returns the current index starting in 1 [1,nPages]
+ unsigned int getIndex();
+ void updateComic(ComicDB &comic);
+signals:
+ void backgroundChanges();
+ void pageAvailable(bool);
+ void pageIsBookmark(bool);
+ void reset();
+ void openNextComic();
+ void openPreviousComic();
+ void zoomUpdated(int);
+};
#endif
diff --git a/YACReader/width_slider.cpp b/YACReader/width_slider.cpp
index dcbd3c87..c75dabe6 100644
--- a/YACReader/width_slider.cpp
+++ b/YACReader/width_slider.cpp
@@ -4,13 +4,14 @@
#include "configuration.h"
-YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
- :QWidgetAction (parent) {
-
+YACReaderSliderAction::YACReaderSliderAction(QWidget *parent)
+ : QWidgetAction(parent)
+{
+
widget = new YACReaderSlider();
setDefaultWidget(widget);
- connect(widget,SIGNAL(zoomRatioChanged(int)),this,SIGNAL(zoomRatioChanged(int)));
+ connect(widget, SIGNAL(zoomRatioChanged(int)), this, SIGNAL(zoomRatioChanged(int)));
}
void YACReaderSliderAction::updateText(int value)
@@ -24,7 +25,7 @@ void YACReaderSliderAction::updateZoomRatio(int value)
}
YACReaderSlider::YACReaderSlider(QWidget *parent)
- :QWidget(parent)
+ : QWidget(parent)
{
const int sliderWidth = 200;
const int contentsMargin = 10;
@@ -33,7 +34,7 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
setFocusPolicy(Qt::StrongFocus);
- QHBoxLayout* pLayout = new QHBoxLayout();
+ QHBoxLayout *pLayout = new QHBoxLayout();
pLayout->addStretch();
@@ -56,10 +57,10 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
pLayout->setMargin(0);
- setLayout (pLayout);
+ setLayout(pLayout);
setAutoFillBackground(false);
- setContentsMargins(contentsMargin,contentsMargin,contentsMargin,contentsMargin);
+ setContentsMargins(contentsMargin, contentsMargin, contentsMargin, contentsMargin);
setFixedSize(sliderWidth + 2 * contentsMargin + 2 * elementsSpacing + percentageLabelWidth + resetButton->sizeHint().width(), 45);
slider->setMinimum(30);
@@ -78,7 +79,7 @@ void YACReaderSlider::paintEvent(QPaintEvent *)
{
QPainter painter(this);
- painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
+ painter.fillRect(0, 0, width(), height(), QColor("#BB000000"));
}
void YACReaderSlider::show()
@@ -87,7 +88,7 @@ void YACReaderSlider::show()
setFocus();
}
-void YACReaderSlider::focusOutEvent(QFocusEvent * event)
+void YACReaderSlider::focusOutEvent(QFocusEvent *event)
{
QWidget::focusOutEvent(event);
hide();
diff --git a/YACReader/width_slider.h b/YACReader/width_slider.h
index 7eed67b6..2fbb4079 100644
--- a/YACReader/width_slider.h
+++ b/YACReader/width_slider.h
@@ -10,15 +10,15 @@ class YACReaderSlider : public QWidget
{
Q_OBJECT
private:
- QLabel * percentageLabel;
- QSlider * slider;
+ QLabel *percentageLabel;
+ QSlider *slider;
public:
- YACReaderSlider (QWidget * parent = 0);
+ YACReaderSlider(QWidget *parent = 0);
void show();
protected:
- virtual void focusOutEvent(QFocusEvent * event);
+ virtual void focusOutEvent(QFocusEvent *event);
virtual void paintEvent(QPaintEvent *);
public slots:
@@ -26,26 +26,23 @@ public slots:
void updateZoomRatio(int value);
void resetValueToDefault();
-
signals:
void zoomRatioChanged(int value);
};
-class YACReaderSliderAction : public QWidgetAction
+class YACReaderSliderAction : public QWidgetAction
{
- Q_OBJECT
+ Q_OBJECT
private:
- YACReaderSlider * widget;
+ YACReaderSlider *widget;
public:
-
- YACReaderSliderAction (QWidget * parent = 0);
+ YACReaderSliderAction(QWidget *parent = 0);
public slots:
- void updateText(int value);
+ void updateText(int value);
void updateZoomRatio(int value);
-
signals:
void zoomRatioChanged(int value);
};
diff --git a/YACReader/yacreader_local_client.cpp b/YACReader/yacreader_local_client.cpp
index fde82a7e..6556d31b 100644
--- a/YACReader/yacreader_local_client.cpp
+++ b/YACReader/yacreader_local_client.cpp
@@ -8,129 +8,116 @@
using namespace YACReader;
-YACReaderLocalClient::YACReaderLocalClient(QObject *parent) :
- QObject(parent)
+YACReaderLocalClient::YACReaderLocalClient(QObject *parent)
+ : QObject(parent)
{
- localSocket = new QLocalSocket(this);
+ localSocket = new QLocalSocket(this);
- //connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
-
- /*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
+ //connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
+
+ /*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
this, SLOT(displayError(QLocalSocket::LocalSocketError)));*/
}
YACReaderLocalClient::~YACReaderLocalClient()
{
- delete localSocket;
+ delete localSocket;
}
//información de comic recibida...
void YACReaderLocalClient::readMessage()
{
-
}
#include
-bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic, QList & siblings)
-{
- localSocket->connectToServer(YACREADERLIBRARY_GUID);
- if(localSocket->isOpen())
- {
- QByteArray block;
- QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_4_8);
- out << (quint32)0;
- out << (quint8)YACReader::RequestComicInfo;
- out << libraryId;
- out << comic;
- out.device()->seek(0);
- out << (quint32)(block.size() - sizeof(quint32));
-
- int written = 0;
- int previousWritten = 0;
- quint16 tries = 0;
- while(written != block.size() && tries < 200)
- {
- written += localSocket->write(block);
- localSocket->flush();
- if(written == previousWritten) //no bytes were written
- tries++;
- previousWritten = written;
- }
- if(tries == 200)
- {
- localSocket->close();
- QLOG_ERROR() << "Requesting Comic Info : unable to send request";
- return false;
- }
-
- localSocket->waitForBytesWritten(2000);
-
- //QByteArray data;
- tries = 0;
- int dataAvailable = 0;
- QByteArray packageSize;
- localSocket->waitForReadyRead(1000);
- while(packageSize.size() < (int)sizeof(quint32) && tries < 20)
- {
- packageSize.append(localSocket->read(sizeof(quint32) - packageSize.size()));
- localSocket->waitForReadyRead(100);
- if(dataAvailable == packageSize.size())
- {
- tries++; //TODO apply 'tries' fix
- }
- dataAvailable = packageSize.size();
- }
- if(tries == 20)
- {
- localSocket->close();
- QLOG_ERROR() << "Requesting Comic Info : unable to read package size";
- return false;
- }
- QDataStream sizeStream(packageSize);//localSocket->read(sizeof(quint32)));
- sizeStream.setVersion(QDataStream::Qt_4_8);
- quint32 totalSize = 0;
- sizeStream >> totalSize;
-
- QByteArray data;
-
- tries = 0;
- int dataRead = 0;
- localSocket->waitForReadyRead(1000);
- while((unsigned int)data.length() < totalSize && tries < 20 )
- {
- data.append(localSocket->readAll());
- if((unsigned int)data.length() < totalSize)
- localSocket->waitForReadyRead(100);
- if(data.length() == dataRead)
- tries++;
- dataRead = data.length();
- }
-
- if(tries == 20)
- {
- localSocket->close();
- QLOG_ERROR() << "Requesting Comic Info : unable to read data (" << data.length() << "," << totalSize << ")";
- return false;
- }
-
- QDataStream dataStream(data);
- dataStream >> comic;
- dataStream >> siblings;
- localSocket->close();
- return true;
- }
- else
- {
- QLOG_ERROR() << "Requesting Comic Info : unable to connect to the server";
- return false;
- }
-}
-
-
-bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
+bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB &comic, QList &siblings)
{
localSocket->connectToServer(YACREADERLIBRARY_GUID);
- if(localSocket->isOpen())
- {
+ if (localSocket->isOpen()) {
+ QByteArray block;
+ QDataStream out(&block, QIODevice::WriteOnly);
+ out.setVersion(QDataStream::Qt_4_8);
+ out << (quint32)0;
+ out << (quint8)YACReader::RequestComicInfo;
+ out << libraryId;
+ out << comic;
+ out.device()->seek(0);
+ out << (quint32)(block.size() - sizeof(quint32));
+
+ int written = 0;
+ int previousWritten = 0;
+ quint16 tries = 0;
+ while (written != block.size() && tries < 200) {
+ written += localSocket->write(block);
+ localSocket->flush();
+ if (written == previousWritten) //no bytes were written
+ tries++;
+ previousWritten = written;
+ }
+ if (tries == 200) {
+ localSocket->close();
+ QLOG_ERROR() << "Requesting Comic Info : unable to send request";
+ return false;
+ }
+
+ localSocket->waitForBytesWritten(2000);
+
+ //QByteArray data;
+ tries = 0;
+ int dataAvailable = 0;
+ QByteArray packageSize;
+ localSocket->waitForReadyRead(1000);
+ while (packageSize.size() < (int)sizeof(quint32) && tries < 20) {
+ packageSize.append(localSocket->read(sizeof(quint32) - packageSize.size()));
+ localSocket->waitForReadyRead(100);
+ if (dataAvailable == packageSize.size()) {
+ tries++; //TODO apply 'tries' fix
+ }
+ dataAvailable = packageSize.size();
+ }
+ if (tries == 20) {
+ localSocket->close();
+ QLOG_ERROR() << "Requesting Comic Info : unable to read package size";
+ return false;
+ }
+ QDataStream sizeStream(packageSize); //localSocket->read(sizeof(quint32)));
+ sizeStream.setVersion(QDataStream::Qt_4_8);
+ quint32 totalSize = 0;
+ sizeStream >> totalSize;
+
+ QByteArray data;
+
+ tries = 0;
+ int dataRead = 0;
+ localSocket->waitForReadyRead(1000);
+ while ((unsigned int)data.length() < totalSize && tries < 20) {
+ data.append(localSocket->readAll());
+ if ((unsigned int)data.length() < totalSize)
+ localSocket->waitForReadyRead(100);
+ if (data.length() == dataRead)
+ tries++;
+ dataRead = data.length();
+ }
+
+ if (tries == 20) {
+ localSocket->close();
+ QLOG_ERROR() << "Requesting Comic Info : unable to read data (" << data.length() << "," << totalSize << ")";
+ return false;
+ }
+
+ QDataStream dataStream(data);
+ dataStream >> comic;
+ dataStream >> siblings;
+ localSocket->close();
+ return true;
+ } else {
+ QLOG_ERROR() << "Requesting Comic Info : unable to connect to the server";
+ return false;
+ }
+}
+
+bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB &comic)
+{
+ localSocket->connectToServer(YACREADERLIBRARY_GUID);
+ if (localSocket->isOpen()) {
//QLOG_INFO() << "Connection opened for sending ComicInfo";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
@@ -142,21 +129,19 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
out.device()->seek(0);
out << (quint32)(block.size() - sizeof(quint32));
- int written, previousWritten;
+ int written, previousWritten;
written = previousWritten = 0;
int tries = 0;
- while(written != block.size() && tries < 100)
- {
+ while (written != block.size() && tries < 100) {
written += localSocket->write(block);
- if(written == previousWritten)
+ if (written == previousWritten)
tries++;
previousWritten = written;
}
localSocket->waitForBytesWritten(2000);
localSocket->close();
//QLOG_INFO() << QString("Sending Comic Info : writen data (%1,%2)").arg(written).arg(block.size());
- if(tries == 100 && written != block.size())
- {
+ if (tries == 100 && written != block.size()) {
emit finished();
QLOG_ERROR() << QString("Sending Comic Info : unable to write data (%1,%2)").arg(written).arg(block.size());
return false;
@@ -170,11 +155,10 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
return false;
}
-bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic, qulonglong nextComicId)
+bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB &comic, qulonglong nextComicId)
{
localSocket->connectToServer(YACREADERLIBRARY_GUID);
- if(localSocket->isOpen())
- {
+ if (localSocket->isOpen()) {
//QLOG_INFO() << "Connection opened for sending ComicInfo";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
@@ -187,21 +171,19 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic, qul
out.device()->seek(0);
out << (quint32)(block.size() - sizeof(quint32));
- int written, previousWritten;
+ int written, previousWritten;
written = previousWritten = 0;
int tries = 0;
- while(written != block.size() && tries < 100)
- {
+ while (written != block.size() && tries < 100) {
written += localSocket->write(block);
- if(written == previousWritten)
+ if (written == previousWritten)
tries++;
previousWritten = written;
}
localSocket->waitForBytesWritten(2000);
localSocket->close();
//QLOG_INFO() << QString("Sending Comic Info : writen data (%1,%2)").arg(written).arg(block.size());
- if(tries == 100 && written != block.size())
- {
+ if (tries == 100 && written != block.size()) {
emit finished();
QLOG_ERROR() << QString("Sending Comic Info : unable to write data (%1,%2)").arg(written).arg(block.size());
return false;
diff --git a/YACReader/yacreader_local_client.h b/YACReader/yacreader_local_client.h
index 840c1047..4bbbd616 100644
--- a/YACReader/yacreader_local_client.h
+++ b/YACReader/yacreader_local_client.h
@@ -16,14 +16,12 @@ signals:
void finished();
public slots:
void readMessage();
- bool requestComicInfo(quint64 libraryId, ComicDB & comic,QList & siblings);
- bool sendComicInfo(quint64 libraryId, ComicDB & comic);
- bool sendComicInfo(quint64 libraryId, ComicDB & comic, qulonglong nextComicId);
-
+ bool requestComicInfo(quint64 libraryId, ComicDB &comic, QList &siblings);
+ bool sendComicInfo(quint64 libraryId, ComicDB &comic);
+ bool sendComicInfo(quint64 libraryId, ComicDB &comic, qulonglong nextComicId);
private:
- QLocalSocket * localSocket;
-
+ QLocalSocket *localSocket;
};
#endif // YACREADER_LOCAL_CLIENT_H
diff --git a/YACReaderLibrary/add_label_dialog.cpp b/YACReaderLibrary/add_label_dialog.cpp
index f1b91fb0..c9b09946 100644
--- a/YACReaderLibrary/add_label_dialog.cpp
+++ b/YACReaderLibrary/add_label_dialog.cpp
@@ -1,15 +1,15 @@
#include "add_label_dialog.h"
-AddLabelDialog::AddLabelDialog(QWidget *parent) :
- QDialog(parent)
+AddLabelDialog::AddLabelDialog(QWidget *parent)
+ : QDialog(parent)
{
- QVBoxLayout * layout = new QVBoxLayout;
+ QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(new QLabel(tr("Label name:")));
layout->addWidget(edit = new QLineEdit());
layout->addWidget(new QLabel(tr("Choose a color:")));
- layout->addWidget(list = new QListWidget() );
+ layout->addWidget(list = new QListWidget());
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_red.png"), tr("red")));
list->addItem(new QListWidgetItem(QIcon(":/images/lists/label_orange.png"), tr("orange")));
@@ -33,10 +33,10 @@ AddLabelDialog::AddLabelDialog(QWidget *parent) :
setMinimumHeight(340);
//buttons
- acceptButton = new QPushButton(tr("accept"),this);
- cancelButton = new QPushButton(tr("cancel"),this);
+ acceptButton = new QPushButton(tr("accept"), this);
+ cancelButton = new QPushButton(tr("cancel"), this);
- QHBoxLayout * buttons = new QHBoxLayout;
+ QHBoxLayout *buttons = new QHBoxLayout;
buttons->addStretch();
buttons->addWidget(acceptButton);
buttons->addWidget(cancelButton);
@@ -47,15 +47,14 @@ AddLabelDialog::AddLabelDialog(QWidget *parent) :
setLayout(layout);
//connections
- connect(edit,SIGNAL(textChanged(QString)),this,SLOT(validateName(QString)));
- connect(cancelButton,SIGNAL(clicked()),this,SLOT(close()));
- connect(acceptButton,SIGNAL(clicked()),this,SLOT(accept()));
-
+ connect(edit, SIGNAL(textChanged(QString)), this, SLOT(validateName(QString)));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));
}
YACReader::LabelColors AddLabelDialog::selectedColor()
{
- return YACReader::LabelColors(list->currentRow()+1);
+ return YACReader::LabelColors(list->currentRow() + 1);
}
QString AddLabelDialog::name()
@@ -63,7 +62,7 @@ QString AddLabelDialog::name()
return edit->text();
}
-int AddLabelDialog::exec()
+int AddLabelDialog::exec()
{
edit->clear();
list->clearSelection();
@@ -77,7 +76,7 @@ int AddLabelDialog::exec()
void AddLabelDialog::validateName(const QString &name)
{
- if(name.isEmpty())
+ if (name.isEmpty())
acceptButton->setDisabled(true);
else
acceptButton->setEnabled(true);
diff --git a/YACReaderLibrary/add_label_dialog.h b/YACReaderLibrary/add_label_dialog.h
index da11befa..02262d25 100644
--- a/YACReaderLibrary/add_label_dialog.h
+++ b/YACReaderLibrary/add_label_dialog.h
@@ -18,14 +18,14 @@ public slots:
int exec();
protected slots:
- void validateName(const QString & name);
+ void validateName(const QString &name);
protected:
- QLineEdit * edit;
- QListWidget * list;
+ QLineEdit *edit;
+ QListWidget *list;
- QPushButton * acceptButton;
- QPushButton * cancelButton;
+ QPushButton *acceptButton;
+ QPushButton *cancelButton;
};
#endif // ADD_LABEL_DIALOG_H
diff --git a/YACReaderLibrary/add_library_dialog.cpp b/YACReaderLibrary/add_library_dialog.cpp
index a7bcb152..9b5f74e8 100644
--- a/YACReaderLibrary/add_library_dialog.cpp
+++ b/YACReaderLibrary/add_library_dialog.cpp
@@ -5,120 +5,112 @@
#include
#include
-
-AddLibraryDialog::AddLibraryDialog(QWidget * parent)
-:QDialog(parent)
+AddLibraryDialog::AddLibraryDialog(QWidget *parent)
+ : QDialog(parent)
{
- setupUI();
+ setupUI();
}
void AddLibraryDialog::setupUI()
{
- textLabel = new QLabel(tr("Comics folder : "));
- path = new QLineEdit;
- textLabel->setBuddy(path);
- connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
+ textLabel = new QLabel(tr("Comics folder : "));
+ path = new QLineEdit;
+ textLabel->setBuddy(path);
+ connect(path, SIGNAL(textChanged(QString)), this, SLOT(pathSetted(QString)));
- nameLabel = new QLabel(tr("Library name : "));
- nameEdit = new QLineEdit;
- nameLabel->setBuddy(nameEdit);
- connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
+ nameLabel = new QLabel(tr("Library name : "));
+ nameEdit = new QLineEdit;
+ nameLabel->setBuddy(nameEdit);
+ connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameSetted(QString)));
- accept = new QPushButton(tr("Add"));
- accept->setDisabled(true);
- connect(accept,SIGNAL(clicked()),this,SLOT(add()));
+ accept = new QPushButton(tr("Add"));
+ accept->setDisabled(true);
+ connect(accept, SIGNAL(clicked()), this, SLOT(add()));
- cancel = new QPushButton(tr("Cancel"));
- connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
+ cancel = new QPushButton(tr("Cancel"));
+ connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
- find = new QPushButton(QIcon(":/images/find_folder.png"),"");
- connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
+ find = new QPushButton(QIcon(":/images/find_folder.png"), "");
+ connect(find, SIGNAL(clicked()), this, SLOT(findPath()));
- QGridLayout * content = new QGridLayout;
+ QGridLayout *content = new QGridLayout;
- content->addWidget(nameLabel,0,0);
- content->addWidget(nameEdit,0,1);
+ content->addWidget(nameLabel, 0, 0);
+ content->addWidget(nameEdit, 0, 1);
- content->addWidget(textLabel,1,0);
- content->addWidget(path,1,1);
- content->addWidget(find,1,2);
- content->setColumnStretch(2,0);
+ content->addWidget(textLabel, 1, 0);
+ content->addWidget(path, 1, 1);
+ content->addWidget(find, 1, 2);
+ content->setColumnStretch(2, 0);
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addStretch();
- bottomLayout->addWidget(accept);
- bottomLayout->addWidget(cancel);
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addWidget(accept);
+ bottomLayout->addWidget(cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addLayout(content);
- mainLayout->addStretch();
- mainLayout->addLayout(bottomLayout);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addLayout(content);
+ mainLayout->addStretch();
+ mainLayout->addLayout(bottomLayout);
- QHBoxLayout * imgMainLayout = new QHBoxLayout;
- QLabel * imgLabel = new QLabel(this);
- QPixmap p(":/images/openLibrary.png");
- imgLabel->setPixmap(p);
- imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
- imgMainLayout->addLayout(mainLayout);
+ QHBoxLayout *imgMainLayout = new QHBoxLayout;
+ QLabel *imgLabel = new QLabel(this);
+ QPixmap p(":/images/openLibrary.png");
+ imgLabel->setPixmap(p);
+ imgMainLayout->addWidget(imgLabel); //,0,Qt::AlignTop);
+ imgMainLayout->addLayout(mainLayout);
- setLayout(imgMainLayout);
+ setLayout(imgMainLayout);
- setModal(true);
- setWindowTitle(tr("Add an existing library"));
+ setModal(true);
+ setWindowTitle(tr("Add an existing library"));
}
void AddLibraryDialog::add()
{
- //accept->setEnabled(false);
- emit(addLibrary(QDir::cleanPath(path->text()),nameEdit->text()));
+ //accept->setEnabled(false);
+ emit(addLibrary(QDir::cleanPath(path->text()), nameEdit->text()));
}
-void AddLibraryDialog::nameSetted(const QString & text)
+void AddLibraryDialog::nameSetted(const QString &text)
{
- if(!text.isEmpty())
- {
- if(!path->text().isEmpty())
- {
- QFileInfo fi(path->text());
- if(fi.isDir())
- accept->setEnabled(true);
- else
- accept->setEnabled(false);
- }
- }
- else
- accept->setEnabled(false);
+ if (!text.isEmpty()) {
+ if (!path->text().isEmpty()) {
+ QFileInfo fi(path->text());
+ if (fi.isDir())
+ accept->setEnabled(true);
+ else
+ accept->setEnabled(false);
+ }
+ } else
+ accept->setEnabled(false);
}
-void AddLibraryDialog::pathSetted(const QString & text)
+void AddLibraryDialog::pathSetted(const QString &text)
{
- QFileInfo fi(text);
- if(fi.isDir())
- {
- if(!nameEdit->text().isEmpty())
- accept->setEnabled(true);
- }
- else
- accept->setEnabled(false);
+ QFileInfo fi(text);
+ if (fi.isDir()) {
+ if (!nameEdit->text().isEmpty())
+ accept->setEnabled(true);
+ } else
+ accept->setEnabled(false);
}
void AddLibraryDialog::findPath()
{
- QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
- if(!s.isEmpty())
- {
- path->setText(s);
- if(!nameEdit->text().isEmpty())
- accept->setEnabled(true);
- }
- else
- accept->setEnabled(false);
+ QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
+ if (!s.isEmpty()) {
+ path->setText(s);
+ if (!nameEdit->text().isEmpty())
+ accept->setEnabled(true);
+ } else
+ accept->setEnabled(false);
}
void AddLibraryDialog::close()
{
- path->clear();
- nameEdit->clear();
- accept->setEnabled(false);
- QDialog::close();
+ path->clear();
+ nameEdit->clear();
+ accept->setEnabled(false);
+ QDialog::close();
}
diff --git a/YACReaderLibrary/add_library_dialog.h b/YACReaderLibrary/add_library_dialog.h
index 4cbdd42b..eaa70817 100644
--- a/YACReaderLibrary/add_library_dialog.h
+++ b/YACReaderLibrary/add_library_dialog.h
@@ -7,29 +7,29 @@
#include
#include
- class AddLibraryDialog : public QDialog
- {
- Q_OBJECT
- public:
- AddLibraryDialog(QWidget * parent = 0);
- private:
- QLabel * nameLabel;
- QLabel * textLabel;
- QLineEdit * path;
- QLineEdit * nameEdit;
- QPushButton * find;
- QPushButton * accept;
- QPushButton * cancel;
- void setupUI();
- public slots:
- void add();
- void findPath();
- void close();
- void nameSetted(const QString & text);
- void pathSetted(const QString & text);
- signals:
- void addLibrary(QString target, QString name);
- };
+class AddLibraryDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ AddLibraryDialog(QWidget *parent = 0);
+
+private:
+ QLabel *nameLabel;
+ QLabel *textLabel;
+ QLineEdit *path;
+ QLineEdit *nameEdit;
+ QPushButton *find;
+ QPushButton *accept;
+ QPushButton *cancel;
+ void setupUI();
+public slots:
+ void add();
+ void findPath();
+ void close();
+ void nameSetted(const QString &text);
+ void pathSetted(const QString &text);
+signals:
+ void addLibrary(QString target, QString name);
+};
#endif
-
diff --git a/YACReaderLibrary/bundle_creator.cpp b/YACReaderLibrary/bundle_creator.cpp
index ea2ff602..b910b59e 100644
--- a/YACReaderLibrary/bundle_creator.cpp
+++ b/YACReaderLibrary/bundle_creator.cpp
@@ -1,13 +1,10 @@
#include "bundle_creator.h"
-
BundleCreator::BundleCreator(void)
- :QObject()
+ : QObject()
{
-
}
-
BundleCreator::~BundleCreator(void)
{
}
diff --git a/YACReaderLibrary/bundle_creator.h b/YACReaderLibrary/bundle_creator.h
index 2a6159a0..a5c68463 100644
--- a/YACReaderLibrary/bundle_creator.h
+++ b/YACReaderLibrary/bundle_creator.h
@@ -5,10 +5,10 @@
class BundleCreator : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
- BundleCreator(void);
- ~BundleCreator(void);
+ BundleCreator(void);
+ ~BundleCreator(void);
};
#endif
\ No newline at end of file
diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp
index e17fe3f1..ff121921 100644
--- a/YACReaderLibrary/classic_comics_view.cpp
+++ b/YACReaderLibrary/classic_comics_view.cpp
@@ -9,22 +9,22 @@
#include "yacreader_tool_bar_stretch.h"
ClassicComicsView::ClassicComicsView(QWidget *parent)
- :ComicsView(parent),searching(false)
+ : ComicsView(parent), searching(false)
{
- QHBoxLayout * layout = new QHBoxLayout;
+ QHBoxLayout *layout = new QHBoxLayout;
- settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
+ settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("libraryConfig");
//FLOW-----------------------------------------------------------------------
//---------------------------------------------------------------------------
//FORCE_ANGLE is not used here, because ComicFlowWidgetGL will use OpenGL ES in the future
#ifndef NO_OPENGL
- if((settings->value(USE_OPEN_GL).toBool() == true))
+ if ((settings->value(USE_OPEN_GL).toBool() == true))
comicFlow = new ComicFlowWidgetGL(0);
else
comicFlow = new ComicFlowWidgetSW(0);
#else
- comicFlow = new ComicFlowWidgetSW(0);
+ comicFlow = new ComicFlowWidgetSW(0);
#endif
comicFlow->updateConfig(settings);
comicFlow->setFocusPolicy(Qt::StrongFocus);
@@ -35,21 +35,19 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
comicFlow->setContextMenuPolicy(Qt::CustomContextMenu);
-
//layout-----------------------------------------------
- sVertical = new QSplitter(Qt::Vertical); //spliter derecha
+ sVertical = new QSplitter(Qt::Vertical); //spliter derecha
stack = new QStackedWidget;
stack->addWidget(comicFlow);
setupSearchingIcon();
stack->addWidget(searchingIcon);
-
sVertical->addWidget(stack);
comics = new QWidget;
- QVBoxLayout * comicsLayout = new QVBoxLayout;
+ QVBoxLayout *comicsLayout = new QVBoxLayout;
comicsLayout->setSpacing(0);
- comicsLayout->setContentsMargins(0,0,0,0);
+ comicsLayout->setContentsMargins(0, 0, 0, 0);
//TODO ComicsView:(set toolbar) comicsLayout->addWidget(editInfoToolBar);
tableView = new YACReaderTableView;
@@ -62,17 +60,17 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
tableView->setContextMenuPolicy(Qt::CustomContextMenu);
//config--------------------------------------------------
- if(settings->contains(COMICS_VIEW_HEADERS))
+ if (settings->contains(COMICS_VIEW_HEADERS))
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
//connections---------------------------------------------
connect(tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(centerComicFlow(QModelIndex)));
connect(tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectedComicForOpening(QModelIndex)));
connect(comicFlow, SIGNAL(centerIndexChanged(int)), this, SLOT(updateTableView(int)));
- connect(tableView, SIGNAL(comicRated(int,QModelIndex)), this, SIGNAL(comicRated(int,QModelIndex)));
+ connect(tableView, SIGNAL(comicRated(int, QModelIndex)), this, SIGNAL(comicRated(int, QModelIndex)));
connect(comicFlow, SIGNAL(selected(uint)), this, SIGNAL(selected(uint)));
- connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveTableHeadersStatus()));
- connect(tableView->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveTableHeadersStatus()));
+ connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveTableHeadersStatus()));
+ connect(tableView->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveTableHeadersStatus()));
connect(comicFlow, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(requestedViewContextMenu(QPoint)));
connect(tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(requestedItemContextMenu(QPoint)));
layout->addWidget(sVertical);
@@ -81,10 +79,10 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
layout->setMargin(0);
#ifdef Q_OS_MAC
- sVertical->setCollapsible(1,false);
+ sVertical->setCollapsible(1, false);
#endif
- if(settings->contains(COMICS_VIEW_FLOW_SPLITTER_STATUS))
+ if (settings->contains(COMICS_VIEW_FLOW_SPLITTER_STATUS))
sVertical->restoreState(settings->value(COMICS_VIEW_FLOW_SPLITTER_STATUS).toByteArray());
//hide flow widgets
@@ -96,25 +94,22 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
hideFlowViewAction->setCheckable(true);
hideFlowViewAction->setChecked(false);
- connect(hideFlowViewAction, SIGNAL(toggled(bool)),this, SLOT(hideComicFlow(bool)));
+ connect(hideFlowViewAction, SIGNAL(toggled(bool)), this, SLOT(hideComicFlow(bool)));
}
void ClassicComicsView::hideComicFlow(bool hide)
{
- if(hide)
- {
+ if (hide) {
QList sizes;
sizes.append(0);
int total = sVertical->sizes().at(0) + sVertical->sizes().at(1);
sizes.append(total);
sVertical->setSizes(sizes);
- }
- else
- {
+ } else {
QList sizes;
int total = sVertical->sizes().at(0) + sVertical->sizes().at(1);
- sizes.append(2*total/3);
- sizes.append(total/3);
+ sizes.append(2 * total / 3);
+ sizes.append(total / 3);
sVertical->setSizes(sizes);
}
}
@@ -122,7 +117,7 @@ void ClassicComicsView::hideComicFlow(bool hide)
//the toolbar has to be populated
void ClassicComicsView::setToolBar(QToolBar *toolBar)
{
- static_cast(comics->layout())->insertWidget(0,toolBar);
+ static_cast(comics->layout())->insertWidget(0, toolBar);
this->toolbar = toolBar;
toolBarStretch = new YACReaderToolBarStretch(this);
@@ -135,54 +130,50 @@ void ClassicComicsView::setModel(ComicModel *model)
{
ComicsView::setModel(model);
- if(model == NULL)
- {
+ if (model == NULL) {
comicFlow->clear();
- }
- else
- {
- connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector)), this, SLOT(applyModelChanges(QModelIndex,QModelIndex,QVector)),Qt::UniqueConnection);
- connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(removeItemsFromFlow(QModelIndex,int,int)),Qt::UniqueConnection);
- connect(model, SIGNAL(resortedIndexes(QList)),comicFlow,SLOT(resortCovers(QList)),Qt::UniqueConnection);
- connect(model, SIGNAL(newSelectedIndex(QModelIndex)),this,SLOT(setCurrentIndex(QModelIndex)),Qt::UniqueConnection);
+ } else {
+ connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector)), this, SLOT(applyModelChanges(QModelIndex, QModelIndex, QVector)), Qt::UniqueConnection);
+ connect(model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(removeItemsFromFlow(QModelIndex, int, int)), Qt::UniqueConnection);
+ connect(model, SIGNAL(resortedIndexes(QList)), comicFlow, SLOT(resortCovers(QList)), Qt::UniqueConnection);
+ connect(model, SIGNAL(newSelectedIndex(QModelIndex)), this, SLOT(setCurrentIndex(QModelIndex)), Qt::UniqueConnection);
tableView->setModel(model);
- if(model->rowCount()>0)
- tableView->setCurrentIndex(model->index(0,0));
+ if (model->rowCount() > 0)
+ tableView->setCurrentIndex(model->index(0, 0));
tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
- #if QT_VERSION >= 0x050000
+#if QT_VERSION >= 0x050000
tableView->horizontalHeader()->setSectionsMovable(true);
- #else
+#else
tableView->horizontalHeader()->setMovable(true);
- #endif
+#endif
//TODO parametrizar la configuración de las columnas
/*if(!settings->contains(COMICS_VIEW_HEADERS))
{*/
- for(int i = 0;ihorizontalHeader()->count();i++)
- tableView->horizontalHeader()->hideSection(i);
+ for (int i = 0; i < tableView->horizontalHeader()->count(); i++)
+ tableView->horizontalHeader()->hideSection(i);
- tableView->horizontalHeader()->showSection(ComicModel::Number);
- tableView->horizontalHeader()->showSection(ComicModel::Title);
- tableView->horizontalHeader()->showSection(ComicModel::FileName);
- tableView->horizontalHeader()->showSection(ComicModel::NumPages);
- tableView->horizontalHeader()->showSection(ComicModel::Hash); //Size is part of the Hash...TODO add Columns::Size to Columns
- tableView->horizontalHeader()->showSection(ComicModel::ReadColumn);
- tableView->horizontalHeader()->showSection(ComicModel::CurrentPage);
- tableView->horizontalHeader()->showSection(ComicModel::Rating);
+ tableView->horizontalHeader()->showSection(ComicModel::Number);
+ tableView->horizontalHeader()->showSection(ComicModel::Title);
+ tableView->horizontalHeader()->showSection(ComicModel::FileName);
+ tableView->horizontalHeader()->showSection(ComicModel::NumPages);
+ tableView->horizontalHeader()->showSection(ComicModel::Hash); //Size is part of the Hash...TODO add Columns::Size to Columns
+ tableView->horizontalHeader()->showSection(ComicModel::ReadColumn);
+ tableView->horizontalHeader()->showSection(ComicModel::CurrentPage);
+ tableView->horizontalHeader()->showSection(ComicModel::Rating);
//}
//debido a un bug, qt4 no es capaz de ajustar el ancho teniendo en cuenta todas la filas (no sólo las visibles)
//asà que se ecala la primera vez y después se deja el control al usuario.
//if(!settings->contains(COMICS_VIEW_HEADERS))
-
- QStringList paths = model->getPaths(model->getCurrentPath());//TODO ComicsView: get currentpath from somewhere currentPath());
+ QStringList paths = model->getPaths(model->getCurrentPath()); //TODO ComicsView: get currentpath from somewhere currentPath());
comicFlow->setImagePaths(paths);
comicFlow->setMarks(model->getReadList());
//comicFlow->setFocus(Qt::OtherFocusReason);
- if(settings->contains(COMICS_VIEW_HEADERS))
+ if (settings->contains(COMICS_VIEW_HEADERS))
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
tableView->resizeColumnsToContents();
@@ -207,7 +198,7 @@ QItemSelectionModel *ClassicComicsView::selectionModel()
return tableView->selectionModel();
}
-void ClassicComicsView::scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint)
+void ClassicComicsView::scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint)
{
Q_UNUSED(hint);
@@ -242,15 +233,13 @@ void ClassicComicsView::updateConfig(QSettings *settings)
void ClassicComicsView::enableFilterMode(bool enabled)
{
- if(enabled)
- {
+ if (enabled) {
comicFlow->clear();
- if(previousSplitterStatus.isEmpty())
+ if (previousSplitterStatus.isEmpty())
previousSplitterStatus = sVertical->saveState();
- sVertical->setSizes(QList () << 100 << 10000000);
+ sVertical->setSizes(QList() << 100 << 10000000);
showSearchingIcon();
- }else
- {
+ } else {
hideSearchingIcon();
sVertical->restoreState(previousSplitterStatus);
previousSplitterStatus.clear();
@@ -267,7 +256,6 @@ void ClassicComicsView::selectIndex(int index)
void ClassicComicsView::updateCurrentComicView()
{
-
}
void ClassicComicsView::selectAll()
@@ -295,7 +283,7 @@ void ClassicComicsView::setShowMarks(bool show)
comicFlow->setShowMarks(show);
}
-void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
+void ClassicComicsView::centerComicFlow(const QModelIndex &mi)
{
comicFlow->showSlide(mi.row());
comicFlow->setFocus(Qt::OtherFocusReason);
@@ -303,20 +291,20 @@ void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
void ClassicComicsView::updateTableView(int i)
{
- QModelIndex mi = model->index(i,2);
+ QModelIndex mi = model->index(i, 2);
tableView->setCurrentIndex(mi);
- tableView->scrollTo(mi,QAbstractItemView::EnsureVisible);
+ tableView->scrollTo(mi, QAbstractItemView::EnsureVisible);
}
void ClassicComicsView::saveTableHeadersStatus()
{
- settings->setValue(COMICS_VIEW_HEADERS,tableView->horizontalHeader()->saveState());
+ settings->setValue(COMICS_VIEW_HEADERS, tableView->horizontalHeader()->saveState());
}
void ClassicComicsView::saveSplitterStatus()
{
settingsMutex.lock();
- if(!searching)
+ if (!searching)
settings->setValue(COMICS_VIEW_FLOW_SPLITTER_STATUS, sVertical->saveState());
settingsMutex.unlock();
}
@@ -325,8 +313,7 @@ void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QMod
{
Q_UNUSED(topLeft);
Q_UNUSED(bottomRight);
- if(roles.contains(ComicModel::ReadColumnRole))
- {
+ if (roles.contains(ComicModel::ReadColumnRole)) {
comicFlow->setMarks(model->getReadList());
comicFlow->updateMarks();
}
@@ -335,7 +322,7 @@ void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QMod
void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, int to)
{
Q_UNUSED(parent);
- for(int i = from; i<=to; i++)
+ for (int i = from; i <= to; i++)
comicFlow->remove(i);
}
@@ -353,13 +340,13 @@ void ClassicComicsView::setupSearchingIcon()
{
searchingIcon = new QWidget(comicFlow);
- QHBoxLayout * h = new QHBoxLayout;
+ QHBoxLayout *h = new QHBoxLayout;
QPixmap p(":/images/searching_icon.png");
- QLabel * l = new QLabel(searchingIcon);
+ QLabel *l = new QLabel(searchingIcon);
l->setPixmap(p);
l->setFixedSize(p.size());
- h->addWidget(l,0,Qt::AlignCenter);
+ h->addWidget(l, 0, Qt::AlignCenter);
searchingIcon->setLayout(h);
QPalette pal(searchingIcon->palette());
@@ -379,4 +366,3 @@ void ClassicComicsView::hideSearchingIcon()
{
stack->setCurrentWidget(comicFlow);
}
-
diff --git a/YACReaderLibrary/classic_comics_view.h b/YACReaderLibrary/classic_comics_view.h
index 08af02e6..b18bb15c 100644
--- a/YACReaderLibrary/classic_comics_view.h
+++ b/YACReaderLibrary/classic_comics_view.h
@@ -20,54 +20,53 @@ class ClassicComicsView : public ComicsView
Q_OBJECT
public:
ClassicComicsView(QWidget *parent = 0);
- void setToolBar(QToolBar * toolBar);
+ void setToolBar(QToolBar *toolBar);
void setModel(ComicModel *model);
QModelIndex currentIndex();
- QItemSelectionModel * selectionModel();
- void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
+ QItemSelectionModel *selectionModel();
+ void scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint);
void toFullScreen();
void toNormal();
- void updateConfig(QSettings * settings);
+ void updateConfig(QSettings *settings);
void enableFilterMode(bool enabled);
void selectIndex(int index);
void updateCurrentComicView();
public slots:
void setCurrentIndex(const QModelIndex &index);
- void centerComicFlow(const QModelIndex & mi);
+ void centerComicFlow(const QModelIndex &mi);
void updateTableView(int i);
void saveTableHeadersStatus();
void saveSplitterStatus();
- void applyModelChanges(const QModelIndex & topLeft,const QModelIndex & bottomRight,const QVector & roles);
- void removeItemsFromFlow(const QModelIndex & parent, int from, int to);
+ void applyModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles);
+ void removeItemsFromFlow(const QModelIndex &parent, int from, int to);
//ComicsView
void setShowMarks(bool show);
void selectAll();
- void selectedComicForOpening(const QModelIndex & mi);
+ void selectedComicForOpening(const QModelIndex &mi);
protected slots:
void hideComicFlow(bool hide);
- void requestedViewContextMenu(const QPoint & point);
- void requestedItemContextMenu(const QPoint & point);
-
+ void requestedViewContextMenu(const QPoint &point);
+ void requestedItemContextMenu(const QPoint &point);
private:
- YACReaderTableView * tableView;
- YACReaderToolBarStretch * toolBarStretch;
- QAction * toolBarStretchAction;
- QToolBar * toolbar;
+ YACReaderTableView *tableView;
+ YACReaderToolBarStretch *toolBarStretch;
+ QAction *toolBarStretchAction;
+ QToolBar *toolbar;
QWidget *comics;
- QSplitter * sVertical;
- ComicFlowWidget * comicFlow;
- QSettings * settings;
- void closeEvent ( QCloseEvent * event );
- QAction * hideFlowViewAction;
+ QSplitter *sVertical;
+ ComicFlowWidget *comicFlow;
+ QSettings *settings;
+ void closeEvent(QCloseEvent *event);
+ QAction *hideFlowViewAction;
- QStackedWidget * stack;
+ QStackedWidget *stack;
QByteArray previousSplitterStatus;
- QWidget * searchingIcon;
+ QWidget *searchingIcon;
bool searching;
void setupSearchingIcon();
void showSearchingIcon();
diff --git a/YACReaderLibrary/comic_files_manager.cpp b/YACReaderLibrary/comic_files_manager.cpp
index 43c5bcde..9f225be1 100644
--- a/YACReaderLibrary/comic_files_manager.cpp
+++ b/YACReaderLibrary/comic_files_manager.cpp
@@ -7,12 +7,12 @@
#include "comic.h"
-ComicFilesManager::ComicFilesManager(QObject *parent) :
- QObject(parent), canceled(false)
+ComicFilesManager::ComicFilesManager(QObject *parent)
+ : QObject(parent), canceled(false)
{
}
-void ComicFilesManager::copyComicsTo(const QList > &sourceComics, const QString &folderDest, const QModelIndex & dest)
+void ComicFilesManager::copyComicsTo(const QList> &sourceComics, const QString &folderDest, const QModelIndex &dest)
{
comics = sourceComics;
folder = folderDest;
@@ -20,7 +20,7 @@ void ComicFilesManager::copyComicsTo(const QList > &sourc
move = false;
}
-void ComicFilesManager::moveComicsTo(const QList > &sourceComics, const QString &folderDest, const QModelIndex &dest)
+void ComicFilesManager::moveComicsTo(const QList> &sourceComics, const QString &folderDest, const QModelIndex &dest)
{
comics = sourceComics;
folder = folderDest;
@@ -28,27 +28,23 @@ void ComicFilesManager::moveComicsTo(const QList > &sour
move = true;
}
-QList > ComicFilesManager::getDroppedFiles(const QList &urls)
+QList> ComicFilesManager::getDroppedFiles(const QList &urls)
{
- QList > dropedFiles;
+ QList> dropedFiles;
QString currentPath;
- foreach(QUrl url, urls)
- {
+ foreach (QUrl url, urls) {
currentPath = url.toLocalFile();
- if(currentPath.endsWith('/'))
- currentPath = currentPath.remove(currentPath.length()-1,1); //QTBUG-35896 QUrl.toLocalFile inconsistency.
- if(Comic::fileIsComic(currentPath))
- dropedFiles << QPair(currentPath,"/");
- else
- {
+ if (currentPath.endsWith('/'))
+ currentPath = currentPath.remove(currentPath.length() - 1, 1); //QTBUG-35896 QUrl.toLocalFile inconsistency.
+ if (Comic::fileIsComic(currentPath))
+ dropedFiles << QPair(currentPath, "/");
+ else {
QLOG_DEBUG() << "XXXXXXXXXXXX :" << currentPath;
QFileInfo info(currentPath);
- if(info.isDir())
- {
- QLOG_DEBUG() << "origin path prior to absoluteFilePath : " << info.absolutePath();
- foreach(QString comicPath, Comic::findValidComicFilesInFolder(info.absoluteFilePath()))
- {
+ if (info.isDir()) {
+ QLOG_DEBUG() << "origin path prior to absoluteFilePath : " << info.absolutePath();
+ foreach (QString comicPath, Comic::findValidComicFilesInFolder(info.absoluteFilePath())) {
QFileInfo comicInfo(comicPath);
QString path = comicInfo.absolutePath();
QLOG_DEBUG() << "comic path : " << comicPath;
@@ -65,14 +61,13 @@ QList > ComicFilesManager::getDroppedFiles(const QList source;
foreach (source, comics) {
- if(canceled)
- {
- if(successProcesingFiles)
+ if (canceled) {
+ if (successProcesingFiles)
emit success(folderDestinationModelIndex);
emit finished();
@@ -80,14 +75,12 @@ void ComicFilesManager::process()
}
QFileInfo info(source.first);
- QString destPath = QDir::cleanPath(folder+'/'+source.second);
+ QString destPath = QDir::cleanPath(folder + '/' + source.second);
QLOG_DEBUG() << "crear : " << destPath;
QDir().mkpath(destPath);
- if(QFile::copy(source.first, QDir::cleanPath(destPath+'/'+info.fileName())))
- {
+ if (QFile::copy(source.first, QDir::cleanPath(destPath + '/' + info.fileName()))) {
successProcesingFiles = true;
- if(move)
- {
+ if (move) {
QFile::remove(source.first); //TODO: remove the whole path....
}
}
@@ -96,7 +89,7 @@ void ComicFilesManager::process()
emit progress(i);
}
- if(successProcesingFiles)
+ if (successProcesingFiles)
emit success(folderDestinationModelIndex);
emit finished();
}
diff --git a/YACReaderLibrary/comic_files_manager.h b/YACReaderLibrary/comic_files_manager.h
index 7c2c202b..680ef180 100644
--- a/YACReaderLibrary/comic_files_manager.h
+++ b/YACReaderLibrary/comic_files_manager.h
@@ -6,16 +6,15 @@
#include
#include
-
//this class is intended to work in background, just use moveToThread and process to start working
class ComicFilesManager : public QObject
{
Q_OBJECT
public:
explicit ComicFilesManager(QObject *parent = 0);
- void copyComicsTo(const QList > & sourceComics, const QString & folderDest, const QModelIndex &dest);
- void moveComicsTo(const QList > & comics, const QString & folderDest, const QModelIndex &dest);
- static QList > getDroppedFiles(const QList & urls);
+ void copyComicsTo(const QList> &sourceComics, const QString &folderDest, const QModelIndex &dest);
+ void moveComicsTo(const QList> &comics, const QString &folderDest, const QModelIndex &dest);
+ static QList> getDroppedFiles(const QList &urls);
signals:
void currentComic(QString);
void progress(int);
@@ -28,10 +27,9 @@ public slots:
protected:
bool move;
bool canceled;
- QList > comics;
+ QList> comics;
QString folder;
QModelIndex folderDestinationModelIndex;
-
};
#endif // COMIC_FILES_MANAGER_H
diff --git a/YACReaderLibrary/comic_flow.cpp b/YACReaderLibrary/comic_flow.cpp
index 375a645f..1bd5f32a 100644
--- a/YACReaderLibrary/comic_flow.cpp
+++ b/YACReaderLibrary/comic_flow.cpp
@@ -9,139 +9,133 @@
#include
#include
-ComicFlow::ComicFlow(QWidget* parent,FlowType flowType)
-:YACReaderFlow(parent,flowType)
+ComicFlow::ComicFlow(QWidget *parent, FlowType flowType)
+ : YACReaderFlow(parent, flowType)
{
- updateTimer = new QTimer;
- connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
+ updateTimer = new QTimer;
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData()));
- worker = new ImageLoader;
- connect(this, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
- connect(this, SIGNAL(centerIndexChangedSilent(int)), this, SLOT(preload()));
+ worker = new ImageLoader;
+ connect(this, SIGNAL(centerIndexChanged(int)), this, SLOT(preload()));
+ connect(this, SIGNAL(centerIndexChangedSilent(int)), this, SLOT(preload()));
- setReflectionEffect(PlainReflection);
+ setReflectionEffect(PlainReflection);
}
ComicFlow::~ComicFlow()
{
worker->terminate();
- delete worker;
- delete updateTimer;
+ delete worker;
+ delete updateTimer;
}
-void ComicFlow::setImagePaths(const QStringList& paths)
+void ComicFlow::setImagePaths(const QStringList &paths)
{
- clear();
+ clear();
- //imagePath = path;
- imageFiles = paths;
- imagesLoaded.clear();
- imagesLoaded.fill(false,imageFiles.size());
- numImagesLoaded = 0;
+ //imagePath = path;
+ imageFiles = paths;
+ imagesLoaded.clear();
+ imagesLoaded.fill(false, imageFiles.size());
+ numImagesLoaded = 0;
- imagesSetted.clear();
- imagesSetted.fill(false,imageFiles.size());
+ imagesSetted.clear();
+ imagesSetted.fill(false, imageFiles.size());
- // populate with empty images
- QImage img; //TODO remove
- QString s;
- for(int i = 0; i < (int)imageFiles.size(); i++)
- {
- addSlide(img);
- s = imageFiles.at(i);
- s.remove(s.size()-4,4);
- if(QFileInfo(s+".r").exists())
- markSlide(i);
- }
+ // populate with empty images
+ QImage img; //TODO remove
+ QString s;
+ for (int i = 0; i < (int)imageFiles.size(); i++) {
+ addSlide(img);
+ s = imageFiles.at(i);
+ s.remove(s.size() - 4, 4);
+ if (QFileInfo(s + ".r").exists())
+ markSlide(i);
+ }
- setCenterIndex(0);
- worker->reset();
- preload();
+ setCenterIndex(0);
+ worker->reset();
+ preload();
}
void ComicFlow::preload()
{
- if(numImagesLoaded < imagesLoaded.size())
- updateTimer->start(30); //TODO comprobar rendimiento, originalmente era 70
+ if (numImagesLoaded < imagesLoaded.size())
+ updateTimer->start(30); //TODO comprobar rendimiento, originalmente era 70
}
void ComicFlow::updateImageData()
{
- // can't do anything, wait for the next possibility
- if(worker->busy())
- return;
+ // can't do anything, wait for the next possibility
+ if (worker->busy())
+ return;
- // set image of last one
- int idx = worker->index();
- if( idx >= 0 && !worker->result().isNull())
- {
- if(!imagesSetted[idx])
- {
- setSlide(idx, worker->result());
- imagesSetted[idx] = true;
- numImagesLoaded++;
- imagesLoaded[idx]=true;
- }
- }
+ // set image of last one
+ int idx = worker->index();
+ if (idx >= 0 && !worker->result().isNull()) {
+ if (!imagesSetted[idx]) {
+ setSlide(idx, worker->result());
+ imagesSetted[idx] = true;
+ numImagesLoaded++;
+ imagesLoaded[idx] = true;
+ }
+ }
- // try to load only few images on the left and right side
- // i.e. all visible ones plus some extra
-#define COUNT 8
- int indexes[2*COUNT+1];
- int center = centerIndex();
- indexes[0] = center;
- for(int j = 0; j < COUNT; j++)
- {
- indexes[j*2+1] = center+j+1;
- indexes[j*2+2] = center-j-1;
- }
- for(int c = 0; c < 2*COUNT+1; c++)
- {
- int i = indexes[c];
- if((i >= 0) && (i < slideCount()))
- if(!imagesLoaded[i])//slide(i).isNull())
- {
- // schedule thumbnail generation
- QString fname = imageFiles[i];
-
-
- worker->generate(i, fname, slideSize());
- return;
- }
- }
+ // try to load only few images on the left and right side
+ // i.e. all visible ones plus some extra
+#define COUNT 8
+ int indexes[2 * COUNT + 1];
+ int center = centerIndex();
+ indexes[0] = center;
+ for (int j = 0; j < COUNT; j++) {
+ indexes[j * 2 + 1] = center + j + 1;
+ indexes[j * 2 + 2] = center - j - 1;
+ }
+ for (int c = 0; c < 2 * COUNT + 1; c++) {
+ int i = indexes[c];
+ if ((i >= 0) && (i < slideCount()))
+ if (!imagesLoaded[i]) //slide(i).isNull())
+ {
+ // schedule thumbnail generation
+ QString fname = imageFiles[i];
- // no need to generate anything? stop polling...
- updateTimer->stop();
+ worker->generate(i, fname, slideSize());
+ return;
+ }
+ }
+
+ // no need to generate anything? stop polling...
+ updateTimer->stop();
}
-void ComicFlow::keyPressEvent(QKeyEvent* event)
+void ComicFlow::keyPressEvent(QKeyEvent *event)
{
- PictureFlow::keyPressEvent(event);
+ PictureFlow::keyPressEvent(event);
}
-void ComicFlow::wheelEvent(QWheelEvent * event)
+void ComicFlow::wheelEvent(QWheelEvent *event)
{
- if(event->delta()<0)
- showNext();
- else
- showPrevious();
- event->accept();
+ if (event->delta() < 0)
+ showNext();
+ else
+ showPrevious();
+ event->accept();
}
void ComicFlow::removeSlide(int cover)
{
- worker->lock();
+ worker->lock();
- worker->reset();
+ worker->reset();
- imageFiles.removeAt(cover);
- if(imagesLoaded[cover])
- numImagesLoaded--;
- imagesLoaded.remove(cover);
- imagesSetted.remove(cover);
+ imageFiles.removeAt(cover);
+ if (imagesLoaded[cover])
+ numImagesLoaded--;
+ imagesLoaded.remove(cover);
+ imagesSetted.remove(cover);
- YACReaderFlow::removeSlide(cover);
- worker->unlock();
+ YACReaderFlow::removeSlide(cover);
+ worker->unlock();
preload();
}
@@ -156,15 +150,12 @@ void ComicFlow::resortCovers(QList newOrder)
QStringList imageFilesNew;
QVector imagesLoadedNew;
QVector imagesSettedNew;
- foreach(int index, newOrder)
- {
+ foreach (int index, newOrder) {
imageFilesNew << imageFiles.at(index);
imagesLoadedNew << imagesLoaded.at(index);
imagesSettedNew << imagesSetted.at(index);
}
-
-
imageFiles = imageFilesNew;
imagesLoaded = imagesLoadedNew;
imagesSetted = imagesSettedNew;
@@ -174,92 +165,90 @@ void ComicFlow::resortCovers(QList newOrder)
//-----------------------------------------------------------------------------
//ImageLoader
//-----------------------------------------------------------------------------
-static QImage loadImage(const QString& fileName)
+static QImage loadImage(const QString &fileName)
{
- QImage image;
- bool result = image.load(fileName);
+ QImage image;
+ bool result = image.load(fileName);
- if(!result)
- return QImage();
+ if (!result)
+ return QImage();
- return image;
+ return image;
}
-ImageLoader::ImageLoader():
-QThread(), restart(false), working(false), idx(-1)
+ImageLoader::ImageLoader()
+ : QThread(), restart(false), working(false), idx(-1)
{
}
ImageLoader::~ImageLoader()
{
- mutex.lock();
- condition.wakeOne();
- mutex.unlock();
- wait();
+ mutex.lock();
+ condition.wakeOne();
+ mutex.unlock();
+ wait();
}
bool ImageLoader::busy() const
{
- return isRunning() ? working : false;
-}
+ return isRunning() ? working : false;
+}
-void ImageLoader::generate(int index, const QString& fileName, QSize size)
+void ImageLoader::generate(int index, const QString &fileName, QSize size)
{
- mutex.lock();
- this->idx = index;
- this->fileName = fileName;
- this->size = size;
- this->img = QImage();
- mutex.unlock();
+ mutex.lock();
+ this->idx = index;
+ this->fileName = fileName;
+ this->size = size;
+ this->img = QImage();
+ mutex.unlock();
- if (!isRunning())
- start();
- else
- {
- // already running, wake up whenever ready
- restart = true;
- condition.wakeOne();
- }
+ if (!isRunning())
+ start();
+ else {
+ // already running, wake up whenever ready
+ restart = true;
+ condition.wakeOne();
+ }
}
void ImageLoader::lock()
{
- mutex.lock();
+ mutex.lock();
}
void ImageLoader::unlock()
{
- mutex.unlock();
+ mutex.unlock();
}
void ImageLoader::run()
{
- for(;;)
- {
- // copy necessary data
- mutex.lock();
- this->working = true;
- QString fileName = this->fileName;
- mutex.unlock();
+ for (;;) {
+ // copy necessary data
+ mutex.lock();
+ this->working = true;
+ QString fileName = this->fileName;
+ mutex.unlock();
- QImage image = loadImage(fileName);
+ QImage image = loadImage(fileName);
- // let everyone knows it is ready
- mutex.lock();
- this->working = false;
- this->img = image;
- mutex.unlock();
+ // let everyone knows it is ready
+ mutex.lock();
+ this->working = false;
+ this->img = image;
+ mutex.unlock();
- // put to sleep
- mutex.lock();
- if (!this->restart)
- condition.wait(&mutex);
- restart = false;
- mutex.unlock();
- }
+ // put to sleep
+ mutex.lock();
+ if (!this->restart)
+ condition.wait(&mutex);
+ restart = false;
+ mutex.unlock();
+ }
}
-QImage ImageLoader::result()
-{
- return img;
+QImage ImageLoader::result()
+{
+ return img;
}
diff --git a/YACReaderLibrary/comic_flow.h b/YACReaderLibrary/comic_flow.h
index ecb27916..0d69ed94 100644
--- a/YACReaderLibrary/comic_flow.h
+++ b/YACReaderLibrary/comic_flow.h
@@ -15,32 +15,31 @@
class ImageLoader;
class ComicFlow : public YACReaderFlow
{
- Q_OBJECT
+ Q_OBJECT
public:
- ComicFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
- virtual ~ComicFlow();
+ ComicFlow(QWidget *parent = 0, FlowType flowType = CoverFlowLike);
+ virtual ~ComicFlow();
- void setImagePaths(const QStringList& paths);
- //bool eventFilter(QObject *target, QEvent *event);
- void keyPressEvent(QKeyEvent* event);
- void removeSlide(int cover);
+ void setImagePaths(const QStringList &paths);
+ //bool eventFilter(QObject *target, QEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void removeSlide(int cover);
void resortCovers(QList newOrder);
private slots:
- void preload();
- void updateImageData();
+ void preload();
+ void updateImageData();
private:
- //QString imagePath;
- QStringList imageFiles;
- QVector imagesLoaded;
- QVector imagesSetted;
- int numImagesLoaded;
- QTimer* updateTimer;
- ImageLoader* worker;
- virtual void wheelEvent(QWheelEvent * event);
-};
-
+ //QString imagePath;
+ QStringList imageFiles;
+ QVector imagesLoaded;
+ QVector imagesSetted;
+ int numImagesLoaded;
+ QTimer *updateTimer;
+ ImageLoader *worker;
+ virtual void wheelEvent(QWheelEvent *event);
+};
//-----------------------------------------------------------------------------
// Source code of ImageLoader class was modified from http://code.google.com/p/photoflow/
@@ -48,31 +47,30 @@ private:
class ImageLoader : public QThread
{
public:
- ImageLoader();
- ~ImageLoader();
- // returns FALSE if worker is still busy and can't take the task
- bool busy() const;
- void generate(int index, const QString& fileName, QSize size);
- void reset(){idx = -1;};
- int index() const { return idx; };
- void lock();
- void unlock();
- QImage result();
+ ImageLoader();
+ ~ImageLoader();
+ // returns FALSE if worker is still busy and can't take the task
+ bool busy() const;
+ void generate(int index, const QString &fileName, QSize size);
+ void reset() { idx = -1; };
+ int index() const { return idx; };
+ void lock();
+ void unlock();
+ QImage result();
protected:
- void run();
+ void run();
private:
- QMutex mutex;
- QWaitCondition condition;
+ QMutex mutex;
+ QWaitCondition condition;
- bool restart;
- bool working;
- int idx;
- QString fileName;
- QSize size;
- QImage img;
+ bool restart;
+ bool working;
+ int idx;
+ QString fileName;
+ QSize size;
+ QImage img;
};
-
#endif
diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp
index 6c114a54..313d1b00 100644
--- a/YACReaderLibrary/comic_flow_widget.cpp
+++ b/YACReaderLibrary/comic_flow_widget.cpp
@@ -1,138 +1,136 @@
#include "comic_flow_widget.h"
#include
-ComicFlowWidget::ComicFlowWidget(QWidget * parent)
- :QWidget(parent)
+ComicFlowWidget::ComicFlowWidget(QWidget *parent)
+ : QWidget(parent)
{
-
}
-ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget * parent)
- :ComicFlowWidget(parent)
+ComicFlowWidgetSW::ComicFlowWidgetSW(QWidget *parent)
+ : ComicFlowWidget(parent)
{
- flow = new ComicFlow(parent);
+ flow = new ComicFlow(parent);
- connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
- connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
+ connect(flow, SIGNAL(centerIndexChanged(int)), this, SIGNAL(centerIndexChanged(int)));
+ connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(selected(unsigned int)));
- QVBoxLayout * l = new QVBoxLayout;
- l->addWidget(flow);
- setLayout(l);
+ QVBoxLayout *l = new QVBoxLayout;
+ l->addWidget(flow);
+ setLayout(l);
- //TODO eleminar "padding"
- QPalette Pal(palette());
- // set black background
- Pal.setColor(QPalette::Background, Qt::black);
- setAutoFillBackground(true);
- setPalette(Pal);
+ //TODO eleminar "padding"
+ QPalette Pal(palette());
+ // set black background
+ Pal.setColor(QPalette::Background, Qt::black);
+ setAutoFillBackground(true);
+ setPalette(Pal);
- //config
- QMatrix m;
- m.rotate(-90);
- m.scale(-1,1);
- QImage image(":/images/setRead.png");
- QImage imageTransformed = image.transformed(m,Qt::SmoothTransformation);
- setMarkImage(imageTransformed);
+ //config
+ QMatrix m;
+ m.rotate(-90);
+ m.scale(-1, 1);
+ QImage image(":/images/setRead.png");
+ QImage imageTransformed = image.transformed(m, Qt::SmoothTransformation);
+ setMarkImage(imageTransformed);
}
QSize ComicFlowWidgetSW::minimumSizeHint() const
{
- return flow->minimumSizeHint();
+ return flow->minimumSizeHint();
}
QSize ComicFlowWidgetSW::sizeHint() const
{
- return flow->sizeHint();
+ return flow->sizeHint();
}
void ComicFlowWidgetSW::setShowMarks(bool value)
{
- flow->setShowMarks(value);
+ flow->setShowMarks(value);
}
void ComicFlowWidgetSW::setMarks(QVector marks)
{
- flow->setMarks(marks);
+ flow->setMarks(marks);
}
-void ComicFlowWidgetSW::setMarkImage(QImage & image)
+void ComicFlowWidgetSW::setMarkImage(QImage &image)
{
- flow->setMarkImage(image);
+ flow->setMarkImage(image);
}
void ComicFlowWidgetSW::markSlide(int index, YACReaderComicReadStatus status)
{
- flow->markSlide(index,status);
+ flow->markSlide(index, status);
}
void ComicFlowWidgetSW::unmarkSlide(int index)
{
- flow->unmarkSlide(index);
+ flow->unmarkSlide(index);
}
void ComicFlowWidgetSW::setSlideSize(QSize size)
{
- flow->setSlideSize(size);
+ flow->setSlideSize(size);
}
void ComicFlowWidgetSW::clear()
{
- flow->clear();
+ flow->clear();
}
void ComicFlowWidgetSW::setImagePaths(QStringList paths)
{
- flow->setImagePaths(paths);
+ flow->setImagePaths(paths);
}
void ComicFlowWidgetSW::setCenterIndex(int index)
{
- flow->setCenterIndex(index);
+ flow->setCenterIndex(index);
}
void ComicFlowWidgetSW::showSlide(int index)
{
- flow->showSlide(index);
+ flow->showSlide(index);
}
int ComicFlowWidgetSW::centerIndex()
{
- return flow->centerIndex();
+ return flow->centerIndex();
}
void ComicFlowWidgetSW::updateMarks()
{
- flow->updateMarks();
+ flow->updateMarks();
}
void ComicFlowWidgetSW::setFlowType(FlowType flowType)
{
- flow->setFlowType(flowType);
+ flow->setFlowType(flowType);
}
void ComicFlowWidgetSW::render()
{
- flow->render();
+ flow->render();
}
-void ComicFlowWidgetSW::keyPressEvent(QKeyEvent* event)
+void ComicFlowWidgetSW::keyPressEvent(QKeyEvent *event)
{
- flow->keyPressEvent(event);
+ flow->keyPressEvent(event);
}
void ComicFlowWidgetSW::paintEvent(QPaintEvent *event)
{
- ComicFlowWidget::paintEvent(event);
+ ComicFlowWidget::paintEvent(event);
}
-void ComicFlowWidgetSW::mousePressEvent(QMouseEvent* event)
+void ComicFlowWidgetSW::mousePressEvent(QMouseEvent *event)
{
- flow->mousePressEvent(event);
+ flow->mousePressEvent(event);
}
-void ComicFlowWidgetSW::resizeEvent(QResizeEvent* event)
+void ComicFlowWidgetSW::resizeEvent(QResizeEvent *event)
{
- flow->resizeEvent(event);
+ flow->resizeEvent(event);
}
-void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent* event)
+void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent *event)
{
- flow->mouseDoubleClickEvent(event);
+ flow->mouseDoubleClickEvent(event);
}
-void ComicFlowWidgetSW::updateConfig(QSettings * settings)
+void ComicFlowWidgetSW::updateConfig(QSettings *settings)
{
- switch (settings->value(FLOW_TYPE_SW).toInt())
- {
- case CoverFlowLike:
- flow->setFlowType(CoverFlowLike);
- return;
- case Strip:
- flow->setFlowType(Strip);
- return;
- case StripOverlapped:
- flow->setFlowType(StripOverlapped);
- return;
- }
+ switch (settings->value(FLOW_TYPE_SW).toInt()) {
+ case CoverFlowLike:
+ flow->setFlowType(CoverFlowLike);
+ return;
+ case Strip:
+ flow->setFlowType(Strip);
+ return;
+ case StripOverlapped:
+ flow->setFlowType(StripOverlapped);
+ return;
+ }
}
void ComicFlowWidgetSW::remove(int cover)
@@ -152,184 +150,181 @@ void ComicFlowWidgetSW::resortCovers(QList newOrder)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent)
- :ComicFlowWidget(parent)
+ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget *parent)
+ : ComicFlowWidget(parent)
{
- flow = new YACReaderComicFlowGL(parent);
+ flow = new YACReaderComicFlowGL(parent);
- connect(flow,SIGNAL(centerIndexChanged(int)),this,SIGNAL(centerIndexChanged(int)));
- connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(selected(unsigned int)));
+ connect(flow, SIGNAL(centerIndexChanged(int)), this, SIGNAL(centerIndexChanged(int)));
+ connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(selected(unsigned int)));
- QVBoxLayout * l = new QVBoxLayout;
- l->addWidget(flow);
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
+ QVBoxLayout *l = new QVBoxLayout;
+ l->addWidget(flow);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
- //TODO eleminar "padding"
- QPalette Pal(palette());
- // set black background
- Pal.setColor(QPalette::Background, Qt::black);
- setAutoFillBackground(true);
- setPalette(Pal);
+ //TODO eleminar "padding"
+ QPalette Pal(palette());
+ // set black background
+ Pal.setColor(QPalette::Background, Qt::black);
+ setAutoFillBackground(true);
+ setPalette(Pal);
}
QSize ComicFlowWidgetGL::minimumSizeHint() const
{
- return flow->minimumSizeHint();
+ return flow->minimumSizeHint();
}
QSize ComicFlowWidgetGL::sizeHint() const
{
- return flow->sizeHint();
+ return flow->sizeHint();
}
void ComicFlowWidgetGL::setShowMarks(bool value)
{
- flow->setShowMarks(value);
+ flow->setShowMarks(value);
}
void ComicFlowWidgetGL::setMarks(QVector marks)
{
- flow->setMarks(marks);
+ flow->setMarks(marks);
}
-void ComicFlowWidgetGL::setMarkImage(QImage & image)
+void ComicFlowWidgetGL::setMarkImage(QImage &image)
{
- flow->setMarkImage(image);
+ flow->setMarkImage(image);
}
void ComicFlowWidgetGL::markSlide(int index, YACReaderComicReadStatus status)
{
- flow->markSlide(index,status);
+ flow->markSlide(index, status);
}
void ComicFlowWidgetGL::unmarkSlide(int index)
{
- flow->unmarkSlide(index);
+ flow->unmarkSlide(index);
}
void ComicFlowWidgetGL::setSlideSize(QSize size)
{
- flow->setSlideSize(size);
+ flow->setSlideSize(size);
}
void ComicFlowWidgetGL::clear()
{
- flow->clear();
+ flow->clear();
}
void ComicFlowWidgetGL::setImagePaths(QStringList paths)
{
- flow->setImagePaths(paths);
+ flow->setImagePaths(paths);
}
void ComicFlowWidgetGL::setCenterIndex(int index)
{
- flow->setCenterIndex(index);
+ flow->setCenterIndex(index);
}
void ComicFlowWidgetGL::showSlide(int index)
{
- flow->showSlide(index);
+ flow->showSlide(index);
}
int ComicFlowWidgetGL::centerIndex()
{
- return flow->centerIndex();
+ return flow->centerIndex();
}
void ComicFlowWidgetGL::updateMarks()
{
- flow->updateMarks();
+ flow->updateMarks();
}
void ComicFlowWidgetGL::setFlowType(FlowType flowType)
{
- if(flowType == CoverFlowLike)
- flow->setPreset(presetYACReaderFlowClassicConfig);
- else if(flowType == Strip)
- flow->setPreset(presetYACReaderFlowStripeConfig);
- else if(flowType == StripOverlapped)
- flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
- else
- flow->setPreset(defaultYACReaderFlowConfig);
+ if (flowType == CoverFlowLike)
+ flow->setPreset(presetYACReaderFlowClassicConfig);
+ else if (flowType == Strip)
+ flow->setPreset(presetYACReaderFlowStripeConfig);
+ else if (flowType == StripOverlapped)
+ flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
+ else
+ flow->setPreset(defaultYACReaderFlowConfig);
}
void ComicFlowWidgetGL::render()
{
- flow->render();
+ flow->render();
}
-void ComicFlowWidgetGL::keyPressEvent(QKeyEvent* event)
+void ComicFlowWidgetGL::keyPressEvent(QKeyEvent *event)
{
- flow->keyPressEvent(event);
+ flow->keyPressEvent(event);
}
void ComicFlowWidgetGL::paintEvent(QPaintEvent *event)
{
- //flow->paintEvent(event);
- ComicFlowWidget::paintEvent(event);
+ //flow->paintEvent(event);
+ ComicFlowWidget::paintEvent(event);
}
-void ComicFlowWidgetGL::mousePressEvent(QMouseEvent* event)
+void ComicFlowWidgetGL::mousePressEvent(QMouseEvent *event)
{
- flow->mousePressEvent(event);
+ flow->mousePressEvent(event);
}
-void ComicFlowWidgetGL::resizeEvent(QResizeEvent* event)
+void ComicFlowWidgetGL::resizeEvent(QResizeEvent *event)
{
- flow->resizeGL(event->size().width(),event->size().height());
+ flow->resizeGL(event->size().width(), event->size().height());
}
-void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent* event)
+void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent *event)
{
- flow->mouseDoubleClickEvent(event);
+ flow->mouseDoubleClickEvent(event);
}
-void ComicFlowWidgetGL::updateConfig(QSettings * settings)
+void ComicFlowWidgetGL::updateConfig(QSettings *settings)
{
- Performance performance = medium;
+ Performance performance = medium;
- switch (settings->value(PERFORMANCE).toInt())
- {
- case 0:
- performance = low;
- break;
- case 1:
- performance = medium;
- break;
- case 2:
- performance = high;
- break;
- case 3:
- performance = ultraHigh;
- break;
- }
+ switch (settings->value(PERFORMANCE).toInt()) {
+ case 0:
+ performance = low;
+ break;
+ case 1:
+ performance = medium;
+ break;
+ case 2:
+ performance = high;
+ break;
+ case 3:
+ performance = ultraHigh;
+ break;
+ }
- flow->setPerformance(performance);
- if(!settings->contains(V_SYNC))
- flow->useVSync(false);
- else
- flow->useVSync(settings->value(V_SYNC).toBool());
+ flow->setPerformance(performance);
+ if (!settings->contains(V_SYNC))
+ flow->useVSync(false);
+ else
+ flow->useVSync(settings->value(V_SYNC).toBool());
- switch (settings->value(FLOW_TYPE_GL).toInt())
- {
- case 0:
- flow->setPreset(presetYACReaderFlowClassicConfig);
- return;
- case 1:
- flow->setPreset(presetYACReaderFlowStripeConfig);
- return;
- case 2:
- flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
- return;
- case 3:
- flow->setPreset(defaultYACReaderFlowConfig);
- return;
- case 4:
- flow->setPreset(pressetYACReaderFlowDownConfig);
- return;
- }
+ switch (settings->value(FLOW_TYPE_GL).toInt()) {
+ case 0:
+ flow->setPreset(presetYACReaderFlowClassicConfig);
+ return;
+ case 1:
+ flow->setPreset(presetYACReaderFlowStripeConfig);
+ return;
+ case 2:
+ flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
+ return;
+ case 3:
+ flow->setPreset(defaultYACReaderFlowConfig);
+ return;
+ case 4:
+ flow->setPreset(pressetYACReaderFlowDownConfig);
+ return;
+ }
+ //custom config
- //custom config
-
- flow->setCF_RX(settings->value(X_ROTATION).toInt());
- flow->setCF_Y(settings->value(Y_POSITION).toInt());
- flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
- flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
- flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
- flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
- flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
- flow->setRotation(settings->value(COVER_ROTATION).toInt());
- flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
- flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
- flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
-
-/* flow->setVisibility(settings->value("visibilityDistance").toInt());
- flow->setLightStrenght(settings->value("lightStrength").toInt())*/;
+ flow->setCF_RX(settings->value(X_ROTATION).toInt());
+ flow->setCF_Y(settings->value(Y_POSITION).toInt());
+ flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
+ flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
+ flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
+ flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
+ flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
+ flow->setRotation(settings->value(COVER_ROTATION).toInt());
+ flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
+ flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
+ flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
+ /* flow->setVisibility(settings->value("visibilityDistance").toInt());
+ flow->setLightStrenght(settings->value("lightStrength").toInt())*/
+ ;
}
void ComicFlowWidgetGL::remove(int cover)
diff --git a/YACReaderLibrary/comic_flow_widget.h b/YACReaderLibrary/comic_flow_widget.h
index 014c8ac0..08bde4be 100644
--- a/YACReaderLibrary/comic_flow_widget.h
+++ b/YACReaderLibrary/comic_flow_widget.h
@@ -1,7 +1,6 @@
#ifndef __COMIC_FLOW_WIDGET_H
#define __COMIC_FLOW_WIDGET_H
-
#include
#include "pictureflow.h"
@@ -10,124 +9,126 @@
#include "yacreader_flow_gl.h"
#endif
class ComicFlowWidget : public QWidget
-{
- Q_OBJECT
+{
+ Q_OBJECT
public:
- ComicFlowWidget(QWidget * paret = 0);
+ ComicFlowWidget(QWidget *paret = 0);
public slots:
- virtual void setShowMarks(bool value) = 0;
- virtual void setMarks(QVector marks) = 0;
- virtual void setMarkImage(QImage & image) = 0;
- virtual void markSlide(int index, YACReaderComicReadStatus status) = 0;
- virtual void unmarkSlide(int index) = 0;
- virtual void setSlideSize(QSize size) = 0;
- virtual void clear() = 0;
- virtual void setImagePaths(QStringList paths) = 0;
- virtual void setCenterIndex(int index) = 0;
- virtual void showSlide(int index) = 0;
- virtual int centerIndex() = 0;
- virtual void updateMarks() = 0;
- virtual void setFlowType(FlowType flowType) = 0;
- virtual void render() = 0;
- virtual void updateConfig(QSettings * settings) = 0;
- virtual void remove(int cover) = 0;
+ virtual void setShowMarks(bool value) = 0;
+ virtual void setMarks(QVector marks) = 0;
+ virtual void setMarkImage(QImage &image) = 0;
+ virtual void markSlide(int index, YACReaderComicReadStatus status) = 0;
+ virtual void unmarkSlide(int index) = 0;
+ virtual void setSlideSize(QSize size) = 0;
+ virtual void clear() = 0;
+ virtual void setImagePaths(QStringList paths) = 0;
+ virtual void setCenterIndex(int index) = 0;
+ virtual void showSlide(int index) = 0;
+ virtual int centerIndex() = 0;
+ virtual void updateMarks() = 0;
+ virtual void setFlowType(FlowType flowType) = 0;
+ virtual void render() = 0;
+ virtual void updateConfig(QSettings *settings) = 0;
+ virtual void remove(int cover) = 0;
virtual void resortCovers(QList newOrder) = 0;
signals:
- void centerIndexChanged(int);
- void selected(unsigned int);
+ void centerIndexChanged(int);
+ void selected(unsigned int);
};
-
class ComicFlowWidgetSW : public ComicFlowWidget
{
- Q_OBJECT
+ Q_OBJECT
private:
- ComicFlow * flow;
-public:
- ComicFlowWidgetSW(QWidget * parent = 0);
+ ComicFlow *flow;
- void setShowMarks(bool value);
- void setMarks(QVector marks);
- void setMarkImage(QImage & image);
- void markSlide(int index, YACReaderComicReadStatus status);
- void unmarkSlide(int index);
- void setSlideSize(QSize size);
- void clear();
- void setImagePaths(QStringList paths);
- void setCenterIndex(int index);
- void showSlide(int index);
- int centerIndex();
- void updateMarks();
- void setFlowType(FlowType flowType);
- void render();
- void updateConfig(QSettings * settings);
- void remove(int cover);
+public:
+ ComicFlowWidgetSW(QWidget *parent = 0);
+
+ void setShowMarks(bool value);
+ void setMarks(QVector marks);
+ void setMarkImage(QImage &image);
+ void markSlide(int index, YACReaderComicReadStatus status);
+ void unmarkSlide(int index);
+ void setSlideSize(QSize size);
+ void clear();
+ void setImagePaths(QStringList paths);
+ void setCenterIndex(int index);
+ void showSlide(int index);
+ int centerIndex();
+ void updateMarks();
+ void setFlowType(FlowType flowType);
+ void render();
+ void updateConfig(QSettings *settings);
+ void remove(int cover);
void resortCovers(QList newOrder);
+
protected:
- void keyPressEvent(QKeyEvent* event);
- void paintEvent(QPaintEvent *event);
- void mousePressEvent(QMouseEvent* event);
- void resizeEvent(QResizeEvent* event);
- void mouseDoubleClickEvent(QMouseEvent* event);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
- QSize slideSizeW;
- QSize slideSizeF;
+ void keyPressEvent(QKeyEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ QSize minimumSizeHint() const;
+ QSize sizeHint() const;
+ QSize slideSizeW;
+ QSize slideSizeF;
};
#ifndef NO_OPENGL
class ComicFlowWidgetGL : public ComicFlowWidget
{
- Q_OBJECT
+ Q_OBJECT
private:
- YACReaderComicFlowGL * flow;
-public:
- ComicFlowWidgetGL(QWidget * parent = 0);
+ YACReaderComicFlowGL *flow;
- void setShowMarks(bool value);
- void setMarks(QVector marks);
- void setMarkImage(QImage & image);
- void markSlide(int index, YACReaderComicReadStatus status);
- void unmarkSlide(int index);
- void setSlideSize(QSize size);
- void clear();
- void setImagePaths(QStringList paths);
- void setCenterIndex(int index);
- void showSlide(int index);
- int centerIndex();
- void updateMarks();
- void setFlowType(FlowType flowType);
- void render();
- void updateConfig(QSettings * settings);
- void remove(int cover);
+public:
+ ComicFlowWidgetGL(QWidget *parent = 0);
+
+ void setShowMarks(bool value);
+ void setMarks(QVector marks);
+ void setMarkImage(QImage &image);
+ void markSlide(int index, YACReaderComicReadStatus status);
+ void unmarkSlide(int index);
+ void setSlideSize(QSize size);
+ void clear();
+ void setImagePaths(QStringList paths);
+ void setCenterIndex(int index);
+ void showSlide(int index);
+ int centerIndex();
+ void updateMarks();
+ void setFlowType(FlowType flowType);
+ void render();
+ void updateConfig(QSettings *settings);
+ void remove(int cover);
void resortCovers(QList newOrder);
-//public slots:
-// void setCF_RX(int value);
-// //the Y Rotation of the Coverflow
-// void setCF_RY(int value);
-// //the Z Rotation of the Coverflow
-// void setCF_RZ(int value);
-// //perspective
-// void setZoom(int zoom);
-// void setRotation(int angle);
-// //sets the distance between the covers
-// void setX_Distance(int distance);
-// //sets the distance between the centered and the non centered covers
-// void setCenter_Distance(int distance);
-// //sets the pushback amount
-// void setZ_Distance(int distance);
-// void setCF_Y(int value);
-// void setY_Distance(int value);
-// void setPreset(const Preset & p);
+ //public slots:
+ // void setCF_RX(int value);
+ // //the Y Rotation of the Coverflow
+ // void setCF_RY(int value);
+ // //the Z Rotation of the Coverflow
+ // void setCF_RZ(int value);
+ // //perspective
+ // void setZoom(int zoom);
+ // void setRotation(int angle);
+ // //sets the distance between the covers
+ // void setX_Distance(int distance);
+ // //sets the distance between the centered and the non centered covers
+ // void setCenter_Distance(int distance);
+ // //sets the pushback amount
+ // void setZ_Distance(int distance);
+ // void setCF_Y(int value);
+ // void setY_Distance(int value);
+ // void setPreset(const Preset & p);
protected:
- void keyPressEvent(QKeyEvent* event);
- void paintEvent(QPaintEvent *event);
- void mousePressEvent(QMouseEvent* event);
- void resizeEvent(QResizeEvent* event);
- void mouseDoubleClickEvent(QMouseEvent* event);
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
+ void keyPressEvent(QKeyEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ QSize minimumSizeHint() const;
+ QSize sizeHint() const;
};
#endif
#endif
diff --git a/YACReaderLibrary/comic_vine/api_key_dialog.cpp b/YACReaderLibrary/comic_vine/api_key_dialog.cpp
index fd45af96..062c9652 100644
--- a/YACReaderLibrary/comic_vine/api_key_dialog.cpp
+++ b/YACReaderLibrary/comic_vine/api_key_dialog.cpp
@@ -9,28 +9,28 @@
#include "yacreader_global_gui.h"
-ApiKeyDialog::ApiKeyDialog(QWidget *parent) :
- QDialog(parent)
+ApiKeyDialog::ApiKeyDialog(QWidget *parent)
+ : QDialog(parent)
{
- QVBoxLayout * layout = new QVBoxLayout;
- QHBoxLayout * buttonsLayout = new QHBoxLayout;
+ QVBoxLayout *layout = new QVBoxLayout;
+ QHBoxLayout *buttonsLayout = new QHBoxLayout;
- settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
+ settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("ComicVine");
- QLabel * info = new QLabel(tr("Before you can connect to Comic Vine, you need your own API key. Please, get one free here"));
+ QLabel *info = new QLabel(tr("Before you can connect to Comic Vine, you need your own API key. Please, get one free here"));
info->setWordWrap(true);
info->setOpenExternalLinks(true);
edit = new QLineEdit();
edit->setPlaceholderText(tr("Paste here your Comic Vine API key"));
- connect(edit,SIGNAL(textChanged(QString)),this,SLOT(enableAccept(QString)));
+ connect(edit, SIGNAL(textChanged(QString)), this, SLOT(enableAccept(QString)));
acceptButton = new QPushButton(tr("Accept"));
acceptButton->setDisabled(true);
- connect(acceptButton,SIGNAL(clicked()),this,SLOT(saveApiKey()));
+ connect(acceptButton, SIGNAL(clicked()), this, SLOT(saveApiKey()));
cancelButton = new QPushButton(tr("Cancel"));
- connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
layout->addWidget(info);
layout->addWidget(edit);
@@ -44,9 +44,9 @@ ApiKeyDialog::ApiKeyDialog(QWidget *parent) :
setLayout(layout);
- resize(400,150);
+ resize(400, 150);
- if(settings->contains(COMIC_VINE_API_KEY))
+ if (settings->contains(COMIC_VINE_API_KEY))
edit->setText(settings->value(COMIC_VINE_API_KEY).toString());
}
@@ -63,6 +63,6 @@ void ApiKeyDialog::enableAccept(const QString &text)
void ApiKeyDialog::saveApiKey()
{
- settings->setValue(COMIC_VINE_API_KEY,edit->text().trimmed());
+ settings->setValue(COMIC_VINE_API_KEY, edit->text().trimmed());
accept();
}
diff --git a/YACReaderLibrary/comic_vine/api_key_dialog.h b/YACReaderLibrary/comic_vine/api_key_dialog.h
index 0d8fc153..f6532c76 100644
--- a/YACReaderLibrary/comic_vine/api_key_dialog.h
+++ b/YACReaderLibrary/comic_vine/api_key_dialog.h
@@ -18,14 +18,14 @@ signals:
public slots:
protected slots:
- void enableAccept(const QString & text);
+ void enableAccept(const QString &text);
void saveApiKey();
protected:
- QPushButton * acceptButton;
- QPushButton * cancelButton;
- QLineEdit * edit;
- QSettings * settings;
+ QPushButton *acceptButton;
+ QPushButton *cancelButton;
+ QLineEdit *edit;
+ QSettings *settings;
};
#endif // API_KEY_DIALOG_H
diff --git a/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.cpp b/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.cpp
index a6c79d98..9b468afe 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.cpp
+++ b/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.cpp
@@ -8,7 +8,6 @@
ComicVineAllVolumeComicsRetriever::ComicVineAllVolumeComicsRetriever(const QString &volumeURLString, QObject *parent)
: QObject(parent), volumeURLString(volumeURLString)
{
-
}
void ComicVineAllVolumeComicsRetriever::getAllVolumeComics()
@@ -18,11 +17,11 @@ void ComicVineAllVolumeComicsRetriever::getAllVolumeComics()
void ComicVineAllVolumeComicsRetriever::getAllVolumeComics(int range)
{
- HttpWorker * search = new HttpWorker(volumeURLString.arg(range));
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(appendVolumeComicsInfo(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
- connect(search,SIGNAL(timeout()),this,SIGNAL(finished()));
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
+ HttpWorker *search = new HttpWorker(volumeURLString.arg(range));
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(appendVolumeComicsInfo(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(finished()));
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
@@ -42,9 +41,7 @@ void ComicVineAllVolumeComicsRetriever::appendVolumeComicsInfo(const QByteArray
if (!isLastResponse) {
getAllVolumeComics(currentPage * 100);
- }
- else
- {
+ } else {
emit allVolumeComicsInfo(consolidateJSON());
emit finished();
}
@@ -58,28 +55,23 @@ QString ComicVineAllVolumeComicsRetriever::consolidateJSON()
foreach (QByteArray json, jsonResponses) {
QJsonDocument doc = QJsonDocument::fromJson(json);
- if(doc.isNull() || !doc.isObject() || doc.isEmpty())
- {
+ if (doc.isNull() || !doc.isObject() || doc.isEmpty()) {
continue;
}
QJsonObject main = doc.object();
QJsonValue error = main["error"];
- if (error.isUndefined() || error.toString() != "OK")
- {
+ if (error.isUndefined() || error.toString() != "OK") {
continue;
- }
- else
- {
+ } else {
QJsonValue results = main["results"];
- if (results.isUndefined() || !results.isArray())
- {
+ if (results.isUndefined() || !results.isArray()) {
continue;
}
QJsonArray resultsArray = results.toArray();
- foreach (const QJsonValue & v, resultsArray)
+ foreach (const QJsonValue &v, resultsArray)
comicsInfo.append(v);
}
}
@@ -93,5 +85,3 @@ QString ComicVineAllVolumeComicsRetriever::consolidateJSON()
QJsonDocument doc(consolidatedJSON);
return doc.toJson(QJsonDocument::Compact);
}
-
-
diff --git a/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.h b/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.h
index 65e21a0d..e880699b 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.h
+++ b/YACReaderLibrary/comic_vine/comic_vine_all_volume_comics_retriever.h
@@ -9,6 +9,7 @@ class ComicVineAllVolumeComicsRetriever : public QObject
public:
explicit ComicVineAllVolumeComicsRetriever(const QString &volumeURLString, QObject *parent = 0);
void getAllVolumeComics();
+
protected:
void getAllVolumeComics(const int range);
signals:
diff --git a/YACReaderLibrary/comic_vine/comic_vine_client.cpp b/YACReaderLibrary/comic_vine/comic_vine_client.cpp
index c8d1d13b..7f996207 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_client.cpp
+++ b/YACReaderLibrary/comic_vine/comic_vine_client.cpp
@@ -12,28 +12,28 @@ static const QString CV_WEB_ADDRESS = "%CV_WEB_ADDRESS%"; //get from settings
//gets any volumen containing any comic matching 'query'
static const QString CV_SEARCH = CV_WEB_ADDRESS + "/search/?api_key=" + CV_API_KEY +
- "&format=json&limit=100&resources=volume"
- "&field_list=name,start_year,publisher,id,image,count_of_issues,deck"
- "&sort=name:asc"
- "&query=%1&page=%2";
+ "&format=json&limit=100&resources=volume"
+ "&field_list=name,start_year,publisher,id,image,count_of_issues,deck"
+ "&sort=name:asc"
+ "&query=%1&page=%2";
//http://www.comicvine.com/api/search/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&format=json&limit=100&resources=volume&field_list=name,start_year,publisher,id,image,count_of_issues,deck&query=superman
//gets the detail for a volume %1
static const QString CV_SERIES_DETAIL = CV_WEB_ADDRESS + "/volume/4050-%1/?api_key=" + CV_API_KEY +
- "&format=json&field_list=name,start_year,publisher,image,count_of_issues,id,description";
+ "&format=json&field_list=name,start_year,publisher,image,count_of_issues,id,description";
//gets info for comics in a volume id %1
static const QString CV_COMICS_INFO = CV_WEB_ADDRESS + "/issues/?api_key=" + CV_API_KEY +
- "&limit=1000&format=json&field_list=name,issue_number,id,image&filter=volume:%1"
- "&sort=cover_date:asc" //sorting by cover_date, because comic vine doesn't use natural sorting (issue_number -> 1 10 11 ... 100 2 20 21....)
- "&offset=%2";
+ "&limit=1000&format=json&field_list=name,issue_number,id,image&filter=volume:%1"
+ "&sort=cover_date:asc" //sorting by cover_date, because comic vine doesn't use natural sorting (issue_number -> 1 10 11 ... 100 2 20 21....)
+ "&offset=%2";
//"http://www.comicvine.com/api/issues/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&format=json&field_list=name,issue_number,id,image&filter=volume:%1&page=%2
//gets id for comic number %2 in a volume id %1
static const QString CV_COMIC_ID = CV_WEB_ADDRESS + "/issues/?api_key=" + CV_API_KEY +
- "&format=json&field_list=name,issue_number,id,image"
- "&filter=volume:%1,issue_number:%2";
+ "&format=json&field_list=name,issue_number,id,image"
+ "&filter=volume:%1,issue_number:%2";
//gets comic detail
static const QString CV_COMIC_DETAIL = CV_WEB_ADDRESS + "/issue/4000-%1/?api_key=" + CV_API_KEY + "&format=json";
//http://www.comicvine.com/api/issue/4000-%1/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&format=json
@@ -44,10 +44,10 @@ static const QString CV_COVER_URL = CV_WEB_ADDRESS + "/issue/4000-%1/?api_key="
//gets comics matching name %1 and number %2
//http://comicvine.com/api/issues/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&limit=20&filter=name:super,issue_number:15
-ComicVineClient::ComicVineClient(QObject *parent) :
- QObject(parent)
+ComicVineClient::ComicVineClient(QObject *parent)
+ : QObject(parent)
{
- settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
+ settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
settings->beginGroup("ComicVine");
baseURL = settings->value(COMIC_VINE_BASE_URL, "https://comicvine.gamespot.com/api").toString();
}
@@ -58,76 +58,76 @@ ComicVineClient::~ComicVineClient()
}
//CV_SEARCH
-void ComicVineClient::search(const QString & query, int page)
+void ComicVineClient::search(const QString &query, int page)
{
- HttpWorker * search = new HttpWorker(QString(CV_SEARCH).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(query).arg(page));
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessVolumesSearchData(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
+ HttpWorker *search = new HttpWorker(QString(CV_SEARCH).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(query).arg(page));
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessVolumesSearchData(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
+ search->get();
}
//CV_SEARCH result
-void ComicVineClient::proccessVolumesSearchData(const QByteArray & data)
+void ComicVineClient::proccessVolumesSearchData(const QByteArray &data)
{
- QString json(data);
- emit searchResult(json);
- emit finished();
+ QString json(data);
+ emit searchResult(json);
+ emit finished();
}
void ComicVineClient::proccessSeriesDetailData(const QByteArray &data)
{
- QString json(data);
- emit seriesDetail(json);
- emit finished();
+ QString json(data);
+ emit seriesDetail(json);
+ emit finished();
}
void ComicVineClient::processVolumeComicsInfo(const QByteArray &data)
{
- QString json(data);
- emit volumeComicsInfo(json);
- emit finished();
+ QString json(data);
+ emit volumeComicsInfo(json);
+ emit finished();
}
void ComicVineClient::proccessComicDetailData(const QByteArray &data)
{
- QString json(data);
- emit comicDetail(json);
- emit finished();
+ QString json(data);
+ emit comicDetail(json);
+ emit finished();
}
//CV_SERIES_DETAIL
-void ComicVineClient::getSeriesDetail(const QString & id)
+void ComicVineClient::getSeriesDetail(const QString &id)
{
- HttpWorker * search = new HttpWorker(QString(CV_SERIES_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessSeriesDetailData(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
+ HttpWorker *search = new HttpWorker(QString(CV_SERIES_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessSeriesDetailData(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
+ search->get();
}
-void ComicVineClient::getSeriesCover(const QString & url)
+void ComicVineClient::getSeriesCover(const QString &url)
{
- HttpWorker * search = new HttpWorker(url);
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SIGNAL(seriesCover(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
+ HttpWorker *search = new HttpWorker(url);
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SIGNAL(seriesCover(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
+ search->get();
}
//CV_COMIC_IDS
-void ComicVineClient::getVolumeComicsInfo(const QString & idVolume, int page)
+void ComicVineClient::getVolumeComicsInfo(const QString &idVolume, int page)
{
- HttpWorker * search = new HttpWorker(QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(idVolume).arg((page-1)*100)); //page doesn't work for search, using offset instead
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(processVolumeComicsInfo(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
+ HttpWorker *search = new HttpWorker(QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(idVolume).arg((page - 1) * 100)); //page doesn't work for search, using offset instead
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(processVolumeComicsInfo(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
search->get();
}
void ComicVineClient::getAllVolumeComicsInfo(const QString &idVolume)
{
- QString url = QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(idVolume);
- ComicVineAllVolumeComicsRetriever * comicsRetriever = new ComicVineAllVolumeComicsRetriever(url);
+ QString url = QString(CV_COMICS_INFO).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(idVolume);
+ ComicVineAllVolumeComicsRetriever *comicsRetriever = new ComicVineAllVolumeComicsRetriever(url);
connect(comicsRetriever, &ComicVineAllVolumeComicsRetriever::allVolumeComicsInfo, this, &ComicVineClient::volumeComicsInfo);
connect(comicsRetriever, &ComicVineAllVolumeComicsRetriever::finished, this, &ComicVineClient::finished);
@@ -138,52 +138,52 @@ void ComicVineClient::getAllVolumeComicsInfo(const QString &idVolume)
}
//CV_COMIC_ID
-void ComicVineClient::getComicId(const QString & id, int comicNumber)
+void ComicVineClient::getComicId(const QString &id, int comicNumber)
{
Q_UNUSED(id);
Q_UNUSED(comicNumber);
}
//CV_COMIC_DETAIL
-QByteArray ComicVineClient::getComicDetail(const QString & id, bool & outError, bool & outTimeout)
+QByteArray ComicVineClient::getComicDetail(const QString &id, bool &outError, bool &outTimeout)
{
- HttpWorker * search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
+ HttpWorker *search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
- //connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
- //connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
- //connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
- search->wait();
- outError = !(search->wasValid());
- outTimeout = search->wasTimeout();
- QByteArray result = search->getResult();
- delete search;
+ //connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
+ //connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
+ //connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
+ search->get();
+ search->wait();
+ outError = !(search->wasValid());
+ outTimeout = search->wasTimeout();
+ QByteArray result = search->getResult();
+ delete search;
- return result;
+ return result;
}
//CV_COMIC_DETAIL
-void ComicVineClient::getComicDetailAsync(const QString & id)
+void ComicVineClient::getComicDetailAsync(const QString &id)
{
- HttpWorker * search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY,settings->value(COMIC_VINE_API_KEY,CV_API_KEY_DEFAULT).toString()).arg(id));
+ HttpWorker *search = new HttpWorker(QString(CV_COMIC_DETAIL).replace(CV_WEB_ADDRESS, baseURL).replace(CV_API_KEY, settings->value(COMIC_VINE_API_KEY, CV_API_KEY_DEFAULT).toString()).arg(id));
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SLOT(proccessComicDetailData(const QByteArray &)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut()));
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
+ search->get();
}
void ComicVineClient::getComicCover(const QString &url)
{
- HttpWorker * search = new HttpWorker(url);
- connect(search,SIGNAL(dataReady(const QByteArray &)),this,SIGNAL(comicCover(QByteArray)));
- connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
- connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
- search->get();
+ HttpWorker *search = new HttpWorker(url);
+ connect(search, SIGNAL(dataReady(const QByteArray &)), this, SIGNAL(comicCover(QByteArray)));
+ connect(search, SIGNAL(timeout()), this, SIGNAL(timeOut())); //TODO
+ connect(search, SIGNAL(finished()), search, SLOT(deleteLater()));
+ search->get();
}
//CV_COVER_DETAIL
-void ComicVineClient::getCoverURL(const QString & id)
+void ComicVineClient::getCoverURL(const QString &id)
{
Q_UNUSED(id);
}
diff --git a/YACReaderLibrary/comic_vine/comic_vine_client.h b/YACReaderLibrary/comic_vine/comic_vine_client.h
index c7e6b6f7..d99b491f 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_client.h
+++ b/YACReaderLibrary/comic_vine/comic_vine_client.h
@@ -8,41 +8,40 @@
class ComicVineClient : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ComicVineClient(QObject *parent = 0);
+ explicit ComicVineClient(QObject *parent = 0);
~ComicVineClient();
-
-signals:
- void searchResult(QString);
- void seriesDetail(QString);//JSON
- void comicDetail(QString);//JSON
- void seriesCover(const QByteArray &);
- void comicCover(const QByteArray &);
- void volumeComicsInfo(QString);
- void timeOut();
- void finished();
-public slots:
- void search(const QString & query, int page = 1);
- void getSeriesDetail(const QString & id);
- void getSeriesCover(const QString & url);
- void getVolumeComicsInfo(const QString & idVolume, int page=1);
- void getAllVolumeComicsInfo(const QString & idVolume);
- QByteArray getComicDetail(const QString & id, bool &outError, bool &outTimeout);
- void getComicCover(const QString & url);
- void getComicId(const QString & id, int comicNumber);
- void getCoverURL(const QString & id);
- void getComicDetailAsync(const QString &id);
+signals:
+ void searchResult(QString);
+ void seriesDetail(QString); //JSON
+ void comicDetail(QString); //JSON
+ void seriesCover(const QByteArray &);
+ void comicCover(const QByteArray &);
+ void volumeComicsInfo(QString);
+ void timeOut();
+ void finished();
+public slots:
+ void search(const QString &query, int page = 1);
+ void getSeriesDetail(const QString &id);
+ void getSeriesCover(const QString &url);
+ void getVolumeComicsInfo(const QString &idVolume, int page = 1);
+ void getAllVolumeComicsInfo(const QString &idVolume);
+ QByteArray getComicDetail(const QString &id, bool &outError, bool &outTimeout);
+ void getComicCover(const QString &url);
+
+ void getComicId(const QString &id, int comicNumber);
+ void getCoverURL(const QString &id);
+ void getComicDetailAsync(const QString &id);
protected slots:
- void proccessVolumesSearchData(const QByteArray & data);
- void proccessSeriesDetailData(const QByteArray & data);
- void processVolumeComicsInfo(const QByteArray & data);
- void proccessComicDetailData(const QByteArray & data);
+ void proccessVolumesSearchData(const QByteArray &data);
+ void proccessSeriesDetailData(const QByteArray &data);
+ void processVolumeComicsInfo(const QByteArray &data);
+ void proccessComicDetailData(const QByteArray &data);
protected:
- QSettings * settings;
+ QSettings *settings;
QString baseURL;
-
};
#endif // COMIC_VINE_CLIENT_H
diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
index 4d29921a..624bc7c5 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
+++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
@@ -9,9 +9,9 @@
#include
#include
#if QT_VERSION >= 0x050000
- #include
+#include
#else
- #include
+#include
#endif
#include
#include
@@ -32,174 +32,165 @@
#include "QsLog.h"
-
-
-ComicVineDialog::ComicVineDialog(QWidget *parent) :
- QDialog(parent)
+ComicVineDialog::ComicVineDialog(QWidget *parent)
+ : QDialog(parent)
{
setWindowFlags(Qt::Window);
- doLayout();
- doStackedWidgets();
- doConnections();
+ doLayout();
+ doStackedWidgets();
+ doConnections();
}
void ComicVineDialog::doLayout()
{
- setStyleSheet(""
- "QDialog {background-color: #404040; }"
- "");
+ setStyleSheet(""
+ "QDialog {background-color: #404040; }"
+ "");
- QString dialogButtonsStyleSheet = "QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}";
+ QString dialogButtonsStyleSheet = "QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}";
- skipButton = new QPushButton(tr("skip"));
- backButton = new QPushButton(tr("back"));
- nextButton = new QPushButton(tr("next"));
- searchButton = new QPushButton(tr("search"));
- closeButton = new QPushButton(tr("close"));
+ skipButton = new QPushButton(tr("skip"));
+ backButton = new QPushButton(tr("back"));
+ nextButton = new QPushButton(tr("next"));
+ searchButton = new QPushButton(tr("search"));
+ closeButton = new QPushButton(tr("close"));
- skipButton->setStyleSheet(dialogButtonsStyleSheet);
- backButton->setStyleSheet(dialogButtonsStyleSheet);
- nextButton->setStyleSheet(dialogButtonsStyleSheet);
- searchButton->setStyleSheet(dialogButtonsStyleSheet);
- closeButton->setStyleSheet(dialogButtonsStyleSheet);
+ skipButton->setStyleSheet(dialogButtonsStyleSheet);
+ backButton->setStyleSheet(dialogButtonsStyleSheet);
+ nextButton->setStyleSheet(dialogButtonsStyleSheet);
+ searchButton->setStyleSheet(dialogButtonsStyleSheet);
+ closeButton->setStyleSheet(dialogButtonsStyleSheet);
- content = new QStackedWidget(this);
+ content = new QStackedWidget(this);
- QVBoxLayout * mainLayout = new QVBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout;
- QHBoxLayout * buttonLayout = new QHBoxLayout;
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
- buttonLayout->addStretch();
- buttonLayout->addWidget(skipButton);
- buttonLayout->addWidget(backButton);
- buttonLayout->addWidget(nextButton);
- buttonLayout->addWidget(searchButton);
- buttonLayout->addWidget(closeButton);
- buttonLayout->setContentsMargins(0,0,0,0);
+ buttonLayout->addStretch();
+ buttonLayout->addWidget(skipButton);
+ buttonLayout->addWidget(backButton);
+ buttonLayout->addWidget(nextButton);
+ buttonLayout->addWidget(searchButton);
+ buttonLayout->addWidget(closeButton);
+ buttonLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(titleHeader = new TitleHeader, 0);
mainLayout->addWidget(content, 1);
mainLayout->addLayout(buttonLayout, 0);
- mainLayout->setContentsMargins(26,16,26,11);
+ mainLayout->setContentsMargins(26, 16, 26, 11);
- setLayout(mainLayout);
+ setLayout(mainLayout);
- setWindowTitle("Comic Vine Scraper (beta)");
+ setWindowTitle("Comic Vine Scraper (beta)");
}
void ComicVineDialog::doStackedWidgets()
{
- doLoading();
- content->addWidget(seriesQuestionWidget = new SeriesQuestion);
- content->addWidget(searchSingleComicWidget = new SearchSingleComic);
- content->addWidget(searchVolumeWidget = new SearchVolume);
- content->addWidget(selectVolumeWidget = new SelectVolume);
- content->addWidget(selectComicWidget = new SelectComic);
- content->addWidget(sortVolumeComicsWidget = new SortVolumeComics);
+ doLoading();
+ content->addWidget(seriesQuestionWidget = new SeriesQuestion);
+ content->addWidget(searchSingleComicWidget = new SearchSingleComic);
+ content->addWidget(searchVolumeWidget = new SearchVolume);
+ content->addWidget(selectVolumeWidget = new SelectVolume);
+ content->addWidget(selectComicWidget = new SelectComic);
+ content->addWidget(sortVolumeComicsWidget = new SortVolumeComics);
}
void ComicVineDialog::doConnections()
{
- connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
- connect(nextButton,SIGNAL(clicked()),this,SLOT(goNext()));
- connect(backButton,SIGNAL(clicked()),this,SLOT(goBack()));
- connect(searchButton,SIGNAL(clicked()),this,SLOT(search()));
- connect(skipButton,SIGNAL(clicked()),this,SLOT(goToNextComic()));
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(nextButton, SIGNAL(clicked()), this, SLOT(goNext()));
+ connect(backButton, SIGNAL(clicked()), this, SLOT(goBack()));
+ connect(searchButton, SIGNAL(clicked()), this, SLOT(search()));
+ connect(skipButton, SIGNAL(clicked()), this, SLOT(goToNextComic()));
- connect(selectVolumeWidget,SIGNAL(loadPage(QString,int)),this,SLOT(searchVolume(QString,int)));
- connect(selectComicWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int)));
- connect(sortVolumeComicsWidget,SIGNAL(loadPage(QString,int)),this,SLOT(getVolumeComicsInfo(QString,int)));
+ connect(selectVolumeWidget, SIGNAL(loadPage(QString, int)), this, SLOT(searchVolume(QString, int)));
+ connect(selectComicWidget, SIGNAL(loadPage(QString, int)), this, SLOT(getVolumeComicsInfo(QString, int)));
+ connect(sortVolumeComicsWidget, SIGNAL(loadPage(QString, int)), this, SLOT(getVolumeComicsInfo(QString, int)));
connect(this, SIGNAL(accepted()), this, SLOT(close()), Qt::QueuedConnection);
}
void ComicVineDialog::goNext()
{
- //
- if(content->currentWidget() == seriesQuestionWidget)
- {
- if(seriesQuestionWidget->getYes())
- {
- QString volumeSearchString = comics[0].getParentFolderName();
- mode = Volume;
+ //
+ if (content->currentWidget() == seriesQuestionWidget) {
+ if (seriesQuestionWidget->getYes()) {
+ QString volumeSearchString = comics[0].getParentFolderName();
+ mode = Volume;
- if(volumeSearchString.isEmpty())
- showSearchVolume();
- else
- {
- status = AutoSearching;
+ if (volumeSearchString.isEmpty())
+ showSearchVolume();
+ else {
+ status = AutoSearching;
showLoading(tr("Looking for volume..."));
- searchVolume(volumeSearchString);
- }
- }
- else
- {
- status = AutoSearching;
- mode = SingleComicInList;
- ComicDB comic = comics[currentIndex];
- QString title = comic.getTitleOrFileName();
- titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
+ searchVolume(volumeSearchString);
+ }
+ } else {
+ status = AutoSearching;
+ mode = SingleComicInList;
+ ComicDB comic = comics[currentIndex];
+ QString title = comic.getTitleOrFileName();
+ titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
showLoading(tr("Looking for volume..."));
- searchVolume(title);
- }
- }
- else if (content->currentWidget() == selectVolumeWidget) {
- currentVolumeId = selectVolumeWidget->getSelectedVolumeId();
- getVolumeComicsInfo(currentVolumeId);
+ searchVolume(title);
+ }
+ } else if (content->currentWidget() == selectVolumeWidget) {
+ currentVolumeId = selectVolumeWidget->getSelectedVolumeId();
+ getVolumeComicsInfo(currentVolumeId);
- } else if (content->currentWidget() == sortVolumeComicsWidget) {
+ } else if (content->currentWidget() == sortVolumeComicsWidget) {
showLoading();
- //ComicDB-ComicVineID
- QList > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
+ //ComicDB-ComicVineID
+ QList> matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
- QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo,count,publisher);
- } else if (content->currentWidget() == selectComicWidget)
- {
+ QtConcurrent::run(this, &ComicVineDialog::getComicsInfo, matchingInfo, count, publisher);
+ } else if (content->currentWidget() == selectComicWidget) {
showLoading();
QString comicId = selectComicWidget->getSelectedComicId();
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
- QtConcurrent::run(this, &ComicVineDialog::getComicInfo,comicId,count,publisher);
+ QtConcurrent::run(this, &ComicVineDialog::getComicInfo, comicId, count, publisher);
}
}
void ComicVineDialog::goBack()
{
- switch (status) {
- case SelectingSeries:
- if(mode == Volume)
- showSearchVolume();
- else
- showSearchSingleComic();
- break;
- case SortingComics:
- showSelectVolume();
- break;
+ switch (status) {
+ case SelectingSeries:
+ if (mode == Volume)
+ showSearchVolume();
+ else
+ showSearchSingleComic();
+ break;
+ case SortingComics:
+ showSelectVolume();
+ break;
case SelectingComic:
- if(mode == SingleComic)
+ if (mode == SingleComic)
showSelectVolume();
break;
- case AutoSearching:
- if(mode == Volume)
- showSearchVolume();
- else
- showSearchSingleComic();
- break;
- default:
- if(mode == Volume)
- showSearchVolume();
- else
- showSearchSingleComic();
- break;
- }
+ case AutoSearching:
+ if (mode == Volume)
+ showSearchVolume();
+ else
+ showSearchSingleComic();
+ break;
+ default:
+ if (mode == Volume)
+ showSearchVolume();
+ else
+ showSearchSingleComic();
+ break;
+ }
}
-void ComicVineDialog::setComics(const QList & comics)
+void ComicVineDialog::setComics(const QList &comics)
{
this->comics = comics;
}
@@ -208,8 +199,8 @@ QSize ComicVineDialog::sizeHint() const
{
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width();
- int height,width;
- height = qMax(529, static_cast(heightDesktopResolution*0.5));
+ int height, width;
+ height = qMax(529, static_cast(heightDesktopResolution * 0.5));
width = height * 1.65;
if (width > widthDesktopResolution)
@@ -225,239 +216,231 @@ QSize ComicVineDialog::minimumSizeHint() const
void ComicVineDialog::show()
{
- QDialog::show();
+ QDialog::show();
- currentIndex = 0;
+ currentIndex = 0;
- seriesQuestionWidget->setYes(true);
- searchSingleComicWidget->clean();
- searchVolumeWidget->clean();
+ seriesQuestionWidget->setYes(true);
+ searchSingleComicWidget->clean();
+ searchVolumeWidget->clean();
- if(comics.length() == 1)
- {
- status = AutoSearching;
- mode = SingleComic;
+ if (comics.length() == 1) {
+ status = AutoSearching;
+ mode = SingleComic;
- ComicDB singleComic = comics[0];
- QString title = singleComic.getTitleOrFileName();
- titleHeader->setSubTitle(title);
+ ComicDB singleComic = comics[0];
+ QString title = singleComic.getTitleOrFileName();
+ titleHeader->setSubTitle(title);
showLoading(tr("Looking for volume..."));
- searchVolume(singleComic.getParentFolderName());
- QLOG_TRACE() << singleComic.getParentFolderName();
- }else if(comics.length()>1)
- {
- titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length()));
- showSeriesQuestion();
- }
+ searchVolume(singleComic.getParentFolderName());
+ QLOG_TRACE() << singleComic.getParentFolderName();
+ } else if (comics.length() > 1) {
+ titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length()));
+ showSeriesQuestion();
+ }
}
void ComicVineDialog::doLoading()
{
- QWidget * w = new QWidget;
- QVBoxLayout * l = new QVBoxLayout;
+ QWidget *w = new QWidget;
+ QVBoxLayout *l = new QVBoxLayout;
- YACReaderBusyWidget * bw = new YACReaderBusyWidget;
+ YACReaderBusyWidget *bw = new YACReaderBusyWidget;
loadingMessage = new QLabel;
loadingMessage->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
- l->addStretch();
- l->addWidget(bw,0,Qt::AlignHCenter);
+ l->addStretch();
+ l->addWidget(bw, 0, Qt::AlignHCenter);
l->addStretch();
l->addWidget(loadingMessage);
+ l->setContentsMargins(0, 0, 0, 0);
+ w->setLayout(l);
+ w->setContentsMargins(0, 0, 0, 0);
- l->setContentsMargins(0,0,0,0);
- w->setLayout(l);
- w->setContentsMargins(0,0,0,0);
-
- content->addWidget(w);
+ content->addWidget(w);
}
-void ComicVineDialog::debugClientResults(const QString & string)
+void ComicVineDialog::debugClientResults(const QString &string)
{
- ResponseParser p;
- p.loadJSONResponse(string);
- //QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
- if(p.responseError())
- {
- QMessageBox::critical(0,tr("Error connecting to ComicVine"), p.errorDescription());
- goBack();
- }
- else
- {
- switch(mode)
- {
- case SingleComic: case SingleComicInList:
- if(p.getNumResults() == 0)
- showSearchSingleComic();
- else
- if(status == SearchingVolume)
- showSelectVolume(string);
- else
- showSelectComic(string);
- break;
- case Volume:
- if(p.getNumResults() == 0)
- showSearchVolume();
- else
- showSelectVolume(string);
- break;
- }
- }
+ ResponseParser p;
+ p.loadJSONResponse(string);
+ //QMessageBox::information(0,"Result", QString("Number of results : %1").arg(p.getNumResults()));
+ if (p.responseError()) {
+ QMessageBox::critical(0, tr("Error connecting to ComicVine"), p.errorDescription());
+ goBack();
+ } else {
+ switch (mode) {
+ case SingleComic:
+ case SingleComicInList:
+ if (p.getNumResults() == 0)
+ showSearchSingleComic();
+ else if (status == SearchingVolume)
+ showSelectVolume(string);
+ else
+ showSelectComic(string);
+ break;
+ case Volume:
+ if (p.getNumResults() == 0)
+ showSearchVolume();
+ else
+ showSelectVolume(string);
+ break;
+ }
+ }
}
void ComicVineDialog::showSeriesQuestion()
{
- status = AskingForInfo;
- content->setCurrentWidget(seriesQuestionWidget);
- backButton->setHidden(true);
- skipButton->setHidden(true);
- nextButton->setVisible(true);
- searchButton->setHidden(true);
- closeButton->setVisible(true);
+ status = AskingForInfo;
+ content->setCurrentWidget(seriesQuestionWidget);
+ backButton->setHidden(true);
+ skipButton->setHidden(true);
+ nextButton->setVisible(true);
+ searchButton->setHidden(true);
+ closeButton->setVisible(true);
- if(mode == SingleComicInList)
- skipButton->setVisible(true);
- else
- skipButton->setHidden(true);
+ if (mode == SingleComicInList)
+ skipButton->setVisible(true);
+ else
+ skipButton->setHidden(true);
}
void ComicVineDialog::showSearchSingleComic()
{
- status = AskingForInfo;
- content->setCurrentWidget(searchSingleComicWidget);
- backButton->setHidden(true);
- skipButton->setHidden(true);
- nextButton->setHidden(true);
- searchButton->setVisible(true);
- closeButton->setVisible(true);
+ status = AskingForInfo;
+ content->setCurrentWidget(searchSingleComicWidget);
+ backButton->setHidden(true);
+ skipButton->setHidden(true);
+ nextButton->setHidden(true);
+ searchButton->setVisible(true);
+ closeButton->setVisible(true);
- if(mode == SingleComicInList)
- skipButton->setVisible(true);
- else
- skipButton->setHidden(true);
+ if (mode == SingleComicInList)
+ skipButton->setVisible(true);
+ else
+ skipButton->setHidden(true);
}
void ComicVineDialog::showSearchVolume()
{
- status = AskingForInfo;
- content->setCurrentWidget(searchVolumeWidget);
- backButton->setHidden(true);
- nextButton->setHidden(true);
- searchButton->setVisible(true);
- closeButton->setVisible(true);
- toggleSkipButton();
+ status = AskingForInfo;
+ content->setCurrentWidget(searchVolumeWidget);
+ backButton->setHidden(true);
+ nextButton->setHidden(true);
+ searchButton->setVisible(true);
+ closeButton->setVisible(true);
+ toggleSkipButton();
}
-void ComicVineDialog::showSelectVolume(const QString & json)
+void ComicVineDialog::showSelectVolume(const QString &json)
{
- showSelectVolume();
- selectVolumeWidget->load(json,currentVolumeSearchString);
+ showSelectVolume();
+ selectVolumeWidget->load(json, currentVolumeSearchString);
}
void ComicVineDialog::showSelectVolume()
{
- status = SelectingSeries;
+ status = SelectingSeries;
- content->setCurrentWidget(selectVolumeWidget);
+ content->setCurrentWidget(selectVolumeWidget);
- backButton->setVisible(true);
- nextButton->setVisible(true);
- searchButton->setHidden(true);
- closeButton->setVisible(true);
- toggleSkipButton();
+ backButton->setVisible(true);
+ nextButton->setVisible(true);
+ searchButton->setHidden(true);
+ closeButton->setVisible(true);
+ toggleSkipButton();
}
void ComicVineDialog::showSelectComic(const QString &json)
{
status = SelectingComic;
- content->setCurrentWidget(selectComicWidget);
- selectComicWidget->load(json,currentVolumeId);
+ content->setCurrentWidget(selectComicWidget);
+ selectComicWidget->load(json, currentVolumeId);
backButton->setVisible(true);
nextButton->setVisible(true);
searchButton->setHidden(true);
closeButton->setVisible(true);
- toggleSkipButton();
+ toggleSkipButton();
}
void ComicVineDialog::showSortVolumeComics(const QString &json)
{
- status = SortingComics;
+ status = SortingComics;
- content->setCurrentWidget(sortVolumeComicsWidget);
+ content->setCurrentWidget(sortVolumeComicsWidget);
- sortVolumeComicsWidget->setData(comics, json, currentVolumeId);
+ sortVolumeComicsWidget->setData(comics, json, currentVolumeId);
- backButton->setVisible(true);
- nextButton->setVisible(true);
- searchButton->setHidden(true);
- closeButton->setVisible(true);
- toggleSkipButton();
+ backButton->setVisible(true);
+ nextButton->setVisible(true);
+ searchButton->setHidden(true);
+ closeButton->setVisible(true);
+ toggleSkipButton();
}
void ComicVineDialog::queryTimeOut()
{
- QMessageBox::warning(this,"Comic Vine error", "Time out connecting to Comic Vine");
+ QMessageBox::warning(this, "Comic Vine error", "Time out connecting to Comic Vine");
- switch (status) {
- case AutoSearching:
- if(mode == Volume)
- showSearchVolume();
- else
- showSearchSingleComic();
- break;
- case SearchingVolume:
- if(mode == Volume)
- showSearchVolume();
- else
- showSearchSingleComic();
- break;
- case SearchingSingleComic:
- showSearchSingleComic();
- break;
- case GettingVolumeComics:
- showSelectVolume();
- break;
- default:
- break;
- }
+ switch (status) {
+ case AutoSearching:
+ if (mode == Volume)
+ showSearchVolume();
+ else
+ showSearchSingleComic();
+ break;
+ case SearchingVolume:
+ if (mode == Volume)
+ showSearchVolume();
+ else
+ showSearchSingleComic();
+ break;
+ case SearchingSingleComic:
+ showSearchSingleComic();
+ break;
+ case GettingVolumeComics:
+ showSelectVolume();
+ break;
+ default:
+ break;
+ }
}
-void ComicVineDialog::getComicsInfo(QList > & matchingInfo, int count,const QString & publisher)
+void ComicVineDialog::getComicsInfo(QList> &matchingInfo, int count, const QString &publisher)
{
- QPair p;
- QList comics;
- foreach (p, matchingInfo) {
- ComicVineClient * comicVineClient = new ComicVineClient;
- //connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
- //connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
- //connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
- bool error;
- bool timeout;
- QByteArray result = comicVineClient->getComicDetail(p.second,error,timeout); //TODO check timeOut or Connection error
- if(error || timeout)
- continue; //TODO
- ComicDB comic = parseComicInfo(p.first,result,count,publisher);//TODO check result error
+ QPair p;
+ QList comics;
+ foreach (p, matchingInfo) {
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ //connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
+ //connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
+ //connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
+ bool error;
+ bool timeout;
+ QByteArray result = comicVineClient->getComicDetail(p.second, error, timeout); //TODO check timeOut or Connection error
+ if (error || timeout)
+ continue; //TODO
+ ComicDB comic = parseComicInfo(p.first, result, count, publisher); //TODO check result error
comic.info.comicVineID = p.second;
comics.push_back(comic);
setLoadingMessage(tr("Retrieving tags for : %1").arg(p.first.getFileName()));
- }
+ }
- QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
- db.open();
- db.transaction();
- foreach(ComicDB comic, comics)
- {
- DBHelper::update(&(comic.info),db);
- }
- db.commit();
- db.close();
- QSqlDatabase::removeDatabase(db.connectionName());
+ QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
+ db.open();
+ db.transaction();
+ foreach (ComicDB comic, comics) {
+ DBHelper::update(&(comic.info), db);
+ }
+ db.commit();
+ db.close();
+ QSqlDatabase::removeDatabase(db.connectionName());
emit accepted();
}
@@ -465,23 +448,20 @@ void ComicVineDialog::getComicsInfo(QList > & matchingIn
void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QString &publisher)
{
- ComicVineClient * comicVineClient = new ComicVineClient;
- bool error;
- bool timeout;
- QByteArray result = comicVineClient->getComicDetail(comicId,error,timeout); //TODO check timeOut or Connection error
- if(error || timeout)
- {
- //TODO
- if(mode == SingleComic || currentIndex == (comics.count()-1))
- {
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ bool error;
+ bool timeout;
+ QByteArray result = comicVineClient->getComicDetail(comicId, error, timeout); //TODO check timeOut or Connection error
+ if (error || timeout) {
+ //TODO
+ if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
emit accepted();
- } else
- {
- goToNextComic();
- }
- }
+ } else {
+ goToNextComic();
+ }
+ }
- ComicDB comic = parseComicInfo(comics[currentIndex],result,count,publisher); //TODO check result error
+ ComicDB comic = parseComicInfo(comics[currentIndex], result, count, publisher); //TODO check result error
comic.info.comicVineID = comicId;
setLoadingMessage(tr("Retrieving tags for : %1").arg(comics[currentIndex].getFileName()));
@@ -489,38 +469,32 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
db.open();
db.transaction();
- DBHelper::update(&(comic.info),db);
+ DBHelper::update(&(comic.info), db);
db.commit();
db.close();
QSqlDatabase::removeDatabase(db.connectionName());
- if(mode == SingleComic || currentIndex == (comics.count()-1))
- {
+ if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
emit accepted();
- } else
- {
- goToNextComic();
+ } else {
+ goToNextComic();
}
}
-ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, int count, const QString & publisher)
+ComicDB ComicVineDialog::parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + json + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + json + ")");
- if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
- {
- qDebug("Error detected");
- }
- else
- {
- int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
+ if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
+ qDebug("Error detected");
+ } else {
+ int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
- if(numResults > 0)
- {
- QScriptValue result = sc.property("results");
+ if (numResults > 0) {
+ QScriptValue result = sc.property("results");
if (!result.property("name").isNull()) {
QString title = result.property("name").toString();
@@ -541,7 +515,7 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, i
}
if (!result.property("person_credits").isNull()) {
- QMap authors = getAuthors(result.property("person_credits"));
+ QMap authors = getAuthors(result.property("person_credits"));
QString writer = QStringList(authors.values("writer")).join("\n");
QString penciller = QStringList(authors.values("penciller")).join("\n");
@@ -564,7 +538,7 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, i
QStringList tempList = date.split("-");
if (tempList.length() == 3) {
- std::reverse(tempList.begin(),tempList.end());
+ std::reverse(tempList.begin(), tempList.end());
comic.info.date = tempList.join("/");
}
}
@@ -583,8 +557,8 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, i
comic.info.count = count;
comic.info.publisher = publisher;
- }
- }
+ }
+ }
return comic;
}
@@ -597,7 +571,7 @@ QString ComicVineDialog::getCharacters(const QScriptValue &json_characters)
QScriptValue resultsValue;
while (it.hasNext()) {
it.next();
- if(it.flags() & QScriptValue::SkipInEnumeration)
+ if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
resultsValue = it.value();
@@ -615,67 +589,65 @@ QMap ComicVineDialog::getAuthors(const QScriptValue &json_auth
QScriptValue resultsValue;
while (it.hasNext()) {
it.next();
- if(it.flags() & QScriptValue::SkipInEnumeration)
+ if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
resultsValue = it.value();
QString authorName = resultsValue.property("name").toString();
QStringList roles = resultsValue.property("role").toString().split(",");
- foreach(QString role, roles)
- {
- if(role.trimmed() == "writer")
- authors.insertMulti("writer",authorName);
- else if(role.trimmed() == "inker")
- authors.insertMulti("inker",authorName);
- else if(role.trimmed() == "penciler" || role.trimmed() == "penciller")
- authors.insertMulti("penciller",authorName);
- else if(role.trimmed() == "colorist")
- authors.insertMulti("colorist",authorName);
- else if(role.trimmed() == "letterer")
- authors.insertMulti("letterer",authorName);
- else if(role.trimmed() == "cover")
- authors.insertMulti("cover",authorName);
+ foreach (QString role, roles) {
+ if (role.trimmed() == "writer")
+ authors.insertMulti("writer", authorName);
+ else if (role.trimmed() == "inker")
+ authors.insertMulti("inker", authorName);
+ else if (role.trimmed() == "penciler" || role.trimmed() == "penciller")
+ authors.insertMulti("penciller", authorName);
+ else if (role.trimmed() == "colorist")
+ authors.insertMulti("colorist", authorName);
+ else if (role.trimmed() == "letterer")
+ authors.insertMulti("letterer", authorName);
+ else if (role.trimmed() == "cover")
+ authors.insertMulti("cover", authorName);
}
}
- return authors;
+ return authors;
}
void ComicVineDialog::toggleSkipButton()
{
- if (mode == SingleComicInList)
- skipButton->setVisible(true);
- else
- skipButton->setHidden(true);
+ if (mode == SingleComicInList)
+ skipButton->setVisible(true);
+ else
+ skipButton->setHidden(true);
}
void ComicVineDialog::goToNextComic()
{
- if(mode == SingleComic || currentIndex == (comics.count()-1))
- {
- emit accepted();
- return;
- }
+ if (mode == SingleComic || currentIndex == (comics.count() - 1)) {
+ emit accepted();
+ return;
+ }
- currentIndex++;
+ currentIndex++;
- showSearchSingleComic();
+ showSearchSingleComic();
- ComicDB comic = comics[currentIndex];
- QString title = comic.getTitleOrFileName();
- titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
+ ComicDB comic = comics[currentIndex];
+ QString title = comic.getTitleOrFileName();
+ titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
}
void ComicVineDialog::showLoading(const QString &message)
{
- content->setCurrentIndex(0);
+ content->setCurrentIndex(0);
loadingMessage->setText(message);
- backButton->setHidden(true);
- skipButton->setHidden(true);
- nextButton->setHidden(true);
- searchButton->setHidden(true);
- closeButton->setVisible(true);
+ backButton->setHidden(true);
+ skipButton->setHidden(true);
+ nextButton->setHidden(true);
+ searchButton->setHidden(true);
+ closeButton->setVisible(true);
}
void ComicVineDialog::setLoadingMessage(const QString &message)
@@ -685,46 +657,46 @@ void ComicVineDialog::setLoadingMessage(const QString &message)
void ComicVineDialog::search()
{
- switch (mode) {
- case Volume:
- launchSearchVolume();
- break;
- default:
- launchSearchComic();
- break;
- }
+ switch (mode) {
+ case Volume:
+ launchSearchVolume();
+ break;
+ default:
+ launchSearchComic();
+ break;
+ }
}
void ComicVineDialog::searchVolume(const QString &v, int page)
{
- showLoading(tr("Looking for volume..."));
+ showLoading(tr("Looking for volume..."));
- currentVolumeSearchString = v;
+ currentVolumeSearchString = v;
- ComicVineClient * comicVineClient = new ComicVineClient;
- connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
- connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
- connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
- comicVineClient->search(v,page);
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ connect(comicVineClient, SIGNAL(searchResult(QString)), this, SLOT(debugClientResults(QString)));
+ connect(comicVineClient, SIGNAL(timeOut()), this, SLOT(queryTimeOut()));
+ connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
+ comicVineClient->search(v, page);
- status = SearchingVolume;
+ status = SearchingVolume;
}
void ComicVineDialog::getVolumeComicsInfo(const QString &vID, int /* page */)
{
- showLoading(tr("Retrieving volume info..."));
+ showLoading(tr("Retrieving volume info..."));
- status = GettingVolumeComics;
+ status = GettingVolumeComics;
- ComicVineClient * comicVineClient = new ComicVineClient;
- if(mode == Volume)
- connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSortVolumeComics(QString)));
- else
- connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSelectComic(QString)));
- connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
- connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ if (mode == Volume)
+ connect(comicVineClient, SIGNAL(volumeComicsInfo(QString)), this, SLOT(showSortVolumeComics(QString)));
+ else
+ connect(comicVineClient, SIGNAL(volumeComicsInfo(QString)), this, SLOT(showSelectComic(QString)));
+ connect(comicVineClient, SIGNAL(timeOut()), this, SLOT(queryTimeOut()));
+ connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
- QLOG_TRACE() << vID;
+ QLOG_TRACE() << vID;
comicVineClient->getAllVolumeComicsInfo(vID);
}
@@ -732,19 +704,18 @@ void ComicVineDialog::getVolumeComicsInfo(const QString &vID, int /* page */)
void ComicVineDialog::launchSearchVolume()
{
showLoading(tr("Looking for volume..."));
- //TODO: check if volume info is empty.
- searchVolume(searchVolumeWidget->getVolumeInfo());
+ //TODO: check if volume info is empty.
+ searchVolume(searchVolumeWidget->getVolumeInfo());
}
void ComicVineDialog::launchSearchComic()
{
showLoading(tr("Looking for comic..."));
- QString volumeInfo = searchSingleComicWidget->getVolumeInfo();
- //QString comicInfo = searchSingleComicWidget->getComicInfo();
- //int comicNumber = searchSingleComicWidget->getComicNumber();
+ QString volumeInfo = searchSingleComicWidget->getVolumeInfo();
+ //QString comicInfo = searchSingleComicWidget->getComicInfo();
+ //int comicNumber = searchSingleComicWidget->getComicNumber();
- //if(comicInfo.isEmpty() && comicNumber == -1)
- searchVolume(volumeInfo);
+ //if(comicInfo.isEmpty() && comicNumber == -1)
+ searchVolume(volumeInfo);
}
-
diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.h b/YACReaderLibrary/comic_vine/comic_vine_dialog.h
index 66a2be26..39b7688f 100644
--- a/YACReaderLibrary/comic_vine/comic_vine_dialog.h
+++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.h
@@ -24,108 +24,105 @@ class QScriptValue;
//----------------------------------------
class ComicVineDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ComicVineDialog(QWidget *parent = 0);
- QString databasePath;
- QString basePath;
- void setComics(const QList & comics);
+ explicit ComicVineDialog(QWidget *parent = 0);
+ QString databasePath;
+ QString basePath;
+ void setComics(const QList &comics);
QSize sizeHint() const;
QSize minimumSizeHint() const;
signals:
-
+
public slots:
- void show();
+ void show();
protected slots:
- void goNext();
- void goBack();
- void debugClientResults(const QString & string);
- //show widget methods
- void showSeriesQuestion();
- void showSearchSingleComic();
- void showSearchVolume();
- void showLoading(const QString & message = "");
- void search();
- void searchVolume(const QString & v, int page = 1);
- void getVolumeComicsInfo(const QString &vID, int page = 1);
- void launchSearchVolume();
- void launchSearchComic();
- void showSelectVolume(const QString & json);
- void showSelectVolume();
- void showSelectComic(const QString & json);
- void showSortVolumeComics(const QString & json);
- void queryTimeOut();
- void getComicsInfo(QList > & matchingInfo, int count, const QString & publisher);
- void getComicInfo(const QString & comicId, int count, const QString & publisher);
- ComicDB parseComicInfo(ComicDB &comic, const QString & json, int count, const QString &publisher);
+ void goNext();
+ void goBack();
+ void debugClientResults(const QString &string);
+ //show widget methods
+ void showSeriesQuestion();
+ void showSearchSingleComic();
+ void showSearchVolume();
+ void showLoading(const QString &message = "");
+ void search();
+ void searchVolume(const QString &v, int page = 1);
+ void getVolumeComicsInfo(const QString &vID, int page = 1);
+ void launchSearchVolume();
+ void launchSearchComic();
+ void showSelectVolume(const QString &json);
+ void showSelectVolume();
+ void showSelectComic(const QString &json);
+ void showSortVolumeComics(const QString &json);
+ void queryTimeOut();
+ void getComicsInfo(QList> &matchingInfo, int count, const QString &publisher);
+ void getComicInfo(const QString &comicId, int count, const QString &publisher);
+ ComicDB parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher);
void setLoadingMessage(const QString &message);
- void goToNextComic();
+ void goToNextComic();
private:
+ QString getCharacters(const QScriptValue &json_characters);
+ QMap getAuthors(const QScriptValue &json_authors);
- QString getCharacters(const QScriptValue & json_characters);
- QMap getAuthors(const QScriptValue & json_authors);
+ void toggleSkipButton();
- void toggleSkipButton();
+ enum ScraperMode {
+ SingleComic, //the scraper has been opened for a single comic
+ Volume, //the scraper is trying to get comics info for a whole volume
+ SingleComicInList //the scraper has been opened for a list of unrelated comics
+ };
- enum ScraperMode
- {
- SingleComic, //the scraper has been opened for a single comic
- Volume, //the scraper is trying to get comics info for a whole volume
- SingleComicInList //the scraper has been opened for a list of unrelated comics
- };
+ enum ScraperStatus {
+ AutoSearching,
+ AskingForInfo,
+ SelectingComic,
+ SelectingSeries,
+ SearchingSingleComic,
+ SearchingVolume,
+ SortingComics,
+ GettingVolumeComics
+ };
- enum ScraperStatus
- {
- AutoSearching,
- AskingForInfo,
- SelectingComic,
- SelectingSeries,
- SearchingSingleComic,
- SearchingVolume,
- SortingComics,
- GettingVolumeComics
- };
+ ScraperMode mode;
+ ScraperStatus status;
- ScraperMode mode;
- ScraperStatus status;
+ int currentIndex;
- int currentIndex;
+ TitleHeader *titleHeader;
- TitleHeader * titleHeader;
+ QPushButton *skipButton;
+ QPushButton *backButton;
+ QPushButton *nextButton;
+ QPushButton *searchButton;
+ QPushButton *closeButton;
- QPushButton * skipButton;
- QPushButton * backButton;
- QPushButton * nextButton;
- QPushButton * searchButton;
- QPushButton * closeButton;
+ //stacked widgets
+ QStackedWidget *content;
- //stacked widgets
- QStackedWidget * content;
+ QWidget *infoNotFound;
+ QWidget *singleComicBrowser;
- QWidget * infoNotFound;
- QWidget * singleComicBrowser;
-
- QLabel * loadingMessage;
+ QLabel *loadingMessage;
- void doLayout();
- void doStackedWidgets();
- void doLoading();
- void doConnections();
+ void doLayout();
+ void doStackedWidgets();
+ void doLoading();
+ void doConnections();
- QList comics;
+ QList comics;
- SeriesQuestion * seriesQuestionWidget;
- SearchSingleComic * searchSingleComicWidget;
- SearchVolume * searchVolumeWidget;
- SelectVolume * selectVolumeWidget;
- SelectComic * selectComicWidget;
- SortVolumeComics * sortVolumeComicsWidget;
+ SeriesQuestion *seriesQuestionWidget;
+ SearchSingleComic *searchSingleComicWidget;
+ SearchVolume *searchVolumeWidget;
+ SelectVolume *selectVolumeWidget;
+ SelectComic *selectComicWidget;
+ SortVolumeComics *sortVolumeComicsWidget;
- QString currentVolumeSearchString;
- QString currentVolumeId;
+ QString currentVolumeSearchString;
+ QString currentVolumeId;
};
#endif // COMIC_VINE_DIALOG_H
diff --git a/YACReaderLibrary/comic_vine/model/comics_model.cpp b/YACReaderLibrary/comic_vine/model/comics_model.cpp
index 0aa22a03..6d3f2371 100644
--- a/YACReaderLibrary/comic_vine/model/comics_model.cpp
+++ b/YACReaderLibrary/comic_vine/model/comics_model.cpp
@@ -1,6 +1,6 @@
#include "comics_model.h"
-ComicsModel::ComicsModel(QObject *parent) :
- JSONModel(parent)
+ComicsModel::ComicsModel(QObject *parent)
+ : JSONModel(parent)
{
}
diff --git a/YACReaderLibrary/comic_vine/model/comics_model.h b/YACReaderLibrary/comic_vine/model/comics_model.h
index d99625c1..e019bb89 100644
--- a/YACReaderLibrary/comic_vine/model/comics_model.h
+++ b/YACReaderLibrary/comic_vine/model/comics_model.h
@@ -5,14 +5,13 @@
class ComicsModel : public JSONModel
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ComicsModel(QObject *parent = 0);
+ explicit ComicsModel(QObject *parent = 0);
signals:
public slots:
-
};
#endif // COMICS_MODEL_H
diff --git a/YACReaderLibrary/comic_vine/model/json_model.cpp b/YACReaderLibrary/comic_vine/model/json_model.cpp
index 65d54f32..3f8eb869 100644
--- a/YACReaderLibrary/comic_vine/model/json_model.cpp
+++ b/YACReaderLibrary/comic_vine/model/json_model.cpp
@@ -1,6 +1,6 @@
#include "json_model.h"
-JSONModel::JSONModel(QObject *parent) :
- QAbstractItemModel(parent)
+JSONModel::JSONModel(QObject *parent)
+ : QAbstractItemModel(parent)
{
}
diff --git a/YACReaderLibrary/comic_vine/model/json_model.h b/YACReaderLibrary/comic_vine/model/json_model.h
index 7a70fb70..747f221d 100644
--- a/YACReaderLibrary/comic_vine/model/json_model.h
+++ b/YACReaderLibrary/comic_vine/model/json_model.h
@@ -5,15 +5,14 @@
class JSONModel : public QAbstractItemModel
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit JSONModel(QObject *parent = 0);
- virtual void load(const QString & json) = 0 ;
+ explicit JSONModel(QObject *parent = 0);
+ virtual void load(const QString &json) = 0;
signals:
public slots:
-
};
#endif // JSON_MODEL_H
diff --git a/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp
index b4c45239..ce99b786 100644
--- a/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp
+++ b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp
@@ -1,90 +1,86 @@
#include "local_comic_list_model.h"
-LocalComicListModel::LocalComicListModel(QObject *parent) :
- QAbstractItemModel(parent),numExtraRows(0)
+LocalComicListModel::LocalComicListModel(QObject *parent)
+ : QAbstractItemModel(parent), numExtraRows(0)
{
}
void LocalComicListModel::load(QList &comics)
{
- _data = comics;
+ _data = comics;
}
-
QModelIndex LocalComicListModel::parent(const QModelIndex &index) const
{
- Q_UNUSED(index)
- return QModelIndex(); //no parent
+ Q_UNUSED(index)
+ return QModelIndex(); //no parent
}
int LocalComicListModel::rowCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- return _data.count();
+ Q_UNUSED(parent)
+ return _data.count();
}
int LocalComicListModel::columnCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- if(_data.isEmpty())
- return 0;
- else
- return 1;//_data.at(0)->count();
+ Q_UNUSED(parent)
+ if (_data.isEmpty())
+ return 0;
+ else
+ return 1; //_data.at(0)->count();
}
QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
- return QVariant();
+ if (!index.isValid())
+ return QVariant();
- if (role == Qt::DecorationRole)
- {
- return QVariant();
- }
- if (role == Qt::TextAlignmentRole)
- {
- //TODO
- }
+ if (role == Qt::DecorationRole) {
+ return QVariant();
+ }
+ if (role == Qt::TextAlignmentRole) {
+ //TODO
+ }
- if(role != Qt::DisplayRole)
- return QVariant();
+ if (role != Qt::DisplayRole)
+ return QVariant();
- int row = index.row();
+ int row = index.row();
- //if(row < _data.count())
- return _data[row].getFileName();
- //else
- //return QVariant();
+ //if(row < _data.count())
+ return _data[row].getFileName();
+ //else
+ //return QVariant();
}
Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const
{
- if (!index.isValid())
- return 0;
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ if (!index.isValid())
+ return 0;
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant LocalComicListModel::headerData(int section, Qt::Orientation orientation, int role) const
{
Q_UNUSED(section);
- if ( role == Qt::TextAlignmentRole)
- return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
+ if (role == Qt::TextAlignmentRole)
+ return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- {
- return QVariant(QString(tr("file name")));
- }
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ return QVariant(QString(tr("file name")));
+ }
- return QVariant();
+ return QVariant();
}
QModelIndex LocalComicListModel::index(int row, int column, const QModelIndex &parent) const
{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
- return createIndex(row, column);
+ return createIndex(row, column);
}
QList LocalComicListModel::getData()
@@ -99,18 +95,17 @@ void LocalComicListModel::removeComics(const QList &selectedIndexes
int sourceRow = mi.row();
int sourceLastRow = lastMi.row();
- beginRemoveRows(QModelIndex(),selectedIndexes.first().row(),selectedIndexes.last().row());
+ beginRemoveRows(QModelIndex(), selectedIndexes.first().row(), selectedIndexes.last().row());
- for(int i = sourceLastRow;i>=sourceRow;i--)
- {
+ for (int i = sourceLastRow; i >= sourceRow; i--) {
_removed.push_front(_data.at(i));
_data.removeAt(i);
}
endRemoveRows();
- beginInsertRows(QModelIndex(),_data.count()-_removed.count(),_data.count()-1);
- for(int i = 0; i<_removed.count(); i++)
+ beginInsertRows(QModelIndex(), _data.count() - _removed.count(), _data.count() - 1);
+ for (int i = 0; i < _removed.count(); i++)
_data.append(ComicDB());
endInsertRows();
}
@@ -118,16 +113,14 @@ void LocalComicListModel::removeComics(const QList &selectedIndexes
void LocalComicListModel::restoreAll()
{
int numItemsToRemove = 0;
- for(int i = 0;numItemsToRemove<_removed.count();i++)
- {
- if(_data.at(i).getFileName().isEmpty())
- {
- beginRemoveRows(QModelIndex(),i,i);
+ for (int i = 0; numItemsToRemove < _removed.count(); i++) {
+ if (_data.at(i).getFileName().isEmpty()) {
+ beginRemoveRows(QModelIndex(), i, i);
_data.removeAt(i);
endRemoveRows();
- beginInsertRows(QModelIndex(),i,i);
- _data.insert(i,_removed.at(numItemsToRemove));
+ beginInsertRows(QModelIndex(), i, i);
+ _data.insert(i, _removed.at(numItemsToRemove));
endInsertRows();
numItemsToRemove++;
@@ -139,46 +132,45 @@ void LocalComicListModel::restoreAll()
void LocalComicListModel::moveSelectionUp(const QList &selectedIndexes)
{
- QModelIndex mi = selectedIndexes.first();
- QModelIndex lastMi = selectedIndexes.last();
- int sourceRow = mi.row();
- int sourceLastRow = lastMi.row();
- int destRow = sourceRow - 1;
+ QModelIndex mi = selectedIndexes.first();
+ QModelIndex lastMi = selectedIndexes.last();
+ int sourceRow = mi.row();
+ int sourceLastRow = lastMi.row();
+ int destRow = sourceRow - 1;
- if(destRow < 0)
- return;
+ if (destRow < 0)
+ return;
- beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow);
+ beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow);
- for(int i = sourceRow; i <= sourceLastRow; i++)
- _data.swap(i, i-1);
+ for (int i = sourceRow; i <= sourceLastRow; i++)
+ _data.swap(i, i - 1);
- endMoveRows();
+ endMoveRows();
}
void LocalComicListModel::moveSelectionDown(const QList &selectedIndexes)
{
- QModelIndex mi = selectedIndexes.first();
- QModelIndex lastMi = selectedIndexes.last();
- int sourceRow = mi.row();
- int sourceLastRow = lastMi.row();
- int destRow = sourceLastRow + 1;
+ QModelIndex mi = selectedIndexes.first();
+ QModelIndex lastMi = selectedIndexes.last();
+ int sourceRow = mi.row();
+ int sourceLastRow = lastMi.row();
+ int destRow = sourceLastRow + 1;
- if(destRow >= _data.count())
- return;
+ if (destRow >= _data.count())
+ return;
- beginMoveRows(mi.parent(),sourceRow,sourceLastRow,mi.parent(),destRow+1);
+ beginMoveRows(mi.parent(), sourceRow, sourceLastRow, mi.parent(), destRow + 1);
- for(int i = sourceLastRow; i >= sourceRow; i--)
- _data.swap(i, i+1);
+ for (int i = sourceLastRow; i >= sourceRow; i--)
+ _data.swap(i, i + 1);
- endMoveRows();
+ endMoveRows();
}
void LocalComicListModel::addExtraRows(int numRows)
{
- numExtraRows = numRows;
- for(int i = 0; i & comics);
+ void load(QList &comics);
- //QAbstractItemModel methods
- QModelIndex parent(const QModelIndex &index) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- QList getData();
+ //QAbstractItemModel methods
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QList getData();
- void removeComics(const QList & selectedIndexes);
+ void removeComics(const QList &selectedIndexes);
void restoreAll();
signals:
public slots:
- void moveSelectionUp(const QList & selectedIndexes);
- void moveSelectionDown(const QList & selectedIndexes);
- void addExtraRows(int numRows);
+ void moveSelectionUp(const QList &selectedIndexes);
+ void moveSelectionDown(const QList &selectedIndexes);
+ void addExtraRows(int numRows);
private:
- int numExtraRows;
- QList _data;
+ int numExtraRows;
+ QList _data;
QList _removed;
};
diff --git a/YACReaderLibrary/comic_vine/model/response_parser.cpp b/YACReaderLibrary/comic_vine/model/response_parser.cpp
index 0990a332..b521d4fc 100644
--- a/YACReaderLibrary/comic_vine/model/response_parser.cpp
+++ b/YACReaderLibrary/comic_vine/model/response_parser.cpp
@@ -3,8 +3,8 @@
#include
#include
-ResponseParser::ResponseParser(QObject *parent) :
- QObject(parent),error(false),errorTxt("None"),numResults(-1),currentPage(-1),totalPages(-1)
+ResponseParser::ResponseParser(QObject *parent)
+ : QObject(parent), error(false), errorTxt("None"), numResults(-1), currentPage(-1), totalPages(-1)
{
}
@@ -20,12 +20,12 @@ QString ResponseParser::errorDescription()
qint32 ResponseParser::getNumResults()
{
- return numResults;
+ return numResults;
}
qint32 ResponseParser::getCurrentPage()
{
- return currentPage;
+ return currentPage;
}
qint32 ResponseParser::getTotalPages()
@@ -35,49 +35,43 @@ qint32 ResponseParser::getTotalPages()
bool ResponseParser::isError(qint32 error)
{
- switch(error)
- {
- case 100:
- return true;
+ switch (error) {
+ case 100:
+ return true;
- default:
- return false;
+ default:
+ return false;
}
}
void ResponseParser::loadJSONResponse(const QString &response)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + response + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + response + ")");
errorTxt = "None";
- if (!sc.property("status_code").isValid() || isError(sc.property("status_code").toInt32()))
- {
- error = true;
- if(sc.property("error").isValid())
+ if (!sc.property("status_code").isValid() || isError(sc.property("status_code").toInt32())) {
+ error = true;
+ if (sc.property("error").isValid())
errorTxt = sc.property("error").toString();
else
errorTxt = "Unknown error";
- }
- else
- {
- error = false;
- if(sc.property("number_of_total_results").isValid())
- numResults = sc.property("number_of_total_results").toString().toInt();// sc.property("number_of_total_results").toInt32();
- else
- qDebug() << sc.property("oops").toString();
+ } else {
+ error = false;
+ if (sc.property("number_of_total_results").isValid())
+ numResults = sc.property("number_of_total_results").toString().toInt(); // sc.property("number_of_total_results").toInt32();
+ else
+ qDebug() << sc.property("oops").toString();
- int limit = sc.property("limit").toInt32();
- int offset = sc.property("offset").toInt32();
- int total = sc.property("number_of_total_results").toInt32();
- if(limit > 0)
- {
- totalPages = (total / limit) + (total%limit>0?1:0);
- currentPage = (offset / limit) + 1;
- }
- else
- totalPages = currentPage = 1;
- }
+ int limit = sc.property("limit").toInt32();
+ int offset = sc.property("offset").toInt32();
+ int total = sc.property("number_of_total_results").toInt32();
+ if (limit > 0) {
+ totalPages = (total / limit) + (total % limit > 0 ? 1 : 0);
+ currentPage = (offset / limit) + 1;
+ } else
+ totalPages = currentPage = 1;
+ }
}
diff --git a/YACReaderLibrary/comic_vine/model/response_parser.h b/YACReaderLibrary/comic_vine/model/response_parser.h
index b3325252..c4109491 100644
--- a/YACReaderLibrary/comic_vine/model/response_parser.h
+++ b/YACReaderLibrary/comic_vine/model/response_parser.h
@@ -5,26 +5,26 @@
class ResponseParser : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ResponseParser(QObject *parent = 0);
- bool responseError();
+ explicit ResponseParser(QObject *parent = 0);
+ bool responseError();
QString errorDescription();
- qint32 getNumResults();
- qint32 getCurrentPage();
- qint32 getTotalPages();
+ qint32 getNumResults();
+ qint32 getCurrentPage();
+ qint32 getTotalPages();
bool isError(qint32 error);
signals:
public slots:
- void loadJSONResponse(const QString & response);
+ void loadJSONResponse(const QString &response);
protected:
- bool error;
+ bool error;
QString errorTxt;
- qint32 numResults;
- qint32 currentPage;
- qint32 totalPages;
+ qint32 numResults;
+ qint32 currentPage;
+ qint32 totalPages;
};
#endif // RESPONSE_PARSER_H
diff --git a/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp
index ceb8c3b3..78e28b59 100644
--- a/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp
+++ b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp
@@ -1,53 +1,49 @@
#include "volume_comics_model.h"
#include "qnaturalsorting.h"
-
#include
-bool lessThan(const QList & left, const QList & right)
+bool lessThan(const QList &left, const QList &right)
{
- if ((left.count() > 0) && (right.count() > 0))
- return naturalSortLessThanCI(left.at(0),right.at(0));
- else
- return true;
+ if ((left.count() > 0) && (right.count() > 0))
+ return naturalSortLessThanCI(left.at(0), right.at(0));
+ else
+ return true;
}
-VolumeComicsModel::VolumeComicsModel(QObject * parent) :
- JSONModel(parent),numExtraRows(0)
+VolumeComicsModel::VolumeComicsModel(QObject *parent)
+ : JSONModel(parent), numExtraRows(0)
{
}
-void VolumeComicsModel::load(const QString & json)
+void VolumeComicsModel::load(const QString &json)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + json + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + json + ")");
- if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
- {
- qDebug("Error detected");
- }
- else
- {
- QScriptValueIterator it(sc.property("results"));
- //bool test;
- QScriptValue resultsValue;
- while (it.hasNext()) {
- it.next();
- if(it.flags() & QScriptValue::SkipInEnumeration)
+ if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
+ qDebug("Error detected");
+ } else {
+ QScriptValueIterator it(sc.property("results"));
+ //bool test;
+ QScriptValue resultsValue;
+ while (it.hasNext()) {
+ it.next();
+ if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
- resultsValue = it.value();
- QString issueNumber = resultsValue.property("issue_number").toString();
+ resultsValue = it.value();
+ QString issueNumber = resultsValue.property("issue_number").toString();
QScriptValue propertyName = resultsValue.property("name");
QString name = propertyName.isNull() ? "-" : propertyName.toString();
- QString coverURL = resultsValue.property("image").property("medium_url").toString();
- QString id = resultsValue.property("id").toString();
- QStringList l;
- l << issueNumber << name << coverURL << id;
+ QString coverURL = resultsValue.property("image").property("medium_url").toString();
+ QString id = resultsValue.property("id").toString();
+ QStringList l;
+ l << issueNumber << name << coverURL << id;
_data.push_back(l);
- }
+ }
- qSort(_data.begin(),_data.end(),lessThan);
+ qSort(_data.begin(), _data.end(), lessThan);
}
}
@@ -60,121 +56,116 @@ void VolumeComicsModel::load(const QString & json)
QModelIndex VolumeComicsModel::parent(const QModelIndex &index) const
{
- Q_UNUSED(index)
- return QModelIndex(); //no parent
+ Q_UNUSED(index)
+ return QModelIndex(); //no parent
}
int VolumeComicsModel::rowCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- return _data.count() + numExtraRows;
+ Q_UNUSED(parent)
+ return _data.count() + numExtraRows;
}
int VolumeComicsModel::columnCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- if(_data.isEmpty())
- return 0;
- else
- return 2;
+ Q_UNUSED(parent)
+ if (_data.isEmpty())
+ return 0;
+ else
+ return 2;
}
QVariant VolumeComicsModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
- return QVariant();
+ if (!index.isValid())
+ return QVariant();
- int row = index.row();
- int column = index.column();
+ int row = index.row();
+ int column = index.column();
- if (role == Qt::DecorationRole)
- {
- return QVariant();
- }
- if (role == Qt::TextAlignmentRole)
- {
- switch(column)//TODO obtener esto de la query
- {
- case ISSUE:
- return QVariant(Qt::AlignRight | Qt::AlignVCenter);
- case TITLE:
- return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
- }
- }
+ if (role == Qt::DecorationRole) {
+ return QVariant();
+ }
+ if (role == Qt::TextAlignmentRole) {
+ switch (column) //TODO obtener esto de la query
+ {
+ case ISSUE:
+ return QVariant(Qt::AlignRight | Qt::AlignVCenter);
+ case TITLE:
+ return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
+ }
+ }
- if(role != Qt::DisplayRole)
- return QVariant();
+ if (role != Qt::DisplayRole)
+ return QVariant();
- if(row<_data.count())
- return _data[row][column];
- else
- return QVariant();
+ if (row < _data.count())
+ return _data[row][column];
+ else
+ return QVariant();
}
Qt::ItemFlags VolumeComicsModel::flags(const QModelIndex &index) const
{
- if (!index.isValid())
- return 0;
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ if (!index.isValid())
+ return 0;
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant VolumeComicsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- {
- switch(section)//TODO obtener esto de la query
- {
- case ISSUE:
- return QVariant(QString("issue"));
- case TITLE:
- return QVariant(QString(tr("title")));
- }
- }
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) //TODO obtener esto de la query
+ {
+ case ISSUE:
+ return QVariant(QString("issue"));
+ case TITLE:
+ return QVariant(QString(tr("title")));
+ }
+ }
- if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole)
- {
- switch(section)//TODO obtener esto de la query
- {
- case ISSUE:
- return QVariant(Qt::AlignRight | Qt::AlignVCenter);
- case TITLE:
- return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
- }
- }
+ if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole) {
+ switch (section) //TODO obtener esto de la query
+ {
+ case ISSUE:
+ return QVariant(Qt::AlignRight | Qt::AlignVCenter);
+ case TITLE:
+ return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
+ }
+ }
- return QVariant();
+ return QVariant();
}
QModelIndex VolumeComicsModel::index(int row, int column, const QModelIndex &parent) const
{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
- return createIndex(row, column);
+ return createIndex(row, column);
}
QString VolumeComicsModel::getComicId(const QModelIndex &index) const
{
- int row = index.row();
- if(row >= _data.count())
- return "";
- return _data[row][ID];
+ int row = index.row();
+ if (row >= _data.count())
+ return "";
+ return _data[row][ID];
}
QString VolumeComicsModel::getComicId(int row) const
{
- if(row >= _data.count())
- return "";
- return _data[row][ID];
+ if (row >= _data.count())
+ return "";
+ return _data[row][ID];
}
QString VolumeComicsModel::getCoverURL(const QModelIndex &index) const
{
- return _data[index.row()][COVER_URL];
+ return _data[index.row()][COVER_URL];
}
void VolumeComicsModel::addExtraRows(int numRows)
{
- numExtraRows = numRows;
+ numExtraRows = numRows;
}
-
diff --git a/YACReaderLibrary/comic_vine/model/volume_comics_model.h b/YACReaderLibrary/comic_vine/model/volume_comics_model.h
index b9d9aaeb..5d7003bb 100644
--- a/YACReaderLibrary/comic_vine/model/volume_comics_model.h
+++ b/YACReaderLibrary/comic_vine/model/volume_comics_model.h
@@ -5,38 +5,38 @@
class VolumeComicsModel : public JSONModel
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit VolumeComicsModel(QObject *parent = 0);
- void load(const QString & json);
+ explicit VolumeComicsModel(QObject *parent = 0);
+ void load(const QString &json);
//void load(const QStringList & jsonList);
- QModelIndex parent(const QModelIndex &index) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
signals:
public slots:
- QString getComicId(const QModelIndex &index) const;
- QString getComicId(int row) const;
- QString getCoverURL(const QModelIndex &index) const;
- void addExtraRows(int numRows);
+ QString getComicId(const QModelIndex &index) const;
+ QString getComicId(int row) const;
+ QString getCoverURL(const QModelIndex &index) const;
+ void addExtraRows(int numRows);
private:
- int numExtraRows;
- QList > _data;
+ int numExtraRows;
+ QList> _data;
- enum Column {
- ISSUE = 0,
- TITLE,
- COVER_URL,
- ID
- };
+ enum Column {
+ ISSUE = 0,
+ TITLE,
+ COVER_URL,
+ ID
+ };
};
#endif // VOLUME_COMICS_MODEL_H
diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.cpp b/YACReaderLibrary/comic_vine/model/volumes_model.cpp
index 7bb63408..4396dfb8 100644
--- a/YACReaderLibrary/comic_vine/model/volumes_model.cpp
+++ b/YACReaderLibrary/comic_vine/model/volumes_model.cpp
@@ -2,90 +2,129 @@
#include
-
-VolumesModel::VolumesModel(QObject *parent) :
- JSONModel(parent)
+VolumesModel::VolumesModel(QObject *parent)
+ : JSONModel(parent)
{
}
VolumesModel::~VolumesModel()
{
- //std::for_each(_data.begin(), _data.end(), [](QList * ptr) { delete ptr; });
+ //std::for_each(_data.begin(), _data.end(), [](QList * ptr) { delete ptr; });
}
void VolumesModel::load(const QString &json)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + json + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + json + ")");
- if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
- {
- qDebug("Error detected");
- }
- else
- {
- int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
- QScriptValueIterator it(sc.property("results"));
- bool test;
- QScriptValue resultsValue;
- while (it.hasNext()) {
- it.next();
- resultsValue = it.value();
- QString numIssues = resultsValue.property("count_of_issues").toString();
- QString year = resultsValue.property("start_year").toString();
- QString name = resultsValue.property("name").toString();
- QString publisher = resultsValue.property("publisher").property("name").toString();
- QString url = resultsValue.property("image").property("medium_url").toString();
- QString deck = resultsValue.property("deck").toString();
- QString id = resultsValue.property("id").toString();
- QStringList l;
- l << name << year << numIssues << publisher << url << deck << id;
- test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
- if(numResults>0 && !test)
- _data.push_back(l);
- numResults--;
- }
- }
+ if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
+ qDebug("Error detected");
+ } else {
+ int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
+ QScriptValueIterator it(sc.property("results"));
+ bool test;
+ QScriptValue resultsValue;
+ while (it.hasNext()) {
+ it.next();
+ resultsValue = it.value();
+ QString numIssues = resultsValue.property("count_of_issues").toString();
+ QString year = resultsValue.property("start_year").toString();
+ QString name = resultsValue.property("name").toString();
+ QString publisher = resultsValue.property("publisher").property("name").toString();
+ QString url = resultsValue.property("image").property("medium_url").toString();
+ QString deck = resultsValue.property("deck").toString();
+ QString id = resultsValue.property("id").toString();
+ QStringList l;
+ l << name << year << numIssues << publisher << url << deck << id;
+ test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
+ if (numResults > 0 && !test)
+ _data.push_back(l);
+ numResults--;
+ }
+ }
}
QModelIndex VolumesModel::parent(const QModelIndex &index) const
{
- Q_UNUSED(index)
- return QModelIndex(); //no parent
+ Q_UNUSED(index)
+ return QModelIndex(); //no parent
}
int VolumesModel::rowCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- return _data.count();
+ Q_UNUSED(parent)
+ return _data.count();
}
int VolumesModel::columnCount(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
- if(_data.isEmpty())
- return 0;
- else
- return 4;//_data.at(0)->count();
+ Q_UNUSED(parent)
+ if (_data.isEmpty())
+ return 0;
+ else
+ return 4; //_data.at(0)->count();
}
QVariant VolumesModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
- return QVariant();
-
- if (role == Qt::DecorationRole)
- {
+ if (!index.isValid())
return QVariant();
- }
+
+ if (role == Qt::DecorationRole) {
+ return QVariant();
+ }
int row = index.row();
int column = index.column();
- if (role == Qt::TextAlignmentRole)
- {
- switch(column)
+ if (role == Qt::TextAlignmentRole) {
+ switch (column) {
+ case YEAR:
+ return QVariant(Qt::AlignRight | Qt::AlignVCenter);
+ case ISSUES:
+ return QVariant(Qt::AlignRight | Qt::AlignVCenter);
+ default:
+ return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
+ }
+ }
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (column == YEAR || column == ISSUES) {
+ return _data[row][column].toInt();
+ } else {
+ return _data[row][column];
+ }
+}
+
+Qt::ItemFlags VolumesModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+QVariant VolumesModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) //TODO obtener esto de la query
+ {
+ case SERIES:
+ return QVariant(QString("series"));
+ case YEAR:
+ return QVariant(QString(tr("year")));
+ case ISSUES:
+ return QVariant(QString(tr("issues")));
+ case PUBLISHER:
+ return QVariant(QString(tr("publisher")));
+ }
+ }
+
+ if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole) {
+ switch (section) //TODO obtener esto de la query
{
case YEAR:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
@@ -94,68 +133,17 @@ QVariant VolumesModel::data(const QModelIndex &index, int role) const
default:
return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
}
- }
-
- if(role != Qt::DisplayRole)
- return QVariant();
-
- if (column == YEAR || column == ISSUES)
- {
- return _data[row][column].toInt();
}
- else
- {
- return _data[row][column];
- }
-}
-Qt::ItemFlags VolumesModel::flags(const QModelIndex &index) const
-{
- if (!index.isValid())
- return 0;
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-
-QVariant VolumesModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
-
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- {
- switch(section)//TODO obtener esto de la query
- {
- case SERIES:
- return QVariant(QString("series"));
- case YEAR:
- return QVariant(QString(tr("year")));
- case ISSUES:
- return QVariant(QString(tr("issues")));
- case PUBLISHER:
- return QVariant(QString(tr("publisher")));
- }
- }
-
- if (orientation == Qt::Horizontal && role == Qt::TextAlignmentRole)
- {
- switch(section)//TODO obtener esto de la query
- {
- case YEAR:
- return QVariant(Qt::AlignRight | Qt::AlignVCenter);
- case ISSUES:
- return QVariant(Qt::AlignRight | Qt::AlignVCenter);
- default:
- return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
- }
- }
-
- return QVariant();
+ return QVariant();
}
QModelIndex VolumesModel::index(int row, int column, const QModelIndex &parent) const
{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
- return createIndex(row, column);
+ return createIndex(row, column);
}
QString VolumesModel::getVolumeId(const QModelIndex &index) const
@@ -175,6 +163,5 @@ QString VolumesModel::getPublisher(const QModelIndex &index) const
QString VolumesModel::getCoverURL(const QModelIndex &index) const
{
- return _data[index.row()][COVER_URL];
+ return _data[index.row()][COVER_URL];
}
-
diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.h b/YACReaderLibrary/comic_vine/model/volumes_model.h
index a9811458..839786e8 100644
--- a/YACReaderLibrary/comic_vine/model/volumes_model.h
+++ b/YACReaderLibrary/comic_vine/model/volumes_model.h
@@ -5,49 +5,49 @@
class VolumesModel : public JSONModel
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit VolumesModel(QObject *parent = 0);
- virtual ~VolumesModel();
- //receive a valid json with a list of volumes
- void load(const QString & json);
+ explicit VolumesModel(QObject *parent = 0);
+ virtual ~VolumesModel();
+ //receive a valid json with a list of volumes
+ void load(const QString &json);
- //QAbstractItemModel methods
- QModelIndex parent(const QModelIndex &index) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ //QAbstractItemModel methods
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- QString getVolumeId(const QModelIndex & index) const;
- int getNumIssues(const QModelIndex & index) const;
- QString getPublisher(const QModelIndex & index) const;
- QString getCoverURL(const QModelIndex & index) const;
+ QString getVolumeId(const QModelIndex &index) const;
+ int getNumIssues(const QModelIndex &index) const;
+ QString getPublisher(const QModelIndex &index) const;
+ QString getCoverURL(const QModelIndex &index) const;
signals:
public slots:
private:
- QList > _data;
+ QList> _data;
public:
- enum Column {
- SERIES = 0,
- YEAR,
- ISSUES,
- PUBLISHER,
- COVER_URL,
- DECK,
- ID
- };
+ enum Column {
+ SERIES = 0,
+ YEAR,
+ ISSUES,
+ PUBLISHER,
+ COVER_URL,
+ DECK,
+ ID
+ };
enum Role {
- SORT_ROLE = Qt::UserRole
- };
+ SORT_ROLE = Qt::UserRole
+ };
};
#endif // VOLUMES_MODEL_H
diff --git a/YACReaderLibrary/comic_vine/scraper_lineedit.cpp b/YACReaderLibrary/comic_vine/scraper_lineedit.cpp
index 5afb4074..d1227085 100644
--- a/YACReaderLibrary/comic_vine/scraper_lineedit.cpp
+++ b/YACReaderLibrary/comic_vine/scraper_lineedit.cpp
@@ -1,21 +1,22 @@
#include "scraper_lineedit.h"
#include
-ScraperLineEdit::ScraperLineEdit(const QString & title, QWidget * widget)
- :QLineEdit(widget)
+ScraperLineEdit::ScraperLineEdit(const QString &title, QWidget *widget)
+ : QLineEdit(widget)
{
- titleLabel = new QLabel(title,this);
- titleLabel->setStyleSheet("QLabel {color:white;}");
+ titleLabel = new QLabel(title, this);
+ titleLabel->setStyleSheet("QLabel {color:white;}");
- setStyleSheet(QString("QLineEdit {"
- "border:none; background-color: #2E2E2E; color : white; padding-left: %1; padding-bottom: 1px; margin-bottom: 0px;"
- "}").arg(titleLabel->sizeHint().width()+6));
+ setStyleSheet(QString("QLineEdit {"
+ "border:none; background-color: #2E2E2E; color : white; padding-left: %1; padding-bottom: 1px; margin-bottom: 0px;"
+ "}")
+ .arg(titleLabel->sizeHint().width() + 6));
- setFixedHeight(22);
+ setFixedHeight(22);
}
void ScraperLineEdit::resizeEvent(QResizeEvent *)
{
- QSize szl = titleLabel->sizeHint();
- titleLabel->move(6,(rect().bottom() + 1 - szl.height())/2);
+ QSize szl = titleLabel->sizeHint();
+ titleLabel->move(6, (rect().bottom() + 1 - szl.height()) / 2);
}
diff --git a/YACReaderLibrary/comic_vine/scraper_lineedit.h b/YACReaderLibrary/comic_vine/scraper_lineedit.h
index 45d58039..e4bd0582 100644
--- a/YACReaderLibrary/comic_vine/scraper_lineedit.h
+++ b/YACReaderLibrary/comic_vine/scraper_lineedit.h
@@ -7,13 +7,15 @@ class QLabel;
class ScraperLineEdit : public QLineEdit
{
- Q_OBJECT
+ Q_OBJECT
public:
- ScraperLineEdit(const QString & title, QWidget * widget = 0);
+ ScraperLineEdit(const QString &title, QWidget *widget = 0);
+
protected:
- void resizeEvent(QResizeEvent *);
+ void resizeEvent(QResizeEvent *);
+
private:
- QLabel * titleLabel;
+ QLabel *titleLabel;
};
#endif // SCRAPPER_LINEEDIT_H
diff --git a/YACReaderLibrary/comic_vine/scraper_results_paginator.cpp b/YACReaderLibrary/comic_vine/scraper_results_paginator.cpp
index c7933510..22f658d5 100644
--- a/YACReaderLibrary/comic_vine/scraper_results_paginator.cpp
+++ b/YACReaderLibrary/comic_vine/scraper_results_paginator.cpp
@@ -6,70 +6,69 @@
#include
#include
-
-ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent) :
- QWidget(parent),customLabel("items")
+ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent)
+ : QWidget(parent), customLabel("items")
{
- QHBoxLayout * pagesButtonsLayout = new QHBoxLayout;
+ QHBoxLayout *pagesButtonsLayout = new QHBoxLayout;
- QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
+ QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
- nextPage = new QToolButton;
- nextPage->setStyleSheet("QToolButton {border:none;}");
- QPixmap np(":/images/comic_vine/nextPage.png");
- nextPage->setIconSize(np.size());
- nextPage->setIcon(np);
+ nextPage = new QToolButton;
+ nextPage->setStyleSheet("QToolButton {border:none;}");
+ QPixmap np(":/images/comic_vine/nextPage.png");
+ nextPage->setIconSize(np.size());
+ nextPage->setIcon(np);
- previousPage = new QToolButton;
- previousPage->setStyleSheet("QToolButton {border:none;}");
- QPixmap pp(":/images/comic_vine/previousPage.png");
- previousPage->setIconSize(pp.size());
- previousPage->setIcon(pp);
+ previousPage = new QToolButton;
+ previousPage->setStyleSheet("QToolButton {border:none;}");
+ QPixmap pp(":/images/comic_vine/previousPage.png");
+ previousPage->setIconSize(pp.size());
+ previousPage->setIcon(pp);
- connect(nextPage,SIGNAL(clicked()),this,SIGNAL(loadNextPage()));
- connect(previousPage,SIGNAL(clicked()),this,SIGNAL(loadPreviousPage()));
+ connect(nextPage, SIGNAL(clicked()), this, SIGNAL(loadNextPage()));
+ connect(previousPage, SIGNAL(clicked()), this, SIGNAL(loadPreviousPage()));
- numElements = new QLabel(tr("Number of volumes found : %1"));
- numElements->setStyleSheet(labelStylesheet);
- numPages = new QLabel(tr("page %1 of %2"));
- numPages->setStyleSheet(labelStylesheet);
+ numElements = new QLabel(tr("Number of volumes found : %1"));
+ numElements->setStyleSheet(labelStylesheet);
+ numPages = new QLabel(tr("page %1 of %2"));
+ numPages->setStyleSheet(labelStylesheet);
- pagesButtonsLayout->addSpacing(15);
- pagesButtonsLayout->addWidget(numElements);
- pagesButtonsLayout->addStretch();
- pagesButtonsLayout->addWidget(numPages);
- pagesButtonsLayout->addWidget(previousPage);
- pagesButtonsLayout->addWidget(nextPage);
+ pagesButtonsLayout->addSpacing(15);
+ pagesButtonsLayout->addWidget(numElements);
+ pagesButtonsLayout->addStretch();
+ pagesButtonsLayout->addWidget(numPages);
+ pagesButtonsLayout->addWidget(previousPage);
+ pagesButtonsLayout->addWidget(nextPage);
- setContentsMargins(0,0,0,0);
- pagesButtonsLayout->setContentsMargins(0,0,0,0);
+ setContentsMargins(0, 0, 0, 0);
+ pagesButtonsLayout->setContentsMargins(0, 0, 0, 0);
- setLayout(pagesButtonsLayout);
+ setLayout(pagesButtonsLayout);
}
void ScraperResultsPaginator::update(const QString &json)
{
- ResponseParser rp;
- rp.loadJSONResponse(json);
+ ResponseParser rp;
+ rp.loadJSONResponse(json);
- currentPage = rp.getCurrentPage();
- numElements->setText(tr("Number of %1 found : %2").arg(customLabel).arg(rp.getNumResults()));
- numPages->setText(tr("page %1 of %2").arg(currentPage).arg(rp.getTotalPages()));
+ currentPage = rp.getCurrentPage();
+ numElements->setText(tr("Number of %1 found : %2").arg(customLabel).arg(rp.getNumResults()));
+ numPages->setText(tr("page %1 of %2").arg(currentPage).arg(rp.getTotalPages()));
- previousPage->setDisabled(currentPage == 1);
- nextPage->setDisabled(currentPage == rp.getTotalPages());
+ previousPage->setDisabled(currentPage == 1);
+ nextPage->setDisabled(currentPage == rp.getTotalPages());
- numPages->setHidden(rp.getTotalPages()==1);
- previousPage->setHidden(rp.getTotalPages()==1);
- nextPage->setHidden(rp.getTotalPages()==1);
+ numPages->setHidden(rp.getTotalPages() == 1);
+ previousPage->setHidden(rp.getTotalPages() == 1);
+ nextPage->setHidden(rp.getTotalPages() == 1);
}
int ScraperResultsPaginator::getCurrentPage()
{
- return currentPage;
+ return currentPage;
}
void ScraperResultsPaginator::setCustomLabel(const QString &label)
{
- customLabel = label;
+ customLabel = label;
}
diff --git a/YACReaderLibrary/comic_vine/scraper_results_paginator.h b/YACReaderLibrary/comic_vine/scraper_results_paginator.h
index feeb0987..8f96adbc 100644
--- a/YACReaderLibrary/comic_vine/scraper_results_paginator.h
+++ b/YACReaderLibrary/comic_vine/scraper_results_paginator.h
@@ -8,27 +8,27 @@ class QLabel;
class ScraperResultsPaginator : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ScraperResultsPaginator(QWidget *parent = 0);
- void update(const QString & json);
- int getCurrentPage();
- void setCustomLabel(const QString & label);
+ explicit ScraperResultsPaginator(QWidget *parent = 0);
+ void update(const QString &json);
+ int getCurrentPage();
+ void setCustomLabel(const QString &label);
signals:
- void loadNextPage();
- void loadPreviousPage();
+ void loadNextPage();
+ void loadPreviousPage();
public slots:
private:
- QToolButton * nextPage;
- QToolButton * previousPage;
- QLabel * numElements;
- QLabel * numPages;
+ QToolButton *nextPage;
+ QToolButton *previousPage;
+ QLabel *numElements;
+ QLabel *numPages;
- int currentPage;
+ int currentPage;
- QString customLabel;
+ QString customLabel;
};
#endif // SCRAPER_RESULTS_PAGINATOR_H
diff --git a/YACReaderLibrary/comic_vine/scraper_scroll_label.cpp b/YACReaderLibrary/comic_vine/scraper_scroll_label.cpp
index 87c16f03..83f29c12 100644
--- a/YACReaderLibrary/comic_vine/scraper_scroll_label.cpp
+++ b/YACReaderLibrary/comic_vine/scraper_scroll_label.cpp
@@ -4,50 +4,49 @@
#include
#include
-ScraperScrollLabel::ScraperScrollLabel(QWidget *parent) :
- QScrollArea(parent)
+ScraperScrollLabel::ScraperScrollLabel(QWidget *parent)
+ : QScrollArea(parent)
{
- textLabel = new QLabel(this);
- textLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
+ textLabel = new QLabel(this);
+ textLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
- textLabel->setWordWrap(true);
- textLabel->setMinimumSize(168,12);
+ textLabel->setWordWrap(true);
+ textLabel->setMinimumSize(168, 12);
- setWidget(textLabel);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setStyleSheet(
- "QScrollArea {background-color:#2B2B2B; border:none;}"
- "QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
- "QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
- "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
- "QScrollBar::handle:horizontal { background: #DDDDDD; width: 7px; min-height: 20px; }"
- "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
- "QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
- "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
- "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
- "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }"
- );
+ setWidget(textLabel);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setStyleSheet(
+ "QScrollArea {background-color:#2B2B2B; border:none;}"
+ "QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
+ "QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
+ "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
+ "QScrollBar::handle:horizontal { background: #DDDDDD; width: 7px; min-height: 20px; }"
+ "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ "QScrollBar::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
+ "QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
+ "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
+ "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
+ "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }");
- connect(textLabel,SIGNAL(linkActivated(QString)),this,SLOT(openLink(QString)));
+ connect(textLabel, SIGNAL(linkActivated(QString)), this, SLOT(openLink(QString)));
}
void ScraperScrollLabel::setAltText(const QString &text)
{
- textLabel->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
- textLabel->setText(text);
- textLabel->adjustSize();
+ textLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
+ textLabel->setText(text);
+ textLabel->adjustSize();
}
void ScraperScrollLabel::setText(const QString &text)
{
- textLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
- textLabel->setText(text);
- textLabel->adjustSize();
+ textLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ textLabel->setText(text);
+ textLabel->adjustSize();
}
-void ScraperScrollLabel::openLink(const QString & link)
+void ScraperScrollLabel::openLink(const QString &link)
{
- QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link));
+ QDesktopServices::openUrl(QUrl("http://www.comicvine.com" + link));
}
diff --git a/YACReaderLibrary/comic_vine/scraper_scroll_label.h b/YACReaderLibrary/comic_vine/scraper_scroll_label.h
index 3319f344..d9fd6837 100644
--- a/YACReaderLibrary/comic_vine/scraper_scroll_label.h
+++ b/YACReaderLibrary/comic_vine/scraper_scroll_label.h
@@ -7,19 +7,20 @@ class QLabel;
class ScraperScrollLabel : public QScrollArea
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ScraperScrollLabel(QWidget *parent = 0);
+ explicit ScraperScrollLabel(QWidget *parent = 0);
signals:
public slots:
- void setText(const QString & text);
- void setAltText(const QString &text);
+ void setText(const QString &text);
+ void setAltText(const QString &text);
+
+ void openLink(const QString &link);
- void openLink(const QString &link);
private:
- QLabel * textLabel;
+ QLabel *textLabel;
};
#endif // SCRAPER_SCROLL_LABEL_H
diff --git a/YACReaderLibrary/comic_vine/scraper_selector.cpp b/YACReaderLibrary/comic_vine/scraper_selector.cpp
index bf6bd5a3..ec83b975 100644
--- a/YACReaderLibrary/comic_vine/scraper_selector.cpp
+++ b/YACReaderLibrary/comic_vine/scraper_selector.cpp
@@ -1,25 +1,25 @@
#include "scraper_selector.h"
-ScraperSelector::ScraperSelector(QWidget *parent) :
- QWidget(parent)
+ScraperSelector::ScraperSelector(QWidget *parent)
+ : QWidget(parent)
{
- paginator = new ScraperResultsPaginator;
- connect(paginator,SIGNAL(loadNextPage()),this,SLOT(loadNextPage()));
- connect(paginator,SIGNAL(loadPreviousPage()),this,SLOT(loadPreviousPage()));
+ paginator = new ScraperResultsPaginator;
+ connect(paginator, SIGNAL(loadNextPage()), this, SLOT(loadNextPage()));
+ connect(paginator, SIGNAL(loadPreviousPage()), this, SLOT(loadPreviousPage()));
}
void ScraperSelector::load(const QString &json, const QString &searchString)
{
- currentSearchString = searchString;
- paginator->update(json);
+ currentSearchString = searchString;
+ paginator->update(json);
}
void ScraperSelector::loadNextPage()
{
- emit loadPage(currentSearchString,paginator->getCurrentPage()+1);
+ emit loadPage(currentSearchString, paginator->getCurrentPage() + 1);
}
void ScraperSelector::loadPreviousPage()
{
- emit loadPage(currentSearchString,paginator->getCurrentPage()-1);
+ emit loadPage(currentSearchString, paginator->getCurrentPage() - 1);
}
diff --git a/YACReaderLibrary/comic_vine/scraper_selector.h b/YACReaderLibrary/comic_vine/scraper_selector.h
index 640a3950..5fdf1b1b 100644
--- a/YACReaderLibrary/comic_vine/scraper_selector.h
+++ b/YACReaderLibrary/comic_vine/scraper_selector.h
@@ -7,22 +7,22 @@
class ScraperSelector : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ScraperSelector(QWidget *parent = 0);
- virtual void load(const QString & json, const QString & searchString);
+ explicit ScraperSelector(QWidget *parent = 0);
+ virtual void load(const QString &json, const QString &searchString);
public slots:
signals:
- void loadPage(QString,int);
+ void loadPage(QString, int);
private slots:
- void loadNextPage();
- void loadPreviousPage();
+ void loadNextPage();
+ void loadPreviousPage();
protected:
- QString currentSearchString;
- ScraperResultsPaginator * paginator;
+ QString currentSearchString;
+ ScraperResultsPaginator *paginator;
};
#endif // SCRAPER_SELECTOR_H
diff --git a/YACReaderLibrary/comic_vine/scraper_tableview.cpp b/YACReaderLibrary/comic_vine/scraper_tableview.cpp
index f78bcc7a..4aaf7da9 100644
--- a/YACReaderLibrary/comic_vine/scraper_tableview.cpp
+++ b/YACReaderLibrary/comic_vine/scraper_tableview.cpp
@@ -2,59 +2,59 @@
#include
-ScraperTableView::ScraperTableView(QWidget *parent) :
- QTableView(parent)
+ScraperTableView::ScraperTableView(QWidget *parent)
+ : QTableView(parent)
{
QString tableStylesheet = "QTableView {color:white; border:0px;alternate-background-color: #2E2E2E;background-color: #2B2B2B; outline: 0px;}"
- "QTableView::item {outline: 0px; border: 0px; color:#FFFFFF;}"
- "QTableView::item:selected {outline: 0px; background-color: #555555; }"
- "QHeaderView::section:horizontal {background-color:#292929; border-bottom:1px solid #1F1F1F; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #292929, stop: 1 #1F1F1F); border-left:none; border-top:none; padding:4px; color:#ebebeb;}"
- "QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}"
- "QHeaderView::down-arrow {image: url(':/images/comic_vine/downArrow.png');}"
- "QHeaderView::up-arrow {image: url(':/images/comic_vine/upArrow.png');}"
- "QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
- "QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
- "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
- "QScrollBar::handle:horizontal { background: #DDDDDD; width: 7px; min-height: 20px; }"
- "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
- "QScrollBar::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
- "QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
- "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
- "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
- "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }";
+ "QTableView::item {outline: 0px; border: 0px; color:#FFFFFF;}"
+ "QTableView::item:selected {outline: 0px; background-color: #555555; }"
+ "QHeaderView::section:horizontal {background-color:#292929; border-bottom:1px solid #1F1F1F; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #292929, stop: 1 #1F1F1F); border-left:none; border-top:none; padding:4px; color:#ebebeb;}"
+ "QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}"
+ "QHeaderView::down-arrow {image: url(':/images/comic_vine/downArrow.png');}"
+ "QHeaderView::up-arrow {image: url(':/images/comic_vine/upArrow.png');}"
+ "QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
+ "QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
+ "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
+ "QScrollBar::handle:horizontal { background: #DDDDDD; width: 7px; min-height: 20px; }"
+ "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
+ "QScrollBar::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
+ "QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
+ "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
+ "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
+ "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }";
- setStyleSheet(tableStylesheet);
+ setStyleSheet(tableStylesheet);
- setShowGrid(false);
+ setShowGrid(false);
#if QT_VERSION >= 0x050000
- verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
+ verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
#else
- verticalHeader()->setResizeMode(QHeaderView::Fixed);
+ verticalHeader()->setResizeMode(QHeaderView::Fixed);
#endif
horizontalHeader()->setStretchLastSection(true);
#if QT_VERSION >= 0x050000
- horizontalHeader()->setSectionsClickable(false);
+ horizontalHeader()->setSectionsClickable(false);
#else
- horizontalHeader()->setClickable(false);
+ horizontalHeader()->setClickable(false);
#endif
- //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- verticalHeader()->setDefaultSectionSize(24);
+ //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
+ verticalHeader()->setDefaultSectionSize(24);
#if QT_VERSION >= 0x050000
- verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo
+ verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo
#else
- verticalHeader()->setClickable(false); //TODO comportamiento anómalo
+ verticalHeader()->setClickable(false); //TODO comportamiento anómalo
#endif
- setCornerButtonEnabled(false);
+ setCornerButtonEnabled(false);
- setSelectionBehavior(QAbstractItemView::SelectRows);
- setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
- setAlternatingRowColors(true);
+ setAlternatingRowColors(true);
- verticalHeader()->hide();
+ verticalHeader()->hide();
setSelectionMode(QAbstractItemView::SingleSelection);
}
diff --git a/YACReaderLibrary/comic_vine/scraper_tableview.h b/YACReaderLibrary/comic_vine/scraper_tableview.h
index b6fe83ef..9c6ad8c6 100644
--- a/YACReaderLibrary/comic_vine/scraper_tableview.h
+++ b/YACReaderLibrary/comic_vine/scraper_tableview.h
@@ -5,14 +5,13 @@
class ScraperTableView : public QTableView
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ScraperTableView(QWidget *parent = 0);
+ explicit ScraperTableView(QWidget *parent = 0);
signals:
public slots:
-
};
#endif // SCRAPPER_TABLEVIEW_H
diff --git a/YACReaderLibrary/comic_vine/search_single_comic.cpp b/YACReaderLibrary/comic_vine/search_single_comic.cpp
index e1a74635..70469e13 100644
--- a/YACReaderLibrary/comic_vine/search_single_comic.cpp
+++ b/YACReaderLibrary/comic_vine/search_single_comic.cpp
@@ -6,57 +6,57 @@
#include
#include
-SearchSingleComic::SearchSingleComic(QWidget * parent)
- :QWidget(parent)
+SearchSingleComic::SearchSingleComic(QWidget *parent)
+ : QWidget(parent)
{
- //QLabel * label = new QLabel(tr("Please provide some additional information. At least one field is needed."));
- QLabel * label = new QLabel(tr("Please provide some additional information."));
- label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
+ //QLabel * label = new QLabel(tr("Please provide some additional information. At least one field is needed."));
+ QLabel *label = new QLabel(tr("Please provide some additional information."));
+ label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
- //titleEdit = new ScraperLineEdit(tr("Title:"));
- //numberEdit = new ScraperLineEdit(tr("Number:"));
- volumeEdit = new ScraperLineEdit(tr("Series:"));
+ //titleEdit = new ScraperLineEdit(tr("Title:"));
+ //numberEdit = new ScraperLineEdit(tr("Number:"));
+ volumeEdit = new ScraperLineEdit(tr("Series:"));
- //numberEdit->setMaximumWidth(126);
+ //numberEdit->setMaximumWidth(126);
- QVBoxLayout * l = new QVBoxLayout;
- //QHBoxLayout * hl = new QHBoxLayout;
- //hl->addWidget(titleEdit);
- //hl->addWidget(numberEdit);
+ QVBoxLayout *l = new QVBoxLayout;
+ //QHBoxLayout * hl = new QHBoxLayout;
+ //hl->addWidget(titleEdit);
+ //hl->addWidget(numberEdit);
- l->addSpacing(35);
- l->addWidget(label);
- //l->addLayout(hl);
- l->addWidget(volumeEdit);
- l->addStretch();
+ l->addSpacing(35);
+ l->addWidget(label);
+ //l->addLayout(hl);
+ l->addWidget(volumeEdit);
+ l->addStretch();
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
}
QString SearchSingleComic::getVolumeInfo()
{
- return volumeEdit->text();
+ return volumeEdit->text();
}
QString SearchSingleComic::getComicInfo()
{
- //return titleEdit->text();
- return "";
+ //return titleEdit->text();
+ return "";
}
int SearchSingleComic::getComicNumber()
{
- //QString numberText = numberEdit->text();
- //if(numberText.isEmpty())
- // return -1;
- //return numberText.toInt();
- return 0;
+ //QString numberText = numberEdit->text();
+ //if(numberText.isEmpty())
+ // return -1;
+ //return numberText.toInt();
+ return 0;
}
void SearchSingleComic::clean()
{
- volumeEdit->clear();
+ volumeEdit->clear();
}
diff --git a/YACReaderLibrary/comic_vine/search_single_comic.h b/YACReaderLibrary/comic_vine/search_single_comic.h
index bb504f0c..6458fe64 100644
--- a/YACReaderLibrary/comic_vine/search_single_comic.h
+++ b/YACReaderLibrary/comic_vine/search_single_comic.h
@@ -7,16 +7,17 @@ class ScraperLineEdit;
class SearchSingleComic : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- SearchSingleComic(QWidget * parent = 0);
- QString getVolumeInfo();
- QString getComicInfo();
- int getComicNumber();
- void clean();
+ SearchSingleComic(QWidget *parent = 0);
+ QString getVolumeInfo();
+ QString getComicInfo();
+ int getComicNumber();
+ void clean();
+
private:
- ScraperLineEdit * titleEdit;
- ScraperLineEdit * numberEdit;
- ScraperLineEdit * volumeEdit;
+ ScraperLineEdit *titleEdit;
+ ScraperLineEdit *numberEdit;
+ ScraperLineEdit *volumeEdit;
};
#endif // SEARCH_SINGLE_COMIC_H
diff --git a/YACReaderLibrary/comic_vine/search_volume.cpp b/YACReaderLibrary/comic_vine/search_volume.cpp
index a2cbcc36..f56bd5b5 100644
--- a/YACReaderLibrary/comic_vine/search_volume.cpp
+++ b/YACReaderLibrary/comic_vine/search_volume.cpp
@@ -5,32 +5,32 @@
#include
#include
-SearchVolume::SearchVolume(QWidget * parent)
- :QWidget(parent)
+SearchVolume::SearchVolume(QWidget *parent)
+ : QWidget(parent)
{
- QLabel * label = new QLabel(tr("Please provide some additional information."));
- label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
+ QLabel *label = new QLabel(tr("Please provide some additional information."));
+ label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
- volumeEdit = new ScraperLineEdit(tr("Series:"));
+ volumeEdit = new ScraperLineEdit(tr("Series:"));
- QVBoxLayout * l = new QVBoxLayout;
+ QVBoxLayout *l = new QVBoxLayout;
- l->addSpacing(35);
- l->addWidget(label);
- l->addWidget(volumeEdit);
- l->addStretch();
+ l->addSpacing(35);
+ l->addWidget(label);
+ l->addWidget(volumeEdit);
+ l->addStretch();
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
}
void SearchVolume::clean()
{
- volumeEdit->clear();
+ volumeEdit->clear();
}
QString SearchVolume::getVolumeInfo()
{
- return volumeEdit->text();
+ return volumeEdit->text();
}
diff --git a/YACReaderLibrary/comic_vine/search_volume.h b/YACReaderLibrary/comic_vine/search_volume.h
index 65057526..f0dcf825 100644
--- a/YACReaderLibrary/comic_vine/search_volume.h
+++ b/YACReaderLibrary/comic_vine/search_volume.h
@@ -5,17 +5,17 @@
class ScraperLineEdit;
-
class SearchVolume : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- SearchVolume(QWidget * parent = 0);
- void clean();
+ SearchVolume(QWidget *parent = 0);
+ void clean();
public slots:
- QString getVolumeInfo();
+ QString getVolumeInfo();
+
private:
- ScraperLineEdit * volumeEdit;
+ ScraperLineEdit *volumeEdit;
};
#endif // SEARCH_VOLUME_H
diff --git a/YACReaderLibrary/comic_vine/select_comic.cpp b/YACReaderLibrary/comic_vine/select_comic.cpp
index c7a9286c..1045bb01 100644
--- a/YACReaderLibrary/comic_vine/select_comic.cpp
+++ b/YACReaderLibrary/comic_vine/select_comic.cpp
@@ -10,135 +10,132 @@
#include
SelectComic::SelectComic(QWidget *parent)
- :ScraperSelector(parent),model(0)
+ : ScraperSelector(parent), model(0)
{
- QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
+ QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
- QLabel * label = new QLabel(tr("Please, select the right comic info."));
- label->setStyleSheet(labelStylesheet);
+ QLabel *label = new QLabel(tr("Please, select the right comic info."));
+ label->setStyleSheet(labelStylesheet);
- QVBoxLayout * l = new QVBoxLayout;
- QWidget * leftWidget = new QWidget;
- QVBoxLayout * left = new QVBoxLayout;
- QGridLayout * content = new QGridLayout;
+ QVBoxLayout *l = new QVBoxLayout;
+ QWidget *leftWidget = new QWidget;
+ QVBoxLayout *left = new QVBoxLayout;
+ QGridLayout *content = new QGridLayout;
- //widgets
- cover = new QLabel();
- cover->setScaledContents(true);
- cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
- cover->setMinimumSize(168,168*5.0/3);
- cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
- detailLabel = new ScraperScrollLabel(this);
+ //widgets
+ cover = new QLabel();
+ cover->setScaledContents(true);
+ cover->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
+ cover->setMinimumSize(168, 168 * 5.0 / 3);
+ cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
+ detailLabel = new ScraperScrollLabel(this);
- tableComics = new ScraperTableView(this);
- //connections
- connect(tableComics,SIGNAL(clicked(QModelIndex)),this,SLOT(loadComicInfo(QModelIndex)));
+ tableComics = new ScraperTableView(this);
+ //connections
+ connect(tableComics, SIGNAL(clicked(QModelIndex)), this, SLOT(loadComicInfo(QModelIndex)));
- paginator->setCustomLabel(tr("comics"));
+ paginator->setCustomLabel(tr("comics"));
- left->addWidget(cover);
- left->addWidget(detailLabel,1);
- leftWidget->setMaximumWidth(180);
- leftWidget->setLayout(left);
- left->setContentsMargins(0,0,0,0);
- leftWidget->setContentsMargins(0,0,0,0);
+ left->addWidget(cover);
+ left->addWidget(detailLabel, 1);
+ leftWidget->setMaximumWidth(180);
+ leftWidget->setLayout(left);
+ left->setContentsMargins(0, 0, 0, 0);
+ leftWidget->setContentsMargins(0, 0, 0, 0);
content->addWidget(leftWidget, 0, 0);
content->addWidget(tableComics, 0, 1);
content->addWidget(paginator, 1, 1);
content->setColumnStretch(1, 1);
- content->setRowStretch(0, 1);;
+ content->setRowStretch(0, 1);
+ ;
- l->addSpacing(15);
- l->addWidget(label);
- l->addSpacing(5);
- l->addLayout(content);
+ l->addSpacing(15);
+ l->addWidget(label);
+ l->addSpacing(5);
+ l->addLayout(content);
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
}
-void SelectComic::load(const QString &json, const QString & searchString)
+void SelectComic::load(const QString &json, const QString &searchString)
{
- VolumeComicsModel * tempM = new VolumeComicsModel();
- tempM->load(json);
- tableComics->setModel(tempM);
+ VolumeComicsModel *tempM = new VolumeComicsModel();
+ tempM->load(json);
+ tableComics->setModel(tempM);
- if(model != 0)
- delete model;
+ if (model != 0)
+ delete model;
- model = tempM;
+ model = tempM;
- if(model->rowCount()>0)
- {
- tableComics->selectRow(0);
- loadComicInfo(model->index(0,0));
- }
+ if (model->rowCount() > 0) {
+ tableComics->selectRow(0);
+ loadComicInfo(model->index(0, 0));
+ }
- tableComics->resizeColumnToContents(0);
+ tableComics->resizeColumnToContents(0);
- ScraperSelector::load(json,searchString);
+ ScraperSelector::load(json, searchString);
}
SelectComic::~SelectComic() {}
void SelectComic::loadComicInfo(const QModelIndex &mi)
{
- QString coverURL = model->getCoverURL(mi);
- QString id = model->getComicId(mi);
+ QString coverURL = model->getCoverURL(mi);
+ QString id = model->getComicId(mi);
- QString loadingStyle = "%1";
- cover->setText(loadingStyle.arg(tr("loading cover")));
- detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
+ QString loadingStyle = "%1";
+ cover->setText(loadingStyle.arg(tr("loading cover")));
+ detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
- ComicVineClient * comicVineClient = new ComicVineClient;
- connect(comicVineClient,SIGNAL(comicCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
- connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
- comicVineClient->getComicCover(coverURL);
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ connect(comicVineClient, SIGNAL(comicCover(const QByteArray &)), this, SLOT(setCover(const QByteArray &)));
+ connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
+ comicVineClient->getComicCover(coverURL);
- ComicVineClient * comicVineClient2 = new ComicVineClient;
- connect(comicVineClient2,SIGNAL(comicDetail(QString)),this,SLOT(setDescription(QString)));
- connect(comicVineClient2,SIGNAL(finished()),comicVineClient2,SLOT(deleteLater()));
- comicVineClient2->getComicDetailAsync(id);
+ ComicVineClient *comicVineClient2 = new ComicVineClient;
+ connect(comicVineClient2, SIGNAL(comicDetail(QString)), this, SLOT(setDescription(QString)));
+ connect(comicVineClient2, SIGNAL(finished()), comicVineClient2, SLOT(deleteLater()));
+ comicVineClient2->getComicDetailAsync(id);
}
-void SelectComic::setCover(const QByteArray & data)
+void SelectComic::setCover(const QByteArray &data)
{
- QPixmap p;
- p.loadFromData(data);
- int w = p.width();
- int h = p.height();
+ QPixmap p;
+ p.loadFromData(data);
+ int w = p.width();
+ int h = p.height();
- cover->setPixmap(p);
- float aspectRatio = static_cast(w)/h;
+ cover->setPixmap(p);
+ float aspectRatio = static_cast(w) / h;
- cover->setFixedSize(180,static_cast(180/aspectRatio));
+ cover->setFixedSize(180, static_cast(180 / aspectRatio));
- cover->update();
+ cover->update();
}
void SelectComic::setDescription(const QString &jsonDetail)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + jsonDetail + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + jsonDetail + ")");
- if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
- {
- qDebug("Error detected");
- }
- else
- {
+ if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
+ qDebug("Error detected");
+ } else {
- QScriptValue descriptionValues = sc.property("results").property("description");
- bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
- detailLabel->setText(valid?descriptionValues.toString().replace("setText(valid ? descriptionValues.toString().replace("getComicId(tableComics->currentIndex());
+ return model->getComicId(tableComics->currentIndex());
}
diff --git a/YACReaderLibrary/comic_vine/select_comic.h b/YACReaderLibrary/comic_vine/select_comic.h
index 1349b7d1..83153702 100644
--- a/YACReaderLibrary/comic_vine/select_comic.h
+++ b/YACReaderLibrary/comic_vine/select_comic.h
@@ -12,23 +12,23 @@ class ScraperTableView;
class SelectComic : public ScraperSelector
{
- Q_OBJECT
+ Q_OBJECT
public:
- SelectComic(QWidget * parent = 0);
- void load(const QString & json, const QString & searchString);
- virtual ~SelectComic();
+ SelectComic(QWidget *parent = 0);
+ void load(const QString &json, const QString &searchString);
+ virtual ~SelectComic();
public slots:
- void loadComicInfo(const QModelIndex & mi);
- void setCover(const QByteArray &);
- void setDescription(const QString & jsonDetail);
- QString getSelectedComicId();
+ void loadComicInfo(const QModelIndex &mi);
+ void setCover(const QByteArray &);
+ void setDescription(const QString &jsonDetail);
+ QString getSelectedComicId();
private:
- QLabel * cover;
- ScraperScrollLabel * detailLabel;
- ScraperTableView * tableComics;
- VolumeComicsModel * model;
+ QLabel *cover;
+ ScraperScrollLabel *detailLabel;
+ ScraperTableView *tableComics;
+ VolumeComicsModel *model;
};
#endif // SELECT_COMIC_H
diff --git a/YACReaderLibrary/comic_vine/select_volume.cpp b/YACReaderLibrary/comic_vine/select_volume.cpp
index db7e2014..61fca639 100644
--- a/YACReaderLibrary/comic_vine/select_volume.cpp
+++ b/YACReaderLibrary/comic_vine/select_volume.cpp
@@ -23,48 +23,48 @@
#include "scraper_results_paginator.h"
SelectVolume::SelectVolume(QWidget *parent)
- :ScraperSelector(parent),model(0)
+ : ScraperSelector(parent), model(0)
{
- proxyModel = new QSortFilterProxyModel;
+ proxyModel = new QSortFilterProxyModel;
- QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
+ QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
- QLabel * label = new QLabel(tr("Please, select the right series for your comic."));
- label->setStyleSheet(labelStylesheet);
+ QLabel *label = new QLabel(tr("Please, select the right series for your comic."));
+ label->setStyleSheet(labelStylesheet);
- QVBoxLayout * l = new QVBoxLayout;
- QWidget * leftWidget = new QWidget;
- QVBoxLayout * left = new QVBoxLayout;
- QGridLayout * content = new QGridLayout;
+ QVBoxLayout *l = new QVBoxLayout;
+ QWidget *leftWidget = new QWidget;
+ QVBoxLayout *left = new QVBoxLayout;
+ QGridLayout *content = new QGridLayout;
- //widgets
- cover = new QLabel();
- cover->setScaledContents(true);
- cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
- cover->setMinimumSize(168,168*5.0/3);
- cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
+ //widgets
+ cover = new QLabel();
+ cover->setScaledContents(true);
+ cover->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
+ cover->setMinimumSize(168, 168 * 5.0 / 3);
+ cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
detailLabel = new ScraperScrollLabel();
tableVolumes = new ScraperTableView();
- tableVolumes->setSortingEnabled(true);
+ tableVolumes->setSortingEnabled(true);
#if QT_VERSION >= 0x050000
- tableVolumes->horizontalHeader()->setSectionsClickable(true);
+ tableVolumes->horizontalHeader()->setSectionsClickable(true);
#else
tableVolumes->horizontalHeader()->setClickable(true);
#endif
- //tableVolumes->horizontalHeader()->setSortIndicatorShown(false);
- connect(tableVolumes->horizontalHeader(),SIGNAL(sectionClicked(int)), tableVolumes, SLOT(sortByColumn(int)));
- //connections
- connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex)));
+ //tableVolumes->horizontalHeader()->setSortIndicatorShown(false);
+ connect(tableVolumes->horizontalHeader(), SIGNAL(sectionClicked(int)), tableVolumes, SLOT(sortByColumn(int)));
+ //connections
+ connect(tableVolumes, SIGNAL(clicked(QModelIndex)), this, SLOT(loadVolumeInfo(QModelIndex)));
- paginator->setCustomLabel(tr("volumes"));
+ paginator->setCustomLabel(tr("volumes"));
- left->addWidget(cover);
- left->addWidget(detailLabel,1);
- leftWidget->setMaximumWidth(180);
- leftWidget->setLayout(left);
- left->setContentsMargins(0,0,0,0);
- leftWidget->setContentsMargins(0,0,0,0);
+ left->addWidget(cover);
+ left->addWidget(detailLabel, 1);
+ leftWidget->setMaximumWidth(180);
+ leftWidget->setLayout(left);
+ left->setContentsMargins(0, 0, 0, 0);
+ leftWidget->setContentsMargins(0, 0, 0, 0);
content->addWidget(leftWidget, 0, 0);
content->addWidget(tableVolumes, 0, 1);
@@ -74,112 +74,106 @@ SelectVolume::SelectVolume(QWidget *parent)
content->setRowStretch(0, 1);
l->addSpacing(15);
- l->addWidget(label);
+ l->addWidget(label);
l->addSpacing(5);
l->addLayout(content);
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
}
-void SelectVolume::load(const QString & json, const QString & searchString)
+void SelectVolume::load(const QString &json, const QString &searchString)
{
- VolumesModel * tempM = new VolumesModel();
- tempM->load(json);
- //tableVolumes->setModel(tempM);
+ VolumesModel *tempM = new VolumesModel();
+ tempM->load(json);
+ //tableVolumes->setModel(tempM);
- proxyModel->setSourceModel( tempM );
- tableVolumes->setModel(proxyModel);
- tableVolumes->sortByColumn(0,Qt::AscendingOrder);
- tableVolumes->resizeColumnsToContents();
+ proxyModel->setSourceModel(tempM);
+ tableVolumes->setModel(proxyModel);
+ tableVolumes->sortByColumn(0, Qt::AscendingOrder);
+ tableVolumes->resizeColumnsToContents();
- if(model != 0)
- delete model;
+ if (model != 0)
+ delete model;
- model = tempM;
+ model = tempM;
- if(model->rowCount()>0)
- {
- tableVolumes->selectRow(0);
- loadVolumeInfo(proxyModel->index(0,0));
+ if (model->rowCount() > 0) {
+ tableVolumes->selectRow(0);
+ loadVolumeInfo(proxyModel->index(0, 0));
}
- tableVolumes->setColumnWidth(0,350);
+ tableVolumes->setColumnWidth(0, 350);
- ScraperSelector::load(json,searchString);
+ ScraperSelector::load(json, searchString);
}
SelectVolume::~SelectVolume() {}
-void SelectVolume::loadVolumeInfo(const QModelIndex & omi)
+void SelectVolume::loadVolumeInfo(const QModelIndex &omi)
{
- QModelIndex mi = proxyModel->mapToSource(omi);
- QString coverURL = model->getCoverURL(mi);
- QString id = model->getVolumeId(mi);
+ QModelIndex mi = proxyModel->mapToSource(omi);
+ QString coverURL = model->getCoverURL(mi);
+ QString id = model->getVolumeId(mi);
- QString loadingStyle = "%1";
- cover->setText(loadingStyle.arg(tr("loading cover")));
- detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
+ QString loadingStyle = "%1";
+ cover->setText(loadingStyle.arg(tr("loading cover")));
+ detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
- ComicVineClient * comicVineClient = new ComicVineClient;
- connect(comicVineClient,SIGNAL(seriesCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
- connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
- comicVineClient->getSeriesCover(coverURL);
+ ComicVineClient *comicVineClient = new ComicVineClient;
+ connect(comicVineClient, SIGNAL(seriesCover(const QByteArray &)), this, SLOT(setCover(const QByteArray &)));
+ connect(comicVineClient, SIGNAL(finished()), comicVineClient, SLOT(deleteLater()));
+ comicVineClient->getSeriesCover(coverURL);
- ComicVineClient * comicVineClient2 = new ComicVineClient;
- connect(comicVineClient2,SIGNAL(seriesDetail(QString)),this,SLOT(setDescription(QString)));
- connect(comicVineClient2,SIGNAL(finished()),comicVineClient2,SLOT(deleteLater()));
- comicVineClient2->getSeriesDetail(id);
+ ComicVineClient *comicVineClient2 = new ComicVineClient;
+ connect(comicVineClient2, SIGNAL(seriesDetail(QString)), this, SLOT(setDescription(QString)));
+ connect(comicVineClient2, SIGNAL(finished()), comicVineClient2, SLOT(deleteLater()));
+ comicVineClient2->getSeriesDetail(id);
}
-void SelectVolume::setCover(const QByteArray & data)
+void SelectVolume::setCover(const QByteArray &data)
{
- QPixmap p;
- p.loadFromData(data);
- int w = p.width();
- int h = p.height();
+ QPixmap p;
+ p.loadFromData(data);
+ int w = p.width();
+ int h = p.height();
- cover->setPixmap(p);
- float aspectRatio = static_cast(w)/h;
+ cover->setPixmap(p);
+ float aspectRatio = static_cast(w) / h;
- cover->setFixedSize(180,static_cast(180/aspectRatio));
+ cover->setFixedSize(180, static_cast(180 / aspectRatio));
- cover->update();
+ cover->update();
}
-void SelectVolume::setDescription(const QString & jsonDetail)
+void SelectVolume::setDescription(const QString &jsonDetail)
{
- QScriptEngine engine;
- QScriptValue sc;
- sc = engine.evaluate("(" + jsonDetail + ")");
+ QScriptEngine engine;
+ QScriptValue sc;
+ sc = engine.evaluate("(" + jsonDetail + ")");
- if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
- {
- qDebug("Error detected");
- }
- else
- {
+ if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
+ qDebug("Error detected");
+ } else {
- QScriptValue descriptionValues = sc.property("results").property("description");
- bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
- detailLabel->setText(valid?descriptionValues.toString().replace("setText(valid ? descriptionValues.toString().replace("getVolumeId(proxyModel->mapToSource(tableVolumes->currentIndex()));
+ return model->getVolumeId(proxyModel->mapToSource(tableVolumes->currentIndex()));
}
int SelectVolume::getSelectedVolumeNumIssues()
{
- return model->getNumIssues(proxyModel->mapToSource(tableVolumes->currentIndex()));
+ return model->getNumIssues(proxyModel->mapToSource(tableVolumes->currentIndex()));
}
QString SelectVolume::getSelectedVolumePublisher()
{
- return model->getPublisher(proxyModel->mapToSource(tableVolumes->currentIndex()));
+ return model->getPublisher(proxyModel->mapToSource(tableVolumes->currentIndex()));
}
-
-
diff --git a/YACReaderLibrary/comic_vine/select_volume.h b/YACReaderLibrary/comic_vine/select_volume.h
index d7c68aae..a02672d5 100644
--- a/YACReaderLibrary/comic_vine/select_volume.h
+++ b/YACReaderLibrary/comic_vine/select_volume.h
@@ -14,26 +14,26 @@ class ScraperTableView;
class SelectVolume : public ScraperSelector
{
- Q_OBJECT
+ Q_OBJECT
public:
- SelectVolume(QWidget * parent = 0);
- void load(const QString & json, const QString & searchString);
- virtual ~SelectVolume();
+ SelectVolume(QWidget *parent = 0);
+ void load(const QString &json, const QString &searchString);
+ virtual ~SelectVolume();
public slots:
- void loadVolumeInfo(const QModelIndex & mi);
- void setCover(const QByteArray &);
- void setDescription(const QString & jsonDetail);
- QString getSelectedVolumeId();
+ void loadVolumeInfo(const QModelIndex &mi);
+ void setCover(const QByteArray &);
+ void setDescription(const QString &jsonDetail);
+ QString getSelectedVolumeId();
int getSelectedVolumeNumIssues();
QString getSelectedVolumePublisher();
private:
- QLabel * cover;
- ScraperScrollLabel * detailLabel;
- ScraperTableView * tableVolumes;
- VolumesModel * model;
- QSortFilterProxyModel * proxyModel;
+ QLabel *cover;
+ ScraperScrollLabel *detailLabel;
+ ScraperTableView *tableVolumes;
+ VolumesModel *model;
+ QSortFilterProxyModel *proxyModel;
};
#endif // SELECT_VOLUME_H
diff --git a/YACReaderLibrary/comic_vine/series_question.cpp b/YACReaderLibrary/comic_vine/series_question.cpp
index 3fdba1d9..9792a9d7 100644
--- a/YACReaderLibrary/comic_vine/series_question.cpp
+++ b/YACReaderLibrary/comic_vine/series_question.cpp
@@ -4,43 +4,42 @@
#include
#include
-
-SeriesQuestion::SeriesQuestion(QWidget * parent)
- :QWidget(parent)
+SeriesQuestion::SeriesQuestion(QWidget *parent)
+ : QWidget(parent)
{
- QVBoxLayout * l = new QVBoxLayout;
+ QVBoxLayout *l = new QVBoxLayout;
- QLabel * questionLabel = new QLabel(tr("You are trying to get information for various comics at once, are they part of the same series?"));
- questionLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
- yes = new QRadioButton(tr("yes"));
- no = new QRadioButton(tr("no"));
+ QLabel *questionLabel = new QLabel(tr("You are trying to get information for various comics at once, are they part of the same series?"));
+ questionLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
+ yes = new QRadioButton(tr("yes"));
+ no = new QRadioButton(tr("no"));
- QString rbStyle = "QRadioButton {margin-left:27px; margin-top:5px; color:white;font-size:12px;font-family:Arial;}"
- "QRadioButton::indicator {width:11px;height:11px;}"
- "QRadioButton::indicator::unchecked {image : url(:/images/comic_vine/radioUnchecked.png);}"
- "QRadioButton::indicator::checked {image : url(:/images/comic_vine/radioChecked.png);}";
- yes->setStyleSheet(rbStyle);
- no->setStyleSheet(rbStyle);
+ QString rbStyle = "QRadioButton {margin-left:27px; margin-top:5px; color:white;font-size:12px;font-family:Arial;}"
+ "QRadioButton::indicator {width:11px;height:11px;}"
+ "QRadioButton::indicator::unchecked {image : url(:/images/comic_vine/radioUnchecked.png);}"
+ "QRadioButton::indicator::checked {image : url(:/images/comic_vine/radioChecked.png);}";
+ yes->setStyleSheet(rbStyle);
+ no->setStyleSheet(rbStyle);
- yes->setChecked(true);
+ yes->setChecked(true);
- l->addSpacing(35);
- l->addWidget(questionLabel);
- l->addWidget(yes);
- l->addWidget(no);
- l->addStretch();
+ l->addSpacing(35);
+ l->addWidget(questionLabel);
+ l->addWidget(yes);
+ l->addWidget(no);
+ l->addStretch();
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
}
bool SeriesQuestion::getYes()
{
- return yes->isChecked();
+ return yes->isChecked();
}
void SeriesQuestion::setYes(bool y)
{
- yes->setChecked(y);
+ yes->setChecked(y);
}
diff --git a/YACReaderLibrary/comic_vine/series_question.h b/YACReaderLibrary/comic_vine/series_question.h
index 31d20e40..d03af685 100644
--- a/YACReaderLibrary/comic_vine/series_question.h
+++ b/YACReaderLibrary/comic_vine/series_question.h
@@ -7,17 +7,16 @@ class QRadioButton;
class SeriesQuestion : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- SeriesQuestion(QWidget * parent = 0);
- bool getYes();
- void setYes(bool yes = true);
+ SeriesQuestion(QWidget *parent = 0);
+ bool getYes();
+ void setYes(bool yes = true);
private:
- QRadioButton * yes;
- QRadioButton * no;
+ QRadioButton *yes;
+ QRadioButton *no;
};
-
#endif // SERIES_QUESTION_H
diff --git a/YACReaderLibrary/comic_vine/sort_volume_comics.cpp b/YACReaderLibrary/comic_vine/sort_volume_comics.cpp
index 2ece5279..cc8e6085 100644
--- a/YACReaderLibrary/comic_vine/sort_volume_comics.cpp
+++ b/YACReaderLibrary/comic_vine/sort_volume_comics.cpp
@@ -10,59 +10,59 @@
#include "local_comic_list_model.h"
#include "volume_comics_model.h"
-SortVolumeComics::SortVolumeComics(QWidget *parent) :
- ScraperSelector(parent)
+SortVolumeComics::SortVolumeComics(QWidget *parent)
+ : ScraperSelector(parent)
{
- QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
+ QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
- QLabel * label = new QLabel(tr("Please, sort the list of comics on the left until it matches the comics' information."));
- label->setStyleSheet(labelStylesheet);
+ QLabel *label = new QLabel(tr("Please, sort the list of comics on the left until it matches the comics' information."));
+ label->setStyleSheet(labelStylesheet);
- QLabel * sortLabel = new QLabel(tr("sort comics to match comic information"));
- sortLabel->setStyleSheet(labelStylesheet);
+ QLabel *sortLabel = new QLabel(tr("sort comics to match comic information"));
+ sortLabel->setStyleSheet(labelStylesheet);
- moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
- moveUpButtonCL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
- moveUpButtonCL->setAutoRepeat(true);
- moveDownButtonCL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
- moveDownButtonCL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
- moveDownButtonCL->setAutoRepeat(true);
- //moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
- //moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
- //moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
- //moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
+ moveUpButtonCL = new ScrapperToolButton(ScrapperToolButton::LEFT);
+ moveUpButtonCL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
+ moveUpButtonCL->setAutoRepeat(true);
+ moveDownButtonCL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
+ moveDownButtonCL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
+ moveDownButtonCL->setAutoRepeat(true);
+ //moveUpButtonIL = new ScrapperToolButton(ScrapperToolButton::LEFT);
+ //moveUpButtonIL->setIcon(QIcon(":/images/comic_vine/rowUp.png"));
+ //moveDownButtonIL = new ScrapperToolButton(ScrapperToolButton::RIGHT);
+ //moveDownButtonIL->setIcon(QIcon(":/images/comic_vine/rowDown.png"));
- connect(moveUpButtonCL,SIGNAL(clicked()),this,SLOT(moveUpCL()));
- connect(moveDownButtonCL,SIGNAL(clicked()),this,SLOT(moveDownCL()));
- //connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveUpIL()));
- //connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveDownIL()));
+ connect(moveUpButtonCL, SIGNAL(clicked()), this, SLOT(moveUpCL()));
+ connect(moveDownButtonCL, SIGNAL(clicked()), this, SLOT(moveDownCL()));
+ //connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveUpIL()));
+ //connect(moveUpButtonIL,SIGNAL(clicked()),this,SLOT(moveDownIL()));
- QVBoxLayout * l = new QVBoxLayout;
- QGridLayout * content = new QGridLayout;
- QHBoxLayout * sortButtonsLayout = new QHBoxLayout;
+ QVBoxLayout *l = new QVBoxLayout;
+ QGridLayout *content = new QGridLayout;
+ QHBoxLayout *sortButtonsLayout = new QHBoxLayout;
- tableFiles = new ScraperTableView();
- tableVolumeComics = new ScraperTableView();
+ tableFiles = new ScraperTableView();
+ tableVolumeComics = new ScraperTableView();
- tableFiles->setSelectionBehavior(QAbstractItemView::SelectRows);
- tableFiles->setSelectionMode(QAbstractItemView::ContiguousSelection);
+ tableFiles->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tableFiles->setSelectionMode(QAbstractItemView::ContiguousSelection);
- //content->addWidget(tableVolumes,0,Qt::AlignRight|Qt::AlignTop);
+ //content->addWidget(tableVolumes,0,Qt::AlignRight|Qt::AlignTop);
- connect(tableVolumeComics->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
- connect(tableFiles->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
+ connect(tableVolumeComics->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
+ connect(tableFiles->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
- //connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
- //connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
+ //connect(tableVolumeComics, SIGNAL(pressed(QModelIndex)), tableFiles, SLOT(setCurrentIndex(QModelIndex)));
+ //connect(tableFiles, SIGNAL(pressed(QModelIndex)), tableVolumeComics, SLOT(setCurrentIndex(QModelIndex)));
- paginator->setCustomLabel(tr("issues"));
- paginator->setMinimumWidth(422);
+ paginator->setCustomLabel(tr("issues"));
+ paginator->setMinimumWidth(422);
- sortButtonsLayout->addWidget(moveUpButtonCL);
- sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
- sortButtonsLayout->addWidget(moveDownButtonCL);
- sortButtonsLayout->addSpacing(10);
- sortButtonsLayout->addWidget(sortLabel);
+ sortButtonsLayout->addWidget(moveUpButtonCL);
+ sortButtonsLayout->addWidget(ScrapperToolButton::getSeparator());
+ sortButtonsLayout->addWidget(moveDownButtonCL);
+ sortButtonsLayout->addSpacing(10);
+ sortButtonsLayout->addWidget(sortLabel);
sortButtonsLayout->addStretch();
sortButtonsLayout->setSpacing(0);
@@ -75,17 +75,17 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
l->addSpacing(15);
l->addWidget(label, 0);
- l->addSpacing(5);
+ l->addSpacing(5);
l->addLayout(content, 1);
l->addLayout(sortButtonsLayout, 0);
- l->setContentsMargins(0,0,0,0);
- setLayout(l);
- setContentsMargins(0,0,0,0);
+ l->setContentsMargins(0, 0, 0, 0);
+ setLayout(l);
+ setContentsMargins(0, 0, 0, 0);
//rows actions
- QAction * removeItemFromList = new QAction(tr("remove selected comics"),this);
- QAction * restoreAllItems = new QAction(tr("restore all removed comics"),this);
+ QAction *removeItemFromList = new QAction(tr("remove selected comics"), this);
+ QAction *restoreAllItems = new QAction(tr("restore all removed comics"), this);
//QAction * restoreItems = new QAction(tr("restore removed comics"),this);
tableFiles->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -93,80 +93,76 @@ SortVolumeComics::SortVolumeComics(QWidget *parent) :
tableFiles->addAction(restoreAllItems);
//tableFiles->addAction(restoreItems);
- connect(removeItemFromList,SIGNAL(triggered()),this,SLOT(removeSelectedComics()));
- connect(restoreAllItems,SIGNAL(triggered()),this,SLOT(restoreAllComics()));
+ connect(removeItemFromList, SIGNAL(triggered()), this, SLOT(removeSelectedComics()));
+ connect(restoreAllItems, SIGNAL(triggered()), this, SLOT(restoreAllComics()));
//connect(restoreItems,SIGNAL(triggered()),this,SLOT(showRemovedComicsSelector()));
}
-void SortVolumeComics::setData(QList & comics, const QString &json, const QString &vID)
+void SortVolumeComics::setData(QList &comics, const QString &json, const QString &vID)
{
- //set up models
- localComicsModel = new LocalComicListModel;
- localComicsModel->load(comics);
+ //set up models
+ localComicsModel = new LocalComicListModel;
+ localComicsModel->load(comics);
- volumeComicsModel = new VolumeComicsModel;
- volumeComicsModel->load(json);
+ volumeComicsModel = new VolumeComicsModel;
+ volumeComicsModel->load(json);
- int numLocalComics = localComicsModel->rowCount();
- int numVolumeComics = volumeComicsModel->rowCount();
+ int numLocalComics = localComicsModel->rowCount();
+ int numVolumeComics = volumeComicsModel->rowCount();
- if(numLocalComics > numVolumeComics)
- volumeComicsModel->addExtraRows(numLocalComics - numVolumeComics);
- if(numLocalComics < numVolumeComics)
- localComicsModel->addExtraRows(numVolumeComics - numLocalComics);
+ if (numLocalComics > numVolumeComics)
+ volumeComicsModel->addExtraRows(numLocalComics - numVolumeComics);
+ if (numLocalComics < numVolumeComics)
+ localComicsModel->addExtraRows(numVolumeComics - numLocalComics);
- tableFiles->setModel(localComicsModel);
- tableVolumeComics->setModel(volumeComicsModel);
+ tableFiles->setModel(localComicsModel);
+ tableVolumeComics->setModel(volumeComicsModel);
- tableVolumeComics->resizeColumnToContents(0);
+ tableVolumeComics->resizeColumnToContents(0);
- ScraperSelector::load(json,vID);
+ ScraperSelector::load(json, vID);
}
void SortVolumeComics::synchronizeScroll(int pos)
{
- void * senderObject = sender();
+ void *senderObject = sender();
- if(senderObject == 0) //invalid call
- return;
+ if (senderObject == 0) //invalid call
+ return;
- QScrollBar * tableVolumeComicsScrollBar = tableVolumeComics->verticalScrollBar();
- QScrollBar * tableFilesScrollBar = tableFiles->verticalScrollBar();
+ QScrollBar *tableVolumeComicsScrollBar = tableVolumeComics->verticalScrollBar();
+ QScrollBar *tableFilesScrollBar = tableFiles->verticalScrollBar();
- if(senderObject == tableVolumeComicsScrollBar)
- {
- disconnect(tableFilesScrollBar,SIGNAL(valueChanged(int)),this,0);
- tableFilesScrollBar->setValue(pos);
- connect(tableFilesScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
- }
- else
- {
- disconnect(tableVolumeComicsScrollBar,SIGNAL(valueChanged(int)),this,0);
- tableVolumeComicsScrollBar->setValue(pos);
- connect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
- }
+ if (senderObject == tableVolumeComicsScrollBar) {
+ disconnect(tableFilesScrollBar, SIGNAL(valueChanged(int)), this, 0);
+ tableFilesScrollBar->setValue(pos);
+ connect(tableFilesScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
+ } else {
+ disconnect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, 0);
+ tableVolumeComicsScrollBar->setValue(pos);
+ connect(tableVolumeComicsScrollBar, SIGNAL(valueChanged(int)), this, SLOT(synchronizeScroll(int)));
+ }
}
void SortVolumeComics::moveUpCL()
{
- QList selection = tableFiles->selectionModel()->selectedIndexes();
+ QList selection = tableFiles->selectionModel()->selectedIndexes();
- if(selection.count() == 0)
- return;
+ if (selection.count() == 0)
+ return;
- localComicsModel->moveSelectionUp(selection);
+ localComicsModel->moveSelectionUp(selection);
- selection = tableFiles->selectionModel()->selectedIndexes();
- tableFiles->scrollTo(selection.first());
+ selection = tableFiles->selectionModel()->selectedIndexes();
+ tableFiles->scrollTo(selection.first());
}
void SortVolumeComics::moveDownCL()
{
- QList selection = tableFiles->selectionModel()->selectedIndexes();
+ QList selection = tableFiles->selectionModel()->selectedIndexes();
- if(selection.count() > 0)
- {
- localComicsModel->moveSelectionDown(selection);
+ if (selection.count() > 0) {
+ localComicsModel->moveSelectionDown(selection);
selection = tableFiles->selectionModel()->selectedIndexes();
tableFiles->scrollTo(selection.last());
@@ -175,12 +171,10 @@ void SortVolumeComics::moveDownCL()
void SortVolumeComics::moveUpIL()
{
-
}
void SortVolumeComics::moveDownIL()
{
-
}
void SortVolumeComics::removeSelectedComics()
@@ -197,26 +191,24 @@ void SortVolumeComics::restoreAllComics()
void SortVolumeComics::showRemovedComicsSelector()
{
-
}
-QList > SortVolumeComics::getMatchingInfo()
+QList> SortVolumeComics::getMatchingInfo()
{
- QList comicList = localComicsModel->getData();
- QList > l;
+ QList comicList = localComicsModel->getData();
+ QList> l;
- int index = 0;
+ int index = 0;
- QString id;
- foreach(ComicDB c, comicList)
- {
- id = volumeComicsModel->getComicId(index);
- if(!c.getFileName().isEmpty() && !id.isEmpty()) //there is a valid comic, and valid comic ID
- {
- l.push_back(QPair(c,id));
- }
- index++;
- }
+ QString id;
+ foreach (ComicDB c, comicList) {
+ id = volumeComicsModel->getComicId(index);
+ if (!c.getFileName().isEmpty() && !id.isEmpty()) //there is a valid comic, and valid comic ID
+ {
+ l.push_back(QPair(c, id));
+ }
+ index++;
+ }
- return l;
+ return l;
}
diff --git a/YACReaderLibrary/comic_vine/sort_volume_comics.h b/YACReaderLibrary/comic_vine/sort_volume_comics.h
index 6e76274a..ac33d1b5 100644
--- a/YACReaderLibrary/comic_vine/sort_volume_comics.h
+++ b/YACReaderLibrary/comic_vine/sort_volume_comics.h
@@ -15,85 +15,88 @@ class VolumeComicsModel;
class ScrapperToolButton : public QPushButton
{
- Q_OBJECT
+ Q_OBJECT
public:
- enum Appearance {
- DEFAULT,
- LEFT,
- RIGHT
- };
-
- ScrapperToolButton(ScrapperToolButton::Appearance appearance = DEFAULT, QWidget * parent=0):QPushButton(parent),appearance(appearance) {
- setStyleSheet("QPushButton {border: none; background: #2e2e2e; color:white; border-radius:2px;}"
- "QPushButton::pressed {border: none; background: #282828; color:white; border-radius:2px;}");
- setFixedSize(18,17);
- }
- static QWidget * getSeparator(){QWidget * w = new QWidget; w->setFixedWidth(1); w->setStyleSheet("QWidget {background:#282828;}"); return w;}
- void setAppearance(ScrapperToolButton::Appearance appearance){this->appearance = appearance;}
- virtual ~ScrapperToolButton() {}
-
+ enum Appearance {
+ DEFAULT,
+ LEFT,
+ RIGHT
+ };
+ ScrapperToolButton(ScrapperToolButton::Appearance appearance = DEFAULT, QWidget *parent = 0)
+ : QPushButton(parent), appearance(appearance)
+ {
+ setStyleSheet("QPushButton {border: none; background: #2e2e2e; color:white; border-radius:2px;}"
+ "QPushButton::pressed {border: none; background: #282828; color:white; border-radius:2px;}");
+ setFixedSize(18, 17);
+ }
+ static QWidget *getSeparator()
+ {
+ QWidget *w = new QWidget;
+ w->setFixedWidth(1);
+ w->setStyleSheet("QWidget {background:#282828;}");
+ return w;
+ }
+ void setAppearance(ScrapperToolButton::Appearance appearance) { this->appearance = appearance; }
+ virtual ~ScrapperToolButton() {}
protected:
- void paintEvent(QPaintEvent * e)
- {
- QPainter p(this);
+ void paintEvent(QPaintEvent *e)
+ {
+ QPainter p(this);
- switch (appearance) {
- case LEFT:
- p.fillRect(16,0,2,18,QColor("#2E2E2E"));
- break;
- case RIGHT:
- p.fillRect(0,0,2,18,QColor("#2E2E2E"));
- break;
- default:
- break;
- }
+ switch (appearance) {
+ case LEFT:
+ p.fillRect(16, 0, 2, 18, QColor("#2E2E2E"));
+ break;
+ case RIGHT:
+ p.fillRect(0, 0, 2, 18, QColor("#2E2E2E"));
+ break;
+ default:
+ break;
+ }
- QPushButton::paintEvent(e);
- }
+ QPushButton::paintEvent(e);
+ }
private:
- Appearance appearance;
+ Appearance appearance;
};
-
class SortVolumeComics : public ScraperSelector
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit SortVolumeComics(QWidget *parent = 0);
+ explicit SortVolumeComics(QWidget *parent = 0);
signals:
public slots:
- void setData(QList & comics, const QString &json, const QString & vID);
- QList > getMatchingInfo();
+ void setData(QList &comics, const QString &json, const QString &vID);
+ QList> getMatchingInfo();
protected slots:
- void synchronizeScroll(int pos);
- void moveUpCL();
- void moveDownCL();
- void moveUpIL();
- void moveDownIL();
+ void synchronizeScroll(int pos);
+ void moveUpCL();
+ void moveDownCL();
+ void moveUpIL();
+ void moveDownIL();
void removeSelectedComics();
void restoreAllComics();
void showRemovedComicsSelector();
-
private:
- ScraperTableView * tableFiles;
- ScraperTableView * tableVolumeComics;
+ ScraperTableView *tableFiles;
+ ScraperTableView *tableVolumeComics;
- LocalComicListModel * localComicsModel;
- VolumeComicsModel * volumeComicsModel;
-
- ScrapperToolButton * moveUpButtonCL;
- ScrapperToolButton * moveDownButtonCL;
- ScrapperToolButton * moveUpButtonIL;
- ScrapperToolButton * moveDownButtonIL;
+ LocalComicListModel *localComicsModel;
+ VolumeComicsModel *volumeComicsModel;
+ ScrapperToolButton *moveUpButtonCL;
+ ScrapperToolButton *moveDownButtonCL;
+ ScrapperToolButton *moveUpButtonIL;
+ ScrapperToolButton *moveDownButtonIL;
};
#endif // SORT_VOLUME_COMICS_H
diff --git a/YACReaderLibrary/comic_vine/title_header.cpp b/YACReaderLibrary/comic_vine/title_header.cpp
index 9fb1c494..588b80ec 100644
--- a/YACReaderLibrary/comic_vine/title_header.cpp
+++ b/YACReaderLibrary/comic_vine/title_header.cpp
@@ -4,50 +4,46 @@
#include
#include
-TitleHeader::TitleHeader(QWidget * parent )
- :QWidget(parent)
+TitleHeader::TitleHeader(QWidget *parent)
+ : QWidget(parent)
{
- mainTitleLabel = new QLabel();
- subTitleLabel = new QLabel();
+ mainTitleLabel = new QLabel();
+ subTitleLabel = new QLabel();
- mainTitleLabel->setStyleSheet("QLabel {color:white; font-size:18px;font-family:Arial;}");
- subTitleLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
+ mainTitleLabel->setStyleSheet("QLabel {color:white; font-size:18px;font-family:Arial;}");
+ subTitleLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
- QHBoxLayout * titleLayout = new QHBoxLayout;
- QVBoxLayout * titleLabelsLayout = new QVBoxLayout;
+ QHBoxLayout *titleLayout = new QHBoxLayout;
+ QVBoxLayout *titleLabelsLayout = new QVBoxLayout;
- titleLabelsLayout->addWidget(mainTitleLabel);
- titleLabelsLayout->addWidget(subTitleLabel);
- titleLabelsLayout->setSpacing(0);
+ titleLabelsLayout->addWidget(mainTitleLabel);
+ titleLabelsLayout->addWidget(subTitleLabel);
+ titleLabelsLayout->setSpacing(0);
- titleLayout->addLayout(titleLabelsLayout);
- titleLayout->setContentsMargins(0,0,0,0);
+ titleLayout->addLayout(titleLabelsLayout);
+ titleLayout->setContentsMargins(0, 0, 0, 0);
- setLayout(titleLayout);
+ setLayout(titleLayout);
- setContentsMargins(0,0,0,0);
+ setContentsMargins(0, 0, 0, 0);
- setTitle(tr("SEARCH"));
+ setTitle(tr("SEARCH"));
}
-void TitleHeader::setTitle(const QString & title)
+void TitleHeader::setTitle(const QString &title)
{
- mainTitleLabel->setText(title);
+ mainTitleLabel->setText(title);
}
-void TitleHeader::setSubTitle(const QString & title)
+void TitleHeader::setSubTitle(const QString &title)
{
- subTitleLabel->setText(title);
+ subTitleLabel->setText(title);
}
void TitleHeader::showButtons(bool show)
{
- if(show)
- {
+ if (show) {
- }
- else
- {
-
- }
+ } else {
+ }
}
diff --git a/YACReaderLibrary/comic_vine/title_header.h b/YACReaderLibrary/comic_vine/title_header.h
index ff258fa3..74d4d3c8 100644
--- a/YACReaderLibrary/comic_vine/title_header.h
+++ b/YACReaderLibrary/comic_vine/title_header.h
@@ -7,16 +7,17 @@ class QLabel;
class TitleHeader : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
public:
- TitleHeader(QWidget * parent = 0);
+ TitleHeader(QWidget *parent = 0);
public slots:
- void setTitle(const QString & title);
- void setSubTitle(const QString & title);
- void showButtons(bool show);
+ void setTitle(const QString &title);
+ void setSubTitle(const QString &title);
+ void showButtons(bool show);
+
private:
- QLabel * mainTitleLabel;
- QLabel * subTitleLabel;
+ QLabel *mainTitleLabel;
+ QLabel *subTitleLabel;
};
#endif // TITLE_HEADER_H
diff --git a/YACReaderLibrary/comics_remover.cpp b/YACReaderLibrary/comics_remover.cpp
index 7c4bc3b9..8c6fb9c6 100644
--- a/YACReaderLibrary/comics_remover.cpp
+++ b/YACReaderLibrary/comics_remover.cpp
@@ -5,38 +5,35 @@
#include "QsLog.h"
-ComicsRemover::ComicsRemover(QModelIndexList & il, QList & ps, qulonglong parentId, QObject *parent)
- :QObject(parent),indexList(il), paths(ps), parentId(parentId)
+ComicsRemover::ComicsRemover(QModelIndexList &il, QList &ps, qulonglong parentId, QObject *parent)
+ : QObject(parent), indexList(il), paths(ps), parentId(parentId)
{
}
void ComicsRemover::process()
{
- QString currentComicPath;
- QListIterator i(indexList);
- QListIterator i2(paths);
- i.toBack();
- i2.toBack();
+ QString currentComicPath;
+ QListIterator i(indexList);
+ QListIterator i2(paths);
+ i.toBack();
+ i2.toBack();
- while (i.hasPrevious() && i2.hasPrevious())
- {
- QModelIndex mi = i.previous();
- currentComicPath = i2.previous();
- if(QFile::remove(currentComicPath))
- emit remove(mi.row());
- else
- emit removeError();
- }
+ while (i.hasPrevious() && i2.hasPrevious()) {
+ QModelIndex mi = i.previous();
+ currentComicPath = i2.previous();
+ if (QFile::remove(currentComicPath))
+ emit remove(mi.row());
+ else
+ emit removeError();
+ }
- emit finished();
+ emit finished();
emit removedItemsFromFolder(parentId);
}
-
FoldersRemover::FoldersRemover(QModelIndexList &il, QList &ps, QObject *parent)
- :QObject(parent),indexList(il), paths(ps)
+ : QObject(parent), indexList(il), paths(ps)
{
-
}
void FoldersRemover::process()
@@ -49,12 +46,11 @@ void FoldersRemover::process()
QLOG_DEBUG() << "Deleting folders" << paths.at(0);
- while (i.hasPrevious() && i2.hasPrevious())
- {
+ while (i.hasPrevious() && i2.hasPrevious()) {
QModelIndex mi = i.previous();
currentFolderPath = i2.previous();
QDir d(currentFolderPath);
- if(d.removeRecursively() || !d.exists()) //the folder is in the DB but no in the drive...
+ if (d.removeRecursively() || !d.exists()) //the folder is in the DB but no in the drive...
emit remove(mi);
else
emit removeError();
diff --git a/YACReaderLibrary/comics_remover.h b/YACReaderLibrary/comics_remover.h
index ffd137fd..68c4e816 100644
--- a/YACReaderLibrary/comics_remover.h
+++ b/YACReaderLibrary/comics_remover.h
@@ -8,22 +8,22 @@
class ComicsRemover : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ComicsRemover(QModelIndexList & indexList, QList & paths, qulonglong parentId, QObject *parent = 0);
-
+ explicit ComicsRemover(QModelIndexList &indexList, QList &paths, qulonglong parentId, QObject *parent = 0);
+
signals:
- void remove(int);
- void removeError();
- void finished();
- void removedItemsFromFolder(qulonglong);
+ void remove(int);
+ void removeError();
+ void finished();
+ void removedItemsFromFolder(qulonglong);
public slots:
void process();
private:
- QModelIndexList indexList;
- QList paths;
+ QModelIndexList indexList;
+ QList paths;
qulonglong parentId;
};
@@ -31,15 +31,15 @@ class FoldersRemover : public QObject
{
Q_OBJECT
public:
- explicit FoldersRemover(QModelIndexList & indexList, QList & paths, QObject *parent = 0);
+ explicit FoldersRemover(QModelIndexList &indexList, QList &paths, QObject *parent = 0);
signals:
- void remove(QModelIndex);
- void removeError();
- void finished();
+ void remove(QModelIndex);
+ void removeError();
+ void finished();
public slots:
- void process();
+ void process();
private:
QModelIndexList indexList;
diff --git a/YACReaderLibrary/comics_view.cpp b/YACReaderLibrary/comics_view.cpp
index 10280a52..6d838d10 100644
--- a/YACReaderLibrary/comics_view.cpp
+++ b/YACReaderLibrary/comics_view.cpp
@@ -8,8 +8,8 @@
#include
#include
-ComicsView::ComicsView(QWidget *parent) :
- QWidget(parent),model(NULL),comicDB(nullptr)
+ComicsView::ComicsView(QWidget *parent)
+ : QWidget(parent), model(NULL), comicDB(nullptr)
{
setAcceptDrops(true);
}
@@ -23,11 +23,12 @@ void ComicsView::updateInfoForIndex(int index)
{
QQmlContext *ctxt = view->rootContext();
- if(comicDB != nullptr) delete comicDB;
+ if (comicDB != nullptr)
+ delete comicDB;
comicDB = new ComicDB(model->getComic(this->model->index(index, 0)));
ComicInfo *comicInfo = &(comicDB->info);
- comicInfo->isFavorite = model->isFavorite(model->index(index,0));
+ comicInfo->isFavorite = model->isFavorite(model->index(index, 0));
ctxt->setContextProperty("comic", comicDB);
ctxt->setContextProperty("comicInfo", comicInfo);
@@ -37,49 +38,41 @@ void ComicsView::updateInfoForIndex(int index)
void ComicsView::dragEnterEvent(QDragEnterEvent *event)
{
- if(model->canDropMimeData(event->mimeData(),event->proposedAction(),0,0,QModelIndex()))
+ if (model->canDropMimeData(event->mimeData(), event->proposedAction(), 0, 0, QModelIndex()))
event->acceptProposedAction();
- else
- {
- QLOG_TRACE() << "dragEnterEvent";
- QList urlList;
+ else {
+ QLOG_TRACE() << "dragEnterEvent";
+ QList urlList;
- if (event->mimeData()->hasUrls() && event->dropAction() == Qt::CopyAction)
- {
- urlList = event->mimeData()->urls();
- QString currentPath;
- foreach (QUrl url, urlList)
- {
- //comics or folders are accepted, folders' content is validate in dropEvent (avoid any lag before droping)
- currentPath = url.toLocalFile();
- if(Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir())
- {
- event->acceptProposedAction();
- return;
+ if (event->mimeData()->hasUrls() && event->dropAction() == Qt::CopyAction) {
+ urlList = event->mimeData()->urls();
+ QString currentPath;
+ foreach (QUrl url, urlList) {
+ //comics or folders are accepted, folders' content is validate in dropEvent (avoid any lag before droping)
+ currentPath = url.toLocalFile();
+ if (Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir()) {
+ event->acceptProposedAction();
+ return;
+ }
}
}
}
- }
}
void ComicsView::dropEvent(QDropEvent *event)
{
QLOG_DEBUG() << "drop" << event->dropAction();
- bool validAction = event->dropAction() == Qt::CopyAction;// || event->dropAction() & Qt::MoveAction; TODO move
+ bool validAction = event->dropAction() == Qt::CopyAction; // || event->dropAction() & Qt::MoveAction; TODO move
- if(event->mimeData()->hasUrls() && validAction)
- {
+ if (event->mimeData()->hasUrls() && validAction) {
- QList > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
+ QList> droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
- if(event->dropAction() == Qt::CopyAction)
- {
+ if (event->dropAction() == Qt::CopyAction) {
QLOG_DEBUG() << "copy :" << droppedFiles;
emit copyComicsToCurrentFolder(droppedFiles);
- }
- else if(event->dropAction() & Qt::MoveAction)
- {
+ } else if (event->dropAction() & Qt::MoveAction) {
QLOG_DEBUG() << "move :" << droppedFiles;
emit moveComicsToCurrentFolder(droppedFiles);
}
diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h
index b6e516d3..b83a0954 100644
--- a/YACReaderLibrary/comics_view.h
+++ b/YACReaderLibrary/comics_view.h
@@ -17,15 +17,15 @@ class ComicsView : public QWidget
Q_OBJECT
public:
explicit ComicsView(QWidget *parent = 0);
- virtual void setToolBar(QToolBar * toolBar) = 0;
+ virtual void setToolBar(QToolBar *toolBar) = 0;
virtual void setModel(ComicModel *model);
virtual void setCurrentIndex(const QModelIndex &index) = 0;
virtual QModelIndex currentIndex() = 0;
- virtual QItemSelectionModel * selectionModel() = 0;
- virtual void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint ) = 0;
+ virtual QItemSelectionModel *selectionModel() = 0;
+ virtual void scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint) = 0;
virtual void toFullScreen() = 0;
virtual void toNormal() = 0;
- virtual void updateConfig(QSettings * settings) = 0;
+ virtual void updateConfig(QSettings *settings) = 0;
virtual void enableFilterMode(bool enabled) = 0;
virtual void selectIndex(int index) = 0;
virtual void updateCurrentComicView() = 0;
@@ -37,19 +37,19 @@ public slots:
signals:
void selected(unsigned int);
- void openComic(const ComicDB& comic);
- void comicRated(int,QModelIndex);
+ void openComic(const ComicDB &comic);
+ void comicRated(int, QModelIndex);
//Context menus
void customContextMenuViewRequested(QPoint);
void customContextMenuItemRequested(QPoint);
//Drops
- void copyComicsToCurrentFolder(QList >);
- void moveComicsToCurrentFolder(QList >);
+ void copyComicsToCurrentFolder(QList>);
+ void moveComicsToCurrentFolder(QList>);
protected:
- ComicModel * model;
+ ComicModel *model;
//Drop to import
void dragEnterEvent(QDragEnterEvent *event);
@@ -61,7 +61,6 @@ protected:
ComicDB *comicDB;
private:
-
};
#endif // COMICS_VIEW_H
diff --git a/YACReaderLibrary/comics_view_transition.cpp b/YACReaderLibrary/comics_view_transition.cpp
index 72d2e3d3..c22bbc8a 100644
--- a/YACReaderLibrary/comics_view_transition.cpp
+++ b/YACReaderLibrary/comics_view_transition.cpp
@@ -10,29 +10,28 @@
#include "yacreader_global_gui.h"
-ComicsViewTransition::ComicsViewTransition(QWidget *parent) :
- QWidget(parent)
+ComicsViewTransition::ComicsViewTransition(QWidget *parent)
+ : QWidget(parent)
{
#ifdef Q_OS_MAC
setStyleSheet("QWidget {background:#FFFFFF}");
#else
- setStyleSheet("QWidget {background:#2A2A2A}");
+ setStyleSheet("QWidget {background:#2A2A2A}");
#endif
-
}
QSize ComicsViewTransition::sizeHint()
{
- return QSize(450,350);
+ return QSize(450, 350);
}
void ComicsViewTransition::paintEvent(QPaintEvent *)
{
- QPainter painter (this);
+ QPainter painter(this);
#ifdef Q_OS_MAC
- painter.fillRect(0,0,width(),height(),QColor("#FFFFFF"));
+ painter.fillRect(0, 0, width(), height(), QColor("#FFFFFF"));
#else
- painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
+ painter.fillRect(0, 0, width(), height(), QColor("#2A2A2A"));
#endif
}
diff --git a/YACReaderLibrary/create_library_dialog.cpp b/YACReaderLibrary/create_library_dialog.cpp
index cc856257..62d694c2 100644
--- a/YACReaderLibrary/create_library_dialog.cpp
+++ b/YACReaderLibrary/create_library_dialog.cpp
@@ -6,201 +6,190 @@
#include
#include
-CreateLibraryDialog::CreateLibraryDialog(QWidget * parent)
-:QDialog(parent)
+CreateLibraryDialog::CreateLibraryDialog(QWidget *parent)
+ : QDialog(parent)
{
- setupUI();
+ setupUI();
}
void CreateLibraryDialog::setupUI()
{
- textLabel = new QLabel(tr("Comics folder : "));
- path = new QLineEdit;
- textLabel->setBuddy(path);
- connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
+ textLabel = new QLabel(tr("Comics folder : "));
+ path = new QLineEdit;
+ textLabel->setBuddy(path);
+ connect(path, SIGNAL(textChanged(QString)), this, SLOT(pathSetted(QString)));
- nameLabel = new QLabel(tr("Library Name : "));
- nameEdit = new QLineEdit;
- nameLabel->setBuddy(nameEdit);
- connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
+ nameLabel = new QLabel(tr("Library Name : "));
+ nameEdit = new QLineEdit;
+ nameLabel->setBuddy(nameEdit);
+ connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameSetted(QString)));
- accept = new QPushButton(tr("Create"));
- accept->setDisabled(true);
- connect(accept,SIGNAL(clicked()),this,SLOT(create()));
+ accept = new QPushButton(tr("Create"));
+ accept->setDisabled(true);
+ connect(accept, SIGNAL(clicked()), this, SLOT(create()));
- cancel = new QPushButton(tr("Cancel"));
- connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelCreate()));
- connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
+ cancel = new QPushButton(tr("Cancel"));
+ connect(cancel, SIGNAL(clicked()), this, SIGNAL(cancelCreate()));
+ connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
- find = new QPushButton(QIcon(":/images/find_folder.png"),"");
- connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
+ find = new QPushButton(QIcon(":/images/find_folder.png"), "");
+ connect(find, SIGNAL(clicked()), this, SLOT(findPath()));
- QGridLayout * content = new QGridLayout;
+ QGridLayout *content = new QGridLayout;
- //QHBoxLayout *nameLayout = new QHBoxLayout;
+ //QHBoxLayout *nameLayout = new QHBoxLayout;
- content->addWidget(nameLabel,0,0);
- content->addWidget(nameEdit,0,1);
+ content->addWidget(nameLabel, 0, 0);
+ content->addWidget(nameEdit, 0, 1);
- //QHBoxLayout *libraryLayout = new QHBoxLayout;
+ //QHBoxLayout *libraryLayout = new QHBoxLayout;
- content->addWidget(textLabel,1,0);
- content->addWidget(path,1,1);
- content->addWidget(find,1,2);
- content->setColumnMinimumWidth(2,0); //TODO
+ content->addWidget(textLabel, 1, 0);
+ content->addWidget(path, 1, 1);
+ content->addWidget(find, 1, 2);
+ content->setColumnMinimumWidth(2, 0); //TODO
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
- message->setWordWrap(true);
- //message->hide();
- bottomLayout->addStretch();
- bottomLayout->addWidget(accept);
- bottomLayout->addWidget(cancel);
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
+ message->setWordWrap(true);
+ //message->hide();
+ bottomLayout->addStretch();
+ bottomLayout->addWidget(accept);
+ bottomLayout->addWidget(cancel);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addLayout(content);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addLayout(content);
- mainLayout->addLayout(bottomLayout);
+ mainLayout->addLayout(bottomLayout);
- QHBoxLayout * imgMainLayout = new QHBoxLayout;
- QLabel * imgLabel = new QLabel(this);
- QPixmap p(":/images/new.png");
- imgLabel->setPixmap(p);
- imgMainLayout->addWidget(imgLabel);
- imgMainLayout->addLayout(mainLayout);
-
- setLayout(imgMainLayout);
+ QHBoxLayout *imgMainLayout = new QHBoxLayout;
+ QLabel *imgLabel = new QLabel(this);
+ QPixmap p(":/images/new.png");
+ imgLabel->setPixmap(p);
+ imgMainLayout->addWidget(imgLabel);
+ imgMainLayout->addLayout(mainLayout);
- setModal(true);
- setWindowTitle(tr("Create new library"));
+ setLayout(imgMainLayout);
+
+ setModal(true);
+ setWindowTitle(tr("Create new library"));
}
-void CreateLibraryDialog::open(const YACReaderLibraries & libs)
+void CreateLibraryDialog::open(const YACReaderLibraries &libs)
{
- libraries = libs;
+ libraries = libs;
QDialog::open();
}
void CreateLibraryDialog::create()
{
- QFileInfo f(path->text());
- if(f.exists() && f.isDir() && f.isWritable())
- {
- if(!libraries.contains(nameEdit->text()))
- {
- emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
- close();
- }
- else
- emit(libraryExists(nameEdit->text()));
- }
- else
- QMessageBox::critical(NULL,tr("Path not found"),tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
+ QFileInfo f(path->text());
+ if (f.exists() && f.isDir() && f.isWritable()) {
+ if (!libraries.contains(nameEdit->text())) {
+ emit(createLibrary(QDir::cleanPath(path->text()), QDir::cleanPath(path->text()) + "/.yacreaderlibrary", nameEdit->text()));
+ close();
+ } else
+ emit(libraryExists(nameEdit->text()));
+ } else
+ QMessageBox::critical(NULL, tr("Path not found"), tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
}
-void CreateLibraryDialog::nameSetted(const QString & text)
+void CreateLibraryDialog::nameSetted(const QString &text)
{
- if(!text.isEmpty())
- {
- if(!path->text().isEmpty())
- {
- QFileInfo fi(path->text());
- if(fi.isDir())
- accept->setEnabled(true);
- else
- accept->setEnabled(false);
- }
- }
- else
- accept->setEnabled(false);
+ if (!text.isEmpty()) {
+ if (!path->text().isEmpty()) {
+ QFileInfo fi(path->text());
+ if (fi.isDir())
+ accept->setEnabled(true);
+ else
+ accept->setEnabled(false);
+ }
+ } else
+ accept->setEnabled(false);
}
-void CreateLibraryDialog::pathSetted(const QString & text)
+void CreateLibraryDialog::pathSetted(const QString &text)
{
- QFileInfo fi(text);
- if(fi.isDir())
- {
- if(!nameEdit->text().isEmpty())
- accept->setEnabled(true);
- }
- else
- accept->setEnabled(false);
+ QFileInfo fi(text);
+ if (fi.isDir()) {
+ if (!nameEdit->text().isEmpty())
+ accept->setEnabled(true);
+ } else
+ accept->setEnabled(false);
}
void CreateLibraryDialog::findPath()
{
- QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
- if(!s.isEmpty())
- {
- path->setText(s);
- if(!nameEdit->text().isEmpty())
- accept->setEnabled(true);
- }
- else
- accept->setEnabled(false);
+ QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
+ if (!s.isEmpty()) {
+ path->setText(s);
+ if (!nameEdit->text().isEmpty())
+ accept->setEnabled(true);
+ } else
+ accept->setEnabled(false);
}
void CreateLibraryDialog::close()
{
- path->clear();
- nameEdit->clear();
- accept->setEnabled(false);
- QDialog::close();
+ path->clear();
+ nameEdit->clear();
+ accept->setEnabled(false);
+ QDialog::close();
}
void CreateLibraryDialog::setDataAndStart(QString name, QString path)
{
- this->path->setText(path);
- this->nameEdit->setText(name);
+ this->path->setText(path);
+ this->nameEdit->setText(name);
QDialog::open();
- create();
+ create();
}
//-----------------------------------------------------------------------------
// UpdateLibraryDialog
//-----------------------------------------------------------------------------
-UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
-:QDialog(parent)
+UpdateLibraryDialog::UpdateLibraryDialog(QWidget *parent)
+ : QDialog(parent)
{
- QVBoxLayout * mainLayout = new QVBoxLayout;
- mainLayout->addWidget(message = new QLabel(tr("Updating....")));
- mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
- currentFileLabel->setWordWrap(true);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(message = new QLabel(tr("Updating....")));
+ mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
+ currentFileLabel->setWordWrap(true);
- QHBoxLayout * bottom = new QHBoxLayout;
- bottom->addStretch();
- bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
+ QHBoxLayout *bottom = new QHBoxLayout;
+ bottom->addStretch();
+ bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
- connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelUpdate()));
- connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
-
- mainLayout->addStretch();
-
- mainLayout->addLayout(bottom);
+ connect(cancel, SIGNAL(clicked()), this, SIGNAL(cancelUpdate()));
+ connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
- QHBoxLayout * imgMainLayout = new QHBoxLayout;
- QLabel * imgLabel = new QLabel(this);
- QPixmap p(":/images/updateLibrary.png");
- imgLabel->setPixmap(p);
- imgMainLayout->addWidget(imgLabel);
- imgMainLayout->addLayout(mainLayout);
-
- setLayout(imgMainLayout);
+ mainLayout->addStretch();
- setModal(true);
- setWindowTitle(tr("Update library"));
+ mainLayout->addLayout(bottom);
+
+ QHBoxLayout *imgMainLayout = new QHBoxLayout;
+ QLabel *imgLabel = new QLabel(this);
+ QPixmap p(":/images/updateLibrary.png");
+ imgLabel->setPixmap(p);
+ imgMainLayout->addWidget(imgLabel);
+ imgMainLayout->addLayout(mainLayout);
+
+ setLayout(imgMainLayout);
+
+ setModal(true);
+ setWindowTitle(tr("Update library"));
}
void UpdateLibraryDialog::showCurrentFile(QString file)
{
- currentFileLabel->setText(file);
- currentFileLabel->update();
- this->update();
+ currentFileLabel->setText(file);
+ currentFileLabel->update();
+ this->update();
}
void UpdateLibraryDialog::close()
{
- currentFileLabel->setText("");
- this->adjustSize();
- QDialog::close();
+ currentFileLabel->setText("");
+ this->adjustSize();
+ QDialog::close();
}
diff --git a/YACReaderLibrary/create_library_dialog.h b/YACReaderLibrary/create_library_dialog.h
index 4b44221c..895d0551 100644
--- a/YACReaderLibrary/create_library_dialog.h
+++ b/YACReaderLibrary/create_library_dialog.h
@@ -10,52 +10,54 @@
#include
#include
- class CreateLibraryDialog : public QDialog
- {
- Q_OBJECT
- public:
- CreateLibraryDialog(QWidget * parent = 0);
- private:
- QLabel * nameLabel;
- QLabel * textLabel;
- QLabel * message;
- QProgressBar *progressBar;
- QLineEdit * path;
- QLineEdit * nameEdit;
- QPushButton * find;
- QPushButton * accept;
- QPushButton * cancel;
- YACReaderLibraries libraries;
- void setupUI();
- public slots:
- void create();
- void findPath();
- void close();
- void setDataAndStart(QString name, QString paht);
- void nameSetted(const QString & text);
- void pathSetted(const QString & text);
- void open(const YACReaderLibraries &libraries);
- signals:
- void createLibrary(QString source, QString target, QString name);
- void cancelCreate();
- void libraryExists(const QString & name);
- };
+class CreateLibraryDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ CreateLibraryDialog(QWidget *parent = 0);
- class UpdateLibraryDialog : public QDialog
- {
- Q_OBJECT
- public:
- UpdateLibraryDialog(QWidget * parent = 0);
- private:
- QLabel * message;
- QLabel * currentFileLabel;
- QProgressBar *progressBar;
- QPushButton * cancel;
- public slots:
- void showCurrentFile(QString file);
- void close();
- signals:
- void cancelUpdate();
- };
+private:
+ QLabel *nameLabel;
+ QLabel *textLabel;
+ QLabel *message;
+ QProgressBar *progressBar;
+ QLineEdit *path;
+ QLineEdit *nameEdit;
+ QPushButton *find;
+ QPushButton *accept;
+ QPushButton *cancel;
+ YACReaderLibraries libraries;
+ void setupUI();
+public slots:
+ void create();
+ void findPath();
+ void close();
+ void setDataAndStart(QString name, QString paht);
+ void nameSetted(const QString &text);
+ void pathSetted(const QString &text);
+ void open(const YACReaderLibraries &libraries);
+signals:
+ void createLibrary(QString source, QString target, QString name);
+ void cancelCreate();
+ void libraryExists(const QString &name);
+};
+
+class UpdateLibraryDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ UpdateLibraryDialog(QWidget *parent = 0);
+
+private:
+ QLabel *message;
+ QLabel *currentFileLabel;
+ QProgressBar *progressBar;
+ QPushButton *cancel;
+public slots:
+ void showCurrentFile(QString file);
+ void close();
+signals:
+ void cancelUpdate();
+};
#endif
diff --git a/YACReaderLibrary/current_comic_view_helper.cpp b/YACReaderLibrary/current_comic_view_helper.cpp
index ea879013..98819078 100644
--- a/YACReaderLibrary/current_comic_view_helper.cpp
+++ b/YACReaderLibrary/current_comic_view_helper.cpp
@@ -2,7 +2,8 @@
#include "comic_db.h"
-ComicDB currentComicFromModel(ComicModel *model, bool &found) {
+ComicDB currentComicFromModel(ComicModel *model, bool &found)
+{
auto comics = model->getAllComics();
foreach (auto comic, comics) {
diff --git a/YACReaderLibrary/db/comic_item.cpp b/YACReaderLibrary/db/comic_item.cpp
index 18adb83a..179f0f54 100644
--- a/YACReaderLibrary/db/comic_item.cpp
+++ b/YACReaderLibrary/db/comic_item.cpp
@@ -5,43 +5,41 @@
//! [0]
ComicItem::ComicItem(const QList &data)
-
+
{
- itemData = data;
+ itemData = data;
}
//! [0]
//! [1]
ComicItem::~ComicItem()
{
-
}
//! [1]
-
//! [5]
int ComicItem::columnCount() const
{
- return itemData.count();
+ return itemData.count();
}
//! [5]
//! [6]
QVariant ComicItem::data(int column) const
{
- return itemData.value(column);
+ return itemData.value(column);
}
//! [6]
-void ComicItem::setData(int column,const QVariant & value)
+void ComicItem::setData(int column, const QVariant &value)
{
- itemData[column] = value;
+ itemData[column] = value;
}
//! [8]
int ComicItem::row() const
{
- return 0;
+ return 0;
}
//! [8]
diff --git a/YACReaderLibrary/db/comic_item.h b/YACReaderLibrary/db/comic_item.h
index c708e38a..0e6c8bc9 100644
--- a/YACReaderLibrary/db/comic_item.h
+++ b/YACReaderLibrary/db/comic_item.h
@@ -7,20 +7,18 @@
//! [0]
class ComicItem : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
ComicItem(const QList