2 * Copyright (C) 2001, 2006 Holger Freyther <freyther@kde.org>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include <kio/renamedialogplugin.h>
27 #include <kio/global.h>
30 #include <kgenericfactory.h>
31 #include <kiconloader.h>
37 #include <QStringList>
40 #include <QGridLayout>
43 #include <sys/types.h>
45 #include "imagevisualizer.h"
47 class ImagePlugin
: public KIO::RenameDialogPlugin
{
49 ImagePlugin( QDialog
*dialog
, const QStringList
& );
50 virtual bool wantToHandle( KIO::RenameDialog_Mode
, const KIO::RenameDialogPlugin::FileItem
&,
51 const KIO::RenameDialogPlugin::FileItem
& ) const;
52 virtual void handle( KIO::RenameDialog_Mode
, const KIO::RenameDialogPlugin::FileItem
&,
53 const KIO::RenameDialogPlugin::FileItem
& );
56 ImagePlugin::ImagePlugin( QDialog
*dialog
, const QStringList
& )
57 : RenameDialogPlugin( dialog
)
61 bool ImagePlugin::wantToHandle( KIO::RenameDialog_Mode
, const KIO::RenameDialogPlugin::FileItem
&,
62 const KIO::RenameDialogPlugin::FileItem
& ) const {
66 void ImagePlugin::handle( KIO::RenameDialog_Mode mode
, const KIO::RenameDialogPlugin::FileItem
& src
,
67 const KIO::RenameDialogPlugin::FileItem
& dst
) {
68 QGridLayout
*lay
= new QGridLayout( this );
69 if( mode
& KIO::M_OVERWRITE
) {
70 QLabel
*label
= new QLabel(this );
71 label
->setText(i18n("You want to overwrite the left picture with the one on the right.") );
73 lay
->addWidget(label
, 1, 0, 1, 3, Qt::AlignHCenter
);
77 ImageVisualizer
*left
= new ImageVisualizer(this, dst
.url() );
78 ImageVisualizer
*right
= new ImageVisualizer( this, src
.url() );
80 lay
->addWidget(left
, 2, 0 );
81 lay
->addWidget(right
, 2, 2 );
85 typedef KGenericFactory
<ImagePlugin
, QDialog
> ImagePluginFactory
;
86 K_EXPORT_COMPONENT_FACTORY( librenimageplugin
, ImagePluginFactory("imagerename_plugin") )