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

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • plugins
  • kjots
kjots_plugin.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KJots.
3 
4  Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "kjots_plugin.h"
26 
27 #include <KontactInterface/Core>
28 
29 #include <KAction>
30 #include <KActionCollection>
31 #include <KCmdLineArgs>
32 #include <KIcon>
33 #include <KLocalizedString>
34 
35 EXPORT_KONTACT_PLUGIN( KJotsPlugin, kjots )
36 
37 KJotsPlugin::KJotsPlugin( KontactInterface::Core *core, const QVariantList & )
38  : KontactInterface::Plugin( core, core, "kjots" ), m_interface( 0 )
39 {
40  setComponentData( KontactPluginFactory::componentData() );
41 
42  KAction *action =
43  new KAction( KIcon( QLatin1String("document-new") ),
44  i18nc( "@action:inmenu", "New KJots Page" ), this );
45  actionCollection()->addAction( QLatin1String("new_kjots_page"), action );
46  action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_P ) );
47  action->setHelpText(
48  i18nc( "@info:status", "Create a new jots page" ) );
49  action->setWhatsThis(
50  i18nc( "@info:whatsthis",
51  "You will be presented with a dialog where you can create a new jots page." ) );
52  connect( action, SIGNAL(triggered(bool)), SLOT(newPage()) );
53  insertNewAction( action );
54 
55  action = new KAction( KIcon( QLatin1String("address-book-new") ),
56  i18nc( "@action:inmenu", "New KJots Book" ), this );
57  actionCollection()->addAction( QLatin1String("new_kjots_book"), action );
58  action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_B ) );
59  action->setHelpText(
60  i18nc( "@info:status", "Create a new jots book" ) );
61  action->setWhatsThis(
62  i18nc( "@info:whatsthis",
63  "You will be presented with a dialog where you can create a new jots book." ) );
64  connect( action, SIGNAL(triggered(bool)), SLOT(newBook()) );
65  insertNewAction( action );
66 
67  mUniqueAppWatcher = new KontactInterface::UniqueAppWatcher(
68  new KontactInterface::UniqueAppHandlerFactory<KJotsUniqueAppHandler>(), this );
69 }
70 
71 KJotsPlugin::~KJotsPlugin()
72 {
73  delete m_interface;
74  m_interface = 0;
75 }
76 
77 bool KJotsPlugin::isRunningStandalone() const
78 {
79  return mUniqueAppWatcher->isRunningStandalone();
80 }
81 
82 QStringList KJotsPlugin::invisibleToolbarActions() const
83 {
84  return QStringList() << QLatin1String("new_page") << QLatin1String("new_book") ;
85 }
86 
87 KParts::ReadOnlyPart *KJotsPlugin::createPart()
88 {
89  KParts::ReadOnlyPart *part = loadPart();
90  if ( !part ) {
91  return 0;
92  }
93 
94  m_interface = new OrgKdeKJotsWidgetInterface(
95  QLatin1String("org.kde.kjots"), QLatin1String("/KJotsWidget"), QDBusConnection::sessionBus() );
96 
97  return part;
98 }
99 
100 OrgKdeKJotsWidgetInterface *KJotsPlugin::interface()
101 {
102  if ( !m_interface ) {
103  part();
104  }
105  Q_ASSERT( m_interface );
106  return m_interface;
107 }
108 
109 void KJotsPlugin::newPage()
110 {
111  core()->selectPlugin( this );
112  interface()->newPage();
113 }
114 
115 void KJotsPlugin::newBook()
116 {
117  core()->selectPlugin( this );
118  interface()->newBook();
119 }
120 
121 bool KJotsPlugin::queryClose() const
122 {
123  if ( m_interface ) {
124  return m_interface->queryClose();
125  }
126  return true;
127 }
128 
129 void KJotsUniqueAppHandler::loadCommandLineOptions()
130 {
131  // No command line args to load.
132  KCmdLineArgs::addCmdLineOptions( KCmdLineOptions() );
133 }
134 
135 int KJotsUniqueAppHandler::newInstance()
136 {
137  // Ensure part is loaded
138  (void)plugin()->part();
139 #if 0
140  org::kde::KJotsWidget kjots(
141  "org.kde.kjots", "/KJotsWidget", QDBusConnection::sessionBus() );
142 #endif
143  return KontactInterface::UniqueAppHandler::newInstance();
144 
145 }
146 
147 
KJotsPlugin::interface
OrgKdeKJotsWidgetInterface * interface()
Definition: kjots_plugin.cpp:100
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KJotsPlugin
Definition: kjots_plugin.h:45
KJotsUniqueAppHandler::newInstance
virtual int newInstance()
Definition: kjots_plugin.cpp:135
KJotsPlugin::~KJotsPlugin
~KJotsPlugin()
Definition: kjots_plugin.cpp:71
KJotsPlugin::invisibleToolbarActions
QStringList invisibleToolbarActions() const
Definition: kjots_plugin.cpp:82
QStringList
KJotsPlugin::mUniqueAppWatcher
KontactInterface::UniqueAppWatcher * mUniqueAppWatcher
Definition: kjots_plugin.h:65
KJotsUniqueAppHandler::loadCommandLineOptions
virtual void loadCommandLineOptions()
Definition: kjots_plugin.cpp:129
KJotsPlugin::createPart
KParts::ReadOnlyPart * createPart()
Definition: kjots_plugin.cpp:87
QLatin1String
QKeySequence
kjots_plugin.h
KJotsPlugin::m_interface
OrgKdeKJotsWidgetInterface * m_interface
Definition: kjots_plugin.h:66
KJotsPlugin::isRunningStandalone
bool isRunningStandalone() const
Definition: kjots_plugin.cpp:77
KJotsPlugin::queryClose
virtual bool queryClose() const
Definition: kjots_plugin.cpp:121
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • 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
  • pimprint

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