added settings to the options dialog for configuring the background image in grid view

This commit is contained in:
Luis Ángel San Martín
2015-12-07 22:48:13 +01:00
parent de59cbd9e3
commit da19e086db
5 changed files with 125 additions and 39 deletions

View File

@ -160,28 +160,40 @@ void GridComicsView::setModel(ComicModel *model)
ctxt->setContextProperty("dragManager", this);
ctxt->setContextProperty("dropManager", this);
updateBackgroundConfig();
//backgroun image configuration
bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool();
if(model->rowCount()>0)
setCurrentIndex(model->index(0,0));
}
}
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).toFloat();
void GridComicsView::updateBackgroundConfig()
{
if(this->model == NULL)
return;
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);
}
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");
@ -190,13 +202,6 @@ void GridComicsView::setModel(ComicModel *model)
ctxt->setContextProperty("cellColor", useBackgroundImage?"#99212121":"#212121");
ctxt->setContextProperty("selectedColor", "#121212");
#endif
if(model->rowCount()>0)
setCurrentIndex(model->index(0,0));
}
}
void GridComicsView::setCurrentIndex(const QModelIndex &index)