A?adida las opciones de control de imagen al di?logo de opciones, falta maquetarlo

adecuadamente.
This commit is contained in:
Luis Ángel San Martín 2013-01-22 17:53:18 +01:00
parent 77fee07968
commit eaa86b2169
8 changed files with 108 additions and 13 deletions

View File

@ -63,6 +63,7 @@ void MainWindowViewer::setupUI()
connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions()));
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions()));
connect(optionsDialog,SIGNAL(changedImageOptions()),viewer,SLOT(updateImageOptions()));
optionsDialog->restoreOptions(settings);
shortcutsDialog = new ShortcutsDialog(this);

View File

@ -18,8 +18,10 @@ OptionsDialog::OptionsDialog(QWidget * parent)
QWidget * pageGeneral = new QWidget();
QWidget * pageFlow = new QWidget();
QWidget * pageImage = new QWidget();
QVBoxLayout * layoutGeneral = new QVBoxLayout();
QVBoxLayout * layoutFlow = new QVBoxLayout();;
QVBoxLayout * layoutFlow = new QVBoxLayout();
QVBoxLayout * layoutImage = new QVBoxLayout();
QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size"));
//slideSizeLabel = new QLabel(,this);
@ -73,6 +75,31 @@ OptionsDialog::OptionsDialog(QWidget * parent)
connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show()));
colorBox->setLayout(colorSelection);
brightnessS = new QSlider();
brightnessS->setMinimum(0);
brightnessS->setMaximum(100);
brightnessS->setPageStep(1);
brightnessS->setOrientation(Qt::Horizontal);
brightnessS->setTracking(false);
connect(brightnessS,SIGNAL(valueChanged(int)),this,SLOT(brightnessChanged(int)));
contrastS = new QSlider();
contrastS->setMinimum(0);
contrastS->setMaximum(250);
contrastS->setPageStep(1);
contrastS->setOrientation(Qt::Horizontal);
contrastS->setTracking(false);
connect(contrastS,SIGNAL(valueChanged(int)),this,SLOT(contrastChanged(int)));
gammaS = new QSlider();
gammaS->setMinimum(0);
gammaS->setMaximum(250);
gammaS->setPageStep(1);
gammaS->setOrientation(Qt::Horizontal);
gammaS->setTracking(false);
connect(gammaS,SIGNAL(valueChanged(int)),this,SLOT(gammaChanged(int)));
//connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions()));
QHBoxLayout * buttons = new QHBoxLayout();
buttons->addStretch();
buttons->addWidget(new QLabel(tr("Restart is needed")));
@ -88,12 +115,18 @@ OptionsDialog::OptionsDialog(QWidget * parent)
layoutFlow->addWidget(gl);
layoutFlow->addWidget(useGL);
layoutFlow->addStretch();
layoutImage->addWidget(brightnessS);
layoutImage->addWidget(contrastS);
layoutImage->addWidget(gammaS);
layoutImage->addStretch();
pageGeneral->setLayout(layoutGeneral);
pageFlow->setLayout(layoutFlow);
pageImage->setLayout(layoutImage);
tabWidget->addTab(pageGeneral,tr("General"));
tabWidget->addTab(pageFlow,tr("Page Flow"));
tabWidget->addTab(pageImage,tr("Immage adjustment"));
layout->addWidget(tabWidget);
layout->addLayout(buttons);
@ -165,6 +198,10 @@ void OptionsDialog::restoreOptions(QSettings * settings)
updateColor(settings->value(BACKGROUND_COLOR).value<QColor>());
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt());
contrastS->setValue(settings->value(CONTRAST,100).toInt());
gammaS->setValue(settings->value(GAMMA,100).toInt());
}
@ -185,4 +222,25 @@ void OptionsDialog::fitToWidthRatio(int value)
{
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
emit(fitToWidthRatioChanged(value/100.0));
}
void OptionsDialog::brightnessChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(BRIGHTNESS,value);
emit(changedImageOptions());
}
void OptionsDialog::contrastChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(CONTRAST,value);
emit(changedImageOptions());
}
void OptionsDialog::gammaChanged(int value)
{
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
settings.setValue(GAMMA,value);
emit(changedImageOptions());
}

View File

@ -37,15 +37,25 @@ Q_OBJECT
QColorDialog * colorDialog;
QSlider * brightnessS;
QSlider * contrastS;
QSlider * gammaS;
public slots:
void saveOptions();
void restoreOptions(QSettings * settings);
void findFolder();
void updateColor(const QColor & color);
void fitToWidthRatio(int value);
void brightnessChanged(int value);
void contrastChanged(int value);
void gammaChanged(int value);
signals:
void changedOptions();
void changedImageOptions();
void fitToWidthRatioChanged(float ratio);
};

View File

