mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added settings to the options dialog for configuring the background image in grid view
This commit is contained in:
parent
de59cbd9e3
commit
da19e086db
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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{
|
||||
|
@ -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("Opacity 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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user