add more spacing
[personal-kdebase.git] / runtime / renamedlgplugins / audio / audio_plugin.cpp
blob4dfb7e1317ed8295f709ae8221115b51c2868545
1 /* This file is part of the KDE project
2 Copyright (C) 2003 Fabian Wolf <fabianw@gmx.net>
4 image_plugin.cpp (also Part of the KDE Project) used as template
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; version 2
9 of the License.
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 GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include <kgenericfactory.h>
23 #include <ksqueezedtextlabel.h>
24 #include <kio/renamedialogplugin.h>
25 #include <qlabel.h>
26 #include <qdialog.h>
27 #include <qwidget.h>
28 #include <qstringlist.h>
29 #include <QGridLayout>
30 #include <kio/global.h>
31 #include <qlayout.h>
33 #include <sys/types.h>
35 #include "audiopreview.h"
37 class AudioPlugin : public KIO::RenameDialogPlugin{
38 public:
39 AudioPlugin( QDialog *dialog, const QStringList & );
40 ~AudioPlugin();
42 bool wantToHandle( KIO::RenameDialog_Mode mode, const KIO::RenameDialogPlugin::FileItem& src,
43 const KIO::RenameDialogPlugin::FileItem& dst ) const;
44 void handle( KIO::RenameDialog_Mode, const KIO::RenameDialogPlugin::FileItem& src,
45 const KIO::RenameDialogPlugin::FileItem& dst );
48 AudioPlugin::AudioPlugin( QDialog *dialog, const QStringList & ) : RenameDialogPlugin( dialog) {
49 qWarning("loaded" );
51 AudioPlugin::~AudioPlugin()
55 bool AudioPlugin::wantToHandle( KIO::RenameDialog_Mode, const KIO::RenameDialogPlugin::FileItem&,
56 const KIO::RenameDialogPlugin::FileItem& ) const {
57 return true;
60 void AudioPlugin::handle( KIO::RenameDialog_Mode mode, const KIO::RenameDialogPlugin::FileItem& src,
61 const KIO::RenameDialogPlugin::FileItem& dst ) {
63 QGridLayout *lay = new QGridLayout( this );
64 if( mode & KIO::M_OVERWRITE ){
65 QLabel *label_src = new QLabel(this);
66 QLabel *label_dst = new QLabel(this);
67 QLabel *label_ask = new QLabel(this);
69 QString sentence1;
70 QString dest = dst.url().pathOrUrl();
71 if ( src.mTime() < dst.mTime() )
72 sentence1 = i18n("An older file named '%1' already exists.\n", dest);
73 else if ( src.mTime() == dst.mTime() )
74 sentence1 = i18n("A similar file named '%1' already exists.\n", dest);
75 else
76 sentence1 = i18n("A newer file named '%1' already exists.\n", dest);
77 QLabel *label_head = new KSqueezedTextLabel(sentence1, this);
78 label_src->setText(i18n("Source File"));
79 label_dst->setText(i18n("Existing File"));
80 label_ask->setText(i18n("Would you like to replace the existing file with the one on the right?") );
81 label_head->adjustSize();
82 label_src->adjustSize();
83 label_dst->adjustSize();
84 label_ask->adjustSize();
85 lay->addWidget(label_head, 0, 0, 1, 3, Qt::AlignLeft);
86 lay->addWidget(label_dst, 1, 0, Qt::AlignLeft);
87 lay->addWidget(label_src, 1, 2, Qt::AlignLeft);
88 lay->addWidget(label_ask, 3, 0, 1, 3, Qt::AlignLeft);
89 adjustSize();
91 AudioPreview *left= new AudioPreview(this, dst.url(), dst.mimeType() );
92 AudioPreview *right = new AudioPreview( this, src.url(), src.mimeType() );
93 lay->addWidget(left, 2, 0 );
94 lay->addWidget(right, 2, 2 );
95 adjustSize();
98 typedef KGenericFactory<AudioPlugin, QDialog> AudioPluginFactory;
99 K_EXPORT_COMPONENT_FACTORY( librenaudioplugin, AudioPluginFactory("audiorename_plugin") )