]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Since Qt 4.5 it is possible to have translucient windows. The tooltip approach having...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 3 Nov 2009 21:48:27 +0000 (21:48 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 3 Nov 2009 21:48:27 +0000 (21:48 +0000)
Additionally the tooltip uses now KMetaDataWidget instead of using KMetaInfo. This assures that no blocking of the application will occur even if there is a buggy Strigi analyzer that ignores the maximum size-setting and might block the retrieving of the meta data.

BUG: 182941
BUG: 195878

svn path=/trunk/KDE/kdebase/apps/; revision=1044485

16 files changed:
src/CMakeLists.txt
src/pixmapviewer.h
src/tooltips/dolphintooltip.cpp [deleted file]
src/tooltips/kformattedballoontipdelegate.cpp [deleted file]
src/tooltips/kformattedballoontipdelegate.h [deleted file]
src/tooltips/ktooltip.cpp
src/tooltips/ktooltip.h
src/tooltips/ktooltip_p.h
src/tooltips/ktooltipdelegate.cpp [deleted file]
src/tooltips/ktooltipdelegate.h [deleted file]
src/tooltips/ktooltipitem.cpp [deleted file]
src/tooltips/ktooltipitem.h [deleted file]
src/tooltips/ktooltipwindow.cpp [new file with mode: 0644]
src/tooltips/ktooltipwindow_p.h [moved from src/tooltips/dolphintooltip.h with 63% similarity]
src/tooltips/tooltipmanager.cpp
src/tooltips/tooltipmanager.h

index f3436785493b5bb1e42f4699e8ac1df62864bfa4..2c08a1ef9daa09d89994a0cc7f0ba2316127b9c1 100644 (file)
@@ -41,11 +41,8 @@ set(dolphinprivate_LIB_SRCS
     settings/dolphinsettings.cpp
     settings/viewpropertiesdialog.cpp
     settings/viewpropsprogressinfo.cpp
-    tooltips/dolphintooltip.cpp
     tooltips/ktooltip.cpp
-    tooltips/ktooltipdelegate.cpp
-    tooltips/ktooltipitem.cpp
-    tooltips/kformattedballoontipdelegate.cpp
+    tooltips/ktooltipwindow.cpp
     tooltips/tooltipmanager.cpp
     versioncontrolobserver.cpp
     viewextensionsfactory.cpp
index 26e520aab3bc05e117bbdf1d242aa4c011891580..c15750bb78a0d0a0127e9f6cd4d0023d2c915531 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     virtual ~PixmapViewer();
     void setPixmap(const QPixmap& pixmap);
-    const QPixmap& pixmap() const;
+    QPixmap pixmap() const;
 
     /**
      * Sets the size hint to \a size and triggers a relayout
@@ -89,7 +89,7 @@ private:
     QSize m_sizeHint;
 };
 
-inline const QPixmap& PixmapViewer::pixmap() const
+inline QPixmap PixmapViewer::pixmap() const
 {
     return m_pixmap;
 }
diff --git a/src/tooltips/dolphintooltip.cpp b/src/tooltips/dolphintooltip.cpp
deleted file mode 100644 (file)
index 63e1c40..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Simon St James <kdedevel@etotheipiplusone.com>  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "dolphintooltip.h"
-
-#include <kicon.h>
-#include <kio/previewjob.h>
-#include <kfileitem.h>
-
-#include <QtGui/QPixmap>
-
-DolphinBalloonTooltipDelegate::DolphinBalloonTooltipDelegate()
-{
-}
-
-DolphinBalloonTooltipDelegate::~DolphinBalloonTooltipDelegate()
-{
-}
-
-// Delegate everything to the base class, after re-setting the decorationSize
-// to the preview size.
-QSize DolphinBalloonTooltipDelegate::sizeHint(const KStyleOptionToolTip& option, const KToolTipItem& item) const
-{
-    KStyleOptionToolTip updatedStyleOption = option;
-    updatedStyleOption.decorationSize = QSize(PREVIEW_WIDTH, PREVIEW_HEIGHT);
-    return KFormattedBalloonTipDelegate::sizeHint(updatedStyleOption, item);
-}
-
-void DolphinBalloonTooltipDelegate::paint(QPainter* painter,
-                                          const KStyleOptionToolTip& option,
-                                          const KToolTipItem& item) const
-{
-    KStyleOptionToolTip updatedStyleOption = option;
-    updatedStyleOption.decorationSize = QSize(PREVIEW_WIDTH, PREVIEW_HEIGHT);
-    return KFormattedBalloonTipDelegate::paint(painter, updatedStyleOption, item);
-}
diff --git a/src/tooltips/kformattedballoontipdelegate.cpp b/src/tooltips/kformattedballoontipdelegate.cpp
deleted file mode 100644 (file)
index 643068c..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>                   *
- *   Copyright (C) 2008 by Konstantin Heil <konst.heil@stud.uni-heidelberg.de> *
- *                                                                             *
- *   This program is free software; you can redistribute it and/or modify      *
- *   it under the terms of the GNU General Public License as published by      *
- *   the Free Software Foundation; either version 2 of the License, or         *
- *   (at your option) any later version.                                       *
- *                                                                             *
- *   This program is distributed in the hope that it will be useful,           *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
- *   GNU General Public License for more details.                              *
- *                                                                             *
- *   You should have received a copy of the GNU General Public License         *
- *   along with this program; if not, write to the                             *
- *   Free Software Foundation, Inc.,                                           *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                *
- *******************************************************************************/
-
-#include "kformattedballoontipdelegate.h"
-#include "ktooltipitem.h"
-#include "ktooltip.h"
-#include <QBitmap>
-#include <QIcon>
-#include <QLinearGradient>
-#include <QTextDocument>
-#include <kcolorscheme.h>
-
-KFormattedBalloonTipDelegate::KFormattedBalloonTipDelegate()
-{
-}
-
-KFormattedBalloonTipDelegate::~KFormattedBalloonTipDelegate()
-{
-}
-
-QSize KFormattedBalloonTipDelegate::sizeHint(const KStyleOptionToolTip &option, const KToolTipItem &item) const
-{
-    QTextDocument doc;
-    doc.setHtml(item.text());
-    const QIcon icon = item.icon();
-
-    const QSize iconSize = icon.isNull() ? QSize(0, 0) : icon.actualSize(option.decorationSize);
-    const QSize docSize = doc.size().toSize();
-    QSize contentSize = iconSize + docSize;
-
-    // assure that the content height is large enough for the icon and the document
-    contentSize.setHeight(iconSize.height() > doc.size().height() ? iconSize.height() : doc.size().height());
-    return contentSize + QSize(Border * 3, Border * 2);
-}
-
-void KFormattedBalloonTipDelegate::paint(QPainter *painter,
-                                         const KStyleOptionToolTip &option,
-                                         const KToolTipItem &item) const
-{
-    QColor toColor = option.palette.brush(QPalette::ToolTipBase).color();
-    QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);
-
-    QPainterPath path = createPath(option);
-    if (haveAlphaChannel()) {
-        painter->setRenderHint(QPainter::Antialiasing);
-        painter->translate(.5, .5);
-        toColor.setAlpha(220);
-        fromColor.setAlpha(220);
-    }
-
-    QLinearGradient gradient(option.rect.topLeft(), option.rect.bottomLeft());
-    gradient.setColorAt(0.0, fromColor);
-    gradient.setColorAt(1.0, toColor);
-    painter->setPen(Qt::NoPen);
-    painter->setBrush(gradient);
-
-    painter->drawPath(path);
-
-    const QIcon icon = item.icon();
-    int x = Border;
-    const int y = Border;
-    if (!icon.isNull()) {
-        const QSize iconSize = icon.actualSize(option.decorationSize);
-        const QPoint pos(x + option.rect.x(), y + option.rect.y());
-        painter->drawPixmap(pos, icon.pixmap(iconSize));
-        x += iconSize.width() + Border;
-    }
-
-    QTextDocument doc;
-    doc.setHtml(item.text());
-    QPixmap bitmap(doc.size().toSize());
-    bitmap.fill(Qt::transparent);
-    QPainter p(&bitmap);
-    doc.drawContents(&p);
-
-    const QRect docRect(QPoint(x, y), doc.size().toSize());
-    painter->drawPixmap(docRect, bitmap);
-}
-
-QRegion KFormattedBalloonTipDelegate::inputShape(const KStyleOptionToolTip &option) const
-{
-    QBitmap bitmap(option.rect.size());
-    bitmap.fill(Qt::color0);
-
-    QPainter p(&bitmap);
-    p.setPen(QPen(Qt::color1, 1));
-    p.setBrush(Qt::color1);
-    p.drawPath(createPath(option));
-
-    return QRegion(bitmap);
-}
-
-QRegion KFormattedBalloonTipDelegate::shapeMask(const KStyleOptionToolTip &option) const
-{
-    return inputShape(option);
-}
-
-static inline void 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);
-}
-
-QPainterPath KFormattedBalloonTipDelegate::createPath(const KStyleOptionToolTip& option) const
-{
-    const QRect rect = option.rect;
-    const qreal radius = 5;
-
-    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();
-
-    return path;
-}
diff --git a/src/tooltips/kformattedballoontipdelegate.h b/src/tooltips/kformattedballoontipdelegate.h
deleted file mode 100644 (file)
index bc8ab23..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>                   *
- *   Copyright (C) 2008 by Konstantin Heil <konst.heil@stud.uni-heidelberg.de> *
- *                                                                             *
- *   This program is free software; you can redistribute it and/or modify      *
- *   it under the terms of the GNU General Public License as published by      *
- *   the Free Software Foundation; either version 2 of the License, or         *
- *   (at your option) any later version.                                       *
- *                                                                             *
- *   This program is distributed in the hope that it will be useful,           *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
- *   GNU General Public License for more details.                              *
- *                                                                             *
- *   You should have received a copy of the GNU General Public License         *
- *   along with this program; if not, write to the                             *
- *   Free Software Foundation, Inc.,                                           *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                *
- *******************************************************************************/
-
-#ifndef KFORMATTEDBALLOONTIPDELEGATE_H
-#define KFORMATTEDBALLOONTIPDELEGATE_H
-
-#include <tooltips/ktooltipdelegate.h>
-#include <QPainter>
-
-class KFormattedBalloonTipDelegate : public KToolTipDelegate
-{
-public:
-    KFormattedBalloonTipDelegate();
-    virtual ~KFormattedBalloonTipDelegate();
-
-    virtual QSize sizeHint(const KStyleOptionToolTip &option, const KToolTipItem &item) const;
-    virtual void paint(QPainter *painter, const KStyleOptionToolTip &option, const KToolTipItem &item) const;
-    virtual QRegion inputShape(const KStyleOptionToolTip &option) const;
-    virtual QRegion shapeMask(const KStyleOptionToolTip &option) const;
-
-private:
-    QPainterPath createPath(const KStyleOptionToolTip& option) const;
-
-private:
-    enum { Border = 8 };
-};
-
-#endif
index 52a4d4a5f5beb5e010859d3339d03510d2158cab..c476fda1b3a89cb776a4c6bd73b199d22a33b32c 100644 (file)
  ***************************************************************************/
 
 #include "ktooltip.h"
-#include "ktooltip_p.h"
-#include "ktooltipdelegate.h"
-
-#include <QApplication>
-#include <QPainter>
+#include "ktooltipwindow_p.h"
+#include <QLabel>
+#include <QPoint>
 #include <QWidget>
-#include <QToolTip>
-
-#ifdef Q_WS_X11
-#  include <QX11Info>
-#  include <X11/Xlib.h>
-#  include <X11/extensions/shape.h>
-#endif
-
-// compile with XShape older than 1.0
-#ifndef ShapeInput
-const int ShapeInput = 2;
-#endif
-
 
-// ----------------------------------------------------------------------------
-
-
-class KTipLabel : public QWidget
+class KToolTipManager
 {
 public:
-    KTipLabel();
-    void showTip(const QPoint &pos, const KToolTipItem *item);
-    void moveTip(const QPoint &pos);
+    ~KToolTipManager();
+
+    static KToolTipManager* instance();
+
+    void showTip(const QPoint& pos, QWidget* content);
     void hideTip();
 
 private:
-    void paintEvent(QPaintEvent*);
-    QSize sizeHint() const;
-    KStyleOptionToolTip styleOption() const;
-    KToolTipDelegate *delegate() const;
+    KToolTipManager();
 
-private:
-    const KToolTipItem *m_currentItem;
+    KToolTipWindow* m_window;
+    static KToolTipManager *s_instance;
 };
 
