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

akregator

akregator_part.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
00005                   2005 Frank Osterfeld <osterfeld@kde.org>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include "aboutdata.h"
00027 #include "actionmanagerimpl.h"
00028 #include "akregatorconfig.h"
00029 #include "akregator_part.h"
00030 #include "article.h"
00031 #include "fetchqueue.h"
00032 #include "feediconmanager.h"
00033 #include "framemanager.h"
00034 #include "kernel.h"
00035 #include "mainwidget.h"
00036 #include "notificationmanager.h"
00037 #include "plugin.h"
00038 #include "pluginmanager.h"
00039 #include "storage.h"
00040 #include "storagefactory.h"
00041 #include "storagefactoryregistry.h"
00042 #include "trayicon.h"
00043 #include "dummystorage/storagefactorydummyimpl.h"
00044 
00045 #include <knotifyconfigwidget.h>
00046 #include <kaboutdata.h>
00047 #include <kapplication.h>
00048 #include <kconfig.h>
00049 #include <kconfigdialog.h>
00050 #include <kfiledialog.h>
00051 #include <kglobalsettings.h>
00052 #include <kmessagebox.h>
00053 #include <kstandarddirs.h>
00054 #include <ktemporaryfile.h>
00055 #include <KSaveFile>
00056 #include <kservice.h>
00057 #include <kxmlguifactory.h>
00058 #include <kio/netaccess.h>
00059 #include <KParts/GenericFactory>
00060 #include <KParts/Plugin>
00061 #include <KCMultiDialog>
00062 #include <kstandardaction.h>
00063 
00064 #include <QFile>
00065 #include <QObject>
00066 #include <QStringList>
00067 #include <QTextStream>
00068 #include <QTimer>
00069 #include <QWidget>
00070 #include <QDomDocument>
00071 #include "partadaptor.h"
00072 
00073 namespace Akregator {
00074 
00075 static const KAboutData &createAboutData()
00076 {
00077   static Akregator::AboutData about;
00078   return about;
00079 }
00080 
00081 K_PLUGIN_FACTORY(AkregatorFactory, registerPlugin<Part>();)
00082 K_EXPORT_PLUGIN(AkregatorFactory(createAboutData()))
00083 
00084 BrowserExtension::BrowserExtension(Part *p, const char *name)
00085         : KParts::BrowserExtension( p)
00086 {
00087     setObjectName(name);
00088     m_part=p;
00089 }
00090 
00091 void BrowserExtension::saveSettings()
00092 {
00093     m_part->saveSettings();
00094 }
00095 
00096 Part::Part( QWidget *parentWidget, QObject *parent, const QVariantList& )
00097     : inherited(parent)
00098     , m_standardListLoaded(false)
00099     , m_shuttingDown(false)
00100     , m_backedUpList(false)
00101     , m_mainWidget(0)
00102     , m_storage(0)
00103     , m_dialog(0)
00104 
00105 {
00106     setPluginLoadingMode( LoadPluginsIfEnabled );
00107     setPluginInterfaceVersion( AKREGATOR_PLUGIN_INTERFACE_VERSION );
00108 
00109     setComponentData( AkregatorFactory::componentData() );
00110     setXMLFile("akregator_part.rc", true);
00111 
00112     new PartAdaptor( this );
00113     QDBusConnection::sessionBus().registerObject("/Akregator", this);
00114 
00115     FeedIconManager::self(); // FIXME: registering the icon manager dbus iface here,
00116                                // because otherwise we get a deadlock later
00117 
00118     m_standardFeedList = KGlobal::dirs()->saveLocation("data", "akregator/data") + "/feeds.opml";
00119 
00120     Backend::StorageFactoryDummyImpl* dummyFactory = new Backend::StorageFactoryDummyImpl();
00121     Backend::StorageFactoryRegistry::self()->registerFactory(dummyFactory, dummyFactory->key());
00122     loadStoragePlugins(); // FIXME: also unload them!
00123 
00124     m_storage = 0;
00125     Backend::StorageFactory* storageFactory = Backend::StorageFactoryRegistry::self()->getFactory(Settings::archiveBackend());
00126     if (storageFactory != 0)
00127         m_storage = storageFactory->createStorage(QStringList());
00128 
00129     if (!m_storage) // Houston, we have a problem
00130     {
00131         m_storage = Backend::StorageFactoryRegistry::self()->getFactory("dummy")->createStorage(QStringList());
00132 
00133         KMessageBox::error(parentWidget, i18n("Unable to load storage backend plugin \"%1\". No feeds are archived.", Settings::archiveBackend()), i18n("Plugin error") );
00134     }
00135 
00136     m_storage->open(true);
00137     Kernel::self()->setStorage(m_storage);
00138 
00139     m_actionManager = new ActionManagerImpl(this);
00140     ActionManager::setInstance(m_actionManager);
00141 
00142     m_mainWidget = new Akregator::MainWidget(this, parentWidget, m_actionManager, "akregator_view");
00143     m_extension = new BrowserExtension(this, "ak_extension");
00144 
00145     connect(Kernel::self()->frameManager(), SIGNAL(signalCaptionChanged(const QString&)), this, SIGNAL(setWindowCaption(const QString&)));
00146     connect(Kernel::self()->frameManager(), SIGNAL(signalStatusText(const QString&)), this, SIGNAL(setStatusBarText(const QString&)));
00147     connect(Kernel::self()->frameManager(), SIGNAL(signalLoadingProgress(int)), m_extension, SIGNAL(loadingProgress(int)));
00148     connect(Kernel::self()->frameManager(), SIGNAL(signalCanceled(const QString&)), this, SIGNAL(canceled(const QString&)));
00149     connect(Kernel::self()->frameManager(), SIGNAL(signalStarted()), this, SLOT(slotStarted()));
00150     connect(Kernel::self()->frameManager(), SIGNAL(signalCompleted()), this, SIGNAL(completed()));
00151 
00152     // notify the part that this is our internal widget
00153     setWidget(m_mainWidget);
00154 
00155     TrayIcon* trayIcon = new TrayIcon( getMainWindow() );
00156     TrayIcon::setInstance(trayIcon);
00157     m_actionManager->initTrayIcon(trayIcon);
00158 
00159     connect(trayIcon, SIGNAL(showPart()), this, SIGNAL(showPart()));
00160 
00161     if ( isTrayIconEnabled() )
00162     {
00163         trayIcon->show();
00164 #ifdef __GNUC__
00165 #warning this needs a way to get the position of the systray
00166 #endif
00167         NotificationManager::self()->setWidget(0, componentData());
00168     }
00169     else
00170         NotificationManager::self()->setWidget(getMainWindow(), componentData());
00171 
00172     connect( trayIcon, SIGNAL(quitSelected()),
00173             kapp, SLOT(quit())) ;
00174 
00175     connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) );
00176 
00177     connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(slotOnShutdown()));
00178 
00179     m_autosaveTimer = new QTimer(this);
00180     connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(slotSaveFeedList()));
00181     m_autosaveTimer->start(5*60*1000); // 5 minutes
00182 
00183     initFonts();
00184 
00185     QString useragent = QString( "Akregator/%1; syndication" ).arg( AKREGATOR_VERSION );
00186 
00187     if( !Settings::customUserAgent().isEmpty() )
00188         useragent = Settings::customUserAgent();
00189 
00190     Syndication::FileRetriever::setUserAgent( useragent );
00191 }
00192 
00193 
00194 void Part::loadStoragePlugins()
00195 {
00196     KService::List offers = PluginManager::query( "[X-KDE-akregator-plugintype] == 'storage'" );
00197     for ( KService::List::ConstIterator it = offers.begin(), end = offers.end(); it != end; ++it )
00198     {
00199         Akregator::Plugin* plugin = PluginManager::createFromService(*it);
00200         if (plugin)
00201             plugin->initialize();
00202     }
00203 }
00204 
00205 void Part::slotStarted()
00206 {
00207     emit started(0L);
00208 }
00209 
00210 void Part::slotOnShutdown()
00211 {
00212     m_shuttingDown = true;
00213     m_autosaveTimer->stop();
00214     saveSettings();
00215     slotSaveFeedList();
00216     m_mainWidget->slotOnShutdown();
00217     //delete m_mainWidget;
00218     delete TrayIcon::getInstance();
00219     TrayIcon::setInstance(0L);
00220     delete m_storage;
00221     m_storage = 0;
00222     //delete m_actionManager;
00223 }
00224 
00225 void Part::slotSettingsChanged()
00226 {
00227 #ifdef __GNUC__
00228 #warning Tray icons are no longer widgets
00229 #endif
00230 //    NotificationManager::self()->setWidget(isTrayIconEnabled() ? TrayIcon::getInstance() : getMainWindow(), instance());
00231     NotificationManager::self()->setWidget( getMainWindow(), componentData());
00232 
00233     Syndication::FileRetriever::setUseCache(Settings::useHTMLCache());
00234 
00235     QStringList fonts;
00236     fonts.append(Settings::standardFont());
00237     fonts.append(Settings::fixedFont());
00238     fonts.append(Settings::sansSerifFont());
00239     fonts.append(Settings::serifFont());
00240     fonts.append(Settings::standardFont());
00241     fonts.append(Settings::standardFont());
00242     fonts.append("0");
00243     Settings::setFonts(fonts);
00244 
00245     if (Settings::minimumFontSize() > Settings::mediumFontSize())
00246         Settings::setMediumFontSize(Settings::minimumFontSize());
00247     saveSettings();
00248     emit signalSettingsChanged();
00249 }
00250 void Part::saveSettings()
00251 {
00252     m_mainWidget->saveSettings();
00253 }
00254 
00255 Part::~Part()
00256 {
00257     kDebug() <<"Part::~Part() enter";
00258     if (!m_shuttingDown)
00259         slotOnShutdown();
00260     delete m_dialog;
00261     kDebug() <<"Part::~Part(): leaving";
00262 }
00263 
00264 void Part::readProperties(const KConfigGroup & config)
00265 {
00266     m_backedUpList = false;
00267     openStandardFeedList();
00268 
00269     if(m_mainWidget)
00270         m_mainWidget->readProperties(config);
00271 }
00272 
00273 void Part::saveProperties(KConfigGroup & config)
00274 {
00275     if (m_mainWidget)
00276     {
00277         slotSaveFeedList();
00278         m_mainWidget->saveProperties(config);
00279     }
00280 }
00281 
00282 bool Part::openUrl(const KUrl& url)
00283 {
00284     setLocalFilePath(url.path());
00285     return openFile();
00286 }
00287 
00288 void Part::openStandardFeedList()
00289 {
00290     if ( !m_standardFeedList.isEmpty() && openUrl(KUrl::fromPath(m_standardFeedList)) )
00291         m_standardListLoaded = true;
00292 }
00293 
00294 QDomDocument Part::createDefaultFeedList()
00295 {
00296     QDomDocument doc;
00297     QDomProcessingInstruction z = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
00298     doc.appendChild( z );
00299 
00300     QDomElement root = doc.createElement( "opml" );
00301     root.setAttribute("version","1.0");
00302     doc.appendChild( root );
00303 
00304     QDomElement head = doc.createElement( "head" );
00305     root.appendChild(head);
00306 
00307     QDomElement text = doc.createElement( "text" );
00308     text.appendChild(doc.createTextNode(i18n("Feeds")));
00309     head.appendChild(text);
00310 
00311     QDomElement body = doc.createElement( "body" );
00312     root.appendChild(body);
00313 
00314     QDomElement mainFolder = doc.createElement( "outline" );
00315     mainFolder.setAttribute("text","KDE");
00316     body.appendChild(mainFolder);
00317 
00318     QDomElement ak = doc.createElement( "outline" );
00319     ak.setAttribute("text",i18n("Akregator News"));
00320     ak.setAttribute("xmlUrl","http://akregator.sf.net/rss2.php");
00321     mainFolder.appendChild(ak);
00322 
00323     QDomElement akb = doc.createElement( "outline" );
00324     akb.setAttribute("text",i18n("Akregator Blog"));
00325     akb.setAttribute("xmlUrl","http://akregator.pwsp.net/blog/?feed=rss2");
00326     mainFolder.appendChild(akb);
00327 
00328     QDomElement dot = doc.createElement( "outline" );
00329     dot.setAttribute("text",i18n("KDE Dot News"));
00330     dot.setAttribute("xmlUrl","http://www.kde.org/dotkdeorg.rdf");
00331     mainFolder.appendChild(dot);
00332 
00333     QDomElement plan = doc.createElement( "outline" );
00334     plan.setAttribute("text",i18n("Planet KDE"));
00335     plan.setAttribute("xmlUrl","http://planetkde.org/rss20.xml");
00336     mainFolder.appendChild(plan);
00337 
00338     QDomElement apps = doc.createElement( "outline" );
00339     apps.setAttribute("text",i18n("KDE Apps"));
00340     apps.setAttribute("xmlUrl","http://www.kde.org/dot/kde-apps-content.rdf");
00341     mainFolder.appendChild(apps);
00342 
00343     QDomElement look = doc.createElement( "outline" );
00344     look.setAttribute("text",i18n("KDE Look"));
00345     look.setAttribute("xmlUrl","http://www.kde.org/kde-look-content.rdf");
00346     mainFolder.appendChild(look);
00347 
00348     return doc;
00349 }
00350 
00351 bool Part::openFile()
00352 {
00353     emit setStatusBarText(i18n("Opening Feed List...") );
00354 
00355     QString str;
00356     // m_file is always local so we can use QFile on it
00357     QFile file(localFilePath());
00358 
00359     bool fileExists = file.exists();
00360     QString listBackup = m_storage->restoreFeedList();
00361 
00362     QDomDocument doc;
00363 
00364     if (!fileExists)
00365     {
00366         doc = createDefaultFeedList();
00367     }
00368     else
00369     {
00370         if (file.open(QIODevice::ReadOnly))
00371         {
00372             // Read OPML feeds list and build QDom tree.
00373             QTextStream stream(&file);
00374             stream.setCodec("UTF-8"); // FIXME not all opmls are in utf8
00375             str = stream.readAll();
00376             file.close();
00377         }
00378 
00379         if (!doc.setContent(str))
00380         {
00381 
00382             QString backup = localFilePath()
00383                 + QLatin1String("-backup.")
00384                 + QString::number(QDateTime::currentDateTime().toTime_t());
00385 
00386             if ( QFile::copy( localFilePath(), backup ) )
00387                 KMessageBox::error(m_mainWidget, i18n("<qt>The standard feed list is corrupted (invalid XML). A backup was created:<p><b>%1</b></p></qt>", backup), i18n("XML Parsing Error") );
00388             else
00389                 KMessageBox::error(m_mainWidget, i18n("<qt>The standard feed list is corrupted (invalid XML). Could not create a backup!</p></qt>" ), i18n("XML Parsing Error") );
00390 
00391             if (!doc.setContent(listBackup))
00392                 doc = createDefaultFeedList();
00393         }
00394     }
00395 
00396     if (!m_mainWidget->loadFeeds(doc))
00397     {
00398         QString backup = localFilePath()
00399             + QLatin1String("-backup.")
00400             + QString::number(QDateTime::currentDateTime().toTime_t());
00401 
00402         if ( QFile::copy( localFilePath(), backup ) )
00403             KMessageBox::error(m_mainWidget, i18n("<qt>The standard feed list is corrupted (no valid OPML). A backup of the previous list was created:<p><b>%1</b></p></qt>", backup), i18n("OPML Parsing Error") );
00404         else
00405             KMessageBox::error(m_mainWidget, i18n("<qt>The standard feed list is corrupted (no valid OPML). Could not create a backup!></p></qt>" ), i18n("OPML Parsing Error") );
00406         m_mainWidget->loadFeeds(createDefaultFeedList());
00407     }
00408 
00409     emit setStatusBarText(QString::null);   //krazy:exclude=nullstrassign for old broken gcc
00410 
00411 
00412     if( Settings::markAllFeedsReadOnStartup() )
00413         m_mainWidget->slotMarkAllFeedsRead();
00414 
00415     if (Settings::fetchOnStartup())
00416             m_mainWidget->slotFetchAllFeeds();
00417 
00418     return true;
00419 }
00420 
00421 bool Part::writeToTextFile( const QString& data, const QString& filename ) const {
00422     KSaveFile file( filename );
00423     if ( !file.open( QIODevice::WriteOnly ) )
00424         return false;
00425     QTextStream stream( &file );
00426     stream.setCodec( "UTF-8" );
00427     stream << data << endl;
00428     return file.finalize();
00429 }
00430 
00431 
00432 void Part::slotSaveFeedList()
00433 {
00434     // don't save to the standard feed list, when it wasn't completely loaded before
00435     if ( !m_standardListLoaded )
00436         return;
00437 
00438     // the first time we overwrite the feed list, we create a backup
00439     if ( !m_backedUpList )
00440     {
00441         const QString backup = localFilePath() + QLatin1String( "~" );
00442         if ( QFile::copy( localFilePath(), backup ) )
00443             m_backedUpList = true;
00444     }
00445 
00446     const QString xml = m_mainWidget->feedListToOPML().toString();
00447     m_storage->storeFeedList( xml );
00448     if ( writeToTextFile( xml, localFilePath() ) )
00449         return;
00450 
00451     KMessageBox::error( m_mainWidget,
00452                         i18n( "Access denied: Cannot save feed list to <b>%1</b>. Please check your permissions.", localFilePath() ),
00453                         i18n( "Write error" ) );
00454 }
00455 
00456 bool Part::isTrayIconEnabled() const
00457 {
00458     return Settings::showTrayIcon();
00459 }
00460 
00461 QWidget* Part::getMainWindow()
00462 {
00463     // this is a dirty fix to get the main window used for the tray icon
00464     QWidgetList l = QApplication::topLevelWidgets();
00465     QWidget* wid = 0L;
00466 
00467     // check if there is an akregator main window
00468     foreach (wid, QApplication::topLevelWidgets())
00469     {
00470         if (wid->objectName() == "akregator_mainwindow")
00471             return wid;
00472     }
00473 
00474     // if not, check if there is an kontact main window
00475     foreach (wid, QApplication::topLevelWidgets())
00476     {
00477         if (wid->objectName().startsWith("kontact-mainwindow"))
00478             return wid;
00479     }
00480 
00481     return 0;
00482 }
00483 
00484 void Part::importFile(const KUrl& url)
00485 {
00486     QString filename;
00487 
00488     bool isRemote = false;
00489 
00490     if (url.isLocalFile())
00491         filename = url.path();
00492     else
00493     {
00494         isRemote = true;
00495 
00496         if (!KIO::NetAccess::download(url, filename, m_mainWidget) )
00497         {
00498             KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
00499             return;
00500         }
00501     }
00502 
00503     QFile file(filename);
00504     if (file.open(QIODevice::ReadOnly))
00505     {
00506         // Read OPML feeds list and build QDom tree.
00507         QDomDocument doc;
00508         if (doc.setContent(file.readAll()))
00509             m_mainWidget->importFeeds(doc);
00510         else
00511             KMessageBox::error(m_mainWidget, i18n("Could not import the file %1 (no valid OPML)", filename), i18n("OPML Parsing Error") );
00512     }
00513     else
00514         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"));
00515 
00516     if (isRemote)
00517         KIO::NetAccess::removeTempFile(filename);
00518 }
00519 
00520 void Part::exportFile(const KUrl& url)
00521 {
00522     if (url.isLocalFile())
00523     {
00524         const QString fname = url.path();
00525 
00526         if ( QFile::exists( fname ) &&
00527                 KMessageBox::questionYesNo(m_mainWidget,
00528             i18n("The file %1 already exists; do you want to overwrite it?", fname ),
00529             i18n("Export"),
00530             KStandardGuiItem::overwrite(),
00531             KStandardGuiItem::cancel()) == KMessageBox::No )
00532             return;
00533 
00534         if ( !writeToTextFile( m_mainWidget->feedListToOPML().toString(), fname ) )
00535             KMessageBox::error(m_mainWidget, i18n("Access denied: cannot write to file %1. Please check your permissions.", fname), i18n("Write Error") );
00536 
00537         return;
00538     }
00539     else
00540     {
00541         KTemporaryFile tmpfile;
00542         tmpfile.open();
00543 
00544         QTextStream stream(&tmpfile);
00545         stream.setCodec("UTF-8");
00546 
00547         stream << m_mainWidget->feedListToOPML().toString() << "\n";
00548         stream.flush();
00549 
00550         if (!KIO::NetAccess::upload(tmpfile.fileName(), url, m_mainWidget))
00551             KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
00552     }
00553 }
00554 
00555 void Part::fileImport()
00556 {
00557     KUrl url = KFileDialog::getOpenUrl( KUrl(),
00558                         "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
00559                         +"\n*|" + i18n("All Files") );
00560 
00561     if (!url.isEmpty())
00562         importFile(url);
00563 }
00564 
00565     void Part::fileExport()
00566 {
00567     KUrl url= KFileDialog::getSaveUrl( KUrl(),
00568                         "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
00569                         +"\n*|" + i18n("All Files") );
00570 
00571     if ( !url.isEmpty() )
00572         exportFile(url);
00573 }
00574 
00575 void Part::fetchAllFeeds()
00576 {
00577     m_mainWidget->slotFetchAllFeeds();
00578 }
00579 
00580 void Part::fetchFeedUrl(const QString&s)
00581 {
00582     kDebug() <<"fetchFeedURL==" << s;
00583 }
00584 
00585 void Part::addFeedsToGroup(const QStringList& urls, const QString& group)
00586 {
00587     for (QStringList::ConstIterator it = urls.begin(); it != urls.end(); ++it)
00588     {
00589         kDebug() <<"Akregator::Part::addFeedToGroup adding feed with URL" << *it <<" to group" << group;
00590         m_mainWidget->addFeedToGroup(*it, group);
00591     }
00592     NotificationManager::self()->slotNotifyFeeds(urls);
00593 }
00594 
00595 void Part::addFeed()
00596 {
00597     m_mainWidget->slotFeedAdd();
00598 }
00599 
00600 void Part::showKNotifyOptions()
00601 {
00602     KAboutData* about = new Akregator::AboutData;
00603     KNotifyConfigWidget::configure(m_mainWidget, about->appName() );
00604     delete about;
00605 }
00606 
00607 void Part::showOptions()
00608 {
00609     saveSettings();
00610 
00611     if ( !m_dialog ) {
00612         m_dialog = new KCMultiDialog( m_mainWidget );
00613         connect( m_dialog, SIGNAL(configCommitted()),
00614                  this, SLOT(slotSettingsChanged()) );
00615         connect( m_dialog, SIGNAL(configCommitted()),
00616                  TrayIcon::getInstance(), SLOT(settingsChanged()) );
00617 
00618         QStringList modules;
00619 
00620         modules.append( "akregator_config_general.desktop" );
00621         modules.append( "akregator_config_onlinesync.desktop" );
00622         modules.append( "akregator_config_archive.desktop" );
00623         modules.append( "akregator_config_appearance.desktop" );
00624         modules.append( "akregator_config_browser.desktop" );
00625         modules.append( "akregator_config_advanced.desktop" );
00626 
00627         // add them all
00628         QStringList::iterator mit;
00629         for ( mit = modules.begin(); mit != modules.end(); ++mit ) {
00630             m_dialog->addModule( *mit );
00631         }
00632     }
00633 
00634     m_dialog->show();
00635     m_dialog->raise();
00636 }
00637 
00638 KParts::Part* Part::hitTest(QWidget *widget, const QPoint &globalPos)
00639 {
00640 /*    bool child = false;
00641     QWidget *me = this->widget();
00642     while (widget)
00643     {
00644         if (widget == me)
00645         {
00646             child = true;
00647             break;
00648         }
00649         if (!widget)
00650         {
00651             break;
00652         }
00653         widget = widget->parentWidget();
00654     }
00655     if (m_mainWidget && m_mainWidget->currentFrame() && child)
00656     {
00657         return m_mainWidget->currentFrame()->part();
00658     }
00659     else
00660     {*/
00661         return inherited::hitTest(widget, globalPos);
00662 /*    }*/
00663 }
00664 
00665 void Part::initFonts()
00666 {
00667     QStringList fonts = Settings::fonts();
00668     if (fonts.isEmpty())
00669     {
00670         fonts.append(KGlobalSettings::generalFont().family());
00671         fonts.append(KGlobalSettings::fixedFont().family());
00672         fonts.append(KGlobalSettings::generalFont().family());
00673         fonts.append(KGlobalSettings::generalFont().family());
00674         fonts.append("0");
00675     }
00676     Settings::setFonts(fonts);
00677     if (Settings::standardFont().isEmpty())
00678         Settings::setStandardFont(fonts[0]);
00679     if (Settings::fixedFont().isEmpty())
00680         Settings::setFixedFont(fonts[1]);
00681     if (Settings::sansSerifFont().isEmpty())
00682         Settings::setSansSerifFont(fonts[2]);
00683     if (Settings::serifFont().isEmpty())
00684         Settings::setSerifFont(fonts[3]);
00685 
00686     KConfigGroup conf( Settings::self()->config(), "HTML Settings");
00687 
00688     KConfig _konq( "konquerorrc", KConfig::NoGlobals  );
00689     KConfigGroup konq(&_konq, "HTML Settings");
00690 
00691     if (!conf.hasKey("MinimumFontSize"))
00692     {
00693         int minfs;
00694         if (konq.hasKey("MinimumFontSize"))
00695             minfs = konq.readEntry("MinimumFontSize", 0);
00696         else
00697             minfs = KGlobalSettings::generalFont().pointSize();
00698         kDebug() <<"Part::initFonts(): set MinimumFontSize to" << minfs;
00699         Settings::setMinimumFontSize(minfs);
00700     }
00701 
00702     if (!conf.hasKey("MediumFontSize"))
00703     {
00704         int medfs;
00705         if (konq.hasKey("MediumFontSize"))
00706             medfs = konq.readEntry("MediumFontSize", 0);
00707         else
00708             medfs = KGlobalSettings::generalFont().pointSize();
00709         kDebug() <<"Part::initFonts(): set MediumFontSize to" << medfs;
00710         Settings::setMediumFontSize(medfs);
00711     }
00712 
00713     if (!conf.hasKey("UnderlineLinks"))
00714     {
00715         bool underline = true;
00716         if (konq.hasKey("UnderlineLinks"))
00717             underline = konq.readEntry("UnderlineLinks", false);
00718 
00719         kDebug() <<"Part::initFonts(): set UnderlineLinks to" << underline;
00720         Settings::setUnderlineLinks(underline);
00721     }
00722 
00723 }
00724 
00725 } // namespace Akregator
00726 
00727 #include "akregator_part.moc"

akregator

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal