• 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
  • ktimetracker
ktimetracker_plugin.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5  adapted for karm 2005 by Thorsten Staerk <kde@staerk.de>
6  karm renamed to ktimetracker 2007-2008
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License along
19  with this program; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 
22  As a special exception, permission is given to link this program
23  with any edition of Qt, and distribute the resulting executable,
24  without including the source code for Qt in the source distribution.
25 */
26 
27 #include "ktimetracker_plugin.h"
28 #include "ktimetrackerinterface.h"
29 
30 #include <KontactInterface/Core>
31 
32 #include <KActionCollection>
33 #include <KCmdLineArgs>
34 #include <KDebug>
35 #include <KIcon>
36 #include <KXMLGUIFactory>
37 
38 #include <QMenu>
39 
40 EXPORT_KONTACT_PLUGIN( ktimetrackerplugin, ktimetracker )
41 
42 ktimetrackerplugin::ktimetrackerplugin( KontactInterface::Core *core, const QVariantList & )
43  : KontactInterface::Plugin( core, core, "ktimetracker" ), mInterface( 0 )
44 {
45  setComponentData( KontactPluginFactory::componentData() );
46 
47  KAction *action = new KAction( KIcon( "ktimetracker" ),
48  i18nc( "@action:inmenu", "New Task" ), this );
49  actionCollection()->addAction( "new_task", action );
50  action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_W ) );
51  action->setHelpText( i18nc( "@info:status", "Create a new time tracker" ) );
52  action->setWhatsThis(
53  i18nc( "@info:whatsthis",
54  "You will be presented with a dialog where you can create "
55  "and start a new time tracker." ) );
56  connect( action, SIGNAL(triggered(bool)), SLOT(newTask()) );
57  insertNewAction( action );
58 
59  mUniqueAppWatcher = new KontactInterface::UniqueAppWatcher(
60  new KontactInterface::UniqueAppHandlerFactory<KtimetrackerUniqueAppHandler>(), this );
61 }
62 
63 ktimetrackerplugin::~ktimetrackerplugin()
64 {
65  delete mInterface;
66 }
67 
68 bool ktimetrackerplugin::isRunningStandalone() const
69 {
70  return mUniqueAppWatcher->isRunningStandalone();
71 }
72 
73 QStringList ktimetrackerplugin::invisibleToolbarActions() const
74 {
75  return QStringList() << "new_task" << "new_sub_task" ;
76 }
77 
78 KParts::ReadOnlyPart *ktimetrackerplugin::createPart()
79 {
80  KParts::ReadOnlyPart *part = loadPart();
81  if ( !part ) {
82  return 0;
83  }
84  mInterface = new OrgKdeKtimetrackerKtimetrackerInterface(
85  "org.kde.ktimetracker", "/KTimeTracker", QDBusConnection::sessionBus() );
86  // Setup context menu request handling
87  connect( part->widget(),
88  SIGNAL(contextMenuRequested(QPoint)),
89  this,
90  SLOT(taskViewCustomContextMenuRequested(QPoint)) );
91 
92  return part;
93 }
94 
95 void ktimetrackerplugin::taskViewCustomContextMenuRequested( const QPoint &point )
96 {
97  kDebug() << "entering function";
98  QMenu *pop = dynamic_cast<QMenu*>( factory()->container( i18n( "task_popup" ), part() ) );
99  if ( pop ) {
100  pop->popup( point );
101  }
102 }
103 
104 OrgKdeKtimetrackerKtimetrackerInterface *ktimetrackerplugin::interface()
105 {
106  if ( !mInterface ) {
107  part();
108  }
109  Q_ASSERT( mInterface );
110  return mInterface;
111 }
112 
113 QStringList ktimetrackerplugin::configModules() const
114 {
115  QStringList modules;
116  modules << "PIM/ktimetrackerconfig.desktop";
117  return modules;
118 }
119 
120 void ktimetrackerplugin::newTask()
121 {
122  kDebug() << "entering function";
123  core()->selectPlugin( this );
124  interface()->newTask();
125 }
126 
127 void KtimetrackerUniqueAppHandler::loadCommandLineOptions()
128 {
129  // TODO: handle command line options
130  KCmdLineArgs::addCmdLineOptions( KCmdLineOptions() );
131 }
132 
133 int KtimetrackerUniqueAppHandler::newInstance()
134 {
135  // Ensure part is loaded
136  (void)plugin()->part();
137  return KontactInterface::UniqueAppHandler::newInstance();
138 }
139 
ktimetrackerplugin::isRunningStandalone
virtual bool isRunningStandalone() const
Definition: ktimetracker_plugin.cpp:68
KtimetrackerUniqueAppHandler::newInstance
virtual int newInstance()
Definition: ktimetracker_plugin.cpp:133
ktimetrackerplugin::~ktimetrackerplugin
~ktimetrackerplugin()
Definition: ktimetracker_plugin.cpp:63
ktimetrackerplugin
Definition: ktimetracker_plugin.h:46
ktimetrackerplugin::interface
OrgKdeKtimetrackerKtimetrackerInterface * interface()
Definition: ktimetracker_plugin.cpp:104
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KtimetrackerUniqueAppHandler::loadCommandLineOptions
virtual void loadCommandLineOptions()
Definition: ktimetracker_plugin.cpp:127
QPoint
QMenu::popup
void popup(const QPoint &p, QAction *atAction)
QStringList
QMenu
ktimetracker_plugin.h
QKeySequence
ktimetrackerplugin::createPart
KParts::ReadOnlyPart * createPart()
Definition: ktimetracker_plugin.cpp:78
ktimetrackerplugin::invisibleToolbarActions
virtual QStringList invisibleToolbarActions() const
Definition: ktimetracker_plugin.cpp:73
ktimetrackerplugin::configModules
virtual QStringList configModules() const
Definition: ktimetracker_plugin.cpp:113
ktimetrackerplugin::taskViewCustomContextMenuRequested
void taskViewCustomContextMenuRequested(const QPoint &)
Definition: ktimetracker_plugin.cpp:95
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