Commit a4c5ac99 authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

Bring back configuration of raster image view alpha background

parent 33ae855f
......@@ -74,8 +74,8 @@ ConfigDialog::ConfigDialog(QWidget* parent)
d->mAlphaBackgroundModeGroup = new InvisibleButtonGroup(widget);
d->mAlphaBackgroundModeGroup->setObjectName( QLatin1String("kcfg_AlphaBackgroundMode" ));
d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.checkBoardRadioButton, int(ImageView::AlphaBackgroundCheckBoard));
d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.solidColorRadioButton, int(ImageView::AlphaBackgroundSolid));
d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.checkBoardRadioButton, int(RasterImageView::AlphaBackgroundCheckBoard));
d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.solidColorRadioButton, int(RasterImageView::AlphaBackgroundSolid));
d->mWheelBehaviorGroup = new InvisibleButtonGroup(widget);
d->mWheelBehaviorGroup->setObjectName( QLatin1String("kcfg_MouseWheelBehavior" ));
......
......@@ -106,6 +106,7 @@ struct DocumentViewPrivate {
that, SIGNAL(zoomToFitChanged(bool)) );
}
adapter->loadConfig();
// FIXME QGV
/*
QAbstractScrollArea* area = qobject_cast<QAbstractScrollArea*>(adapter->widget());
......
......@@ -109,12 +109,9 @@ void ImageViewAdapter::slotLoadingFailed() {
void ImageViewAdapter::loadConfig() {
// FIXME: QGV
/*
d->mView->setAlphaBackgroundMode(GwenviewConfig::alphaBackgroundMode());
d->mView->setAlphaBackgroundColor(GwenviewConfig::alphaBackgroundColor());
d->mView->setEnlargeSmallerImages(GwenviewConfig::enlargeSmallerImages());
*/
}
RasterImageView* ImageViewAdapter::rasterImageView() const {
......
......@@ -41,6 +41,13 @@ struct RasterImageViewPrivate {
RasterImageView* q;
ImageScaler* mScaler;
QPixmap mBackgroundTexture;
// Config
RasterImageView::AlphaBackgroundMode mAlphaBackgroundMode;
QColor mAlphaBackgroundColor;
bool mEnlargeSmallerImages;
// /Config
bool mBufferIsEmpty;
QPixmap mCurrentBuffer;
// The alternate buffer is useful when scrolling: existing content is copied
......@@ -125,8 +132,7 @@ struct RasterImageViewPrivate {
}
void drawAlphaBackground(QPainter* painter, const QRect& viewportRect, const QPoint& zoomedImageTopLeft) {
// FIXME: QGV
//if (mAlphaBackgroundMode == ImageView::AlphaBackgroundCheckBoard) {
if (mAlphaBackgroundMode == RasterImageView::AlphaBackgroundCheckBoard) {
QPoint textureOffset(
zoomedImageTopLeft.x() % mBackgroundTexture.width(),
zoomedImageTopLeft.y() % mBackgroundTexture.height()
......@@ -135,9 +141,9 @@ struct RasterImageViewPrivate {
viewportRect,
mBackgroundTexture,
textureOffset);
/*} else {
} else {
painter->fillRect(viewportRect, mAlphaBackgroundColor);
}*/
}
}
};
......@@ -145,6 +151,11 @@ RasterImageView::RasterImageView(QGraphicsItem* parent)
: AbstractImageView(parent)
, d(new RasterImageViewPrivate) {
d->q = this;
d->mAlphaBackgroundMode = AlphaBackgroundCheckBoard;
d->mAlphaBackgroundColor = Qt::black;
d->mEnlargeSmallerImages = false;
d->mBufferIsEmpty = true;
d->mScaler = new ImageScaler(this);
connect(d->mScaler, SIGNAL(scaledRect(int,int,QImage)),
......@@ -159,6 +170,31 @@ RasterImageView::~RasterImageView() {
delete d;
}
void RasterImageView::setAlphaBackgroundMode(AlphaBackgroundMode mode) {
d->mAlphaBackgroundMode = mode;
if (document() && document()->hasAlphaChannel()) {
d->mCurrentBuffer = QPixmap();
updateBuffer();
}
}
void RasterImageView::setAlphaBackgroundColor(const QColor& color) {
d->mAlphaBackgroundColor = color;
if (document() && document()->hasAlphaChannel()) {
d->mCurrentBuffer = QPixmap();
updateBuffer();
}
}
void RasterImageView::setEnlargeSmallerImages(bool value) {
d->mEnlargeSmallerImages = value;
if (zoomToFit()) {
setZoom(computeZoomToFit());
}
}
void RasterImageView::loadFromDocument() {
Document::Ptr doc = document();
connect(doc.data(), SIGNAL(metaInfoLoaded(KUrl)),
......
......@@ -38,6 +38,11 @@ class RasterImageViewPrivate;
class GWENVIEWLIB_EXPORT RasterImageView : public AbstractImageView {
Q_OBJECT
public:
enum AlphaBackgroundMode {
AlphaBackgroundCheckBoard,
AlphaBackgroundSolid
};
RasterImageView(QGraphicsItem* parent = 0);
~RasterImageView();
......@@ -46,6 +51,10 @@ public:
void setCurrentTool(AbstractRasterImageViewTool* tool);
AbstractRasterImageViewTool* currentTool() const;
void setAlphaBackgroundMode(AlphaBackgroundMode mode);
void setAlphaBackgroundColor(const QColor& color);
void setEnlargeSmallerImages(bool value);
Q_SIGNALS:
void currentToolChanged(AbstractRasterImageViewTool*);
......
......@@ -7,7 +7,7 @@
<kcfgfile name="gwenviewrc"/>
<include>lib/sorting.h</include>
<include>lib/mousewheelbehavior.h</include>
<include>lib/imageview.h</include>
<include>lib/documentview/rasterimageview.h</include>
<include>lib/print/printoptionspage.h</include>
<group name="SideBar">
<entry name="PreferredMetaInfoKeyList" type="StringList">
......@@ -90,11 +90,11 @@
<group name="ImageView">
<entry name="AlphaBackgroundMode" type="Enum">
<choices name="Gwenview::ImageView::AlphaBackgroundMode">
<choice name="ImageView::AlphaBackgroundCheckBoard"/>
<choice name="ImageView::AlphaBackgroundSolid"/>
<choices name="Gwenview::RasterImageView::AlphaBackgroundMode">
<choice name="RasterImageView::AlphaBackgroundCheckBoard"/>
<choice name="RasterImageView::AlphaBackgroundSolid"/>
</choices>
<default>ImageView::AlphaBackgroundCheckBoard</default>
<default>RasterImageView::AlphaBackgroundCheckBoard</default>
</entry>
<entry name="AlphaBackgroundColor" type="Color">
<default>#ffffff</default>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment