Commit 0b39e7d6 authored by David Faure's avatar David Faure
Browse files

akregator: port away from ReadOnlyPart.

Summary:
This removes the konqueror integration which didn't really work anyway
(RMB on .rss file / Preview In / Akregator -> akregrator would be
embedded but wouldn't add this feed). RMB / Add to Akregator is simpler
and works better anyway.

This will allow us to load kontact plugins without desktop files
(using json) in the future.

Depends on D28581.

Test Plan:
akregator still works (standalone and in kontact) and I was able to add a new feed
in the GUI (and the icon worked btw, also after a restart).

Reviewers: mlaurent

Differential Revision: https://phabricator.kde.org/D28584
parent 7494996c
......@@ -235,7 +235,6 @@ install(TARGETS akregatorpart DESTINATION ${KDE_INSTALL_PLUGINDIR})
########### install files ###############
install(PROGRAMS data/org.kde.akregator.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES data/akregator_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES data/org.kde.akregator.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES data/akregator_plugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
install(FILES feed.protocol DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......
......@@ -150,22 +150,9 @@ K_PLUGIN_FACTORY(AkregatorFactory, registerPlugin<Part>();
)
static Part *mySelf = nullptr;
BrowserExtension::BrowserExtension(Part *p, const char *name)
: KParts::BrowserExtension(p)
{
AkregratorMigrateApplication migrate;
migrate.migrate();
setObjectName(QLatin1String(name));
m_part = p;
}
void BrowserExtension::saveSettings()
{
m_part->saveSettings();
}
Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &)
: KParts::ReadOnlyPart(parent)
: KParts::Part(parent)
, m_standardListLoaded(false)
, m_shuttingDown(false)
, m_doCrashSave(false)
......@@ -175,6 +162,10 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &)
, m_dialog(nullptr)
{
mySelf = this;
AkregratorMigrateApplication migrate;
migrate.migrate();
//Make sure to initialize settings
Part::config();
initFonts();
......@@ -221,14 +212,9 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &)
connect(mCentralWidget, &AkregatorCentralWidget::restoreSession, this, &Part::slotRestoreSession);
m_mainWidget = new Akregator::MainWidget(this, parentWidget, m_actionManager, QStringLiteral("akregator_view"));
mCentralWidget->setMainWidget(m_mainWidget);
m_extension = new BrowserExtension(this, "ak_extension");
connect(Kernel::self()->frameManager(), &FrameManager::signalCaptionChanged, this, &Part::setWindowCaption);
connect(Kernel::self()->frameManager(), &FrameManager::signalStatusText, this, &Part::slotSetStatusText);
connect(Kernel::self()->frameManager(), &FrameManager::signalLoadingProgress, m_extension, &BrowserExtension::loadingProgress);
connect(Kernel::self()->frameManager(), &FrameManager::signalCanceled, this, &ReadOnlyPart::canceled);
connect(Kernel::self()->frameManager(), &FrameManager::signalStarted, this, &Part::slotStarted);
connect(Kernel::self()->frameManager(), SIGNAL(signalCompleted()), this, SIGNAL(completed()));
// notify the part that this is our internal widget
setWidget(mCentralWidget);
......@@ -290,11 +276,6 @@ void Part::loadPlugins(const QString &type)
}
}
void Part::slotStarted()
{
Q_EMIT started(nullptr);
}
void Part::slotOnShutdown()
{
autoSaveProperties();
......@@ -421,34 +402,27 @@ void Part::exportFile(const QString &str)
exportFile(QUrl(str));
}
bool Part::openUrl(const QUrl &url)
{
setLocalFilePath(url.toLocalFile());
return openFile();
}
void Part::openStandardFeedList()
{
if (!m_standardFeedList.isEmpty()) {
openUrl(QUrl::fromLocalFile(m_standardFeedList));
openFile(m_standardFeedList);
}
}
bool Part::openFile()
void Part::openFile(const QString &filePath)
{
if (m_loadFeedListCommand || m_standardListLoaded) {
return true;
return;
}
QScopedPointer<LoadFeedListCommand> cmd(new LoadFeedListCommand(m_mainWidget));
cmd->setParentWidget(m_mainWidget);
cmd->setStorage(Kernel::self()->storage());
cmd->setFileName(localFilePath());
cmd->setFileName(filePath);
cmd->setDefaultFeedList(createDefaultFeedList());
connect(cmd.data(), &LoadFeedListCommand::result,
this, &Part::feedListLoaded);
m_loadFeedListCommand = cmd.take();
m_loadFeedListCommand->start();
return true;
}
bool Part::writeToTextFile(const QString &data, const QString &filename) const
......@@ -516,11 +490,11 @@ void Part::slotSaveFeedList()
// the first time we overwrite the feed list, we create a backup
if (!m_backedUpList) {
const QString backup = localFilePath() + QLatin1Char('~');
const QString backup = m_standardFeedList + QLatin1Char('~');
if (QFile::exists(backup)) {
QFile::remove(backup);
}
if (QFile::copy(localFilePath(), backup)) {
if (QFile::copy(m_standardFeedList, backup)) {
m_backedUpList = true;
}
}
......@@ -531,12 +505,12 @@ void Part::slotSaveFeedList()
}
m_storage->storeFeedList(xml);
if (writeToTextFile(xml, localFilePath())) {
if (writeToTextFile(xml, m_standardFeedList)) {
return;
}
KMessageBox::error(m_mainWidget,
i18n("Access denied: Cannot save feed list to <b>%1</b>. Please check your permissions.", localFilePath()),
i18n("Access denied: Cannot save feed list to <b>%1</b>. Please check your permissions.", m_standardFeedList),
i18n("Write Error"));
}
......
......@@ -31,10 +31,8 @@
#include <KSharedConfig>
#include <QUrl>
#include <kparts/browserextension.h>
#include <kparts/part.h>
#include <kparts/readonlypart.h>
#include "crashwidget/crashwidget.h"
class KConfigGroup;
......@@ -57,23 +55,11 @@ class Part;
class TrayIcon;
class AkregatorCentralWidget;
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT
public:
explicit BrowserExtension(Part *p, const char *name = nullptr);
public Q_SLOTS:
void saveSettings();
private:
Part *m_part;
};
/**
This is a RSS Aggregator "Part". It does all the real work.
It is also embeddable into other applications (e.g. for use in Kontact).
*/
class Part : public KParts::ReadOnlyPart
class Part : public KParts::Part
{
Q_OBJECT
public:
......@@ -83,12 +69,6 @@ public:
/** Destructor. */
~Part() override;
/**
Opens feedlist
@param url URL to feedlist
*/
bool openUrl(const QUrl &url) override;
/** Opens standard feedlist */
void openStandardFeedList();
......@@ -159,14 +139,11 @@ private:
*/
void loadPlugins(const QString &type);
/** This must be implemented by each part */
bool openFile() override;
void importFile(const QUrl &url);
private Q_SLOTS:
void slotStarted();
void openFile(const QString &filePath);
private Q_SLOTS:
void slotOnShutdown();
void slotSettingsChanged();
void slotSetStatusText(const QString &statusText);
......@@ -215,8 +192,6 @@ private: // attributes
bool m_shuttingDown;
bool m_doCrashSave;
KParts::BrowserExtension *m_extension = nullptr;
QTimer *m_autosaveTimer = nullptr;
/** did we backup the feed list already? */
bool m_backedUpList;
......
[Desktop Entry]
Name=aKregatorPart
Name[af]=aKregatorPart
Name[ar]=جزء أكريغاتور
Name[be]=аKregatorPart
Name[bg]=aKregatorPart
Name[br]=aKregatorPart
Name[bs]=aKregatorPart
Name[ca]=aKregatorPart
Name[ca@valencia]=aKregatorPart
Name[cs]=Komponenta Akregatoru
Name[da]=AkregatorPart
Name[de]=aKregator-Komponente
Name[el]=aKregatorPart
Name[en_GB]=aKregatorPart
Name[eo]=aKregatorPart
Name[es]=aKregatorPart
Name[et]=aKregatorPart
Name[eu]=aKregatorPart
Name[fi]=aKregatorPart
Name[fr]=aKregatorPart
Name[fy]=aKregatorPart
Name[ga]=aKregatorPart
Name[gl]=aKregatorPart
Name[he]=aKregatorPart
Name[hu]=aKregatorPart
Name[ia]=aKregatorPart
Name[is]=aKregatorPart
Name[it]=aKregatorPart
Name[ja]=aKregatorPart
Name[ka]=aKregatorPart
Name[kk]=aKregatorPart
Name[km]=aKregatorPart
Name[ko]=aKregatorPart
Name[lt]=aKregatorPart
Name[lv]=aKregatorPart
Name[mr]=एक्रीगेटर-पार्ट
Name[ms]=aKregatorPart
Name[nb]=aKregatorPart
Name[nds]=aKregator-Komponent
Name[ne]=aKregatorPart
Name[nl]=aKregatorPart
Name[nn]=aKregator-del
Name[pa]=aKregatorPart
Name[pl]=Moduł aKregator
Name[pt]=aKregatorPart
Name[pt_BR]=Componente do aKregator
Name[ro]=aKregatorPart
Name[ru]=aKregatorPart
Name[se]=aKregatorPart
Name[sk]=aKregatorPart
Name[sl]=aKregatorPart
Name[sr]=Акрегатор део
Name[sr@ijekavian]=Акрегатор дио
Name[sr@ijekavianlatin]=Akregator dio
Name[sr@latin]=Akregator deo
Name[sv]=aKregator-delprogram
Name[ta]=aKregatorபகுதி
Name[tr]=aKregatorPart
Name[uk]=aKregatorPart
Name[uz]=aKregatorPart
Name[uz@cyrillic]=aKregatorPart
Name[wa]=aKregatorPårt
Name[x-test]=xxaKregatorPartxx
Name[zh_CN]=aKregatorPart
Name[zh_TW]=aKregatorPart
X-KDE-ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=akregatorpart
Type=Service
Icon=akregator
MimeType=application/atom+xml;application/rss+xml;application/rdf+xml;
......@@ -28,7 +28,6 @@
#include <QWidget>
#include <QIcon>
#include <kparts/browserextension.h>
#include <KConfigGroup>
#include "akregator_export.h"
......
......@@ -23,6 +23,8 @@
#include "frame.h"
#include "akregatorpart_export.h"
class KActionCollection;
namespace Akregator {
class ArticleViewerWebEngineWidgetNg;
class AKREGATORPART_EXPORT WebEngineFrame : public Frame
......
......@@ -99,7 +99,7 @@ bool MainWindow::loadPart()
return false;
}
m_part = static_cast<Akregator::Part *>(factory->create<KParts::ReadOnlyPart>(this));
m_part = static_cast<Akregator::Part *>(factory->create<KParts::Part>(this));
if (!m_part) {
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment