1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
/* ============================================================
* File : plugin_helloworld.cpp
* Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
* Date : 2003-03-10
* Description :
*
* Copyright 2003 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================ */
// KDE includes.
#include <klocale.h>
#include <tdeaction.h>
#include <kgenericfactory.h>
#include <klibloader.h>
#include <tdeconfig.h>
#include <kdebug.h>
// LibKIPi includes.
#include <libkipi/imagecollection.h>
// Local includes.
#include "plugin_helloworld.h"
// A macro from KDE KParts to export the symbols for this plugin and
// create the factory for it. The first argument is the name of the
// plugin library and the second is the genericfactory templated from
// the class for your plugin
typedef KGenericFactory<Plugin_HelloWorld> Factory;
K_EXPORT_COMPONENT_FACTORY( kipiplugin_helloworld,
Factory("kipiplugin_helloworld"));
Plugin_HelloWorld::Plugin_HelloWorld(TQObject *parent,
const char*,
const TQStringList&)
: KIPI::Plugin( Factory::instance(), parent, "HelloWorld")
{
kdDebug( 51001 ) << "Plugin_HelloWorld plugin loaded" << endl;
}
void Plugin_HelloWorld::setup( TQWidget* widget )
{
KIPI::Plugin::setup( widget );
// this is our action shown in the menubar/toolbar of the mainwindow
m_actionHelloWorld = new TDEAction (i18n("Hello World..."),
"misc",
0, // do never set shortcuts from plugins.
this,
TQT_SLOT(slotActivate()),
actionCollection(),
"helloworld");
addAction( m_actionHelloWorld );
m_interface = dynamic_cast< KIPI::Interface* >( parent() );
if ( !m_interface )
{
kdError( 51000 ) << "Kipi interface is null!" << endl;
return;
}
}
void Plugin_HelloWorld::slotActivate()
{
kdDebug( 51000 ) << "Plugin_HelloWorld slot activated" << endl;
// Print some information about the capabilities of the host application.
kdDebug( 51000 ) << "Features supported by the host application:"
<< endl;
kdDebug( 51000 ) << " AlbumsHaveComments: "
<< (m_interface->hasFeature( KIPI::AlbumsHaveComments ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " ImagesHasComments: "
<< (m_interface->hasFeature( KIPI::ImagesHasComments ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " ImagesHasTime: "
<< (m_interface->hasFeature( KIPI::ImagesHasTime ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " SupportsDateRanges: "
<< (m_interface->hasFeature( KIPI::SupportsDateRanges ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " AcceptNewImages: "
<< (m_interface->hasFeature( KIPI::AcceptNewImages ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " ImageTitlesWritable: "
<< (m_interface->hasFeature( KIPI::ImageTitlesWritable ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " AlbumsHaveCategory: "
<< (m_interface->hasFeature( KIPI::AlbumsHaveCategory ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " AlbumsHaveCreationDate: "
<< (m_interface->hasFeature( KIPI::AlbumsHaveCreationDate ) ? "Yes" : "No")
<< endl;
kdDebug( 51000 ) << " AlbumsUseFirstImagePreview: "
<< (m_interface->hasFeature( KIPI::AlbumsUseFirstImagePreview ) ? "Yes" : "No")
<< endl;
// ================================================== Selection
kdDebug( 51000 ) << endl
<< "==================================================" << endl
<< " Selection " << endl
<< "==================================================" << endl;
KIPI::ImageCollection selection = m_interface->currentSelection();
if ( !selection.isValid() ) {
kdDebug( 51000) << "No Selection!" << endl;
}
else {
KURL::List images = selection.images();
for( KURL::List::Iterator selIt = images.begin(); selIt != images.end(); ++selIt ) {
kdDebug( 51000 ) << *selIt << endl;
KIPI::ImageInfo info = m_interface->info( *selIt );
kdDebug( 51000 ) << "\ttitle: " << info.title() << endl;
if ( m_interface->hasFeature( KIPI::ImagesHasComments ) )
kdDebug( 51000 ) << "\tdescription: " << info.description() << endl;
}
}
// ================================================== Current Album
kdDebug( 51000 ) << endl
<< "==================================================" << endl
<< " Current Album " << endl
<< "==================================================" << endl;
KIPI::ImageCollection album = m_interface->currentAlbum();
if ( !album.isValid() ) {
kdDebug( 51000 ) << "No album!" << endl;
}
else {
KURL::List images = album.images();
for( KURL::List::Iterator albumIt = images.begin(); albumIt != images.end(); ++albumIt ) {
kdDebug( 51000 ) << *albumIt << endl;
}
kdDebug( 51000 ) << "Album name: " << album.name() << endl;
if ( m_interface->hasFeature( KIPI::AlbumsHaveComments ) ) {
kdDebug( 51000 ) << "Album Comment: " << album.comment() << endl;
}
}
}
KIPI::Category Plugin_HelloWorld::category( TDEAction* action ) const
{
if ( action == m_actionHelloWorld )
return KIPI::IMAGESPLUGIN;
kdWarning( 51000 ) << "Unrecognized action for plugin category identification" << endl;
return KIPI::IMAGESPLUGIN; // no warning from compiler, please
}
#include "plugin_helloworld.moc"
|