kontact
kjots_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 "kjots_plugin.h"
00026
00027 #include <kontactinterfaces/core.h>
00028 #include <kjotspart.h>
00029
00030 #include <kactioncollection.h>
00031 #include <kaction.h>
00032 #include <kcmdlineargs.h>
00033 #include <kdebug.h>
00034 #include <kgenericfactory.h>
00035 #include <kicon.h>
00036 #include <kiconloader.h>
00037 #include <kparts/componentfactory.h>
00038
00039 class OrgKdeKJotsComponentInterface;
00040
00041 EXPORT_KONTACT_PLUGIN( KJotsPlugin, kjots )
00042
00043 KJotsPlugin::KJotsPlugin( Kontact::Core *core, const QVariantList & )
00044 : Kontact::Plugin( core, core, "kjots" ), m_interface( 0 )
00045 {
00046 setComponentData( KontactPluginFactory::componentData() );
00047
00048 KAction *action = new KAction( KIcon( "document-new" ), i18n( "New KJots Page" ), this );
00049 actionCollection()->addAction( "new_kjots_page", action );
00050 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_J ) );
00051 connect( action, SIGNAL(triggered(bool)), SLOT( newPage()) );
00052 insertNewAction( action );
00053
00054 action = new KAction( KIcon( "address-book-new" ), i18n( "New KJots Book" ), this );
00055 actionCollection()->addAction( "new_kjots_book", action );
00056 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_B ) );
00057 connect( action, SIGNAL(triggered(bool)), SLOT( newBook()) );
00058 insertNewAction( action );
00059
00060 mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
00061 new Kontact::UniqueAppHandlerFactory<KJotsUniqueAppHandler>(), this );
00062 }
00063
00064 KJotsPlugin::~KJotsPlugin()
00065 {
00066 }
00067
00068 bool KJotsPlugin::isRunningStandalone()
00069 {
00070 return mUniqueAppWatcher->isRunningStandalone();
00071 }
00072
00073 QStringList KJotsPlugin::invisibleToolbarActions() const
00074 {
00075 return QStringList() << "new_page" << "new_book" ;
00076 }
00077
00078 KParts::ReadOnlyPart *KJotsPlugin::createPart()
00079 {
00080 KParts::ReadOnlyPart *part = loadPart();
00081 if ( !part ) {
00082 return 0;
00083 }
00084
00085 m_interface = new OrgKdeKJotsComponentInterface(
00086 "org.kde.kjots", "/KJotsComponent", QDBusConnection::sessionBus() );
00087
00088 return part;
00089 }
00090
00091 OrgKdeKJotsComponentInterface *KJotsPlugin::interface()
00092 {
00093 if ( !m_interface ) {
00094 part();
00095 }
00096 Q_ASSERT( m_interface );
00097 return m_interface;
00098 }
00099
00100 void KJotsPlugin::newPage()
00101 {
00102 core()->selectPlugin( this );
00103 interface()->newPage();
00104 }
00105
00106 void KJotsPlugin::newBook()
00107 {
00108 core()->selectPlugin( this );
00109 interface()->createNewBook();
00110 }
00111
00112 void KJotsUniqueAppHandler::loadCommandLineOptions()
00113 {
00114
00115 KCmdLineArgs::addCmdLineOptions( KCmdLineOptions() );
00116 }
00117
00118 int KJotsUniqueAppHandler::newInstance()
00119 {
00120 kDebug();
00121
00122 (void)plugin()->part();
00123 org::kde::KJotsComponent kjots(
00124 "org.kde.kjots", "/KJotsComponent", QDBusConnection::sessionBus() );
00125 return Kontact::UniqueAppHandler::newInstance();
00126
00127 }
00128