diff --git a/plugins/akregator/CMakeLists.txt b/plugins/akregator/CMakeLists.txt index 1c978df35..f3dfe54de 100644 --- a/plugins/akregator/CMakeLists.txt +++ b/plugins/akregator/CMakeLists.txt @@ -1,39 +1,34 @@ + +ecm_qt_declare_logging_category(akregatorplugin_DEBUG_SRCS HEADER akregatorplugindebug.h IDENTIFIER AKREGATORPLUGIN_LOG CATEGORY_NAME org.kde.konqueror.akregatorplugin) + ########### next target ############### -add_definitions(-DTRANSLATION_DOMAIN=\"akregator_konqplugin\") -MESSAGE(STATUS "akregator popupmenu plugin disabled. Doable via servicemenu or should we re-introduce ServiceMenusPlugin?") -#set(akregatorkonqplugin_PART_SRCS akregatorplugin.cpp pluginbase.cpp ) -# -#kde4_add_plugin(akregatorkonqplugin ${akregatorkonqplugin_PART_SRCS} ${akregatorplugin_DEBUG_SRCS}) -# -#target_link_libraries(akregatorkonqplugin ${KDE4_KDE3SUPPORT_LIBS} Qt5::Xml konq -# KF5::KHtml ) -# -#install(TARGETS akregatorkonqplugin DESTINATION ${KDE_INSTALL_PLUGINDIR} ) +set(akregatorplugin_PART_SRCS akregatorplugin.cpp pluginbase.cpp ) +kcoreaddons_add_plugin(akregatorplugin SOURCES ${akregatorplugin_PART_SRCS} ${akregatorplugin_DEBUG_SRCS} INSTALL_NAMESPACE "kf5/kfileitemaction") +kcoreaddons_desktop_to_json(akregatorplugin akregator_konqplugin.desktop) -ecm_qt_declare_logging_category(akregatorplugin_DEBUG_SRCS HEADER akregatorplugindebug.h IDENTIFIER AKREGATORPLUGIN_LOG CATEGORY_NAME org.kde.konqueror.akregatorplugin) +target_compile_definitions(akregatorplugin PRIVATE TRANSLATION_DOMAIN="akregator_konqplugin") +target_link_libraries(akregatorplugin KF5::I18n KF5::KIOWidgets) ########### next target ############### set(akregatorkonqfeedicon_PART_SRCS konqfeedicon.cpp feeddetector.cpp pluginbase.cpp ) add_library(akregatorkonqfeedicon MODULE ${akregatorkonqfeedicon_PART_SRCS} ${akregatorplugin_DEBUG_SRCS}) target_compile_definitions(akregatorkonqfeedicon PRIVATE TRANSLATION_DOMAIN="akregator_konqplugin") - target_link_libraries(akregatorkonqfeedicon KF5::Parts KF5::IconThemes) install(TARGETS akregatorkonqfeedicon DESTINATION ${KDE_INSTALL_PLUGINDIR} ) - ########### install files ############### -#install( FILES akregator_konqplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) +install( FILES akregator_konqplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) install( FILES akregator_konqfeedicon.desktop akregator_konqfeedicon.rc DESTINATION ${KDE_INSTALL_DATADIR}/khtml/kpartplugins ) install( FILES akregator_konqfeedicon.desktop akregator_konqfeedicon.rc DESTINATION ${KDE_INSTALL_DATADIR}/kwebkitpart/kpartplugins ) install( FILES feed.png DESTINATION ${KDE_INSTALL_DATADIR}/akregator/pics ) # contains list of debug categories, for kdebugsettings install(FILES akregatorplugin.categories DESTINATION ${KDE_INSTALL_CONFDIR}) diff --git a/plugins/akregator/akregator_konqplugin.desktop b/plugins/akregator/akregator_konqplugin.desktop index e8cf4c642..77288ee41 100644 --- a/plugins/akregator/akregator_konqplugin.desktop +++ b/plugins/akregator/akregator_konqplugin.desktop @@ -1,130 +1,131 @@ [Desktop Entry] -Encoding=UTF-8 Type=Service +X-KDE-ServiceTypes=KFileItemAction/Plugin +X-KDE-Library=akregatorplugin +MimeType=application/octet-stream +Icon=akregator Name=Add Feed to Akregator Name[ar]=أضف التغذية إلى Akregator Name[be]=Дадаць стужку ў Akregator Name[bg]=Добавяне на емисия към Akregator Name[bs]=Dodaj dovod u Akregator Name[ca]=Afegeix aquesta font a l'Akregator Name[ca@valencia]=Afig aquesta font a l'Akregator Name[cs]=Přidat kanál do Akregatoru Name[da]=Tilføj feed til Akregator Name[de]=Nachrichtenquelle zu Akregator hinzufügen Name[el]=Προσθήκη Καναλιού Ειδήσεων στον aKregator Name[en_GB]=Add Feed to Akregator Name[eo]=Aldoni fluon al Akregatoro Name[es]=Añadir una fuente a Akregator Name[et]=Lisa uudistevoog Akregatorile Name[eu]=Gehitu jarioa Akregatorri Name[fi]=Lisää syöte Akregatoriin Name[fr]=Ajouter un flux à Akregator Name[ga]=Cuir Fotha le hAkregator Name[gl]=Engadir a fonte a Akregator Name[he]=הוסף הזנה ל־Akregator Name[hne]=फीड ल एकेरेगेटर मं जोड़व Name[hr]=Dodaj kanal u Akregator Name[hu]=Hírforrás hozzáadása az Akregatorhoz Name[ia]=Adde syndication a Akregator Name[id]=Tambah Umpan ke Akregator Name[is]=Bæta fréttastraumi við Akregator Name[it]=Aggiungi la fonte ad Akregator Name[ja]=Akregator にフィードを追加 Name[kk]=Akregator-ға ақпарды қосу Name[km]=បន្ថែម​មតិព័ត៌មាន​ទៅ Akregator Name[ko]=Akregator에 피드 추가하기 Name[ku]=Lê Akregator Çavkanî Zêde Bike Name[lt]=Įdėti kanalą į Akregator Name[lv]=Pievienot barotni Akregator Name[mr]=एक्रीगेटरला फीड जोडतो Name[ms]=Tambah Feed ke Akregator Name[nb]=Legg til kilde i Akregator Name[nds]=Stroom na Akregator tofögen Name[nl]=Feed aan aKregator toevoegen Name[nn]=Legg til kjelda i Akregator Name[oc]=Apondre lo flus a Akregator Name[pa]=ਅਕਰੀਗੇਟਰ ਲਈ ਫੀਡ ਸ਼ਾਮਿਲ Name[pl]=Dodaj kanał do Akregatora Name[pt]=Adicionar a Fonte ao Akregator Name[pt_BR]=Adicionar fonte de notícias ao Akregator Name[ro]=Adaugă flux la Akregator Name[ru]=Добавить ленту новостей в Akregator Name[sk]=Pridať kanál do Akregatoru Name[sl]=Dodaj vir v Akregator Name[sr]=Додај довод у Акрегатор Name[sr@ijekavian]=Додај довод у Акрегатор Name[sr@ijekavianlatin]=Dodaj dovod u Akregator Name[sr@latin]=Dodaj dovod u Akregator Name[sv]=Lägg till kanal i Akregator Name[tg]=Иловаи ахборот ба Агрегатор Name[th]=เพิ่มแหล่งป้อนไปยัง Akregator Name[tr]=Haber Kaynağını Akregator uygulamasına ekle Name[ug]=Akregator غا خەۋەر مەنبە قوش Name[uk]=Додати подачу в Akregator Name[wa]=Radjouter floû a Akgregator Name[x-test]=xxAdd Feed to Akregatorxx Name[zh_CN]=向 Akregator 添加种子 Name[zh_TW]=將 Feed 新增到 Akregator icon=akregator Comment=Adds selected feed to Akregator Comment[ar]=تضيف التغذية المختارة إلى Akregator Comment[bg]=Добавяне на избраната емисия към четеца Akregator Comment[bs]=Dodaje izabrani dovod u Akregator Comment[ca]=Afegeix la font seleccionada a l'Akregator Comment[ca@valencia]=Afig la font seleccionada a l'Akregator Comment[cs]=Přidá vybraný kanál do Akregatoru Comment[da]=Tilføjer det valgte feed til Akregator Comment[de]=Fügt die ausgewählte Nachrichtenquelle zu Akregator hinzu Comment[el]=Προσθήκη της επιλεγμένης ροής στο aKregator Comment[en_GB]=Adds selected feed to Akregator Comment[es]=Añade la fuente RSS seleccionada a Akregator Comment[et]=Lisab valitud uudistevoo Akregatorile Comment[eu]=Hautatutako jarioak gehitzen dizkio Akregatorri Comment[fi]=Lisää valitun syötteen Akregatoriin Comment[fr]=Ajoute le flux sélectionné dans Akregator Comment[ga]=Cuir an fotha roghnaithe le hAkregator Comment[gl]=Engade a fonte escollida a Akregator Comment[he]=הוסף הזנות נבחרות ל־Akregator Comment[hne]=चुने गे आरएसएस फीड ल एकेरेगेटर मं जोड़थे Comment[hr]=Dodaj odabrani kanal u Akregator Comment[hu]=A kiválasztott hírforrások hozzáadása az Akregatorhoz Comment[ia]=Adde syndication seligite a Akregator Comment[id]=Tambah umpan terpilih ke Akregator Comment[is]=Bæta völdum fréttastraumi við Akregator Comment[it]=Aggiunge la fonte RSS selezionata ad Akregator Comment[ja]=選択したフィードを Akregator に追加します Comment[kk]=Akregator-ға таңдалған ақпарды қосу Comment[km]=បន្ថែម​មតិព័ត៌មាន​ដែលបាន​ជ្រើស​ទៅ Akregator Comment[ko]=선택한 RSS 피드를 Akregator에 추가하기 Comment[ku]=Lê Akregator çavkaniya hilbijartî zêde bike Comment[lt]=Įdėti pasirinktą kanalą į Akregator Comment[lv]=Pievieno izvēlēto barotni Akregator Comment[mr]=एक्रीगेटरला निवडलेले फीड जोडतो Comment[nb]=Legger til den valgte kilden til Akregator Comment[nds]=Föögt den utsöchten Narichtenstroom na Akregator to Comment[nl]=Voegt geselecteerde feeds toe aan aKregator Comment[nn]=Legg til den valde kjelda i Akregator Comment[pa]=ਚੁਣੀ ਫੀਡ ਅਕਰੀਗੇਟਰ ਵਿੱਚ ਸ਼ਾਮਲ ਕਰੋ Comment[pl]=Dodaje wybrany kanał do Akregatora Comment[pt]=Adiciona a fonte seleccionada ao Akregator Comment[pt_BR]=Adiciona a fonte selecionada ao Akregator Comment[ro]=Adaugă fluxul selectat la Akregator Comment[ru]=Добавляет выбранную ленту новостей в Akregator Comment[sk]=Pridá vybraný kanál do Akregatoru Comment[sl]=Doda izbran vir v Akregator Comment[sr]=Додаје изабрани довод у Акрегатор Comment[sr@ijekavian]=Додаје изабрани довод у Акрегатор Comment[sr@ijekavianlatin]=Dodaje izabrani dovod u Akregator Comment[sr@latin]=Dodaje izabrani dovod u Akregator Comment[sv]=Lägger till vald kanal i Akregator Comment[tg]=Ахбороти интихобшударо ба Агрегатор илова мекунад Comment[th]=เพิ่มแหล่งป้อนที่เลือกไว้ไปยัง Akregator Comment[tr]=Seçili RSS haber kaynağını Akregator uygulamasına ekler Comment[ug]=Akregator تاللانغان خەۋەر مەنبەسىنى قوشىدۇ Comment[uk]=Додає вибрану подачу у Akregator Comment[wa]=Radjoute floû tchoezi a Akgregator Comment[x-test]=xxAdds selected feed to Akregatorxx Comment[zh_CN]=向 Akregator 添加选中的 RSS 种子 Comment[zh_TW]=將所選取的 RSS feed 加到 Akregator -X-KDE-Library=akregatorkonqplugin -ServiceTypes=KonqPopupMenu/Plugin,all/all diff --git a/plugins/akregator/akregatorplugin.cpp b/plugins/akregator/akregatorplugin.cpp index 548218c2d..5f31e7731 100644 --- a/plugins/akregator/akregatorplugin.cpp +++ b/plugins/akregator/akregatorplugin.cpp @@ -1,145 +1,127 @@ /* This file is part of the KDE project Copyright (C) 2004 Gary Cramblitt Adapted from kdeutils/ark/konqplugin by Georg Robbers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "akregatorplugin.h" #include "pluginbase.h" +#include "akregatorplugindebug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include +#include + +#include +#include using namespace Akregator; -typedef KGenericFactory AkregatorMenuFactory; -K_EXPORT_PLUGIN(AkregatorMenuFactory("akregatorkonqplugin")) +K_PLUGIN_FACTORY_WITH_JSON(AkregatorMenuFactory, "akregator_konqplugin.json", registerPlugin();) -AkregatorMenu::AkregatorMenu(KonqPopupMenu *popupmenu, const QStringList & /* list */) - : KonqPopupMenuPlugin(popupmenu), PluginBase(), /*m_conf(0),*/ m_part(0) +AkregatorMenu::AkregatorMenu(QObject *parent, const QVariantList &args) + : KAbstractFileItemActionPlugin(parent), + PluginBase() { - kDebug() << "AkregatorMenu::AkregatorMenu()"; + Q_UNUSED(args); + #if 0 if (QByteArray(kapp->name()) == "kdesktop" && !KAuthorized::authorizeKAction("editable_desktop_icons")) { return; } #endif // Do nothing if user has turned us off. // TODO: Not yet implemented in aKregator settings. /* m_conf = new KConfig( "akregatorrc" ); m_conf->setGroup( "AkregatorKonqPlugin" ); if ( !m_conf->readEntry( "Enable", true ) ) return; */ - KHTMLView *view = 0L; - if (popupmenu && popupmenu->parent() && popupmenu->parent()->inherits("KHTMLView")) { - view = static_cast(popupmenu->parent()); - } + m_feedMimeTypes << "application/rss+xml" << "text/rdf" << "application/xml"; +} - if (view) { - m_part = view->part(); - } - //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead -//KLocale::global()->insertCatalog("akregator_konqplugin"); - m_feedMimeTypes << "application/rss+xml" << "text/rdf" << "application/xml"; - // Get the list of URLs clicked on from Konqi. - //KFileItemList m_list = popupmenu->fileItemList(); - // See if any are RSS feeds. - - KFileItemList list = popupmenu->fileItemList(); - foreach (const KFileItem &it, list) { - if (isFeedUrl(it)) { - kDebug() << "AkregatorMenu: found feed URL " << it.url().prettyUrl(); - QAction *action = actionCollection()->addAction("akregatorkonqplugin_mnu"); - action->setText(i18n("Add Feed to Akregator")); - action->setIcon(KIcon("akregator")); +QList AkregatorMenu::actions(const KFileItemListProperties &fileItemInfos, QWidget *parent) +{ + Q_UNUSED(parent); + + QList acts; + const KFileItemList items = fileItemInfos.items(); + foreach (const KFileItem &item, items) { + if (isFeedUrl(item)) { + qCDebug(AKREGATORPLUGIN_LOG) << "found feed" << item.url(); + + QAction *action = new QAction(this); + action->setText(i18nc("@action:inmenu", "Add Feed to Akregator")); + action->setIcon(QIcon::fromTheme("akregator")); + action->setData(item.url()); connect(action, SIGNAL(triggered()), this, SLOT(slotAddFeed())); - //addAction( action ); - addSeparator(); - m_feedURL = it.url().url(); - break; + acts.append(action); } } -} -AkregatorMenu::~AkregatorMenu() -{ - KLocale::global()->removeCatalog("akregator_konqplugin"); - //delete m_conf; + return acts; } -bool AkregatorMenu::isFeedUrl(const QString &url) + +static bool isFeedUrl(const QString &urlPath) { - if (url.contains(".htm", false) != 0) { + // If URL ends in .htm or .html, it is not a feed url. + if (urlPath.endsWith(".htm", Qt::CaseInsensitive) || urlPath.endsWith(".html", Qt::CaseInsensitive)) { return false; } - if (url.contains("rss", false) != 0) { + if (urlPath.contains("rss", Qt::CaseInsensitive)) { return true; } - if (url.contains("rdf", false) != 0) { - return true; - } - if (url.contains("xml", false) != 0) { + if (urlPath.contains("rdf", Qt::CaseInsensitive)) { return true; } return false; } -bool AkregatorMenu::isFeedUrl(const KFileItem &item) +bool AkregatorMenu::isFeedUrl(const KFileItem &item) const { if (m_feedMimeTypes.contains(item.mimetype())) { return true; } else { - QString url = item.url().url(); - // If URL ends in .htm or .html, it is not a feed url. - return isFeedUrl(url); + return ::isFeedUrl(item.url().path()); } return false; } void AkregatorMenu::slotAddFeed() { - QString url = m_part ? fixRelativeURL(m_feedURL, m_part->baseURL()) : m_feedURL; + QAction *action = qobject_cast(sender()); + Q_ASSERT(action!=nullptr); + + QString url = action->data().toUrl().url(); + qCDebug(AKREGATORPLUGIN_LOG) << "for feed url" << url; if (akregatorRunning()) { addFeedsViaDBUS(QStringList(url)); } else { addFeedViaCmdLine(url); } } + +#include "akregatorplugin.moc" diff --git a/plugins/akregator/akregatorplugin.h b/plugins/akregator/akregatorplugin.h index 5df89b962..67bdb2fd9 100644 --- a/plugins/akregator/akregatorplugin.h +++ b/plugins/akregator/akregatorplugin.h @@ -1,57 +1,54 @@ /* This file is part of the KDE project Copyright (C) 2004 Gary Cramblitt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _AKREGATORPLUGIN_H_ #define _AKREGATORPLUGIN_H_ -#include -#include -#include +#include #include "pluginbase.h" -class KHTMLPart; +class KFileItem; +class KFileItemListProperties; namespace Akregator { -class AkregatorMenu : public KonqPopupMenuPlugin, PluginBase +class AkregatorMenu : public KAbstractFileItemActionPlugin, PluginBase { Q_OBJECT + public: - AkregatorMenu(KonqPopupMenu *, const QStringList &list); - virtual ~AkregatorMenu(); + AkregatorMenu(QObject *parent, const QVariantList &args); + virtual ~AkregatorMenu() = default; + + QList actions(const KFileItemListProperties &fileItemInfos, QWidget *parent) override; public slots: void slotAddFeed(); -protected: - bool isFeedUrl(const QString &s); - bool isFeedUrl(const KFileItem &item); +private: + bool isFeedUrl(const KFileItem &item) const; private: QStringList m_feedMimeTypes; -// KConfig *m_conf; - KHTMLPart *m_part; - QString m_feedURL; }; } #endif -