File indexing completed on 2024-09-08 12:17:47
0001 /* This file is part of the KDE project 0002 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef __khtmlimage_h__ 0021 #define __khtmlimage_h__ 0022 0023 #include "khtml_part.h" 0024 #include <kpluginfactory.h> 0025 #include <kparts/browserextension.h> 0026 #include <kparts/statusbarextension.h> 0027 0028 #include "misc/loader_client.h" 0029 0030 class KHTMLPart; 0031 class KComponentData; 0032 0033 namespace khtml 0034 { 0035 class CachedImage; 0036 } 0037 0038 /** 0039 * @internal 0040 */ 0041 class KHTML_EXPORT KHTMLImage : public KParts::ReadOnlyPart, public khtml::CachedObjectClient 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 KHTMLImage(QWidget *parentWidget, 0047 QObject *parent, const QVariantList &args); 0048 virtual ~KHTMLImage(); 0049 0050 bool openFile() override 0051 { 0052 return true; // grmbl, should be non-pure in part.h, IMHO 0053 } 0054 0055 bool openUrl(const QUrl &url) override; 0056 0057 bool closeUrl() override; 0058 0059 KHTMLPart *doc() const 0060 { 0061 return m_khtml; 0062 } 0063 0064 void notifyFinished(khtml::CachedObject *o) override; 0065 0066 protected: 0067 void guiActivateEvent(KParts::GUIActivateEvent *e) override; 0068 0069 private Q_SLOTS: 0070 void restoreScrollPosition(); 0071 0072 void slotPopupMenu(const QPoint &global, const QUrl &url, mode_t mode, 0073 const KParts::OpenUrlArguments &args, 0074 const KParts::BrowserArguments &browserArgs, 0075 KParts::BrowserExtension::PopupFlags flags, 0076 const KParts::BrowserExtension::ActionGroupMap &actionGroups); 0077 0078 // void slotImageJobFinished( KIO::Job *job ); 0079 0080 // void updateWindowCaption(); 0081 0082 private: 0083 void disposeImage(); 0084 0085 QPointer<KHTMLPart> m_khtml; 0086 KParts::BrowserExtension *m_ext; 0087 KParts::StatusBarExtension *m_sbExt; 0088 QString m_mimeType; 0089 khtml::CachedImage *m_image; 0090 int m_xOffset, m_yOffset; 0091 }; 0092 0093 /** 0094 * @internal 0095 */ 0096 class KHTMLImageBrowserExtension : public KParts::BrowserExtension 0097 { 0098 Q_OBJECT 0099 public: 0100 KHTMLImageBrowserExtension(KHTMLImage *parent); 0101 0102 int xOffset() override; 0103 int yOffset() override; 0104 0105 protected Q_SLOTS: 0106 void print(); 0107 void reparseConfiguration(); 0108 void disableScrolling(); 0109 0110 private: 0111 KHTMLImage *m_imgPart; 0112 }; 0113 0114 #endif