File indexing completed on 2024-04-28 04:21:26

0001 // SPDX-FileCopyrightText: 2003-2022 The KPhotoAlbum Development Team
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #ifndef INFOBOX_H
0006 #define INFOBOX_H
0007 
0008 #include "InfoBoxResizer.h"
0009 #include "ViewerWidget.h"
0010 
0011 #include <kpabase/SettingsData.h>
0012 #include <kpabase/config-kpa-marble.h>
0013 
0014 #include <QMouseEvent>
0015 #include <QPointer>
0016 #include <QTextBrowser>
0017 
0018 // Qt classes
0019 class QMenu;
0020 class QToolButton;
0021 
0022 namespace Map
0023 {
0024 
0025 // Local classes
0026 class MapView;
0027 
0028 }
0029 
0030 namespace Viewer
0031 {
0032 
0033 // Local classes
0034 class VisibleOptionsMenu;
0035 
0036 class InfoBox : public QTextBrowser
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     explicit InfoBox(ViewerWidget *parent);
0042     void setSource(const QUrl &source) override;
0043     void setInfo(const QString &text, const QMap<int, QPair<QString, QString>> &linkMap);
0044     void setSize();
0045 
0046 protected:
0047     bool event(QEvent *e) override;
0048     QVariant loadResource(int type, const QUrl &name) override;
0049     void mouseMoveEvent(QMouseEvent *) override;
0050     void mousePressEvent(QMouseEvent *) override;
0051     void mouseReleaseEvent(QMouseEvent *) override;
0052     void resizeEvent(QResizeEvent *) override;
0053     void contextMenuEvent(QContextMenuEvent *event) override;
0054     void updateCursor(const QPoint &pos);
0055     bool atBlackoutPos(bool left, bool right, bool top, bool bottom, Settings::Position windowPos) const;
0056     void showBrowser();
0057     void possiblyStartResize(const QPoint &pos);
0058     void hackLinkColorForQt52();
0059     void updatePalette();
0060 
0061 protected Q_SLOTS:
0062     void jumpToContext();
0063     void linkHovered(const QUrl &link);
0064 #ifdef HAVE_MARBLE
0065     void launchMapView();
0066     void updateMapForCurrentImage(DB::FileName);
0067 #endif
0068 
0069 Q_SIGNALS:
0070     void tagHovered(const QPair<QString, QString> &tagData);
0071     void noTagHovered();
0072 
0073 private: // Variables
0074     QMap<int, QPair<QString, QString>> m_linkMap;
0075     ViewerWidget *m_viewer;
0076     QToolButton *m_jumpToContext;
0077     bool m_hoveringOverLink;
0078     InfoBoxResizer m_infoBoxResizer;
0079     VisibleOptionsMenu *m_menu;
0080     QList<QPixmap> m_ratingPixmap;
0081 #ifdef HAVE_MARBLE
0082     QToolButton *m_showOnMap;
0083     QPointer<Map::MapView> m_map;
0084 #endif
0085 };
0086 }
0087 
0088 #endif // INFOBOX_H
0089 
0090 // vi:expandtab:tabstop=4 shiftwidth=4: