summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Tröscher <fritz_van_tom@hotmail.com>2011-09-09 18:47:32 +0200
committerJohannes Tröscher <fritz_van_tom@hotmail.com>2011-09-09 18:47:32 +0200
commit01a3922568ca12d0901ac6dee50794bc2b62c938 (patch)
treea8beccdaa14531c52f9fa8971d374148dd0fb1b7
parentoops... forgot to update ui.rc number... (diff)
downloadrekonq-01a3922568ca12d0901ac6dee50794bc2b62c938.tar.xz
exact tooltip look for tabPreviewPopup
REVIEWED-BY: me
-rw-r--r--src/tabpreviewpopup.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/tabpreviewpopup.cpp b/src/tabpreviewpopup.cpp
index 2a35a63e..b94cf425 100644
--- a/src/tabpreviewpopup.cpp
+++ b/src/tabpreviewpopup.cpp
@@ -43,10 +43,6 @@
#include <QStylePainter>
#include <QStyleOptionFrame>
-// static
-static const int borderRadius = 5;
-static const double transparency = 0.90;
-
TabPreviewPopup::TabPreviewPopup(WebTab* tab, QWidget* parent)
: KPassivePopup(parent),
@@ -66,6 +62,7 @@ TabPreviewPopup::TabPreviewPopup(WebTab* tab, QWidget* parent)
setPopupStyle(KPassivePopup::CustomStyle + 1);
+ // use ToolTip appearance
QPalette p;
// adjust background color to use tooltip colors
@@ -77,8 +74,15 @@ TabPreviewPopup::TabPreviewPopup(WebTab* tab, QWidget* parent)
p.setColor(QPalette::Text, p.color(QPalette::ToolTipText));
setPalette(p);
- setWindowOpacity(transparency);
+
+ // window flags and attributes
setWindowFlags(Qt::ToolTip);
+ setAttribute(Qt::WA_TranslucentBackground);
+ setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
+
+ // margins
+ const int margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
+ setContentsMargins(margin, margin, margin, margin);
setWebTab(tab);
}
@@ -115,7 +119,8 @@ void TabPreviewPopup::setUrl(const QString& text)
void TabPreviewPopup::setFixedSize(int w, int h)
{
KPassivePopup::setFixedSize(w, h);
- m_url->setText(m_url->fontMetrics().elidedText(m_url->text(), Qt::ElideMiddle, this->width() - borderRadius));
+ const int margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
+ m_url->setText(m_url->fontMetrics().elidedText(m_url->text(), Qt::ElideMiddle, this->width() - margin * 2));
//calculate mask
QStyleOptionFrame opt;