┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/tooltips/filemetadatatooltip.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-03-22 18:43:12 +0100
committerPeter Penz <[email protected]>2011-03-22 18:46:11 +0100
commite3063e001a016849276b65527ac56c26d56b5f30 (patch)
tree5f9c230a21f3cf6c4ad75cb0be085c06ebcf1d2b /src/views/tooltips/filemetadatatooltip.cpp
parentdfe02a06b5de4df9def4f16fa6d1829887b18247 (diff)
Tooltip improvements
- Use the default style for drawing the tooltip background - Get rid of the workaround to keep only one KFileMetaDataWidget instance. This is not required anymore as internally in KFileMetaDataWidget a process is used to get the metadata instead of a thread.
Diffstat (limited to 'src/views/tooltips/filemetadatatooltip.cpp')
-rw-r--r--src/views/tooltips/filemetadatatooltip.cpp55
1 files changed, 9 insertions, 46 deletions
diff --git a/src/views/tooltips/filemetadatatooltip.cpp b/src/views/tooltips/filemetadatatooltip.cpp
index b8e1724d8..deda38ab6 100644
--- a/src/views/tooltips/filemetadatatooltip.cpp
+++ b/src/views/tooltips/filemetadatatooltip.cpp
@@ -26,7 +26,8 @@
#include <KWindowSystem>
#include <QLabel>
-#include <QPainter>
+#include <QStyleOptionFrame>
+#include <QStylePainter>
#include <QVBoxLayout>
FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
@@ -49,7 +50,7 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
m_name->setFont(font);
// Create widget for the meta data
- m_fileMetaDataWidget = new KFileMetaDataWidget();
+ m_fileMetaDataWidget = new KFileMetaDataWidget(this);
m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText);
m_fileMetaDataWidget->setReadOnly(true);
connect(m_fileMetaDataWidget, SIGNAL(metaDataRequestFinished(KFileItemList)),
@@ -112,51 +113,13 @@ KFileItemList FileMetaDataToolTip::items() const
void FileMetaDataToolTip::paintEvent(QPaintEvent* event)
{
- Q_UNUSED(event);
+ QStylePainter painter(this);
+ QStyleOptionFrame option;
+ option.init(this);
+ painter.drawPrimitive(QStyle::PE_PanelTipLabel, option);
+ painter.end();
- QPainter painter(this);
-
- QColor toColor = palette().brush(QPalette::ToolTipBase).color();
- QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);
-
- const bool haveAlphaChannel = KWindowSystem::compositingActive();
- if (haveAlphaChannel) {
- painter.setRenderHint(QPainter::Antialiasing);
- painter.translate(0.5, 0.5);
- toColor.setAlpha(220);
- fromColor.setAlpha(220);
- }
-
- QLinearGradient gradient(QPointF(0.0, 0.0), QPointF(0.0, height()));
- gradient.setColorAt(0.0, fromColor);
- gradient.setColorAt(1.0, toColor);
- painter.setPen(Qt::NoPen);
- painter.setBrush(gradient);
-
- const QRect rect(0, 0, width(), height());
- if (haveAlphaChannel) {
- const qreal radius = 5.0;
-
- QPainterPath path;
- path.moveTo(rect.left(), rect.top() + radius);
- arc(path, rect.left() + radius, rect.top() + radius, radius, 180, -90);
- arc(path, rect.right() - radius, rect.top() + radius, radius, 90, -90);
- arc(path, rect.right() - radius, rect.bottom() - radius, radius, 0, -90);
- arc(path, rect.left() + radius, rect.bottom() - radius, radius, 270, -90);
- path.closeSubpath();
-
- painter.drawPath(path);
- } else {
- painter.drawRect(rect);
- }
-}
-
-void FileMetaDataToolTip::arc(QPainterPath& path,
- qreal cx, qreal cy,
- qreal radius, qreal angle,
- qreal sweepLength)
-{
- path.arcTo(cx-radius, cy-radius, radius * 2, radius * 2, angle, sweepLength);
+ QWidget::paintEvent(event);
}
#include "filemetadatatooltip.moc"