1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[LocationBar] Tweaked Linux theme. No longer hardcode height

It is now specified only minimum height.
Fixes issue with locationbar being too small with bigger fonts.
This commit is contained in:
nowrep 2014-03-16 09:38:28 +01:00
parent 23a599ed75
commit caabbc237f
7 changed files with 79 additions and 109 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 152 B

View File

@ -129,13 +129,8 @@ IconProvider
/*LocationBar*/
#locationbar
{
border-width: 4px;
padding-right: -4px;
padding-left: -4px;
padding-top: -2px;
padding-bottom: -2px;
qproperty-fixedheight: 27;
qproperty-leftMargin: 26;
qproperty-minHeight: 28;
qproperty-leftMargin: 22;
}
#locationbar[secured="true"]
@ -156,14 +151,15 @@ IconProvider
#locationbar-siteicon
{
padding-left: 6px;
border-image: url(images/transp.png);
qproperty-fixedsize:30px 27px;
padding-left: 0px;
qproperty-fixedsize: 22px 16px;
}
#locationbar-rss-icon
{
qproperty-pixmap: url(images/rss.png);
qproperty-fixedsize: 16px 16px;
}
#locationbar-goicon
@ -183,6 +179,33 @@ IconProvider
qproperty-pixmap: url(images/key.png);
}
/*WebSearchBar*/
#websearchbar
{
qproperty-minHeight: 28;
qproperty-leftMargin: 30;
}
#websearchbar-searchbutton
{
qproperty-fixedsize: 22px 16px;
qproperty-themeIcon: "edit-find";
qproperty-fallbackIcon: url(images/edit-find.png);
}
#websearchbar-searchprovider-comobobox
{
border-image: url(images/websearch-bg.png);
padding-right: 6px;
padding-left: 2px;
qproperty-fixedsize: 32px 16px;
}
#websearchbar-searchprovider-comobobox::menu-indicator
{
image: none;
}
/*BookmarksToolbar*/
#bookmarksbar QToolButton
{
@ -202,35 +225,6 @@ IconProvider
background: transparent;
}
/*WebSearchBar*/
#websearchbar
{
border-width: 4px;
padding-right: -4px;
padding-top: -2px;
padding-bottom: -2px;
qproperty-fixedheight: 27;
qproperty-leftMargin: 30;
}
#websearchbar-searchbutton
{
qproperty-fixedsize: 20px 16px;
qproperty-themeIcon: "edit-find";
qproperty-fallbackIcon: url(images/edit-find.png);
}
#websearchbar-searchprovider-comobobox
{
border-image: url(images/websearch-bg.png);
padding-left:-8px;
qproperty-fixedsize: 37px 27px;
}
#websearchbar-searchprovider-comobobox::menu-indicator
{
image: none;
}
/*SourceViewer*/
#sourceviewer-textedit

View File

@ -28,6 +28,7 @@
SideWidget::SideWidget(QWidget* parent)
: QWidget(parent)
{
setCursor(Qt::ArrowCursor);
}
bool SideWidget::event(QEvent* event)
@ -35,6 +36,7 @@ bool SideWidget::event(QEvent* event)
if (event->type() == QEvent::LayoutRequest) {
emit sizeHintChanged();
}
return QWidget::event(event);
}
@ -42,23 +44,13 @@ LineEdit::LineEdit(QWidget* parent)
: QLineEdit(parent)
, m_leftLayout(0)
, m_rightLayout(0)
, m_minHeight(0)
, m_leftMargin(-1)
, m_ignoreMousePress(false)
{
init();
}
LineEdit::LineEdit(const QString &contents, QWidget* parent)
: QLineEdit(contents, parent)
, m_leftWidget(0)
, m_rightWidget(0)
, m_leftLayout(0)
, m_rightLayout(0)
, m_leftMargin(0)
{
init();
}
void LineEdit::setLeftMargin(int margin)
{
m_leftMargin = margin;
@ -66,12 +58,6 @@ void LineEdit::setLeftMargin(int margin)
void LineEdit::init()
{
// We use setTextMargins() instead of padding property, and we should
// uncomment following line or just update padding property of LineEdit's
// subclasses in all themes and use same value for padding-left and padding-right,
// with this new implementation padding-left and padding-right show padding from
// edges of m_leftWidget and m_rightWidget.
mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
@ -79,41 +65,24 @@ void LineEdit::init()
m_leftWidget = new SideWidget(this);
m_leftWidget->resize(0, 0);
m_leftLayout = new QHBoxLayout(m_leftWidget);
m_leftLayout->setContentsMargins(0, 0, 2, 0);
if (isRightToLeft()) {
m_leftLayout->setDirection(QBoxLayout::RightToLeft);
}
else {
m_leftLayout->setDirection(QBoxLayout::LeftToRight);
}
m_leftLayout->setSizeConstraint(QLayout::SetFixedSize);
m_leftLayout->setContentsMargins(0, 0, 0, 0);
m_leftLayout->setDirection(isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight);
m_rightWidget = new SideWidget(this);
m_rightWidget->resize(0, 0);
m_rightLayout = new QHBoxLayout(m_rightWidget);
if (isRightToLeft()) {
m_rightLayout->setDirection(QBoxLayout::RightToLeft);
}
else {
m_rightLayout->setDirection(QBoxLayout::LeftToRight);
}
m_rightLayout->setDirection(isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight);
m_rightLayout->setContentsMargins(0, 0, 2, 0);
QSpacerItem* horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
mainLayout->addWidget(m_leftWidget, 0, Qt::AlignVCenter | Qt::AlignLeft);
mainLayout->addItem(horizontalSpacer);
mainLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
mainLayout->addWidget(m_rightWidget, 0, Qt::AlignVCenter | Qt::AlignRight);
// by this we undo reversing of layout when direction is RTL.
// TODO: don't do this and show reversed icon when needed
mainLayout->setDirection(isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight);
setWidgetSpacing(3);
connect(m_leftWidget, SIGNAL(sizeHintChanged()),
this, SLOT(updateTextMargins()));
connect(m_rightWidget, SIGNAL(sizeHintChanged()),
this, SLOT(updateTextMargins()));
connect(m_leftWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins()));
connect(m_rightWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins()));
}
bool LineEdit::event(QEvent* event)
@ -170,22 +139,6 @@ int LineEdit::widgetSpacing() const
return m_leftLayout->spacing();
}
int LineEdit::textMargin(WidgetPosition position) const
{
int spacing = m_rightLayout->spacing();
int w = 0;
if (position == LeftSide) {
w = m_leftWidget->sizeHint().width();
}
else {
w = m_rightWidget->sizeHint().width();
}
if (w == 0) {
return 0;
}
return w + spacing * 2;
}
int LineEdit::leftMargin() const
{
return m_leftMargin;
@ -213,12 +166,38 @@ void LineEdit::clearTextFormat()
setTextFormat(TextFormat());
}
int LineEdit::minHeight() const
{
return m_minHeight;
}
void LineEdit::setMinHeight(int height)
{
m_minHeight = height;
}
QSize LineEdit::sizeHint() const
{
QSize s = QLineEdit::sizeHint();
if (s.height() < m_minHeight) {
s.setHeight(m_minHeight);
}
return s;
}
void LineEdit::updateTextMargins()
{
int left = m_leftMargin < 0 ? m_leftWidget->sizeHint().width() : m_leftMargin;
int left = m_leftWidget->sizeHint().width();
int right = m_rightWidget->sizeHint().width();
int top = 0;
int bottom = 0;
if (m_leftMargin >= 0) {
left = m_leftMargin;
}
setTextMargins(left, top, right, bottom);
}

View File

@ -66,7 +66,11 @@ class SideWidget;
class QUPZILLA_EXPORT LineEdit : public QLineEdit
{
Q_OBJECT
Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize)
Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin)
Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth)
Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight)
Q_PROPERTY(int minHeight READ minHeight WRITE setMinHeight)
public:
typedef QList<QTextLayout::FormatRange> TextFormat;
@ -77,18 +81,21 @@ public:
};
LineEdit(QWidget* parent = 0);
LineEdit(const QString &contents, QWidget* parent = 0);
void addWidget(QWidget* widget, WidgetPosition position);
void removeWidget(QWidget* widget);
void setWidgetSpacing(int spacing);
int widgetSpacing() const;
int textMargin(WidgetPosition position) const;
int leftMargin() const;
void setTextFormat(const TextFormat &format);
void clearTextFormat();
int minHeight() const;
void setMinHeight(int height);
QSize sizeHint() const;
public slots:
void setLeftMargin(int margin);
void updateTextMargins();
@ -109,6 +116,7 @@ private:
QHBoxLayout* m_rightLayout;
QHBoxLayout* mainLayout;
int m_minHeight;
int m_leftMargin;
bool m_ignoreMousePress;
};

View File

@ -69,11 +69,6 @@ LocationBar::LocationBar(BrowserWindow* window)
m_autofillIcon = new AutoFillIcon(this);
DownIcon* down = new DownIcon(this);
// RTL Support
// if we don't add 'm_siteIcon' by following code, then we should use suitable padding-left value
// but then, when typing RTL text the layout dynamically changed and within RTL layout direction
// padding-left is equivalent to padding-right and vice versa, and because style sheet is
// not changed dynamically this create padding problems.
addWidget(m_siteIcon, LineEdit::LeftSide);
addWidget(m_autofillIcon, LineEdit::RightSide);

View File

@ -39,9 +39,6 @@ class AutoFillIcon;
class QUPZILLA_EXPORT LocationBar : public LineEdit
{
Q_OBJECT
Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize)
Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth)
Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight)
public:
explicit LocationBar(BrowserWindow* window);

View File

@ -47,9 +47,6 @@ private:
class QUPZILLA_EXPORT WebSearchBar : public LineEdit
{
Q_OBJECT
Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize)
Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth)
Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight)
public:
explicit WebSearchBar(BrowserWindow* window);