diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Tools/QtTestBrowser/locationedit.cpp | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Tools/QtTestBrowser/locationedit.cpp')
-rw-r--r-- | Tools/QtTestBrowser/locationedit.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Tools/QtTestBrowser/locationedit.cpp b/Tools/QtTestBrowser/locationedit.cpp index 85bd222..04a6018 100644 --- a/Tools/QtTestBrowser/locationedit.cpp +++ b/Tools/QtTestBrowser/locationedit.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 2011 Andreas Kling <kling@webkit.org> * * All rights reserved. * @@ -29,12 +30,35 @@ #ifndef QT_NO_INPUTDIALOG +static const QSize gPageIconSize(16, 16); + +static QPixmap defaultPageIcon() +{ + static QPixmap icon; + if (icon.isNull()) + icon.load(":/favicon.png"); + + return icon; +} + LocationEdit::LocationEdit(QWidget* parent) : QLineEdit(parent) , m_progress(0) { m_clearTimer.setSingleShot(true); connect(&m_clearTimer, SIGNAL(timeout()), this, SLOT(reset())); + + m_pageIconLabel = new QLabel(this); + m_pageIconLabel->setFixedSize(gPageIconSize); + m_pageIconLabel->setPixmap(defaultPageIcon()); +} + +void LocationEdit::setPageIcon(const QIcon& icon) +{ + if (icon.isNull()) + m_pageIconLabel->setPixmap(defaultPageIcon()); + else + m_pageIconLabel->setPixmap(icon.pixmap(gPageIconSize)); } void LocationEdit::setProgress(int progress) @@ -49,6 +73,30 @@ void LocationEdit::reset() setProgress(0); } +void LocationEdit::resizeEvent(QResizeEvent*) +{ + updateInternalGeometry(); +} + +void LocationEdit::updateInternalGeometry() +{ + QStyleOptionFrameV3 styleOption; + initStyleOption(&styleOption); + + QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &styleOption, this); + + const int spacing = 2; + + int x = textRect.x() + spacing; + int y = (textRect.center().y() + 1) - gPageIconSize.height() / 2; + + m_pageIconLabel->move(x, y); + + QMargins margins = textMargins(); + margins.setLeft(m_pageIconLabel->sizeHint().width() + spacing); + setTextMargins(margins); +} + void LocationEdit::paintEvent(QPaintEvent* ev) { QColor backgroundColor = QApplication::palette().color(QPalette::Base); |