@ -10,6 +10,8 @@
#define NL 2
#define NR 2
#include "yacreader_global.h"
template<class T>
inline const T& kClamp( const T& x, const T& low, const T& high )
{
@ -238,8 +240,8 @@ QImage BrightnessFilter::setFilter(const QImage & image)
}
}
return result;*/
return changeBrightness(image,50);
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
}
//-----------------------------------------------------------------------------
@ -309,8 +311,8 @@ QImage ContrastFilter::setFilter(const QImage & image)
}
return result;*/
return changeContrast(image,level);
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeContrast(image,settings.value(CONTRAST,100).toInt());
}
//-----------------------------------------------------------------------------
// ContrastFilter
@ -322,7 +324,8 @@ GammaFilter::GammaFilter(int l)
QImage GammaFilter::setFilter(const QImage & image)
{
return changeGamma(image,level);
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
return changeGamma(image,settings.value(GAMMA,100).toInt());
}
//-----------------------------------------------------------------------------
@ -438,7 +441,9 @@ Render::Render()
pageRenders.push_back(0);
}
//filters.push_back(new GammaFilter(250));
filters.push_back(new BrightnessFilter());
filters.push_back(new ContrastFilter());
filters.push_back(new GammaFilter());
}
//Este método se encarga de forzar el renderizado de las páginas.
@ -822,7 +827,7 @@ void Render::fillBuffer()
pageRenders[currentPageBufferedIndex+i]==0 &&
pagesReady[currentIndex+1]) //preload next pages
{
pageRenders[currentPageBufferedIndex+i] = new PageRender(currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation);
pageRenders[currentPageBufferedIndex+i] = new PageRender(currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex+i]->start();
}
@ -833,7 +838,7 @@ void Render::fillBuffer()
pageRenders[currentPageBufferedIndex-i]==0 &&
pagesReady[currentIndex-1]) //preload previous pages
{
pageRenders[currentPageBufferedIndex-i] = new PageRender(currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation);
pageRenders[currentPageBufferedIndex-i] = new PageRender(currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex-i]->start();
}
@ -851,9 +856,9 @@ void Render::fillBufferDoublePage()
(pagesReady[currentIndex+2*i] && pagesReady[qMin(currentIndex+(2*i)+1,(int)comic->numPages()-1)])) //preload next pages
{
if(currentIndex+(2*i)+1 > comic->numPages()-1)
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),QByteArray(),buffer[currentPageBufferedIndex+i],imageRotation);
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),QByteArray(),buffer[currentPageBufferedIndex+i],imageRotation,filters);
else
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),comic->getRawData()->at(currentIndex+(2*i)+1),buffer[currentPageBufferedIndex+i],imageRotation);
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),comic->getRawData()->at(currentIndex+(2*i)+1),buffer[currentPageBufferedIndex+i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex+i]->start();
}
@ -865,9 +870,9 @@ void Render::fillBufferDoublePage()
(pagesReady[qMax(currentIndex-2*i,0)] && pagesReady[qMin(currentIndex-(2*i)+1,(int)comic->numPages()-1)])) //preload previous pages
{
if(currentIndex-2*i == -1)
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(0,QByteArray(),comic->getRawData()->at(0),buffer[currentPageBufferedIndex-i],imageRotation);
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(0,QByteArray(),comic->getRawData()->at(0),buffer[currentPageBufferedIndex-i],imageRotation,filters);
else
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(currentIndex-2*i,comic->getRawData()->at(currentIndex-(2*i)),comic->getRawData()->at(currentIndex-(2*i)+1),buffer[currentPageBufferedIndex-i],imageRotation);
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(currentIndex-2*i,comic->getRawData()->at(currentIndex-(2*i)),comic->getRawData()->at(currentIndex-(2*i)+1),buffer[currentPageBufferedIndex-i],imageRotation,filters);
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
pageRenders[currentPageBufferedIndex-i]->start();
}
@ -932,4 +937,13 @@ void Render::save()
Bookmarks * Render::getBookmarks()
{
return comic->bm;
}
void Render::reload()
{
if(comic)
{
invalidate();
update();
}
}

View File

@ -147,6 +147,7 @@ public slots:
void removeBookmark();
void save();
void reset();
void reload();
Bookmarks * getBookmarks();
signals:

View File

@ -736,6 +736,13 @@ void Viewer::updateConfig(QSettings * settings)
QPalette palette;
palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
setPalette(palette);
}
void Viewer::updateImageOptions()
{
render->reload();
}
void Viewer::setBookmarks()

View File

@ -77,6 +77,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
void updateConfig(QSettings * settings);
void showMessageErrorOpening();
void setBookmarks();
void updateImageOptions();
private:
bool information;

View File

@ -21,6 +21,9 @@
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
#define BRIGHTNESS "BRIGHTNESS"
#define CONTRAST "CONTRAST"
#define GAMMA "GAMMA"
#define FLOW_TYPE_GL "FLOW_TYPE_GL"
#define Y_POSITION "Y_POSITION"