-KTipLabel::KTipLabel() : QWidget(0, Qt::ToolTip)
-{
-#ifdef Q_WS_X11
-    if (QX11Info::isCompositingManagerRunning()) {
-        setAttribute(Qt::WA_TranslucentBackground);
-    }
-#endif
-}
-
-void KTipLabel::showTip(const QPoint &pos, const KToolTipItem *item)
-{
-    m_currentItem = item;
-    move(pos);
-    show();
-}
-
-void KTipLabel::hideTip()
-{
-    hide();
-    m_currentItem = 0;
-}
-
-void KTipLabel::moveTip(const QPoint &pos)
-{
-    move(pos);
-}
-
-void KTipLabel::paintEvent(QPaintEvent*)
-{
-    if (!m_currentItem)
-        return;
-    
-    KStyleOptionToolTip option = styleOption();
-    option.rect = rect();
-
-#ifdef Q_WS_X11
-    if (QX11Info::isCompositingManagerRunning())
-        XShapeCombineRegion(x11Info().display(), winId(), ShapeInput, 0, 0,
-                            delegate()->inputShape(option).handle(), ShapeSet);
-    else
-#endif
-    setMask(delegate()->shapeMask(option));
-
-    QPainter p(this);
-    p.setFont(option.font);
-    p.setPen(QPen(option.palette.brush(QPalette::Text), 0));
-    delegate()->paint(&p, option, *m_currentItem);
-}
-
-QSize KTipLabel::sizeHint() const
-{
-    if (!m_currentItem)
-        return QSize();
-
-    KStyleOptionToolTip option = styleOption();
-    return delegate()->sizeHint(option, *m_currentItem);
-}
-
-KStyleOptionToolTip KTipLabel::styleOption() const
-{
-     KStyleOptionToolTip option;
-     KToolTipManager::instance()->initStyleOption(&option);
-     return option;
-}
-
-KToolTipDelegate *KTipLabel::delegate() const
-{
-    return KToolTipManager::instance()->delegate();
-}
-
-
-// ----------------------------------------------------------------------------
-
-
 KToolTipManager *KToolTipManager::s_instance = 0;
 
-KToolTipManager::KToolTipManager()
-    : m_label(new KTipLabel), m_currentItem(0), m_delegate(0)
+KToolTipManager::KToolTipManager() :
+    m_window(0)
 {
 }
 
 KToolTipManager::~KToolTipManager()
 {
-    delete m_label;
-    delete m_currentItem;
-}
-
-void KToolTipManager::showTip(const QPoint &pos, KToolTipItem *item)
-{
-    hideTip();
-    m_label->showTip(pos, item);
-    m_currentItem = item;
-    m_tooltipPos = pos;
-}
-
-void KToolTipManager::hideTip()
-{
-    m_label->hideTip();
-    delete m_currentItem;
-    m_currentItem = 0;
+    delete m_window;
+    m_window = 0;
 }
 
-void KToolTipManager::initStyleOption(KStyleOptionToolTip *option) const
+KToolTipManager* KToolTipManager::instance()
 {
-    option->direction      = QApplication::layoutDirection();
-    option->fontMetrics    = QFontMetrics(QToolTip::font());
-    option->activeCorner   = KStyleOptionToolTip::TopLeftCorner;
-    option->palette        = QToolTip::palette();
-    option->font           = QToolTip::font();
-    option->rect           = QRect();
-    option->state          = QStyle::State_None;
-    option->decorationSize = QSize(32, 32);
-}
+    if (s_instance == 0) {
+        s_instance = new KToolTipManager();
+    }
 
-void KToolTipManager::setDelegate(KToolTipDelegate *delegate)
-{
-    m_delegate = delegate;
+    return s_instance;
 }
 
-void KToolTipManager::update()
+void KToolTipManager::showTip(const QPoint& pos, QWidget* content)
 {
-    if (m_currentItem == 0)
-        return;
-    m_label->showTip(m_tooltipPos, m_currentItem);
+    hideTip();
+    Q_ASSERT(m_window == 0);
+    m_window = new KToolTipWindow(content);
+    m_window->move(pos);
+    m_window->show();
 }
 
-KToolTipDelegate *KToolTipManager::delegate() const
+void KToolTipManager::hideTip()
 {
-    return m_delegate;
+    if (m_window != 0) {
+        m_window->hide();
+        delete m_window;
+        m_window = 0;
+    }
 }
 
-
-// ----------------------------------------------------------------------------
-
-
 namespace KToolTip
 {
-    void showText(const QPoint &pos, const QString &text, QWidget *widget, const QRect &rect)
-    {
-        Q_UNUSED(widget)
-        Q_UNUSED(rect)
-        KToolTipItem *item = new KToolTipItem(text);
-        KToolTipManager::instance()->showTip(pos, item);
-    }
-
-    void showText(const QPoint &pos, const QString &text, QWidget *widget)
+    void showText(const QPoint& pos, const QString& text)
     {
-        showText(pos, text, widget, QRect());
+        QLabel* label = new QLabel(text);
+        showTip(pos, label);
     }
 
-    void showTip(const QPoint &pos, KToolTipItem *item)
+    void showTip(const QPoint& pos, QWidget* content)
     {
-        KToolTipManager::instance()->showTip(pos, item);
+        KToolTipManager::instance()->showTip(pos, content);
     }
 
     void hideTip()
     {
         KToolTipManager::instance()->hideTip();
     }
-
-    void setToolTipDelegate(KToolTipDelegate *delegate)
-    {
-        KToolTipManager::instance()->setDelegate(delegate);
-    }
 }
 
index 6de08315c0ceeccf857cf3f199c802411bd9cc06..bd539b834c653da9f5eb20de6715103f6632bb02 100644 (file)
 #ifndef KTOOLTIP_H
 #define KTOOLTIP_H
 
-#include <tooltips/ktooltipitem.h>
-
-#include <QStyle>
-#include <QFontMetrics>
-class KToolTipDelegate;
+class QPoint;
+class QString;
+class QWidget;
 
 /**
- * KToolTip provides customizable tooltips that can have animations as well as an alpha
- * channel, allowing for dynamic transparency effects.
- *
- * ARGB tooltips work on X11 even when the application isn't using the ARGB visual.
+ * Allows to show tooltips having a widget as content.
  */
 namespace KToolTip
 {
-    void showText(const QPoint &pos, const QString &text, QWidget *widget, const QRect &rect);
-    void showText(const QPoint &pos, const QString &text, QWidget *widget = 0);
-
+    void showText(const QPoint& pos, const QString& text);
+    
     /**
-     * Shows the tip @p item at the global position indicated by @p pos.
+     * Shows the tip @p content at the global position indicated by @p pos.
      *
-     * Ownership of the item is transferred to KToolTip. The item will be deleted
+     * Ownership of the content widget is transferred to KToolTip. The widget will be deleted
      * automatically when it is hidden.
      *
      * The tip is shown immediately when this function is called.
      */
-    void showTip(const QPoint &pos, KToolTipItem *item);
+    void showTip(const QPoint& pos, QWidget* content);
     void hideTip();
-
-    void setToolTipDelegate(KToolTipDelegate *delegate);
 }
 
 #endif
index 5bc37236de695d4000b2328b3ce507aef6f9de1d..f586229736986bcea49fbcd335de63a296600f7a 100644 (file)
@@ -31,30 +31,15 @@ class KToolTipManager
 public:
     ~KToolTipManager();
 
-    static KToolTipManager *instance() {
-        if (!s_instance)
-            s_instance = new KToolTipManager();
+    static KToolTipManager* instance();
 
-        return s_instance;
-    }
-
-    void showTip(const QPoint &pos, KToolTipItem *item);
+    void showTip(const QPoint &pos, QWidget *tip);
     void hideTip();
 
-    void initStyleOption(KStyleOptionToolTip *option) const;
-
-    void setDelegate(KToolTipDelegate *delegate);
-    KToolTipDelegate *delegate() const;
-    
-    void update();
-
 private:
     KToolTipManager();
 
-    KTipLabel *m_label;
-    KToolTipItem *m_currentItem;
-    KToolTipDelegate *m_delegate;
-
+    QWidget *m_widget;
     QPoint m_tooltipPos;
 
     static KToolTipManager *s_instance;
diff --git a/src/tooltips/ktooltipdelegate.cpp b/src/tooltips/ktooltipdelegate.cpp
deleted file mode 100644 (file)
index 0141db1..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>               *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "ktooltipdelegate.h"
-
-#include "ktooltip.h"
-
-#include <QApplication>
-#include <QPainter>
-#include <QIcon>
-
-#ifdef Q_WS_X11
-#  include <QX11Info>
-#  include <X11/Xlib.h>
-#  include <X11/extensions/shape.h>
-#endif
-
-
-// ----------------------------------------------------------------------------
-
-
-KStyleOptionToolTip::KStyleOptionToolTip()
-    : fontMetrics(QApplication::font())
-{
-}
-
-
-// ----------------------------------------------------------------------------
-
-
-KToolTipDelegate::KToolTipDelegate() : QObject()
-{
-}
-
-KToolTipDelegate::~KToolTipDelegate()
-{
-}
-
-QSize KToolTipDelegate::sizeHint(const KStyleOptionToolTip &option, const KToolTipItem &item) const
-{
-    QSize size;
-    size.rwidth() = option.fontMetrics.width(item.text());
-    size.rheight() = option.fontMetrics.lineSpacing();
-
-    QIcon icon = item.icon();
-    if (!icon.isNull()) {
-        const QSize iconSize = icon.actualSize(option.decorationSize);
-        size.rwidth() += iconSize.width() + 4;
-        size.rheight() = qMax(size.height(), iconSize.height());
-    }
-
-    return size + QSize(20, 20);
-
-}
-
-void KToolTipDelegate::paint(QPainter *painter,
-                             const KStyleOptionToolTip &option,
-                             const KToolTipItem &item) const
-{
-    bool haveAlpha = haveAlphaChannel();
-    painter->setRenderHint(QPainter::Antialiasing);
-
-    QPainterPath path;
-    if (haveAlpha)
-        path.addRoundRect(option.rect.adjusted(0, 0, -1, -1), 25);
-    else
-        path.addRect(option.rect.adjusted(0, 0, -1, -1));
-
-    QColor color = option.palette.color(QPalette::ToolTipBase);
-    QColor from = color.lighter(105);
-    QColor to   = color.darker(120);
-
-    QLinearGradient gradient(0, 0, 0, 1);
-    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
-    gradient.setColorAt(0, from);
-    gradient.setColorAt(1, to);
-
-    painter->translate(.5, .5);
-    painter->setPen(QPen(Qt::black, 1));
-    painter->setBrush(gradient);
-    painter->drawPath(path);
-    painter->translate(-.5, -.5);
-
-    if (haveAlpha) {
-        QLinearGradient mask(0, 0, 0, 1);
-        gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
-        gradient.setColorAt(0, QColor(0, 0, 0, 192));
-        gradient.setColorAt(1, QColor(0, 0, 0, 72));
-        painter->setCompositionMode(QPainter::CompositionMode_DestinationIn);
-        painter->fillRect(option.rect, gradient);
-        painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
-    }
-
-    QRect textRect = option.rect.adjusted(10, 10, -10, -10);
-
-    QIcon icon = item.icon();
-    if (!icon.isNull()) {
-        const QSize iconSize = icon.actualSize(option.decorationSize);
-        painter->drawPixmap(textRect.topLeft(), icon.pixmap(iconSize));
-        textRect.adjust(iconSize.width() + 4, 0, 0, 0);
-    }
-    painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, item.text());
-}
-
-QRegion KToolTipDelegate::inputShape(const KStyleOptionToolTip &option) const
-{
-    return QRegion(option.rect);
-}
-
-QRegion KToolTipDelegate::shapeMask(const KStyleOptionToolTip &option) const
-{
-    return QRegion(option.rect);
-}
-
-bool KToolTipDelegate::haveAlphaChannel() const
-{
-#ifdef Q_WS_X11
-    return QX11Info::isCompositingManagerRunning();
-#else
-       return false;
-#endif
-}
diff --git a/src/tooltips/ktooltipdelegate.h b/src/tooltips/ktooltipdelegate.h
deleted file mode 100644 (file)
index a219ec5..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>               *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef KTOOLTIPDELEGATE_H
-#define KTOOLTIPDELEGATE_H
-
-#include <QFontMetrics>
-#include <QFont>
-#include <QObject>
-#include <QPalette>
-#include <QRect>
-#include <QStyle>
-#include <QSize>
-
-class KStyleOptionToolTip;
-class KToolTipItem;
-class QPainter;
-class QRegion;
-
-class KStyleOptionToolTip
-{
-public:
-    KStyleOptionToolTip();
-    enum Corner { TopLeftCorner, TopRightCorner, BottomLeftCorner, BottomRightCorner, NoCorner };
-
-    Qt::LayoutDirection direction;
-    QFontMetrics fontMetrics;
-    QPalette palette;
-    QRect rect;
-    QStyle::State state;
-    QFont font;
-    QSize decorationSize;
-    Corner activeCorner;
-};
-
-/**
- * KToolTipDelegate is responsible for providing the size hint and
- * painting the tooltips.
- */
-class KToolTipDelegate : public QObject
-{
-    Q_OBJECT
-public:
-     KToolTipDelegate();
-     virtual ~KToolTipDelegate();
-
-     virtual QSize sizeHint(const KStyleOptionToolTip &option, const KToolTipItem &item) const;
-
-     /**
-      * If haveAlphaChannel() returns true, the paint device will be filled with
-      * Qt::transparent when this function is called, otherwise the content is
-      * undefined.
-      */
-     virtual void paint(QPainter *painter,
-                        const KStyleOptionToolTip &option,
-                        const KToolTipItem &item) const;
-
-     /**
-      * Reimplement this function to specify the region of the tooltip
-      * that accepts input. Any mouse events that occur outside this
-      * region will be sent to the widget below the tooltip.
-      *
-      * The default implementation returns a region containing the
-      * bounding rect of the tooltip.
-      *
-      * This function will only be called if haveAlphaChannel()
-      * returns true.
-      */
-     virtual QRegion inputShape(const KStyleOptionToolTip &option) const;
-
-     /**
-      * Reimplement this function to specify a shape mask for the tooltip.
-      *
-      * The default implementation returns a region containing the
-      * bounding rect of the tooltip.
-      *
-      * This function will only be called if haveAlphaChannel()
-      * returns false.
-      */
-     virtual QRegion shapeMask(const KStyleOptionToolTip &option) const;
-
-protected:
-     /**
-      * Returns true if the tooltip has an alpha channel, and false
-      * otherwise.
-      *
-      * Implementors should assume that this condition may change at
-      * any time during the runtime of the application, as compositing
-      * can be enabled or disabled in the window manager.
-      */
-     bool haveAlphaChannel() const;
-};
-
-#endif
diff --git a/src/tooltips/ktooltipitem.cpp b/src/tooltips/ktooltipitem.cpp
deleted file mode 100644 (file)
index 78f778a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>               *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "ktooltipitem.h"
-#include "ktooltip_p.h"
-
-#include <QIcon>
-
-class KToolTipItemPrivate
-{
-public:
-    QMap<int, QVariant> map;
-    int type;
-};
-
-KToolTipItem::KToolTipItem(const QString &text, int type)
-    : d(new KToolTipItemPrivate)
-{
-    d->map[Qt::DisplayRole] = text;
-    d->type = type;
-}
-
-KToolTipItem::KToolTipItem(const QIcon &icon, const QString &text, int type)
-    : d(new KToolTipItemPrivate)
-{
-    d->map[Qt::DecorationRole] = icon;
-    d->map[Qt::DisplayRole]    = text;
-    d->type = type;
-}
-
-KToolTipItem::~KToolTipItem()
-{
-    delete d;
-}
-
-int KToolTipItem::type() const
-{
-    return d->type;
-}
-
-QString KToolTipItem::text() const
-{
-    return data(Qt::DisplayRole).toString();
-}
-
-QIcon KToolTipItem::icon() const
-{
-    return qvariant_cast<QIcon>(data(Qt::DecorationRole));
-}
-
-QVariant KToolTipItem::data(int role) const
-{
-    return d->map.value(role);
-}
-
-void KToolTipItem::setData(int role, const QVariant &data)
-{
-    d->map[role] = data;
-    KToolTipManager::instance()->update();
-}
diff --git a/src/tooltips/ktooltipitem.h b/src/tooltips/ktooltipitem.h
deleted file mode 100644 (file)
index 7142e5d..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>               *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef KTOOLTIPITEM_H
-#define KTOOLTIPITEM_H
-
-#include <QVariant>
-
-class QString;
-class QIcon;
-
-class KToolTipItemPrivate;
-
-/**
- * KToolTipItem contains the data to be displayed in a tooltip.
- *
- * Custom data can be stored as QVariants in the object by calling
- * setData() with a custom item role, and retrieved and displayed
- * by a tooltip delegate by calling data().
- *
- * The default tooltip delegate uses Qt::DecorationRole and
- * Qt::DisplayRole.
- *
- * To display the tooltip, call KToolTip::showTip() with a pointer
- * to the KToolTipItem.
- *
- * You can reimplement the setData() and/or data() methods in this
- * class to implement on-demand loading of data.
- */
-class KToolTipItem
-{
-public:
-     enum ItemType { DefaultType, UserType = 1000 };
-
-     /**
-      * Creates a KToolTipItem with @p text and no icon.
-      */
-     explicit KToolTipItem(const QString &text, int type = DefaultType);
-
-     /**
-      * Creates a KToolTipItem with an @p icon and @p text.
-      */
-     KToolTipItem(const QIcon &icon, const QString &text, int type = DefaultType);
-
-     /**
-      * Destroys the KToolTipItem.
-      */
-     virtual ~KToolTipItem();
-
-     /**
-      * Returns the item type.
-      */
-     int type() const;
-
-     QString text() const;
-     QIcon icon() const;
-
-     virtual QVariant data(int role) const;
-     virtual void setData(int role, const QVariant &data);
-
-private:
-     KToolTipItemPrivate * const d;
-};
-
-#endif
diff --git a/src/tooltips/ktooltipwindow.cpp b/src/tooltips/ktooltipwindow.cpp
new file mode 100644 (file)
index 0000000..9a1cb45
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ *   Copyright (C) 2008 by Fredrik Höglund <fredrik@kde.org>                   *
+ *   Copyright (C) 2008 by Konstantin Heil <konst.heil@stud.uni-heidelberg.de> *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                      *
+ *                                                                             *
+ *   This program is free software; you can redistribute it and/or modify      *
+ *   it under the terms of the GNU General Public License as published by      *
+ *   the Free Software Foundation; either version 2 of the License, or         *
+ *   (at your option) any later version.                                       *
+ *                                                                             *
+ *   This program is distributed in the hope that it will be useful,           *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
+ *   GNU General Public License for more details.                              *
+ *                                                                             *
+ *   You should have received a copy of the GNU General Public License         *
+ *   along with this program; if not, write to the                             *
+ *   Free Software Foundation, Inc.,                                           *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                *
+ *******************************************************************************/
+
+#include "ktooltipwindow_p.h"
+
+#include <kcolorscheme.h>
+
+#include <QPainter>
+#include <QVBoxLayout>
+
+#ifdef Q_WS_X11
+    #include <QX11Info>
+#endif
+
+KToolTipWindow::KToolTipWindow(QWidget* content) :
+    QWidget(0)
+{
+    setAttribute(Qt::WA_TranslucentBackground);
+    setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
+
+    QVBoxLayout* layout = new QVBoxLayout(this);
+    layout->addWidget(content);
+}
+
+KToolTipWindow::~KToolTipWindow()
+{
+}
+
+void KToolTipWindow::paintEvent(QPaintEvent* event)
+{
+    Q_UNUSED(event);
+
+    QPainter painter(this);
+
+    QColor toColor = palette().brush(QPalette::ToolTipBase).color();
+    QColor fromColor = KColorScheme::shade(toColor, KColorScheme::LightShade, 0.2);
+
+#ifdef Q_WS_X11
+    const bool haveAlphaChannel = QX11Info::isCompositingManagerRunning();
+#else
+    const bool haveAlphaChannel = false;
+#endif
+    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(width(), 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());
+    const qreal radius = 5;
+
+    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);
+}
+
+void KToolTipWindow::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);
+}
+
+#include "ktooltipwindow_p.moc"
similarity index 63%
rename from src/tooltips/dolphintooltip.h
rename to src/tooltips/ktooltipwindow_p.h
index 89bbd74d665abf57f02fa3846d8b9587c6d79227..a9ac30f825ef50a16be0823ea9b28465c9c7a7e7 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2008 by Simon St James <kdedevel@etotheipiplusone.com>  *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-// NOTE: proper documentation will be added once the code is better developed.
+#ifndef KTOOLTIPWINDOW_H
+#define KTOOLTIPWINDOW_H
 
-#ifndef DOLPHINTOOLTIP_H
-#define DOLPHINTOOLTIP_H
+#include <QWidget>
+class QPaintEvent;
 
-#include <tooltips/ktooltip.h>
-#include <tooltips/kformattedballoontipdelegate.h>
-
-#include <kio/previewjob.h>
-#include <QtCore/QObject>
-
-
-const int PREVIEW_WIDTH = 256;
-const int PREVIEW_HEIGHT = 256;
-
-
-class DolphinBalloonTooltipDelegate : public KFormattedBalloonTipDelegate
+class KToolTipWindow : public QWidget
 {
-public:
-    DolphinBalloonTooltipDelegate();
-    virtual ~DolphinBalloonTooltipDelegate();
+    Q_OBJECT
 
-    virtual QSize sizeHint(const KStyleOptionToolTip& option, const KToolTipItem& item) const;
-    virtual void paint(QPainter* painter, const KStyleOptionToolTip& option, const KToolTipItem& item) const;
+public:
+    explicit KToolTipWindow(QWidget* content);
+    virtual ~KToolTipWindow();
+
+protected:
+    virtual void paintEvent(QPaintEvent* event);
+
+private:
+    /**
+     * Helper method for KToolTipWindow::paintEvent() to adjust the painter path \p path
+     * by rounded corners.
+     */
+    static void arc(QPainterPath& path, qreal cx, qreal cy, qreal radius, qreal angle, qreal sweeplength);
 };
+
 #endif
index fbb36aaf5b34203cc9c922caee07b8b5f925f312..9851ece6b30267c23b704c5a4fdd8f66fa85772d 100644 (file)
 
 #include "tooltipmanager.h"
 
-#include "dolphintooltip.h"
 #include "dolphinmodel.h"
 #include "dolphinsortfilterproxymodel.h"
 
 #include <kicon.h>
-#include <tooltips/ktooltip.h>
 #include <kio/previewjob.h>
 
+#include "panels/information/kmetadatawidget.h"
+#include "tooltips/ktooltip.h"
+
 #include <QApplication>
 #include <QDesktopWidget>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QScrollArea>
 #include <QScrollBar>
 #include <QTimer>
-#include <QToolTip>
-
-const int ICON_WIDTH = 128;
-const int ICON_HEIGHT = 128;
-const int PREVIEW_DELAY = 250;
-
-K_GLOBAL_STATIC(DolphinBalloonTooltipDelegate, g_delegate)
 
 ToolTipManager::ToolTipManager(QAbstractItemView* parent,
                                DolphinSortFilterProxyModel* model) :
@@ -54,8 +51,6 @@ ToolTipManager::ToolTipManager(QAbstractItemView* parent,
     m_hasDefaultIcon(false),
     m_previewPixmap()
 {
-    KToolTip::setToolTipDelegate(g_delegate);
-
     m_dolphinModel = static_cast<DolphinModel*>(m_proxyModel->sourceModel());
     connect(parent, SIGNAL(entered(const QModelIndex&)),
             this, SLOT(requestToolTip(const QModelIndex&)));
@@ -157,36 +152,55 @@ void ToolTipManager::prepareToolTip()
         m_waitOnPreviewTimer->start(250);
     }
 
-    const QString text = m_item.getToolTipText();
     if (!m_previewPixmap.isNull()) {
-        showToolTip(KIcon(m_previewPixmap), text);
+        showToolTip(m_previewPixmap);
     } else if (!m_hasDefaultIcon) {
-        const QPixmap image(KIcon(m_item.iconName()).pixmap(ICON_WIDTH, ICON_HEIGHT));
-        showToolTip(image, text);
+        const QPixmap image(KIcon(m_item.iconName()).pixmap(128, 128));
+        showToolTip(image);
         m_hasDefaultIcon = true;
     }
 }
 
