mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
added settings to the options dialog for configuring the background image in grid view
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user