summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/urlbar/urlbar.cpp33
-rw-r--r--src/urlbar/urlbar.h5
2 files changed, 24 insertions, 14 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 5e0a0f1a..abbf1296 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -62,6 +62,8 @@
#include <QClipboard>
#include <QTimer>
+// const values
+const int c_iconMargin = 4;
IconButton::IconButton(QWidget *parent)
@@ -414,7 +416,7 @@ void UrlBar::loadFinished()
// removing this code (where setStyleSheet automatically calls update) needs adding again
// an update call
int oneIconWidth = _icon->sizeHint().width();
- int rightIconWidth = (oneIconWidth + 4) * (_rightIconsList.count());
+ int rightIconWidth = (oneIconWidth + c_iconMargin) * (_rightIconsList.count());
setStyleSheet(QString("UrlBar { padding: 2px %2px 2px %1px; height: %1px } ").arg(oneIconWidth).arg(rightIconWidth));
}
@@ -599,14 +601,9 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
_rightIconsList << rightIcon;
- int iw = _icon->width();
- int ih = _icon->height();
- int iconsCount = _rightIconsList.count();
+ int iconsCount = _rightIconsList.count();
+ updateRightIconPosition(rightIcon, iconsCount);
- int iconWidth = width() - ((iw + 4) * iconsCount);
- int iconHeight = (height() - ih) / 2;
-
- rightIcon->move(iconWidth, iconHeight);
rightIcon->show();
return rightIcon;
@@ -622,20 +619,16 @@ void UrlBar::clearRightIcons()
void UrlBar::resizeEvent(QResizeEvent *event)
{
- int iw = _icon->width();
int ih = _icon->height();
int iconsCount = _rightIconsList.count();
-
int iconHeight = (height() - ih) / 2;
- _icon->move(4, iconHeight);
-
- int w = width();
+ _icon->move(c_iconMargin, iconHeight);
for (int i = 0; i < iconsCount; ++i)
{
IconButton *bt = _rightIconsList.at(i);
- bt->move(w - (iw + 4) * (i + 1), iconHeight);
+ updateRightIconPosition(bt, i + 1);
}
KLineEdit::resizeEvent(event);
@@ -753,3 +746,15 @@ void UrlBar::manageFavorites(QPoint pos)
updateRightIcons();
}
+
+
+void UrlBar::updateRightIconPosition(IconButton *icon, int iconsCount)
+{
+ int iw = _icon->width();
+ int ih = _icon->height();
+
+ int iconWidth = width() - ((iw + c_iconMargin) * iconsCount);
+ int iconHeight = (height() - ih) / 2;
+
+ icon->move(iconWidth, iconHeight);
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 4f2586bc..fadd2f95 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -131,6 +131,11 @@ protected:
void resizeEvent(QResizeEvent *);
private:
+ /**
+ * Updates right icon position, given its number in the right icons list
+ * and considering rekonq window position/dimension
+ */
+ void updateRightIconPosition(IconButton *, int);
IconButton *addRightIcon(UrlBar::icon);
QWeakPointer<CompletionWidget> _box;