File indexing completed on 2023-09-24 09:54:56

0001 /*
0002     SPDX-FileCopyrightText: 2017, 2020 Friedrich W. H. Kossebau <kossebau@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef MARKDOWNBROWSEREXTENSION_HPP
0008 #define MARKDOWNBROWSEREXTENSION_HPP
0009 
0010 // Qt
0011 #include <QPoint>
0012 
0013 // KF
0014 #include <kparts_version.h>
0015 
0016 #if KPARTS_VERSION >= QT_VERSION_CHECK(5, 240, 0)
0017 #include <KParts/NavigationExtension>
0018 #else
0019 #include <KParts/BrowserExtension>
0020 #endif
0021 
0022 class MarkdownPart;
0023 class KActionCollection;
0024 
0025 
0026 #if KPARTS_VERSION >= QT_VERSION_CHECK(5, 240, 0)
0027 class MarkdownBrowserExtension : public KParts::NavigationExtension
0028 #else
0029 class MarkdownBrowserExtension : public KParts::BrowserExtension
0030 #endif
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     explicit MarkdownBrowserExtension(MarkdownPart* part);
0036 
0037 public: // KParts::BrowserExtension API
0038     int xOffset() override;
0039     int yOffset() override;
0040 
0041 public Q_SLOTS:
0042     void copy();
0043 
0044     void updateCopyAction(bool enabled);
0045     void requestOpenUrl(const QUrl& url);
0046     void requestOpenUrlNewWindow(const QUrl& url);
0047     void requestContextMenu(QPoint globalPos,
0048                             const QUrl& linkUrl,
0049                             bool hasSelection);
0050 
0051 private:
0052     MarkdownPart* m_part;
0053     // needed to memory manage the context menu actions
0054     KActionCollection* m_contextMenuActionCollection;
0055 };
0056 
0057 #endif