-void ToolTipManager::showToolTip(const QIcon& icon, const QString& text)
+void ToolTipManager::startPreviewJob()
+{
+    m_generatingPreview = true;
+    KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << m_item, 256, 256);
+
+    connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
+            this, SLOT(setPreviewPix(const KFileItem&, const QPixmap&)));
+    connect(job, SIGNAL(failed(const KFileItem&)),
+            this, SLOT(previewFailed()));
+}
+
+
+void ToolTipManager::setPreviewPix(const KFileItem& item,
+                                   const QPixmap& pixmap)
+{
+    if ((m_item.url() != item.url()) || pixmap.isNull()) {
+        // an old preview or an invalid preview has been received
+        previewFailed();
+    } else {
+        m_previewPixmap = pixmap;
+        m_generatingPreview = false;
+    }
+}
+
+void ToolTipManager::previewFailed()
+{
+    m_generatingPreview = false;
+}
+
+
+void ToolTipManager::showToolTip(const QPixmap& pixmap)
 {
     if (QApplication::mouseButtons() & Qt::LeftButton) {
         return;
     }
 
-    KToolTipItem* tip = new KToolTipItem(icon, text);
+    QWidget* tip = createTipContent(pixmap);
 
-    KStyleOptionToolTip option;
-    // TODO: get option content from KToolTip or add KToolTip::sizeHint() method
-    option.direction      = QApplication::layoutDirection();
-    option.fontMetrics    = QFontMetrics(QToolTip::font());
-    option.activeCorner   = KStyleOptionToolTip::TopLeftCorner;
-    option.palette        = QToolTip::palette();
-    option.font           = QToolTip::font();
-    option.rect           = QRect();
-    option.state          = QStyle::State_None;
-    option.decorationSize = QSize(32, 32);
-
-    const QSize size = g_delegate->sizeHint(option, *tip);
+    // calculate the x- and y-position of the tooltip
+    const QSize size = tip->sizeHint();
     const QRect desktop = QApplication::desktop()->screenGeometry(m_itemRect.bottomRight());
 
     // m_itemRect defines the area of the item, where the tooltip should be
@@ -225,37 +239,24 @@ void ToolTipManager::showToolTip(const QIcon& icon, const QString& text)
     KToolTip::showTip(QPoint(x, y), tip);
 }
 
-
-
-void ToolTipManager::startPreviewJob()
+QWidget* ToolTipManager::createTipContent(const QPixmap& pixmap) const
 {
-    m_generatingPreview = true;
-    KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << m_item,
-                                            PREVIEW_WIDTH,
-                                            PREVIEW_HEIGHT);
+    QWidget* tipContent = new QWidget();
 
-    connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
-            this, SLOT(setPreviewPix(const KFileItem&, const QPixmap&)));
-    connect(job, SIGNAL(failed(const KFileItem&)),
-            this, SLOT(previewFailed()));
-}
+    QLabel* pixmapLabel = new QLabel(tipContent);
+    pixmapLabel->setPixmap(pixmap);
+    pixmapLabel->setFixedSize(pixmap.size());
 
+    KMetaDataWidget* metaDataWidget = new KMetaDataWidget(tipContent);
+    metaDataWidget->setItem(m_item);
+    metaDataWidget->setFixedSize(metaDataWidget->sizeHint());
 
-void ToolTipManager::setPreviewPix(const KFileItem& item,
-                                   const QPixmap& pixmap)
-{
-    if ((m_item.url() != item.url()) || pixmap.isNull()) {
-        // an old preview or an invalid preview has been received
-        previewFailed();
-    } else {
-        m_previewPixmap = pixmap;
-        m_generatingPreview = false;
-    }
-}
+    QHBoxLayout* tipLayout = new QHBoxLayout(tipContent);
+    tipLayout->setMargin(0);
+    tipLayout->addWidget(pixmapLabel);
+    tipLayout->addWidget(metaDataWidget);
 
-void ToolTipManager::previewFailed()
-{
-    m_generatingPreview = false;
+    return tipContent;
 }
 
 #include "tooltipmanager.moc"
index b9af694456ba01e2760e6cffe265874fc485edf3..e1f9770c3fda44cb067f5d2ec8edfedd3818a355 100644 (file)
@@ -67,7 +67,13 @@ private slots:
     void previewFailed();
 
 private:
-    void showToolTip(const QIcon& icon, const QString& text);
+    void showToolTip(const QPixmap& pixmap);
+
+    /**
+     * Creates widget that represents the tip content having
+     * an icon and the meta data information.
+     */
+    QWidget* createTipContent(const QPixmap& pixmap) const;
 
     QAbstractItemView* m_view;
     DolphinModel* m_dolphinModel;