23 #include "knotes/resource/resourcemanager.h"
25 #include "migrations/knoteslegacy.h"
26 #include "knotes/knotesglobalconfig.h"
28 #include "kdepim-version.h"
33 #include <KABC/VCardDrag>
34 #include <KCal/CalendarLocal>
35 #include <KCal/ICalDrag>
37 #include <KontactInterface/Core>
40 #include <KCmdLineArgs>
42 #include <KActionCollection>
46 #include <KMessageBox>
47 #include <KSystemTimeZones>
49 #include <QDBusConnection>
50 #include <QDBusMessage>
56 : KontactInterface::Plugin( core, core, "knotes" ),
60 const bool needConvert = (KNotesGlobalConfig::self()->notesVersion()<1);
63 KNotesLegacy::cleanUp();
66 mCalendar =
new CalendarLocal( QString::fromLatin1(
"UTC" ) );
68 mManager =
new KNotesResourceManager();
69 setComponentData( KontactPluginFactory::componentData() );
72 new KAction( KIcon( QLatin1String(
"knotes") ),
73 i18nc(
"@action:inmenu",
"New Popup Note..." ),
this );
74 actionCollection()->addAction( QLatin1String(
"new_note"), action );
75 connect( action, SIGNAL(triggered(
bool)), SLOT(slotNewNote()) );
76 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_N ) );
78 i18nc(
"@info:status",
"Create new popup note" ) );
80 i18nc(
"@info:whatsthis",
81 "You will be presented with a dialog where you can create a new popup note." ) );
82 insertNewAction( action );
84 mUniqueAppWatcher =
new KontactInterface::UniqueAppWatcher(
85 new KontactInterface::UniqueAppHandlerFactory<KNotesUniqueAppHandler>(),
this );
87 QObject::connect( mManager, SIGNAL(sigRegisteredNote(KCal::Journal*)),
88 this, SLOT(addNote(KCal::Journal*)) );
89 QObject::connect( mManager, SIGNAL(sigDeregisteredNote(KCal::Journal*)),
90 this, SLOT(removeNote(KCal::Journal*)) );
100 return mUniqueAppWatcher->isRunningStandalone();
119 return mNotesSummary;
126 new KAboutData(
"knotes", 0,
127 ki18nc(
"@title",
"KNotes" ),
129 ki18nc(
"@title",
"Popup Notes" ),
130 KAboutData::License_GPL_V2,
131 ki18nc(
"@info:credit",
"Copyright © 2003–2013 Kontact authors" ) );
133 mAboutData->addAuthor( ki18nc(
"@info:credit",
"Michael Brade" ),
134 ki18nc(
"@info:credit",
"Current Maintainer" ),
136 mAboutData->addAuthor( ki18nc(
"@info:credit",
"Tobias Koenig" ),
137 ki18nc(
"@info:credit",
"Developer" ),
139 mAboutData->addAuthor( ki18nc(
"@info:credit",
"Laurent Montel" ),
140 ki18nc(
"@info:credit",
"Developer" ),
150 mimeData->hasText() ||
161 KABC::Addressee::List contacts;
165 KABC::Addressee::List::ConstIterator it;
167 QStringList attendees;
168 KABC::Addressee::List::ConstIterator end(contacts.constEnd());
169 for ( it = contacts.constBegin(); it != end; ++it ) {
170 const QString email = (*it).fullEmail();
171 if ( email.isEmpty() ) {
172 attendees.append( (*it).realName() + QLatin1String(
"<>") );
174 attendees.append( email );
179 i18nc(
"@item",
"Meeting" ), attendees.join( QLatin1String(
", ") ) );
184 CalendarLocal cal( KSystemTimeZones::local() );
186 Journal::List journals = cal.journals();
187 if ( !journals.isEmpty() ) {
189 Journal *j = journals.first();
191 newNote( i18nc(
"@item",
"Note: %1", j->summary() ), j->description() );
198 if ( md->hasText() ) {
200 i18nc(
"@item",
"New Note" ), md->text() );
207 if ( mails.count() != 1 ) {
210 i18nc(
"@info",
"Dropping multiple mails is not supported." ) );
213 QString txt = i18nc(
"@item",
"From: %1\nTo: %2\nSubject: %3",
216 i18nc(
"@item",
"Mail: %1", mail.
subject() ), txt );
221 kWarning() << QString::fromLatin1(
"Cannot handle drop events of type '%1'." ).arg( QLatin1String(event->format()) );
226 void KNotesPlugin::slotNewNote()
229 static_cast<KNotesPart *
>( part() )->newNote();
233 void KNotesPlugin::addNote( KCal::Journal *j )
235 mCalendar->addJournal( j );
237 mNotesSummary->updateSummary(
true);
240 void KNotesPlugin::removeNote( KCal::Journal *j )
242 mCalendar->deleteJournal( j );
244 mNotesSummary->updateSummary(
true);
249 KCmdLineArgs::addCmdLineOptions( KCmdLineOptions() );
256 (void)plugin()->part();
257 return KontactInterface::UniqueAppHandler::newInstance();
263 #include "knotes_plugin.moc"
const KAboutData * aboutData() const
virtual KontactInterface::Summary * createSummaryWidget(QWidget *parentWidget)
virtual int newInstance()
static MailList fromMimeData(const QMimeData *md)
bool isRunningStandalone() const
void processDropEvent(QDropEvent *)
bool canDecodeMimeData(const QMimeData *data) const
static bool canDecode(const QMimeData *md)
KParts::ReadOnlyPart * createPart()
virtual void loadCommandLineOptions()