File indexing completed on 2025-04-27 03:58:31
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-23-03 0007 * Description : A tool tip widget which follows cursor movements. 0008 * Tool tip content is displayed without delay. 0009 * 0010 * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_DCURSOR_TRACKER_H 0018 #define DIGIKAM_DCURSOR_TRACKER_H 0019 0020 // Qt includes 0021 0022 #include <QEvent> 0023 #include <QString> 0024 #include <QLabel> 0025 0026 // Local includes 0027 0028 #include "digikam_export.h" 0029 0030 namespace Digikam 0031 { 0032 0033 /** 0034 * This class implements a window which looks like a tool tip. It will follow the cursor 0035 * when it's over a specified widget. 0036 */ 0037 class DIGIKAM_EXPORT DCursorTracker : public QLabel 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 0043 explicit DCursorTracker(const QString& txt, QWidget* const parent, Qt::Alignment align = Qt::AlignCenter); 0044 ~DCursorTracker() override; 0045 0046 void setText(const QString& txt); 0047 void setEnable(bool b); 0048 void setKeepOpen(bool b); 0049 void setTrackerAlignment(Qt::Alignment alignment); 0050 0051 void triggerAutoShow(int timeout = 2000); 0052 void refresh(); 0053 0054 protected: 0055 0056 bool eventFilter(QObject*, QEvent*) override; 0057 void paintEvent(QPaintEvent*) override; 0058 0059 private Q_SLOTS: 0060 0061 void slotAutoHide(); 0062 0063 private: 0064 0065 void moveToParent(QWidget* const parent); 0066 bool canBeDisplayed(); 0067 0068 private: 0069 0070 class Private; 0071 Private* const d; 0072 }; 0073 0074 } // namespace Digikam 0075 0076 #endif // DIGIKAM_DCURSOR_TRACKER_H