summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-11-11 18:43:40 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-11-11 18:43:40 +0530
commit0b7f37d887273cbfb67c9edcf8e50fe088650746 (patch)
tree16f9dffe9bca43b77b25e904b4fbf6b8254b5843
parentd1a7d2575f795711c54285b2dcb1c601ff1f9f83 (diff)
refactoring: make the frame padding changeable easily in code
-rw-r--r--webscrap.cpp17
-rw-r--r--webscrap.h2
2 files changed, 12 insertions, 7 deletions
diff --git a/webscrap.cpp b/webscrap.cpp
index 34d4fa3..c7649c0 100644
--- a/webscrap.cpp
+++ b/webscrap.cpp
@@ -11,6 +11,9 @@
#include <QStyle>
#include "webscrap.h"
+const int WebScrapContainer::s_titlePadding = 25; // padding on the top of the scrap
+const int WebScrapContainer::s_padding = 5; // padding on the other three sides
+
WebScrap::WebScrap(QUrl url, QRect scrapRect, QGraphicsItem * parent)
: QGraphicsWebView(parent)
{
@@ -204,14 +207,14 @@ WebScrapContainer::WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene, qre
QPainterPath path;
QRect scrapRect = scrap->scrapRect();
QRect containerRect(0, 0,
- (scrapRect.width() * xScale) + 10,
- (scrapRect.height() * yScale)+ 30);
+ (scrapRect.width() * xScale) + s_padding * 2,
+ (scrapRect.height() * yScale) + s_titlePadding + s_padding);
setGeometry(containerRect);
path.addRoundedRect(containerRect, 10, 10);
m_frame->setPath(path);
setFlag(QGraphicsItem::ItemIsMovable, true);
scrap->setParentItem(m_frame);
- scrap->setPos(5, 25);
+ scrap->setPos(s_padding, s_titlePadding);
QLinearGradient gradient;
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
@@ -417,9 +420,9 @@ void WebScrapContainer::handleResetZoomClicked() {
m_scrapScale->setXScale(1.0);
m_scrapScale->setYScale(1.0);
QSize scrapSize = webScrap()->size().toSize();
- setGeometry(geometry().left(), geometry().top(), scrapSize.width() + 10, scrapSize.height() + 30);
+ setGeometry(geometry().left(), geometry().top(), scrapSize.width() + s_padding * 2, scrapSize.height() + s_titlePadding + s_padding);
QPainterPath path;
- path.addRoundedRect(0, 0, scrapSize.width() + 10, scrapSize.height() + 30, 10, 10);
+ path.addRoundedRect(0, 0, scrapSize.width() + s_padding * 2 * 2, scrapSize.height() + s_titlePadding + s_padding, s_padding * 2, s_padding * 2);
m_frame->setPath(path);
m_toolbar->setPos(m_frame->pos() + m_frame->boundingRect().topRight() - QPointF(m_toolbar->rect().width(), 0));
m_editToolbar->setPos(m_frame->pos() + m_frame->boundingRect().topRight() - QPointF(m_editToolbar->boundingRect().width() + 30, -30));
@@ -437,9 +440,9 @@ void WebScrapContainer::handleRectResized(QRectF rect) {
m_scrap->setScrapRect(scrapRect);
}
QSize scrapSize = QSize(rect.width() * m_scrapScale->xScale(), rect.height() * m_scrapScale->yScale());
- setGeometry(geometry().left(), geometry().top(), scrapSize.width() + 10, scrapSize.height() + 30);
+ setGeometry(geometry().left(), geometry().top(), scrapSize.width() + s_padding * 2, scrapSize.height() + s_titlePadding + s_padding);
QPainterPath path;
- path.addRoundedRect(0, 0, scrapSize.width() + 10, scrapSize.height() + 30, 10, 10);
+ path.addRoundedRect(0, 0, scrapSize.width() + s_padding * 2, scrapSize.height() + s_titlePadding + s_padding, 10, 10);
m_frame->setPath(path);
m_toolbar->setPos(m_frame->pos() + m_frame->boundingRect().topRight() - QPointF(m_toolbar->rect().width(), 0));
m_editToolbar->setPos(m_frame->pos() + m_frame->boundingRect().topRight() - QPointF(m_editToolbar->boundingRect().width() + 30, -30));
diff --git a/webscrap.h b/webscrap.h
index e9add7e..7dd78e4 100644
--- a/webscrap.h
+++ b/webscrap.h
@@ -60,6 +60,8 @@ private:
class WebScrapContainer : public QGraphicsWidget {
Q_OBJECT
public:
+ const static int s_padding, s_titlePadding;
+
WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene, qreal xScale = 1.0, qreal yScale = 1.0);
void createToolbar();
void createEditToolbar();