digiKam
ditemtooltip.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-12-10
7  * Description : tool tip widget for iconview, thumbbar, and folderview items
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_DITEM_TOOL_TIP_H
25 #define DIGIKAM_DITEM_TOOL_TIP_H
26 
27 // Qt includes
28 
29 #include <QFont>
30 #include <QLabel>
31 #include <QResizeEvent>
32 #include <QString>
33 #include <QImage>
34 #include <QEvent>
35 #include <QFontDatabase>
36 
37 // Local includes
38 
39 #include "digikam_export.h"
40 
41 namespace Digikam
42 {
43 
44 class DIGIKAM_EXPORT DToolTipStyleSheet
45 {
46 
47 public:
48 
49  explicit DToolTipStyleSheet(const QFont& font = QFontDatabase::systemFont(QFontDatabase::GeneralFont));
50 
51  QString breakString(const QString& input) const;
52  QString elidedText(const QString& input, Qt::TextElideMode mode) const;
53  QString imageAsBase64(const QImage& img) const;
54 
55 public:
56 
57  const int maxStringLength;
58 
59  QString unavailable;
60  QString tipHeader;
61  QString tipFooter;
62  QString headBeg;
63  QString headEnd;
64  QString cellBeg;
65  QString cellMid;
66  QString cellEnd;
67  QString cellSpecBeg;
68  QString cellSpecMid;
69  QString cellSpecEnd;
70 };
71 
72 // --------------------------------------------------------------------------------------
73 
74 class DIGIKAM_EXPORT DItemToolTip : public QLabel
75 {
76  Q_OBJECT
77 
78 public:
79 
80  explicit DItemToolTip(QWidget* const parent = nullptr);
81  ~DItemToolTip() override;
82 
83 protected:
84 
85  bool event(QEvent*) override;
86  void resizeEvent(QResizeEvent*) override;
87  void paintEvent(QPaintEvent*) override;
88  void updateToolTip();
89  bool toolTipIsEmpty() const;
90  void reposition();
91  void renderArrows();
92 
93 protected:
94 
95  virtual QRect repositionRect() = 0;
96  virtual QString tipContents() = 0;
97 
98 private:
99 
100  class Private;
101  Private* const d;
102 };
103 
104 } // namespace Digikam
105 
106 #endif // DIGIKAM_DITEM_TOOL_TIP_H
Definition: ditemtooltip.h:75
virtual QString tipContents()=0
virtual QRect repositionRect()=0
Definition: ditemtooltip.h:45
QString headEnd
Definition: ditemtooltip.h:63
QString unavailable
Definition: ditemtooltip.h:59
QString cellEnd
Definition: ditemtooltip.h:66
QString tipFooter
Definition: ditemtooltip.h:61
QString headBeg
Definition: ditemtooltip.h:62
QString cellSpecEnd
Definition: ditemtooltip.h:69
QString cellSpecBeg
Definition: ditemtooltip.h:67
QString cellBeg
Definition: ditemtooltip.h:64
const int maxStringLength
Definition: ditemtooltip.h:57
QString cellSpecMid
Definition: ditemtooltip.h:68
QString tipHeader
Definition: ditemtooltip.h:60
QString cellMid
Definition: ditemtooltip.h:65
Definition: datefolderview.cpp:43