36 #include <QMouseEvent>
78 QRect rect = contentsRect();
95 height = rect.height();
98 double layout_ar = width / height;
100 if (layout_ar > image_ar)
103 width = height * image_ar;
108 height = width / image_ar;
110 rect.setWidth(
int(width + 0.5));
111 rect.setHeight(
int(height + 0.5));
114 int border = lineWidth();
115 resize(rect.width() + 2 * border, rect.height() + 2 * border);
125 int border = lineWidth();
126 QSize new_size = size;
127 new_size += QSize(2 * border, 2 * border);
128 setMinimumSize(new_size);
134 int border = lineWidth();
135 QSize new_size = size;
136 new_size += QSize(2 * border, 2 * border);
137 setMaximumSize(new_size);
158 QPainter painter(
this);
167 painter.drawImage(contentsRect(),
qimage_);
169 if (contentsRect().width() ==
qimage_.width()) {
170 painter.drawImage(contentsRect(),
qimage_);
172 QImage image =
qimage_.scaled(contentsRect().width(), contentsRect().height(),
173 Qt::KeepAspectRatio, Qt::SmoothTransformation);
174 painter.drawImage(contentsRect(), image);
179 QLinearGradient gradient(0, 0, frameRect().width(), frameRect().height());
180 gradient.setColorAt(0, Qt::white);
181 gradient.setColorAt(1, Qt::black);
182 painter.setBrush(gradient);
183 painter.drawRect(0, 0, frameRect().width() + 1, frameRect().height() + 1);
199 if(mouseEvent->button() == Qt::LeftButton)
201 emit
mouseLeft(mouseEvent->x(), mouseEvent->y());
203 QFrame::mousePressEvent(mouseEvent);