diff --git a/thumbnail/CMakeLists.txt b/thumbnail/CMakeLists.txt --- a/thumbnail/CMakeLists.txt +++ b/thumbnail/CMakeLists.txt @@ -98,25 +98,6 @@ install(TARGETS textthumbnail DESTINATION ${PLUGIN_INSTALL_DIR}) -############ next target ############### - -find_package(Qt5WebEngineWidgets 5.7.0 QUIET) -set_package_properties(Qt5WebEngineWidgets PROPERTIES - TYPE OPTIONAL - PURPOSE "Provides support for HTML previews in the thumbnail ioslave" - ) - -if (Qt5WebEngineWidgets_FOUND) - - set(htmlthumbnail_PART_SRCS htmlcreator.cpp) - - add_library(htmlthumbnail MODULE ${htmlthumbnail_PART_SRCS}) - - target_link_libraries(htmlthumbnail Qt5::Core Qt5::WebEngineWidgets KF5::KIOWidgets) - - install(TARGETS htmlthumbnail DESTINATION ${PLUGIN_INSTALL_DIR}) - -endif() ########### next target ############### if(NOT WIN32) @@ -266,8 +247,3 @@ ${audiothumbnail_desktop} DESTINATION ${SERVICES_INSTALL_DIR}) -if (Qt5WebEngineWidgets_FOUND) - install(FILES htmlthumbnail.desktop DESTINATION ${SERVICES_INSTALL_DIR}) - -endif() - diff --git a/thumbnail/htmlcreator.h b/thumbnail/htmlcreator.h deleted file mode 100644 --- a/thumbnail/htmlcreator.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Malte Starostik - Copyright (C) 2006 Roberto Cappuccio - Copyright (C) 2011 Dawit Alemayehu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef HTMLCREATOR_H -#define HTMLCREATOR_H - -#include -#include - -#include - -class QWebEnginePage; - -class HTMLCreator : public QObject, public ThumbCreator -{ - Q_OBJECT -public: - HTMLCreator(); - ~HTMLCreator() override; - bool create(const QString &path, int width, int height, QImage &img) override; - Flags flags() const override; - -protected: - void timerEvent (QTimerEvent*) override; - -private Q_SLOTS: - void slotFinished(bool); - -private: - bool m_loadedOk; - QWebEnginePage *m_page; - QEventLoop m_eventLoop; -}; - -#endif diff --git a/thumbnail/htmlcreator.cpp b/thumbnail/htmlcreator.cpp deleted file mode 100644 --- a/thumbnail/htmlcreator.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Malte Starostik - Copyright (C) 2006 Roberto Cappuccio - Copyright (C) 2011 Dawit Alemayehu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "htmlcreator.h" - -#include -#include -#include -#include -#include - -extern "C" -{ - Q_DECL_EXPORT ThumbCreator *new_creator() - { - return new HTMLCreator; - } -} - -HTMLCreator::HTMLCreator() - : m_loadedOk(true), m_page(nullptr) -{ -} - -HTMLCreator::~HTMLCreator() -{ - delete m_page; -} - -bool HTMLCreator::create(const QString &path, int width, int height, QImage &img) -{ - if (!m_page) - { - m_page = new QWebEnginePage; - connect(m_page, &QWebEnginePage::loadFinished, this, &HTMLCreator::slotFinished); - m_page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); - m_page->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false); - m_page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, false); - m_page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true); - } - - QUrl url = QUrl::fromUserInput(path); // the argument should be a QUrl! - m_loadedOk = false; - m_page->load(url); - - const int t = startTimer((url.isLocalFile()?5000:30000)); - m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents); - killTimer(t); - - if (m_page->contentsSize().isEmpty()) { - m_loadedOk = false; - } - - if (!m_loadedOk) { - return false; - } - - QPixmap pix; - if (width > 400 || height > 600) { - if (height * 3 > width * 4) { - pix = QPixmap(width, width * 4 / 3); - } else { - pix = QPixmap(height * 3 / 4, height); - } - } else { - pix = QPixmap(400, 600); - } - pix.fill(Qt::transparent); - m_page->view()->render(&pix); - img = pix.toImage(); - return true; -} - -void HTMLCreator::timerEvent(QTimerEvent *) -{ - m_eventLoop.quit(); -} - -void HTMLCreator::slotFinished(bool ok) -{ - m_loadedOk = ok; - m_eventLoop.quit(); -} - -ThumbCreator::Flags HTMLCreator::flags() const -{ - return None; -} - - diff --git a/thumbnail/htmlthumbnail.desktop b/thumbnail/htmlthumbnail.desktop deleted file mode 100644 --- a/thumbnail/htmlthumbnail.desktop +++ /dev/null @@ -1,99 +0,0 @@ -[Desktop Entry] -Type=Service -Name=HTML Files -Name[af]=HTML Lêers -Name[ar]=ملفّات HTML -Name[ast]=Ficheros HTML -Name[be]=Файлы HTML -Name[be@latin]=Fajły HTML -Name[bg]=HTML файлове -Name[bn]=HTML ফাইল -Name[bn_IN]=HTML ফাইল -Name[br]=Restroù HTML -Name[bs]=HTML datoteke -Name[ca]=Fitxers HTML -Name[ca@valencia]=Fitxers HTML -Name[cs]=HTML soubory -Name[csb]=Lopczi HTML -Name[cy]=Ffeiliau HTML -Name[da]=HTML-filer -Name[de]=HTML-Dateien -Name[el]=Αρχεία HTML -Name[en_GB]=HTML Files -Name[eo]=HTML-dosieroj -Name[es]=Archivos HTML -Name[et]=HTML-failid -Name[eu]=HTML fitxategiak -Name[fa]=پرونده‌های زنگام -Name[fi]=HTML-tiedostot -Name[fr]=Fichiers HTML -Name[fy]=HTML-triemmen -Name[ga]=Comhaid HTML -Name[gl]=Ficheiros HTML -Name[gu]=HTML ફાઇલો -Name[he]=קבצי HTML -Name[hi]=एचटीएमएल फ़ाइलें -Name[hne]=एचटीएमएल फाइल मन ल -Name[hr]=HTML datoteke -Name[hsb]=HTML-dataje -Name[hu]=HTML-fájlok -Name[ia]=Files HTML -Name[id]=File HTML -Name[is]=HTML skrár -Name[it]=File HTML -Name[ja]=HTML ファイル -Name[ka]=HTML ფაილები -Name[kk]=HTML файлдары -Name[km]=ឯកសារ HTML -Name[kn]=HTML ಕಡತಗಳು -Name[ko]=HTML 파일 -Name[ku]=Pelên HTML -Name[lt]=HTML failai -Name[lv]=HTML Faili -Name[mai]=HTML फाइल -Name[mk]=HTML-датотеки -Name[ml]=എച്ച്ടിഎംഎല്‍ ഫയലുകള്‍ -Name[mr]=HTML फाईल -Name[ms]=Fail HTML -Name[nb]=HTML-filer -Name[nds]=HTML-Dateien -Name[ne]=HTML फाइल -Name[nl]=HTML-bestanden -Name[nn]=HTML-filer -Name[oc]=Fichièrs HTML -Name[or]=HTML ଫାଇଲଗୁଡ଼ିକ -Name[pa]=HTML ਫਾਈਲਾਂ -Name[pl]=Strony HTML -Name[pt]=Ficheiros HTML -Name[pt_BR]=Arquivos HTML -Name[ro]=Fișiere HTML -Name[ru]=Страницы HTML -Name[se]=HTML-fiillat -Name[si]=HTML ගොනු -Name[sk]=HTML súbory -Name[sl]=Datoteke HTML -Name[sr]=ХТМЛ фајлови -Name[sr@ijekavian]=ХТМЛ фајлови -Name[sr@ijekavianlatin]=HTML fajlovi -Name[sr@latin]=HTML fajlovi -Name[sv]=HTML-filer -Name[ta]=HTML கோப்புகள் -Name[te]=హెచ్ టి ఎం ఎల్ దస్త్రాలు -Name[tg]=Файлҳои HTML -Name[th]=แฟ้มเอกสาร HTML -Name[tr]=HTML Dosyaları -Name[ug]=HTML ھۆججەتلەر -Name[uk]=Файли HTML -Name[uz]=HTML-fayllari -Name[uz@cyrillic]=HTML-файллари -Name[vi]=Tập tin HTML -Name[wa]=Fitchîs HTML -Name[xh]=Iifayile ze HTML -Name[x-test]=xxHTML Filesxx -Name[zh_CN]=HTML 文件 -Name[zh_TW]=HTML 檔案 -X-KDE-ServiceTypes=ThumbCreator -MimeType=text/html; -X-KDE-Protocols=KIO -X-KDE-Library=htmlthumbnail -CacheThumbnail=true