diff options
author | Arno <am@disconnect.de> | 2011-04-30 11:20:53 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2011-04-30 11:20:53 +0200 |
commit | f0ac8500b63511a8307f332c4b86670545fc4ca6 (patch) | |
tree | a295e591c9c001f4c873c87a6407717c28f14c79 | |
parent | 9b7075a7fbd3550dec0c98f6d0b4680830324085 (diff) | |
download | SheMov-f0ac8500b63511a8307f332c4b86670545fc4ca6.tar.gz SheMov-f0ac8500b63511a8307f332c4b86670545fc4ca6.tar.bz2 SheMov-f0ac8500b63511a8307f332c4b86670545fc4ca6.zip |
Use BG-Gradient in PictureViewer
Use setGradient in PictureViewer again. Modified it to take the
colors for the gradient from the top left and bottom right of the
QImage.
-rw-r--r-- | pictureviewer.cpp | 8 | ||||
-rw-r--r-- | pictureviewer.h | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/pictureviewer.cpp b/pictureviewer.cpp index 33131de..502c544 100644 --- a/pictureviewer.cpp +++ b/pictureviewer.cpp @@ -29,6 +29,7 @@ void PictureViewer::showPic(const QString &path, bool enableDirEntries){ if(!fi.exists() || fi.isDir()){ return; } + QPixmap img(path); if(img.isNull()){ return; @@ -68,6 +69,7 @@ void PictureViewer::showPic(const QString &path, bool enableDirEntries){ resize(img.size() + QSize(20, 20)); setSceneRect(viewport()->rect()); + setGradient(img.toImage()); QGraphicsPixmapItem *item = new QGraphicsPixmapItem(img); mCurrentPic = item; item->setPos(center(img)); @@ -134,9 +136,9 @@ void PictureViewer::wheelEvent(QWheelEvent *event){ } } -void PictureViewer::setGradient(){ - QColor c1(255, 7, 15); - QColor c2(80, 55, 250); +void PictureViewer::setGradient(const QImage &img){ + QColor c1(img.pixel(2, 2)); + QColor c2(img.pixel(img.width() - 2, img.height() - 2)); QLinearGradient g(QPointF(0, 0), sceneRect().bottomRight()); g.setColorAt(0, c1); g.setColorAt(1, c2); diff --git a/pictureviewer.h b/pictureviewer.h index 83c43d3..d4fba4c 100644 --- a/pictureviewer.h +++ b/pictureviewer.h @@ -31,7 +31,7 @@ class PictureViewer : public QGraphicsView { void wheelEvent(QWheelEvent *event); private: - void setGradient(); + void setGradient(const QImage &img); void setDir(const QString &path); bool isPic(const QString &path); QPointF center(const QPixmap &pic); |