• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.12
  • kdepim
  • akregator
  • src
akregator_part.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5  2005 Frank Osterfeld <osterfeld@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "akregator_part.h"
27 #include "akregatorconfig.h"
28 #include "aboutdata.h"
29 #include "actionmanagerimpl.h"
30 #include "article.h"
31 #include "fetchqueue.h"
32 #include "feediconmanager.h"
33 #include "framemanager.h"
34 #include "kernel.h"
35 #include "loadfeedlistcommand.h"
36 #include "mainwidget.h"
37 #include "notificationmanager.h"
38 #include "plugin.h"
39 #include "pluginmanager.h"
40 #include "storage.h"
41 #include "storagefactory.h"
42 #include "storagefactoryregistry.h"
43 #include "trayicon.h"
44 #include "dummystorage/storagefactorydummyimpl.h"
45 
46 #include <libkdepim/misc/broadcaststatus.h>
47 #include "kdepim-version.h"
48 
49 #include <KActionCollection>
50 #include <knotifyconfigwidget.h>
51 #include <kaboutdata.h>
52 #include <kapplication.h>
53 #include <KCmdLineArgs>
54 #include <kconfig.h>
55 #include <kconfigdialog.h>
56 #include <kfiledialog.h>
57 #include <kglobalsettings.h>
58 #include <kmessagebox.h>
59 #include <kstandarddirs.h>
60 #include <ktemporaryfile.h>
61 #include <KSaveFile>
62 #include <kservice.h>
63 #include <kxmlguifactory.h>
64 #include <kio/netaccess.h>
65 #include <KPluginFactory>
66 #include <KParts/Plugin>
67 #include <KCMultiDialog>
68 #include <kstandardaction.h>
69 
70 #include <QFile>
71 #include <QObject>
72 #include <QStringList>
73 #include <QTextStream>
74 #include <QTimer>
75 #include <QWidget>
76 #include <QDomDocument>
77 #include "partadaptor.h"
78 
79 #include <memory>
80 
81 using namespace boost;
82 
83 namespace {
84 
85  static QDomDocument createDefaultFeedList() {
86  QDomDocument doc;
87  QDomProcessingInstruction z = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
88  doc.appendChild( z );
89 
90  QDomElement root = doc.createElement( "opml" );
91  root.setAttribute("version","1.0");
92  doc.appendChild( root );
93 
94  QDomElement head = doc.createElement( "head" );
95  root.appendChild(head);
96 
97  QDomElement text = doc.createElement( "text" );
98  text.appendChild(doc.createTextNode(i18n("Feeds")));
99  head.appendChild(text);
100 
101  QDomElement body = doc.createElement( "body" );
102  root.appendChild(body);
103 
104  QDomElement mainFolder = doc.createElement( "outline" );
105  mainFolder.setAttribute("text","KDE");
106  body.appendChild(mainFolder);
107 
108  /*
109  // NOTE: If these feeds ever get updated again, reenable them.
110  // For now I (Bertjan, July 2010) just disable them to
111  // make the default feeds non-embarassing (these are
112  // still updated regularly.
113  QDomElement ak = doc.createElement( "outline" );
114  ak.setAttribute("text",i18n("Akregator News"));
115  ak.setAttribute("xmlUrl","http://akregator.sf.net/rss2.php");
116  mainFolder.appendChild(ak);
117 
118  QDomElement akb = doc.createElement( "outline" );
119  akb.setAttribute("text",i18n("Akregator Blog"));
120  akb.setAttribute("xmlUrl","http://akregator.pwsp.net/blog/?feed=rss2");
121  mainFolder.appendChild(akb);
122  */
123 
124  QDomElement dot = doc.createElement( "outline" );
125  dot.setAttribute("text",i18n("KDE Dot News"));
126  dot.setAttribute("xmlUrl","http://www.kde.org/dotkdeorg.rdf");
127  mainFolder.appendChild(dot);
128 
129  QDomElement linuxFeeds = doc.createElement( "outline" );
130  linuxFeeds.setAttribute("text",i18n("Linux.com"));
131  linuxFeeds.setAttribute("xmlUrl","https://www.linux.com/rss/feeds.php");
132  mainFolder.appendChild(linuxFeeds);
133 
134  QDomElement planetkde = doc.createElement( "outline" );
135  planetkde.setAttribute("text",i18n("Planet KDE"));
136  planetkde.setAttribute("xmlUrl","http://planetkde.org/rss20.xml");
137  mainFolder.appendChild(planetkde);
138 
139  QDomElement planetkdepim = doc.createElement( "outline" );
140  planetkdepim.setAttribute("text",i18n("Planet KDE PIM"));
141  planetkdepim.setAttribute("xmlUrl","http://pim.planetkde.org/rss20.xml");
142  mainFolder.appendChild(planetkdepim);
143 
144  QDomElement apps = doc.createElement( "outline" );
145  apps.setAttribute("text",i18n("KDE Apps"));
146  apps.setAttribute("xmlUrl","http://www.kde.org/dot/kde-apps-content.rdf");
147  mainFolder.appendChild(apps);
148 
149  QDomElement look = doc.createElement( "outline" );
150  look.setAttribute("text",i18n("KDE Look"));
151  look.setAttribute("xmlUrl","http://www.kde.org/kde-look-content.rdf");
152  mainFolder.appendChild(look);
153 
154  // hungarian feed(s)
155  QDomElement hungarianFolder = doc.createElement( "outline" );
156  hungarianFolder.setAttribute("text",i18n("Hungarian feeds"));
157  mainFolder.appendChild(hungarianFolder);
158 
159  QDomElement hungarianKde = doc.createElement( "outline" );
160  hungarianKde.setAttribute("text",i18n("KDE.HU"));
161  hungarianKde.setAttribute("xmlUrl","http://kde.hu/rss.xml");
162  hungarianFolder.appendChild(hungarianKde);
163 
164  // spanish feed(s)
165  QDomElement spanishFolder = doc.createElement( "outline" );
166  spanishFolder.setAttribute("text",i18n("Spanish feeds"));
167  mainFolder.appendChild(spanishFolder);
168 
169  QDomElement spanishKde = doc.createElement( "outline" );
170  spanishKde.setAttribute("text",i18n("Planet KDE EspaƱa"));
171  spanishKde.setAttribute("xmlUrl","http://planet.kde-espana.es/");
172  spanishFolder.appendChild(spanishKde);
173 
174  return doc;
175  }
176 }
177 
178 namespace Akregator {
179 
180 static const KAboutData &createAboutData()
181 {
182  static Akregator::AboutData about;
183  return about;
184 }
185 
186 K_PLUGIN_FACTORY(AkregatorFactory, registerPlugin<Part>();)
187 K_EXPORT_PLUGIN(AkregatorFactory(createAboutData()))
188 
189 BrowserExtension::BrowserExtension(Part *p, const char *name)
190  : KParts::BrowserExtension( p)
191 {
192  setObjectName(name);
193  m_part=p;
194 }
195 
196 void BrowserExtension::saveSettings()
197 {
198  m_part->saveSettings();
199 }
200 
201 Part::Part( QWidget *parentWidget, QObject *parent, const QVariantList& )
202  : inherited(parent)
203  , m_standardListLoaded(false)
204  , m_shuttingDown(false)
205  , m_doCrashSave(true)
206  , m_backedUpList(false)
207  , m_mainWidget(0)
208  , m_storage(0)
209  , m_dialog(0)
210 
211 {
212  initFonts();
213 
214  setPluginLoadingMode( LoadPluginsIfEnabled );
215  setPluginInterfaceVersion( AKREGATOR_PLUGIN_INTERFACE_VERSION );
216 
217  setComponentData( AkregatorFactory::componentData() );
218  setXMLFile("akregator_part.rc", true);
219 
220  new PartAdaptor( this );
221  QDBusConnection::sessionBus().registerObject("/Akregator", this);
222 
223  FeedIconManager::self(); // FIXME: registering the icon manager dbus iface here,
224  // because otherwise we get a deadlock later
225 
226  m_standardFeedList = KGlobal::dirs()->saveLocation("data", "akregator/data") + "/feeds.opml";
227 
228  Backend::StorageFactoryDummyImpl* dummyFactory = new Backend::StorageFactoryDummyImpl();
229  if (!Backend::StorageFactoryRegistry::self()->registerFactory(dummyFactory, dummyFactory->key())) {
230  // There was already a dummy factory registered.
231  delete dummyFactory;
232  }
233  loadPlugins( QLatin1String("storage") ); // FIXME: also unload them!
234 
235  m_storage = 0;
236  Backend::StorageFactory* storageFactory = Backend::StorageFactoryRegistry::self()->getFactory(Settings::archiveBackend());
237  if (storageFactory != 0)
238  m_storage = storageFactory->createStorage(QStringList());
239 
240  if (!m_storage) // Houston, we have a problem
241  {
242  m_storage = Backend::StorageFactoryRegistry::self()->getFactory("dummy")->createStorage(QStringList());
243 
244  KMessageBox::error(parentWidget, i18n("Unable to load storage backend plugin \"%1\". No feeds are archived.", Settings::archiveBackend()), i18n("Plugin error") );
245  }
246 
247  m_storage->open(true);
248  Kernel::self()->setStorage(m_storage);
249 
250  m_actionManager = new ActionManagerImpl(this);
251  ActionManager::setInstance(m_actionManager);
252 
253  m_mainWidget = new Akregator::MainWidget(this, parentWidget, m_actionManager, "akregator_view");
254  m_extension = new BrowserExtension(this, "ak_extension");
255 
256  connect(Kernel::self()->frameManager(), SIGNAL(signalCaptionChanged(QString)), this, SIGNAL(setWindowCaption(QString)));
257  connect(Kernel::self()->frameManager(), SIGNAL(signalStatusText(QString)), this, SLOT(slotSetStatusText(QString)));
258  connect(Kernel::self()->frameManager(), SIGNAL(signalLoadingProgress(int)), m_extension, SIGNAL(loadingProgress(int)));
259  connect(Kernel::self()->frameManager(), SIGNAL(signalCanceled(QString)), this, SIGNAL(canceled(QString)));
260  connect(Kernel::self()->frameManager(), SIGNAL(signalStarted()), this, SLOT(slotStarted()));
261  connect(Kernel::self()->frameManager(), SIGNAL(signalCompleted()), this, SIGNAL(completed()));
262 
263  // notify the part that this is our internal widget
264  setWidget(m_mainWidget);
265 
266  if ( Settings::showTrayIcon() && !TrayIcon::getInstance() )
267  {
268  TrayIcon* trayIcon = new TrayIcon( m_mainWidget->window() );
269  TrayIcon::setInstance(trayIcon);
270  m_actionManager->setTrayIcon(trayIcon);
271 
272  if ( isTrayIconEnabled() )
273  trayIcon->setStatus( KStatusNotifierItem::Active );
274 
275  QWidget* const notificationParent = isTrayIconEnabled() ? m_mainWidget->window() : 0;
276  NotificationManager::self()->setWidget(notificationParent, componentData());
277 
278  connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) );
279  connect( m_mainWidget, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)),
280  this, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)) );
281  }
282 
283  connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(slotOnShutdown()));
284 
285  m_autosaveTimer = new QTimer(this);
286  connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(slotSaveFeedList()));
287  m_autosaveTimer->start(5*60*1000); // 5 minutes
288 
289  QString useragent = QString( "Akregator/%1; syndication" ).arg( KDEPIM_VERSION );
290 
291  if( !Settings::customUserAgent().isEmpty() )
292  useragent = Settings::customUserAgent();
293 
294  Syndication::FileRetriever::setUserAgent( useragent );
295 
296  loadPlugins( QLatin1String("extension") ); // FIXME: also unload them!
297 
298  if (!readCrashProperties())
299  autoReadProperties();
300 }
301 
302 void Part::loadPlugins( const QString& type )
303 {
304  const KService::List offers = PluginManager::query( QString::fromLatin1("[X-KDE-akregator-plugintype] == '%1'").arg( type ) );
305 
306  Q_FOREACH ( const KService::Ptr& i, offers ) {
307  Akregator::Plugin* plugin = PluginManager::createFromService( i, this );
308  if ( !plugin )
309  continue;
310  plugin->initialize();
311  plugin->insertGuiClients( this );
312  }
313 }
314 
315 void Part::slotStarted()
316 {
317  emit started(0L);
318 }
319 
320 void Part::slotOnShutdown()
321 {
322  autoSaveProperties();
323  m_shuttingDown = true;
324  m_autosaveTimer->stop();
325  saveSettings();
326  slotSaveFeedList();
327  m_mainWidget->slotOnShutdown();
328  //delete m_mainWidget;
329  delete TrayIcon::getInstance();
330  TrayIcon::setInstance(0L);
331  delete m_storage;
332  m_storage = 0;
333  //delete m_actionManager;
334 }
335 
336 void Part::slotSettingsChanged()
337 {
338  NotificationManager::self()->setWidget(isTrayIconEnabled() ? m_mainWidget->window() : 0, componentData());
339 
340  if ( Settings::showTrayIcon() && !TrayIcon::getInstance() )
341  {
342  TrayIcon* trayIcon = new TrayIcon( m_mainWidget->window() );
343  TrayIcon::setInstance(trayIcon);
344  m_actionManager->setTrayIcon(trayIcon);
345 
346  if ( isTrayIconEnabled() )
347  trayIcon->setStatus( KStatusNotifierItem::Active );
348 
349  connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) );
350  connect( m_mainWidget, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)),
351  this, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)) );
352 
353  m_mainWidget->slotSetTotalUnread();
354  }
355  if ( !Settings::showTrayIcon() )
356  {
357  TrayIcon::getInstance()->disconnect();
358  delete TrayIcon::getInstance();
359  TrayIcon::setInstance(0);
360  m_actionManager->setTrayIcon(0);
361  }
362 
363  Syndication::FileRetriever::setUseCache(Settings::useHTMLCache());
364 
365  QStringList fonts;
366  fonts.append(Settings::standardFont());
367  fonts.append(Settings::fixedFont());
368  fonts.append(Settings::sansSerifFont());
369  fonts.append(Settings::serifFont());
370  fonts.append(Settings::standardFont());
371  fonts.append(Settings::standardFont());
372  fonts.append("0");
373  Settings::setFonts(fonts);
374 
375  if (Settings::minimumFontSize() > Settings::mediumFontSize())
376  Settings::setMediumFontSize(Settings::minimumFontSize());
377  saveSettings();
378  emit signalSettingsChanged();
379 }
380 
381 void Part::slotSetStatusText( const QString& statusText )
382 {
383  KPIM::BroadcastStatus::instance()->setStatusMsg( statusText );
384 }
385 
386 void Part::saveSettings()
387 {
388  m_mainWidget->saveSettings();
389 }
390 
391 Part::~Part()
392 {
393  kDebug() <<"Part::~Part() enter";
394  if (!m_shuttingDown)
395  slotOnShutdown();
396  delete m_dialog;
397  kDebug() <<"Part::~Part(): leaving";
398 }
399 
400 void Part::readProperties(const KConfigGroup & config)
401 {
402  m_backedUpList = false;
403  openStandardFeedList();
404 
405  if(m_mainWidget)
406  m_mainWidget->readProperties(config);
407 }
408 
409 void Part::saveProperties(KConfigGroup & config)
410 {
411  if (m_mainWidget)
412  {
413  slotSaveFeedList();
414  m_mainWidget->saveProperties(config);
415  }
416 }
417 
418 bool Part::openUrl(const KUrl& url)
419 {
420  setLocalFilePath(url.toLocalFile());
421  return openFile();
422 }
423 
424 void Part::openStandardFeedList()
425 {
426  if ( !m_standardFeedList.isEmpty() )
427  openUrl( KUrl::fromPath( m_standardFeedList ) );
428 }
429 
430 bool Part::openFile() {
431  if ( m_loadFeedListCommand || m_standardListLoaded )
432  return true;
433  std::auto_ptr<LoadFeedListCommand> cmd( new LoadFeedListCommand( m_mainWidget ) );
434  cmd->setParentWidget( m_mainWidget );
435  cmd->setStorage( Kernel::self()->storage() );
436  cmd->setFileName( localFilePath() );
437  cmd->setDefaultFeedList( createDefaultFeedList() );
438  connect( cmd.get(), SIGNAL(result(boost::shared_ptr<Akregator::FeedList>)),
439  this, SLOT(feedListLoaded(boost::shared_ptr<Akregator::FeedList>)) );
440  m_loadFeedListCommand = cmd.release();
441  m_loadFeedListCommand->start();
442  return true;
443 }
444 
445 bool Part::writeToTextFile( const QString& data, const QString& filename ) const {
446  KSaveFile file( filename );
447  if ( !file.open( QIODevice::WriteOnly ) )
448  return false;
449  QTextStream stream( &file );
450  stream.setCodec( "UTF-8" );
451  stream << data << endl;
452  return file.finalize();
453 }
454 
455 void Part::feedListLoaded( const shared_ptr<FeedList>& list ) {
456  assert( !m_standardListLoaded );
457  m_mainWidget->setFeedList( list );
458  m_standardListLoaded = list != 0;
459 
460  if( Settings::markAllFeedsReadOnStartup() )
461  m_mainWidget->slotMarkAllFeedsRead();
462 
463  if ( m_standardListLoaded )
464  QTimer::singleShot( 0, this, SLOT(flushAddFeedRequests()) );
465 
466  if (Settings::fetchOnStartup())
467  m_mainWidget->slotFetchAllFeeds();
468 }
469 
470 void Part::flushAddFeedRequests() {
471  Q_FOREACH( const AddFeedRequest& i, m_requests ) {
472  Q_FOREACH ( const QString& j, i.urls )
473  m_mainWidget->addFeedToGroup( j, i.group );
474  NotificationManager::self()->slotNotifyFeeds( i.urls );
475  }
476  m_requests.clear();
477 }
478 
479 void Part::slotSaveFeedList()
480 {
481  // don't save to the standard feed list, when it wasn't completely loaded before
482  if ( !m_standardListLoaded )
483  return;
484 
485  // the first time we overwrite the feed list, we create a backup
486  if ( !m_backedUpList )
487  {
488  const QString backup = localFilePath() + QLatin1String( "~" );
489  if ( QFile::copy( localFilePath(), backup ) )
490  m_backedUpList = true;
491  }
492 
493  const QString xml = m_mainWidget->feedListToOPML().toString();
494  m_storage->storeFeedList( xml );
495  if ( writeToTextFile( xml, localFilePath() ) )
496  return;
497 
498  KMessageBox::error( m_mainWidget,
499  i18n( "Access denied: Cannot save feed list to <b>%1</b>. Please check your permissions.", localFilePath() ),
500  i18n( "Write Error" ) );
501 }
502 
503 bool Part::isTrayIconEnabled() const
504 {
505  return Settings::showTrayIcon();
506 }
507 
508 void Part::importFile(const KUrl& url)
509 {
510  QString filename;
511 
512  bool isRemote = false;
513 
514  if (url.isLocalFile())
515  filename = url.toLocalFile();
516  else
517  {
518  isRemote = true;
519 
520  if (!KIO::NetAccess::download(url, filename, m_mainWidget) )
521  {
522  KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
523  return;
524  }
525  }
526 
527  QFile file(filename);
528  if (file.open(QIODevice::ReadOnly))
529  {
530  // Read OPML feeds list and build QDom tree.
531  QDomDocument doc;
532  if (doc.setContent(file.readAll()))
533  m_mainWidget->importFeedList( doc );
534  else
535  KMessageBox::error(m_mainWidget, i18n("Could not import the file %1 (no valid OPML)", filename), i18n("OPML Parsing Error") );
536  }
537  else
538  KMessageBox::error(m_mainWidget, i18n("The file %1 could not be read, check if it exists or if it is readable for the current user.", filename), i18n("Read Error"));
539 
540  if (isRemote)
541  KIO::NetAccess::removeTempFile(filename);
542 }
543 
544 void Part::exportFile(const KUrl& url)
545 {
546  if (url.isLocalFile())
547  {
548  const QString fname = url.toLocalFile();
549 
550  if ( QFile::exists( fname ) &&
551  KMessageBox::questionYesNo(m_mainWidget,
552  i18n("The file %1 already exists; do you want to overwrite it?", fname ),
553  i18n("Export"),
554  KStandardGuiItem::overwrite(),
555  KStandardGuiItem::cancel()) == KMessageBox::No )
556  return;
557 
558  if ( !writeToTextFile( m_mainWidget->feedListToOPML().toString(), fname ) )
559  KMessageBox::error(m_mainWidget, i18n("Access denied: cannot write to file %1. Please check your permissions.", fname), i18n("Write Error") );
560 
561  return;
562  }
563  else
564  {
565  KTemporaryFile tmpfile;
566  tmpfile.open();
567 
568  QTextStream stream(&tmpfile);
569  stream.setCodec("UTF-8");
570 
571  stream << m_mainWidget->feedListToOPML().toString() << "\n";
572  stream.flush();
573 
574  if (!KIO::NetAccess::upload(tmpfile.fileName(), url, m_mainWidget))
575  KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
576  }
577 }
578 
579 void Part::fileImport()
580 {
581  KUrl url = KFileDialog::getOpenUrl( KUrl(),
582  "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
583  +"\n*|" + i18n("All Files") );
584 
585  if (!url.isEmpty())
586  importFile(url);
587 }
588 
589  void Part::fileExport()
590 {
591  KUrl url= KFileDialog::getSaveUrl( KUrl(),
592  "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
593  +"\n*|" + i18n("All Files") );
594 
595  if ( !url.isEmpty() )
596  exportFile(url);
597 }
598 
599 void Part::fetchAllFeeds()
600 {
601  m_mainWidget->slotFetchAllFeeds();
602 }
603 
604 void Part::fetchFeedUrl(const QString&s)
605 {
606  kDebug() <<"fetchFeedURL==" << s;
607 }
608 
609 void Part::addFeedsToGroup(const QStringList& urls, const QString& group)
610 {
611  AddFeedRequest req;
612  req.group = group;
613  req.urls = urls;
614  m_requests.append( req );
615  if ( m_standardListLoaded )
616  flushAddFeedRequests();
617 }
618 
619 void Part::addFeed()
620 {
621  m_mainWidget->slotFeedAdd();
622 }
623 
624 void Part::showNotificationOptions()
625 {
626  const Akregator::AboutData about;
627  KNotifyConfigWidget::configure(m_mainWidget, about.appName() );
628 }
629 
630 void Part::showOptions()
631 {
632  saveSettings();
633 
634  if ( !m_dialog ) {
635  m_dialog = new KCMultiDialog( m_mainWidget );
636  connect( m_dialog, SIGNAL(configCommitted()),
637  this, SLOT(slotSettingsChanged()) );
638  connect( m_dialog, SIGNAL(configCommitted()),
639  TrayIcon::getInstance(), SLOT(settingsChanged()) );
640 
641  // query for akregator's kcm modules
642  const QString constraint = "[X-KDE-ParentApp] == 'akregator'";
643  const KService::List offers = KServiceTypeTrader::self()->query( "KCModule", constraint );
644  foreach( const KService::Ptr &service, offers ) {
645  m_dialog->addModule( service->storageId() );
646  }
647  }
648 
649  m_dialog->show();
650  m_dialog->raise();
651 }
652 
653 KParts::Part* Part::hitTest(QWidget *widget, const QPoint &globalPos)
654 {
655 /* bool child = false;
656  QWidget *me = this->widget();
657  while (widget)
658  {
659  if (widget == me)
660  {
661  child = true;
662  break;
663  }
664  if (!widget)
665  {
666  break;
667  }
668  widget = widget->parentWidget();
669  }
670  if (m_mainWidget && m_mainWidget->currentFrame() && child)
671  {
672  return m_mainWidget->currentFrame()->part();
673  }
674  else
675  {*/
676  return inherited::hitTest(widget, globalPos);
677 /* }*/
678 }
679 
680 void Part::initFonts()
681 {
682  QStringList fonts = Settings::fonts();
683  if (fonts.isEmpty())
684  {
685  fonts.append(KGlobalSettings::generalFont().family());
686  fonts.append(KGlobalSettings::fixedFont().family());
687  fonts.append(KGlobalSettings::generalFont().family());
688  fonts.append(KGlobalSettings::generalFont().family());
689  fonts.append("0");
690  }
691  Settings::setFonts(fonts);
692  if (Settings::standardFont().isEmpty())
693  Settings::setStandardFont(fonts[0]);
694  if (Settings::fixedFont().isEmpty())
695  Settings::setFixedFont(fonts[1]);
696  if (Settings::sansSerifFont().isEmpty())
697  Settings::setSansSerifFont(fonts[2]);
698  if (Settings::serifFont().isEmpty())
699  Settings::setSerifFont(fonts[3]);
700 
701  KConfigGroup conf( Settings::self()->config(), "HTML Settings");
702 
703  KConfig _konq( "konquerorrc", KConfig::NoGlobals );
704  KConfigGroup konq(&_konq, "HTML Settings");
705 
706  if (!conf.hasKey("MinimumFontSize"))
707  {
708  int minfs;
709  if (konq.hasKey("MinimumFontSize"))
710  minfs = konq.readEntry("MinimumFontSize", 8);
711  else
712  minfs = std::max( KGlobalSettings::generalFont().pointSize() - 2, 4 );
713  Settings::setMinimumFontSize(minfs);
714  }
715 
716  if (!conf.hasKey("MediumFontSize"))
717  {
718  int medfs;
719  if (konq.hasKey("MediumFontSize"))
720  medfs = konq.readEntry("MediumFontSize", 12);
721  else
722  medfs = KGlobalSettings::generalFont().pointSize();
723  Settings::setMediumFontSize(medfs);
724  }
725 
726  if (!conf.hasKey("UnderlineLinks"))
727  {
728  bool underline = true;
729  if (konq.hasKey("UnderlineLinks"))
730  underline = konq.readEntry("UnderlineLinks", false);
731  Settings::setUnderlineLinks(underline);
732  }
733 }
734 
735 bool Part::handleCommandLine() {
736  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
737  QString addFeedGroup = !args->getOption("group").isEmpty() ?
738  args->getOption("group")
739  : i18n("Imported Folder");
740 
741  QStringList feedsToAdd = args->getOptionList("addfeed");
742 
743  if (feedsToAdd.isEmpty() && args->count() > 0) {
744  QString url = args->url(0).url();
745  if(!url.isEmpty())
746  feedsToAdd.append(url);
747  }
748 
749  if (!feedsToAdd.isEmpty())
750  addFeedsToGroup( feedsToAdd, addFeedGroup );
751  return true;
752 }
753 
754 void Part::clearCrashProperties()
755 {
756  if (!m_doCrashSave)
757  return;
758  KConfig config("crashed", KConfig::SimpleConfig,
759  "appdata");
760  KConfigGroup configGroup(&config, "Part");
761  configGroup.writeEntry("crashed", false);
762 }
763 
764 
765 void Part::saveCrashProperties()
766 {
767  if (!m_doCrashSave)
768  return;
769  KConfig config("crashed", KConfig::SimpleConfig,
770  "appdata");
771  KConfigGroup configGroup(&config, "Part");
772  configGroup.deleteGroup();
773 
774  configGroup.writeEntry("crashed", true);
775 
776  saveProperties(configGroup);
777 }
778 
779 bool Part::readCrashProperties()
780 {
781  KConfig config("crashed", KConfig::SimpleConfig,
782  "appdata");
783  KConfigGroup configGroup(&config, "Part");
784 
785  if (!configGroup.readEntry("crashed", false))
786  return false;
787 
788  const int choice = KMessageBox::questionYesNoCancel( m_mainWidget,
789  i18n("Akregator did not close correctly. Would you like to restore the previous session?"),
790  i18n("Restore Session?"),
791  KGuiItem(i18n("Restore Session"), "window-new"),
792  KGuiItem(i18n("Do Not Restore"), "dialog-close"),
793  KGuiItem(i18n("Ask Me Later"), "chronometer"),
794  "Restore session when akregator didn't close correctly" );
795  switch ( choice ) {
796  case KMessageBox::Yes:
797  readProperties(configGroup);
798  clearCrashProperties();
799  return true;
800  case KMessageBox::No:
801  clearCrashProperties();
802  return false;
803  default:
804  break;
805  }
806  m_doCrashSave = false;
807  return false;
808 }
809 
810 void Part::slotAutoSave()
811 {
812  saveCrashProperties();
813 }
814 
815 void Part::autoSaveProperties()
816 {
817  KConfig config("autosaved", KConfig::SimpleConfig, "appdata");
818  KConfigGroup configGroup(&config, "Part");
819  configGroup.deleteGroup();
820 
821  saveProperties(configGroup);
822 
823  clearCrashProperties();
824 }
825 
826 void Part::autoReadProperties()
827 {
828  if(kapp->isSessionRestored())
829  return;
830 
831  KConfig config("autosaved", KConfig::SimpleConfig, "appdata");
832  KConfigGroup configGroup(&config, "Part");
833 
834  readProperties(configGroup);
835 }
836 
837 } // namespace Akregator
838 
839 #include "akregator_part.moc"
storagefactoryregistry.h
Akregator::Settings::setSansSerifFont
static void setSansSerifFont(const QString &v)
Set Sans Serif Font.
Definition: akregatorconfig.h:210
Akregator::Part::~Part
~Part()
Destructor.
Definition: akregator_part.cpp:391
Akregator::MainWidget::saveProperties
void saveProperties(KConfigGroup &config)
Definition: mainwidget.cpp:1163
Akregator::Settings::setFonts
static void setFonts(const QStringList &v)
Set Fonts.
Definition: akregatorconfig.h:286
Akregator::MainWidget::saveSettings
void saveSettings()
saves settings.
Definition: mainwidget.cpp:342
Akregator::TrayIcon
Definition: trayicon.h:39
Akregator::Settings::sansSerifFont
static QString sansSerifFont()
Get Sans Serif Font.
Definition: akregatorconfig.h:220
Akregator::Plugin::initialize
void initialize()
Definition: plugin.cpp:46
Akregator::MainWidget::slotFeedAdd
void slotFeedAdd()
adds a new feed to the feed tree
Definition: mainwidget.cpp:650
Akregator::LoadFeedListCommand
Definition: loadfeedlistcommand.h:42
pluginmanager.h
Akregator::Settings::customUserAgent
static QString customUserAgent()
Get Custom UserAgent.
Definition: akregatorconfig.h:486
AKREGATOR_PLUGIN_INTERFACE_VERSION
#define AKREGATOR_PLUGIN_INTERFACE_VERSION
Definition: plugin.h:37
Akregator::MainWidget
This is the main widget of the view, containing tree view, article list, viewer etc.
Definition: mainwidget.h:68
Akregator::Settings::archiveBackend
static QString archiveBackend()
Get Archive Backend.
Definition: akregatorconfig.h:866
Akregator::Part::readProperties
virtual void readProperties(const KConfigGroup &config)
This method is called when this app is restored.
Definition: akregator_part.cpp:400
Akregator::Part::saveSettings
void saveSettings()
Used to save settings after changing them from configuration dialog.
Definition: akregator_part.cpp:386
kernel.h
Akregator::AboutData
Definition: aboutdata.h:35
Akregator::MainWidget::importFeedList
void importFeedList(const QDomDocument &doc)
Adds the feeds in doc to the "Imported Folder".
Definition: mainwidget.cpp:414
Akregator::MainWidget::setFeedList
void setFeedList(const boost::shared_ptr< FeedList > &feedList)
Definition: mainwidget.cpp:423
Akregator::Backend::StorageFactoryDummyImpl::key
virtual QString key() const
identifier of the storage type, like "metakit", "postgres" etc.
Definition: storagefactorydummyimpl.cpp:41
Akregator::Settings::standardFont
static QString standardFont()
Get Standard Font.
Definition: akregatorconfig.h:163
QWidget
Akregator::Part::handleCommandLine
bool handleCommandLine()
Definition: akregator_part.cpp:735
plugin.h
Akregator::Kernel::setStorage
void setStorage(Backend::Storage *storage)
Definition: kernel.cpp:78
Akregator::Part::signalSettingsChanged
void signalSettingsChanged()
Akregator::Settings::minimumFontSize
static int minimumFontSize()
Get MinimumFontSize.
Definition: akregatorconfig.h:334
Akregator::Part::addFeedsToGroup
void addFeedsToGroup(const QStringList &urls, const QString &group)
Add a feed to a group.
Definition: akregator_part.cpp:609
Akregator::ActionManager::setInstance
static void setInstance(ActionManager *manager)
Definition: actionmanager.cpp:40
Akregator::Settings::mediumFontSize
static int mediumFontSize()
Get MediumFontSize.
Definition: akregatorconfig.h:315
Akregator::Settings::serifFont
static QString serifFont()
Get Serif Font.
Definition: akregatorconfig.h:201
Akregator::Part
This is a RSS Aggregator "Part".
Definition: akregator_part.h:76
Akregator::Settings::showTrayIcon
static bool showTrayIcon()
Get Show tray icon.
Definition: akregatorconfig.h:600
Akregator::Settings::setMediumFontSize
static void setMediumFontSize(int v)
Set MediumFontSize.
Definition: akregatorconfig.h:305
QObject
Akregator::Part::saveProperties
virtual void saveProperties(KConfigGroup &config)
This method is called when it is time for the app to save its properties for session management purpo...
Definition: akregator_part.cpp:409
Akregator::Backend::StorageFactoryRegistry::self
static StorageFactoryRegistry * self()
Definition: storagefactoryregistry.cpp:43
Akregator::Plugin
Definition: plugin.h:41
Akregator::Plugin::insertGuiClients
virtual void insertGuiClients(KXMLGUIClient *parent)
Definition: plugin.cpp:68
Akregator::ActionManagerImpl::setTrayIcon
void setTrayIcon(TrayIcon *trayIcon)
Definition: actionmanagerimpl.cpp:155
Akregator::Part::signalArticlesSelected
void signalArticlesSelected(const QList< Akregator::Article > &)
Akregator::Part::showNotificationOptions
void showNotificationOptions()
Definition: akregator_part.cpp:624
Akregator::MainWidget::slotSetTotalUnread
void slotSetTotalUnread()
emits signalUnreadCountChanged(int)
Definition: mainwidget.cpp:763
Akregator::NotificationManager::setWidget
void setWidget(QWidget *widget, const KComponentData &inst=KComponentData())
the widget used for notification, normally either the mainwindow or the tray icon ...
Definition: notificationmanager.cpp:55
storagefactorydummyimpl.h
Akregator::PluginManager::query
static KService::List query(const QString &constraint=QString())
It will return a list of services that match your specifications.
Definition: pluginmanager.cpp:42
Akregator::Backend::StorageFactory
Definition: storagefactory.h:37
Akregator::Part::exportFile
void exportFile(const KUrl &url)
Definition: akregator_part.cpp:544
Akregator::ActionManagerImpl
Akregator-specific implementation of the ActionManager interface.
Definition: actionmanagerimpl.h:50
akregatorconfig.h
Akregator::NotificationManager::self
static NotificationManager * self()
singleton instance of notification manager
Definition: notificationmanager.cpp:131
Akregator::TrayIcon::setInstance
static void setInstance(TrayIcon *trayIcon)
Definition: trayicon.cpp:52
akregator_part.h
Akregator::Kernel::self
static Kernel * self()
Definition: kernel.cpp:40
Akregator::MainWidget::slotOnShutdown
void slotOnShutdown()
Definition: mainwidget.cpp:317
Akregator::Settings::markAllFeedsReadOnStartup
static bool markAllFeedsReadOnStartup()
Get Mark all feeds as read on startup.
Definition: akregatorconfig.h:524
aboutdata.h
fetchqueue.h
Akregator::Settings::setFixedFont
static void setFixedFont(const QString &v)
Set Fixed Font.
Definition: akregatorconfig.h:172
Akregator::MainWidget::readProperties
void readProperties(const KConfigGroup &config)
session management
Definition: mainwidget.cpp:1138
Akregator::BrowserExtension
Definition: akregator_part.h:60
Akregator::Settings::fixedFont
static QString fixedFont()
Get Fixed Font.
Definition: akregatorconfig.h:182
KAboutData
Akregator::Part::slotSaveFeedList
void slotSaveFeedList()
Saves the standard feed list to it's default location.
Definition: akregator_part.cpp:479
Akregator::Backend::Storage::storeFeedList
virtual void storeFeedList(const QString &opmlStr)=0
stores the feed list in the storage backend.
storagefactory.h
Akregator::MainWidget::slotFetchAllFeeds
void slotFetchAllFeeds()
starts fetching of all feeds in the tree
Definition: mainwidget.cpp:792
article.h
storage.h
Akregator::Part::fileExport
void fileExport()
Definition: akregator_part.cpp:589
Akregator::Backend::StorageFactoryRegistry::getFactory
StorageFactory * getFactory(const QString &typestr)
Definition: storagefactoryregistry.cpp:64
Akregator::Backend::Storage::open
virtual bool open(bool autoCommit=false)=0
Open storage and prepare it for work.
loadfeedlistcommand.h
trayicon.h
Akregator::Part::showOptions
void showOptions()
Shows configuration dialog.
Definition: akregator_part.cpp:630
Akregator::Part::addFeed
void addFeed()
Definition: akregator_part.cpp:619
Akregator::Backend::StorageFactory::createStorage
virtual Storage * createStorage(const QStringList &params) const =0
creates a storage object with given parameters
Akregator::Part::fileImport
void fileImport()
Definition: akregator_part.cpp:579
Akregator::Part::openUrl
bool openUrl(const KUrl &url)
Opens feedlist.
Definition: akregator_part.cpp:418
Akregator::Settings::setUnderlineLinks
static void setUnderlineLinks(bool v)
Set UnderlineLinks.
Definition: akregatorconfig.h:343
mainwidget.h
Akregator::TrayIcon::getInstance
static TrayIcon * getInstance()
Definition: trayicon.cpp:47
Akregator::Backend::StorageFactoryDummyImpl
Definition: storagefactorydummyimpl.h:39
Akregator::K_EXPORT_PLUGIN
K_EXPORT_PLUGIN(AkregatorFactory(createAboutData())) BrowserExtension
Definition: akregator_part.cpp:187
Akregator::MainWidget::slotMarkAllFeedsRead
void slotMarkAllFeedsRead()
marks all articles in all feeds in the tree as read
Definition: mainwidget.cpp:747
Akregator::Settings::fonts
static QStringList fonts()
Get Fonts.
Definition: akregatorconfig.h:296
actionmanagerimpl.h
Akregator::MainWidget::feedListToOPML
QDomDocument feedListToOPML()
Definition: mainwidget.cpp:464
Akregator::Part::fetchAllFeeds
void fetchAllFeeds()
Fetch all feeds in the feed tree.
Definition: akregator_part.cpp:599
Akregator::PluginManager::createFromService
static Akregator::Plugin * createFromService(const KService::Ptr service, QObject *parent=0)
Load and instantiate plugin from service.
Definition: pluginmanager.cpp:82
Akregator::Part::fetchFeedUrl
void fetchFeedUrl(const QString &)
Definition: akregator_part.cpp:604
Akregator::Settings::setSerifFont
static void setSerifFont(const QString &v)
Set Serif Font.
Definition: akregatorconfig.h:191
Akregator::Settings::useHTMLCache
static bool useHTMLCache()
Get Use HTML Cache.
Definition: akregatorconfig.h:467
notificationmanager.h
Akregator::Settings::setMinimumFontSize
static void setMinimumFontSize(int v)
Set MinimumFontSize.
Definition: akregatorconfig.h:324
feediconmanager.h
Akregator::Settings::fetchOnStartup
static bool fetchOnStartup()
Get Fetch on startup.
Definition: akregatorconfig.h:505
Akregator::Settings::self
static Settings * self()
Definition: akregatorconfig.cpp:23
Akregator::Part::slotAutoSave
void slotAutoSave()
Call to auto save.
Definition: akregator_part.cpp:810
framemanager.h
Akregator::Settings::setStandardFont
static void setStandardFont(const QString &v)
Set Standard Font.
Definition: akregatorconfig.h:153
Akregator::Part::openStandardFeedList
void openStandardFeedList()
Opens standard feedlist.
Definition: akregator_part.cpp:424
Akregator::FeedIconManager::self
static FeedIconManager * self()
Definition: feediconmanager.cpp:117
Akregator::Part::inherited
KParts::ReadOnlyPart inherited
Definition: akregator_part.h:80
QList< Akregator::Article >
Akregator::createAboutData
static const KAboutData & createAboutData()
Definition: akregator_part.cpp:180
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal