File indexing completed on 2024-04-28 15:40:26

0001 /* SPDX-FileCopyrightText: 2012-2020 The KPhotoAlbum Development Team
0002 
0003    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #ifndef UTILITIES_TOOLTIP_H
0007 #define UTILITIES_TOOLTIP_H
0008 
0009 #include <ImageManager/ImageClientInterface.h>
0010 #include <kpabase/FileName.h>
0011 
0012 #include <QLabel>
0013 class QTemporaryFile;
0014 
0015 namespace Utilities
0016 {
0017 
0018 /**
0019  * @brief The ToolTip class acts as a base class for tooltips that can show image thumbnails or image info text.
0020  * The subclasses only customize the window behaviour, such as placement and window flags.
0021  */
0022 class ToolTip : public QLabel, public ImageManager::ImageClientInterface
0023 {
0024     Q_OBJECT
0025 public:
0026     void pixmapLoaded(ImageManager::ImageRequest *request, const QImage &image) override;
0027     void requestToolTip(const DB::FileName &fileName);
0028 
0029 protected:
0030     bool event(QEvent *e) override;
0031     explicit ToolTip(QWidget *parent, Qt::WindowFlags f);
0032     virtual void placeWindow() = 0;
0033     void updatePalette();
0034 
0035 private:
0036     void renderToolTip();
0037     void requestImage(const DB::FileName &fileName);
0038     DB::FileName m_currentFileName;
0039     QTemporaryFile *m_tmpFileForThumbnailView;
0040 };
0041 
0042 } // namespace Utilities
0043 
0044 #endif // UTILITIES_TOOLTIP_H
0045 // vi:expandtab:tabstop=4 shiftwidth=4: