kontact
akregator_plugin.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "akregator_plugin.h"
00026 #include "partinterface.h"
00027
00028 #include <akregator_options.h>
00029 #include <akregator_part.h>
00030
00031 #include <kontactinterfaces/core.h>
00032 #include <kontactinterfaces/plugin.h>
00033
00034 #include <kaboutdata.h>
00035 #include <kaction.h>
00036 #include <kactioncollection.h>
00037 #include <kcmdlineargs.h>
00038 #include <kdebug.h>
00039 #include <kgenericfactory.h>
00040 #include <kicon.h>
00041 #include <kiconloader.h>
00042 #include <kmessagebox.h>
00043 #include <kparts/componentfactory.h>
00044
00045 EXPORT_KONTACT_PLUGIN( AkregatorPlugin, akregator )
00046
00047 AkregatorPlugin::AkregatorPlugin( Kontact::Core *core, const QVariantList & )
00048 : Kontact::Plugin( core, core, "akregator" ), m_interface( 0 )
00049 {
00050
00051 setComponentData( KontactPluginFactory::componentData() );
00052
00053 KAction *action = new KAction( KIcon( "bookmark-new" ), i18n( "New Feed..." ), this );
00054 actionCollection()->addAction( "feed_new", action );
00055 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_F ) );
00056 connect( action, SIGNAL(triggered(bool)), SLOT(addFeed()) );
00057 insertNewAction( action );
00058
00059 mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
00060 new Kontact::UniqueAppHandlerFactory<AkregatorUniqueAppHandler>(), this );
00061 }
00062
00063 AkregatorPlugin::~AkregatorPlugin()
00064 {
00065 }
00066
00067 bool AkregatorPlugin::isRunningStandalone()
00068 {
00069 return mUniqueAppWatcher->isRunningStandalone();
00070 }
00071
00072 QStringList AkregatorPlugin::invisibleToolbarActions() const
00073 {
00074 return QStringList( "file_new_contact" );
00075 }
00076
00077 OrgKdeAkregatorPartInterface *AkregatorPlugin::interface()
00078 {
00079 if ( !m_interface ) {
00080 part();
00081 }
00082 Q_ASSERT( m_interface );
00083 return m_interface;
00084
00085 }
00086
00087 QString AkregatorPlugin::tipFile() const
00088 {
00089
00090
00091 QString file;
00092 return file;
00093 }
00094
00095 KParts::ReadOnlyPart *AkregatorPlugin::createPart()
00096 {
00097 KParts::ReadOnlyPart *part = loadPart();
00098 if ( !part ) {
00099 return 0;
00100 }
00101
00102 connect( part, SIGNAL(showPart()), this, SLOT(showPart()) );
00103 m_interface = new OrgKdeAkregatorPartInterface(
00104 "org.kde.akregator", "/Akregator", QDBusConnection::sessionBus() );
00105 m_interface->openStandardFeedList();
00106
00107 return part;
00108 }
00109
00110 void AkregatorPlugin::showPart()
00111 {
00112 core()->selectPlugin( this );
00113 }
00114
00115 void AkregatorPlugin::addFeed()
00116 {
00117 (void) part();
00118 Q_ASSERT( m_interface );
00119 m_interface->addFeed();
00120 }
00121
00122 QStringList AkregatorPlugin::configModules() const
00123 {
00124 QStringList modules;
00125 modules << "PIM/akregator.desktop";
00126 return modules;
00127 }
00128
00129 void AkregatorPlugin::readProperties( const KConfigGroup &config )
00130 {
00131 if ( part() ) {
00132 Akregator::Part *myPart = static_cast<Akregator::Part*>( part() );
00133 myPart->readProperties( config );
00134 }
00135 }
00136
00137 void AkregatorPlugin::saveProperties( KConfigGroup &config )
00138 {
00139 if ( part() ) {
00140 Akregator::Part *myPart = static_cast<Akregator::Part*>( part() );
00141 myPart->saveProperties( config );
00142 }
00143 }
00144
00145 #include "../../../akregator/src/akregator_options.h"
00146 void AkregatorUniqueAppHandler::loadCommandLineOptions()
00147 {
00148 KCmdLineArgs::addCmdLineOptions( Akregator::akregator_options() );
00149 }
00150
00151 int AkregatorUniqueAppHandler::newInstance()
00152 {
00153 kDebug();
00154
00155 (void)plugin()->part();
00156
00157 org::kde::akregator::part akregator(
00158 "org.kde.akregator", "/Akregator", QDBusConnection::sessionBus() );
00159 akregator.openStandardFeedList();
00160
00161 return Kontact::UniqueAppHandler::newInstance();
00162 }
00163
00164 #include "akregator_plugin.moc"