Merge pull request #157 from selmf/feature/overscale

Reader: Add option to stop enlarging images in fit to width and height
This commit is contained in:
Luis Ángel San Martín 2020-09-02 22:28:12 +02:00 committed by GitHub
commit ce90796aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 41 deletions

View File

@ -7,6 +7,9 @@ spanish only. Sorry for the mess.
Version counting is based on semantic versioning (Major.Feature.Patch) Version counting is based on semantic versioning (Major.Feature.Patch)
## 9.7.0 (unreleased) ## 9.7.0 (unreleased)
### YACReader
* Image enlargement/stretching can now be disabled for fit
to width and height
### YACReaderLibrary ### YACReaderLibrary
* update QsLog logger to version 2.1, snapshot 46b643d5bcbc * update QsLog logger to version 2.1, snapshot 46b643d5bcbc

View File

@ -47,14 +47,6 @@ void Configuration::load(QSettings *settings)
settings->setValue(SHOW_TOOLBARS, true); settings->setValue(SHOW_TOOLBARS, true);
if (!settings->contains(QUICK_NAVI_MODE)) if (!settings->contains(QUICK_NAVI_MODE))
settings->setValue(QUICK_NAVI_MODE, false); settings->setValue(QUICK_NAVI_MODE, false);
//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) void Configuration::updateOpenRecentList(QString path)
{ {

View File

@ -51,16 +51,6 @@ public:
void updateOpenRecentList(QString path); void updateOpenRecentList(QString path);
void clearOpenRecentList() { settings->remove("recentFiles"); } void clearOpenRecentList() { settings->remove("recentFiles"); }
//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();}
void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);}
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();}
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
*/
FlowType getFlowType() { return (FlowType)settings->value(FLOW_TYPE_SW).toInt(); } FlowType getFlowType() { return (FlowType)settings->value(FLOW_TYPE_SW).toInt(); }
void setFlowType(FlowType type) { settings->setValue(FLOW_TYPE_SW, type); } void setFlowType(FlowType type) { settings->setValue(FLOW_TYPE_SW, type); }
bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); } bool getFullScreen() { return settings->value(FULLSCREEN).toBool(); }

View File

@ -156,6 +156,7 @@ void MainWindowViewer::setupUI()
connect(optionsDialog, SIGNAL(accepted()), viewer, SLOT(updateOptions())); connect(optionsDialog, SIGNAL(accepted()), viewer, SLOT(updateOptions()));
connect(optionsDialog, SIGNAL(optionsChanged()), this, SLOT(reloadOptions())); connect(optionsDialog, SIGNAL(optionsChanged()), this, SLOT(reloadOptions()));
connect(optionsDialog, SIGNAL(changedFilters(int, int, int)), viewer, SLOT(updateFilters(int, int, int))); connect(optionsDialog, SIGNAL(changedFilters(int, int, int)), viewer, SLOT(updateFilters(int, int, int)));
connect(optionsDialog, &OptionsDialog::changedImageOptions, viewer, &Viewer::updatePage);
optionsDialog->restoreOptions(settings); optionsDialog->restoreOptions(settings);
//shortcutsDialog = new ShortcutsDialog(this); //shortcutsDialog = new ShortcutsDialog(this);

View File

@ -55,18 +55,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
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"));
fitToWidthRatioS = new QSlider(this);
fitToWidthRatioS->setMinimum(50);
fitToWidthRatioS->setMaximum(100);
fitToWidthRatioS->setPageStep(5);
fitToWidthRatioS->setOrientation(Qt::Horizontal);
//connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
QHBoxLayout * fitLayout = new QHBoxLayout;
fitLayout->addWidget(fitToWidthRatioS);
fitBox->setLayout(fitLayout);*/
auto colorSelection = new QHBoxLayout; auto colorSelection = new QHBoxLayout;
backgroundColor = new QLabel(); backgroundColor = new QLabel();
QPalette pal = backgroundColor->palette(); QPalette pal = backgroundColor->palette();
@ -145,6 +133,19 @@ OptionsDialog::OptionsDialog(QWidget *parent)
QGroupBox *imageBox = new QGroupBox(tr("Image options")); QGroupBox *imageBox = new QGroupBox(tr("Image options"));
imageBox->setLayout(layoutImage); imageBox->setLayout(layoutImage);
layoutImageV->addWidget(imageBox); layoutImageV->addWidget(imageBox);
auto scaleBox = new QGroupBox(tr("Fit options"));
auto scaleLayout = new QVBoxLayout();
scaleCheckbox = new QCheckBox(tr("Enlarge images to fit width/height"));
connect(scaleCheckbox, &QCheckBox::clicked,
[=](bool checked) {
settings->setValue(ENLARGE_IMAGES, checked);
emit(changedImageOptions());
});
scaleLayout->addWidget(scaleCheckbox);
scaleBox->setLayout(scaleLayout);
layoutImageV->addWidget(scaleBox);
layoutImageV->addStretch(); layoutImageV->addStretch();
pageGeneral->setLayout(layoutGeneral); pageGeneral->setLayout(layoutGeneral);
@ -233,6 +234,8 @@ void OptionsDialog::restoreOptions(QSettings *settings)
brightnessS->setValue(settings->value(BRIGHTNESS, 0).toInt()); brightnessS->setValue(settings->value(BRIGHTNESS, 0).toInt());
contrastS->setValue(settings->value(CONTRAST, 100).toInt()); contrastS->setValue(settings->value(CONTRAST, 100).toInt());
gammaS->setValue(settings->value(GAMMA, 100).toInt()); gammaS->setValue(settings->value(GAMMA, 100).toInt());
scaleCheckbox->setChecked(settings->value(ENLARGE_IMAGES, true).toBool());
} }
void OptionsDialog::updateColor(const QColor &color) void OptionsDialog::updateColor(const QColor &color)
@ -248,12 +251,6 @@ void OptionsDialog::updateColor(const QColor &color)
emit(changedOptions()); emit(changedOptions());
} }
/*void OptionsDialog::fitToWidthRatio(int value)
{
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
emit(fitToWidthRatioChanged(value/100.0));
}*/
void OptionsDialog::brightnessChanged(int value) void OptionsDialog::brightnessChanged(int value)
{ {
QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat); QSettings settings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);

View File

@ -25,6 +25,7 @@ private:
QPushButton *pathFindButton; QPushButton *pathFindButton;
QCheckBox *quickNavi; QCheckBox *quickNavi;
QCheckBox *disableShowOnMouseOver; QCheckBox *disableShowOnMouseOver;
QCheckBox *scaleCheckbox;
QLabel *magGlassSizeLabel; QLabel *magGlassSizeLabel;

View File

@ -316,24 +316,27 @@ void Viewer::updateContentSize()
{ {
//there is an image to resize //there is an image to resize
if (currentPage != nullptr && !currentPage->isNull()) { if (currentPage != nullptr && !currentPage->isNull()) {
QSize pagefit; QSize pagefit = currentPage->size();
bool stretchImages = Configuration::getConfiguration().getSettings()->value(ENLARGE_IMAGES).toBool();
YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode(); YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode();
switch (fitmode) { switch (fitmode) {
case YACReader::FitMode::FullRes: case YACReader::FitMode::FullRes:
pagefit = currentPage->size();
break; break;
case YACReader::FitMode::ToWidth: case YACReader::FitMode::ToWidth:
pagefit = currentPage->size(); if (!stretchImages && width() > pagefit.width()) {
break;
}
pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding); pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding);
break; break;
case YACReader::FitMode::ToHeight: case YACReader::FitMode::ToHeight:
pagefit = currentPage->size(); if (!stretchImages && height() > pagefit.height()) {
break;
}
pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding); pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
break; break;
//if everything fails showing the full page is a good idea //if everything fails showing the full page is a good idea
case YACReader::FitMode::FullPage: case YACReader::FitMode::FullPage:
default: default:
pagefit = currentPage->size();
pagefit.scale(size(), Qt::KeepAspectRatio); pagefit.scale(size(), Qt::KeepAspectRatio);
break; break;
} }

View File

@ -69,6 +69,8 @@
#define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW" #define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW"
#define DISPLAY_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_CONTINUE_READING_IN_GRID_VIEW" #define DISPLAY_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_CONTINUE_READING_IN_GRID_VIEW"
#define ENLARGE_IMAGES "ENLARGE_IMAGES"
namespace YACReader { namespace YACReader {
static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids"; static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids";