File indexing completed on 2024-05-12 09:56:57
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0003 SPDX-FileCopyrightText: 2020 Tomaz Canabrava <tcanabrava@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef FILE_FILTER_HOTSPOT 0009 #define FILE_FILTER_HOTSPOT 0010 0011 #include "RegExpFilterHotspot.h" 0012 0013 #include <QList> 0014 #include <QPoint> 0015 #include <QString> 0016 0017 #include <KFileItem> 0018 #include <KFileItemActions> 0019 #include <KIO/PreviewJob> 0020 0021 class QAction; 0022 class QPixmap; 0023 class QKeyEvent; 0024 class QMouseEvent; 0025 0026 namespace Konsole 0027 { 0028 class Session; 0029 class TerminalDisplay; 0030 0031 /** 0032 * Hotspot type created by FileFilter instances. 0033 */ 0034 class KONSOLEPRIVATE_EXPORT FileFilterHotSpot : public RegExpFilterHotSpot 0035 { 0036 Q_OBJECT 0037 public: 0038 FileFilterHotSpot(int startLine, int startColumn, int endLine, int endColumn, const QStringList &capturedTexts, const QString &filePath, Session *session); 0039 ~FileFilterHotSpot() override; 0040 0041 QList<QAction *> actions() override; 0042 0043 /** 0044 * Opens kate for editing the file. 0045 */ 0046 void activate(QObject *object = nullptr) override; 0047 QList<QAction *> setupMenu(QMenu *menu) override; 0048 0049 KFileItem fileItem() const; 0050 0051 void requestThumbnail(Qt::KeyboardModifiers modifiers, const QPoint &pos); 0052 void thumbnailRequested(); 0053 0054 bool hasDragOperation() const override; 0055 void startDrag() override; 0056 0057 static void stopThumbnailGeneration(); 0058 0059 void mouseEnterEvent(TerminalDisplay *td, QMouseEvent *ev) override; 0060 void mouseLeaveEvent(TerminalDisplay *td, QMouseEvent *ev) override; 0061 0062 void keyPressEvent(TerminalDisplay *td, QKeyEvent *ev) override; 0063 0064 private: 0065 void openWithSysDefaultApp(const QString &filePath) const; 0066 void openWithEditorFromProfile(const QString &fullCmd, const QString &path) const; 0067 0068 void showThumbnail(const KFileItem &item, const QPixmap &preview); 0069 QString _filePath; 0070 Session *_session = nullptr; 0071 0072 // This is a pointer for performance reasons 0073 // constructing KFileItemActions is super expensive 0074 KFileItemActions *_menuActions = nullptr; 0075 0076 QPoint _eventPos; 0077 QPoint _thumbnailPos; 0078 Qt::KeyboardModifiers _eventModifiers; 0079 bool _thumbnailFinished; 0080 0081 /* This variable stores the pointer of the active HotSpot that 0082 * is generating the thumbnail now, so we can bail out early. 0083 * it's not used for pointer access. 0084 */ 0085 static qintptr currentThumbnailHotspot; 0086 static bool _canGenerateThumbnail; 0087 static QPointer<KIO::PreviewJob> _previewJob; 0088 }; 0089 0090 } 0091 #endif