erged default

This commit is contained in:
Luis Ángel San Martín
2015-12-12 13:21:51 +01:00
18 changed files with 397 additions and 290 deletions

View File

@ -14,7 +14,7 @@ INCLUDEPATH += ../common \
./comic_vine/model
DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY
QMAKE_MAC_SDK = macosx10.11
#load default build flags
include (../config.pri)

View File

@ -395,15 +395,17 @@ void DBHelper::updateReadingRemoteProgress(const ComicInfo &comicInfo, QSqlDatab
{
QSqlQuery updateComicInfo(db);
updateComicInfo.prepare("UPDATE comic_info SET "
"read = :read, "
"currentPage = :currentPage, "
"hasBeenOpened = :hasBeenOpened"
" WHERE id = :id ");
"read = :read, "
"currentPage = :currentPage, "
"hasBeenOpened = :hasBeenOpened, "
"rating = :rating"
" WHERE id = :id ");
updateComicInfo.bindValue(":read", comicInfo.read?1:0);
updateComicInfo.bindValue(":currentPage", comicInfo.currentPage);
updateComicInfo.bindValue(":hasBeenOpened", comicInfo.hasBeenOpened?1:0);
updateComicInfo.bindValue(":id", comicInfo.id);
updateComicInfo.bindValue(":rating", comicInfo.rating);
updateComicInfo.exec();
}
@ -417,10 +419,18 @@ void DBHelper::updateFromRemoteClient(qulonglong libraryId,const ComicInfo & com
if(comic.info.hash == comicInfo.hash)
{
if(comic.info.currentPage == comic.info.numPages)
comic.info.read = true;
comic.info.currentPage = comicInfo.currentPage;
comic.info.hasBeenOpened = true;
if(comicInfo.currentPage > 0)
{
if(comic.info.currentPage == comic.info.numPages)
comic.info.read = true;
comic.info.currentPage = comicInfo.currentPage;
comic.info.hasBeenOpened = true;
}
if(comicInfo.rating > 0)
comic.info.rating = comicInfo.rating;
DBHelper::updateReadingRemoteProgress(comic.info,db);
}

View File

@ -160,12 +160,48 @@ void GridComicsView::setModel(ComicModel *model)
ctxt->setContextProperty("dragManager", this);
ctxt->setContextProperty("dropManager", this);
updateBackgroundConfig();
if(model->rowCount()>0)
setCurrentIndex(model->index(0,0));
}
}
void GridComicsView::updateBackgroundConfig()
{
if(this->model == NULL)
return;
QQmlContext *ctxt = view->rootContext();
//backgroun image configuration
bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool();
if(useBackgroundImage)
{
float opacity = settings->value(OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW, 0.2).toFloat();
float blurRadius = settings->value(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, 75).toInt();
ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole));
ctxt->setContextProperty("backgroundBlurOpacity", opacity);
ctxt->setContextProperty("backgroundBlurRadius", blurRadius);
ctxt->setContextProperty("backgroundBlurVisible", true);
}
else
{
ctxt->setContextProperty("backgroundImage", QVariant());
ctxt->setContextProperty("backgroundBlurOpacity", 0);
ctxt->setContextProperty("backgroundBlurRadius", 0);
ctxt->setContextProperty("backgroundBlurVisible", false);
}
#ifdef Q_OS_MAC
ctxt->setContextProperty("cellColor", useBackgroundImage?"#99FFFFFF":"#FFFFFF");
ctxt->setContextProperty("selectedColor", "#FFFFFF");
#else
ctxt->setContextProperty("cellColor", useBackgroundImage?"#99212121":"#212121");
ctxt->setContextProperty("selectedColor", "#121212");
#endif
}
void GridComicsView::setCurrentIndex(const QModelIndex &index)

View File

@ -63,6 +63,7 @@ public slots:
void droppedFiles(const QList<QUrl> & urls, Qt::DropAction action);
void droppedComicsForResortingAt(const QString & data, int index);
void updateBackgroundConfig();
protected slots:
void requestedContextMenu(const QPoint & point);

View File

@ -135,9 +135,9 @@ void LibraryWindow::setupUI()
createActions();
doModels();
doDialogs();
doLayout();
createToolBars();
doDialogs();
createMenus();
navigationController = new YACReaderNavigationController(this);
@ -245,6 +245,7 @@ void LibraryWindow::doLayout()
//comicsViewStack->setCurrentIndex(Flow);
} else {
comicsView = gridComicsView = new GridComicsView();
connect(optionsDialog, SIGNAL(optionsChanged()), gridComicsView, SLOT(updateBackgroundConfig()));
comicsViewStatus = Grid;
//comicsViewStack->setCurrentIndex(Grid);
}
@ -2256,6 +2257,7 @@ void LibraryWindow::toggleComicsView_delayed()
libraryToolBar->updateViewSelectorIcon(icoViewsButton);
#endif
switchToComicsView(classicComicsView, gridComicsView = new GridComicsView());
connect(optionsDialog, SIGNAL(optionsChanged()), gridComicsView, SLOT(updateBackgroundConfig()));
comicsViewStatus = Grid;
}
else{

View File

@ -7,18 +7,6 @@
#include "yacreader_flow_config_widget.h"
#include "api_key_dialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QGroupBox>
#include <QRadioButton>
#include <QTextStream>
#include <QCoreApplication>
#include <QFile>
#include <QMessageBox>
#include <QCheckBox>
#include <QtWidgets>
FlowType flowType = Strip;
@ -30,6 +18,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
QVBoxLayout * layout = new QVBoxLayout(this);
QVBoxLayout * flowLayout = new QVBoxLayout;
QVBoxLayout * gridViewLayout = new QVBoxLayout();
QVBoxLayout * generalLayout = new QVBoxLayout();
QHBoxLayout * switchFlowType = new QHBoxLayout();
@ -61,9 +50,43 @@ OptionsDialog::OptionsDialog(QWidget * parent)
connect(apiKeyButton,SIGNAL(clicked()),this,SLOT(editApiKey()));
//grid view background config
useBackgroundImageCheck = new QCheckBox(tr("Enable background image"));
opacityLabel = new QLabel(tr("Opacity level"));
backgroundImageOpacitySlider = new QSlider(Qt::Horizontal);
backgroundImageOpacitySlider->setRange(5,100);
blurLabel = new QLabel(tr("Blur level"));
backgroundImageBlurRadiusSlider = new QSlider(Qt::Horizontal);
backgroundImageBlurRadiusSlider->setRange(0,100);
QVBoxLayout * gridBackgroundLayout = new QVBoxLayout();
gridBackgroundLayout->addWidget(useBackgroundImageCheck);
gridBackgroundLayout->addWidget(opacityLabel);
gridBackgroundLayout->addWidget(backgroundImageOpacitySlider);
gridBackgroundLayout->addWidget(blurLabel);
gridBackgroundLayout->addWidget(backgroundImageBlurRadiusSlider);
QGroupBox * gridBackgroundGroup = new QGroupBox(tr("Background"));
gridBackgroundGroup->setLayout(gridBackgroundLayout);
gridViewLayout->addWidget(gridBackgroundGroup);
gridViewLayout->addStretch();
connect(useBackgroundImageCheck, SIGNAL(clicked(bool)), this, SLOT(useBackgroundImageCheckClicked(bool)));
connect(backgroundImageOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(backgroundImageOpacitySliderChanged(int)));
connect(backgroundImageBlurRadiusSlider, SIGNAL(valueChanged(int)), this, SLOT(backgroundImageBlurRadiusSliderChanged(int)));
//end grid view background config
QWidget * comicFlowW = new QWidget;
comicFlowW->setLayout(flowLayout);
QWidget * gridViewW = new QWidget;
gridViewW->setLayout(gridViewLayout);
QWidget * generalW = new QWidget;
generalW->setLayout(generalLayout);
generalLayout->addWidget(shortcutsBox);
@ -71,6 +94,9 @@ OptionsDialog::OptionsDialog(QWidget * parent)
generalLayout->addStretch();
tabWidget->addTab(comicFlowW,tr("Comic Flow"));
#ifndef NO_OPENGL
tabWidget->addTab(gridViewW,tr("Grid view"));
#endif
tabWidget->addTab(generalW,tr("General"));
layout->addWidget(tabWidget);
@ -82,7 +108,6 @@ OptionsDialog::OptionsDialog(QWidget * parent)
setWindowTitle(tr("Options"));
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
}
void OptionsDialog::editApiKey()
@ -91,5 +116,44 @@ void OptionsDialog::editApiKey()
d.exec();
}
void OptionsDialog::restoreOptions(QSettings * settings)
{
YACReaderOptionsDialog::restoreOptions(settings);
bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool();
useBackgroundImageCheck->setChecked(useBackgroundImage);
backgroundImageOpacitySlider->setValue(settings->value(OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW, 0.2).toFloat()*100);
backgroundImageBlurRadiusSlider->setValue(settings->value(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, 75).toInt());
backgroundImageOpacitySlider->setVisible(useBackgroundImage);
backgroundImageBlurRadiusSlider->setVisible(useBackgroundImage);
opacityLabel->setVisible(useBackgroundImage);
blurLabel->setVisible(useBackgroundImage);
}
void OptionsDialog::useBackgroundImageCheckClicked(bool checked)
{
settings->setValue(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, checked);
backgroundImageOpacitySlider->setVisible(checked);
backgroundImageBlurRadiusSlider->setVisible(checked);
opacityLabel->setVisible(checked);
blurLabel->setVisible(checked);
emit optionsChanged();
}
void OptionsDialog::backgroundImageOpacitySliderChanged(int value)
{
settings->setValue(OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW, value/100.0);
emit optionsChanged();
}
void OptionsDialog::backgroundImageBlurRadiusSliderChanged(int value)
{
settings->setValue(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, value);
emit optionsChanged();
}

View File

@ -1,6 +1,8 @@
#ifndef __OPTIONS_DIALOG_H
#define __OPTIONS_DIALOG_H
#include <QtWidgets>
#include "yacreader_options_dialog.h"
#include "yacreader_global.h"
@ -15,6 +17,18 @@ Q_OBJECT
public slots:
void editApiKey();
void restoreOptions(QSettings * settings);
private slots:
void useBackgroundImageCheckClicked(bool checked);
void backgroundImageOpacitySliderChanged(int value);
void backgroundImageBlurRadiusSliderChanged(int value);
private:
QCheckBox * useBackgroundImageCheck;
QSlider * backgroundImageOpacitySlider;
QSlider * backgroundImageBlurRadiusSlider;
QLabel * opacityLabel;
QLabel * blurLabel;
};

View File

@ -2,9 +2,33 @@ import QtQuick 2.3
import QtQuick.Controls 1.2
import comicModel 1.0
import QtGraphicalEffects 1.0
Rectangle {
id: main
clip: true
Image {
id: backgroundImg
anchors.fill: parent
source: backgroundImage
fillMode: Image.PreserveAspectCrop
smooth: true
mipmap: true
asynchronous : true
cache: false //TODO clear cache only when it is needed
opacity: 0
visible: false
}
FastBlur {
anchors.fill: backgroundImg
source: backgroundImg
radius: backgroundBlurRadius
opacity: backgroundBlurOpacity
visible: backgroundBlurVisible
}
color: backgroundColor
width: parent.width
height: parent.height
@ -25,7 +49,7 @@ Rectangle {
id: cell
width: grid.cellWidth
height: grid.cellHeight
color: backgroundColor
color: "#00000000"
Rectangle {
@ -54,7 +78,6 @@ Rectangle {
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index))?selectedColor:cellColor;
border.color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index))?selectedBorderColor:borderColor;
border.width: (Qt.platform.os === "osx")?1:0;
anchors.horizontalCenter: parent.horizontalCenter
MouseArea {
@ -290,7 +313,7 @@ Rectangle {
}
}
YACReaderScrollView{
YACReaderScrollView {
id: scrollView
anchors.fill: parent
anchors.margins: 0
@ -367,7 +390,7 @@ Rectangle {
footer: Rectangle { //fix for the scroll issue, TODO find what causes the issue (some times the bottoms cells are hidden for the toolbar, no full scroll)
height : 25
width : parent.width
color : backgroundColor
color : "#00000000"
}
move: Transition {

View File

@ -274,8 +274,6 @@ FocusScope {
onVerticalValueChanged: {
if (!verticalRecursionGuard) {
//console.log(verticalDelta);
if (flickableItem.contentY < flickThreshold && verticalDelta > speedThreshold) {
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
} else if (flickableItem.contentY > flickableItem.contentHeight
@ -285,16 +283,13 @@ FocusScope {
var absDelta = Math.abs(verticalDelta);
if(verticalDelta < 0)
flickableItem.contentY = verticalValue + Math.min(98,0.93*absDelta+4.5);
flickableItem.contentY = Math.min(verticalMaximumValue, verticalValue + Math.min(98,0.93*absDelta+4.5));
else
flickableItem.contentY = verticalValue - Math.min(98,0.93*absDelta+4.5);
}
//TODO: snap to row
flickableItem.contentY = Math.max(0, verticalValue - Math.min(98,0.93*absDelta+4.5));
}
flickableItem.contentY = Math.min(verticalMaximumValue, Math.max(0, flickableItem.contentY));
}
}
onHorizontalValueChanged: {

View File

@ -23,12 +23,13 @@ void SyncController::service(HttpRequest &request, HttpResponse &response)
qulonglong libraryId;
qulonglong comicId;
int currentPage;
int currentRating;
QString hash;
foreach(QString comicInfo, data)
{
QList<QString> comicInfoProgress = comicInfo.split("\t");
if(comicInfoProgress.length() == 4)
if(comicInfoProgress.length() == 4 || comicInfoProgress.length() == 5)
{
libraryId = comicInfoProgress.at(0).toULongLong();
comicId = comicInfoProgress.at(1).toULongLong();
@ -39,6 +40,14 @@ void SyncController::service(HttpRequest &request, HttpResponse &response)
info.currentPage = currentPage;
info.hash = hash; //TODO remove the hash check and add UUIDs for libraries
info.id = comicId;
//Client 2.1+ version
if(comicInfoProgress.length() > 4)
{
currentRating = comicInfoProgress.at(4).toInt();
info.rating = currentRating;
}
DBHelper::updateFromRemoteClient(libraryId,info);
}
}