summaryrefslogtreecommitdiffstats
path: root/renamedlgplugins/audio
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /renamedlgplugins/audio
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'renamedlgplugins/audio')
-rw-r--r--renamedlgplugins/audio/Makefile.am16
-rw-r--r--renamedlgplugins/audio/TODO9
-rw-r--r--renamedlgplugins/audio/audio_plugin.cpp104
-rw-r--r--renamedlgplugins/audio/audiopreview.cpp135
-rw-r--r--renamedlgplugins/audio/audiopreview.h75
-rw-r--r--renamedlgplugins/audio/renaudiodlg.desktop63
6 files changed, 402 insertions, 0 deletions
diff --git a/renamedlgplugins/audio/Makefile.am b/renamedlgplugins/audio/Makefile.am
new file mode 100644
index 0000000..d9a228f
--- /dev/null
+++ b/renamedlgplugins/audio/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = librenaudioplugin.la
+
+librenaudioplugin_la_SOURCES = audiopreview.cpp audio_plugin.cpp
+librenaudioplugin_la_LIBADD = $(LIB_KIO) -lkmediaplayer
+librenaudioplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+pluginsdir = $(kde_servicesdir)
+plugins_DATA = renaudiodlg.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/audiorename_plugin.pot
diff --git a/renamedlgplugins/audio/TODO b/renamedlgplugins/audio/TODO
new file mode 100644
index 0000000..453c700
--- /dev/null
+++ b/renamedlgplugins/audio/TODO
@@ -0,0 +1,9 @@
+Some ideas on what would be nice if implemented...
+
+* Start playing the audio file when icon is hovered.
+* Colorize differences in file information
+* On remote files: load file when label is clicked
+* Tell if source or destination file is broken
+* Tell if they're different or the same, not taking e.g. the IDtag into
+ account, only the actual audio data.
+* ...
diff --git a/renamedlgplugins/audio/audio_plugin.cpp b/renamedlgplugins/audio/audio_plugin.cpp
new file mode 100644
index 0000000..f8114bd
--- /dev/null
+++ b/renamedlgplugins/audio/audio_plugin.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Fabian Wolf <fabianw@gmx.net>
+
+ image_plugin.cpp (also Part of the KDE Project) used as template
+
+ 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; version 2
+ of the License.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kgenericfactory.h>
+#include <renamedlgplugin.h>
+#include <kio/renamedlg.h>
+#include <qlabel.h>
+#include <qdialog.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <kio/global.h>
+#include <qlayout.h>
+
+#include <sys/types.h>
+
+#include "audiopreview.h"
+
+class AudioPlugin : public RenameDlgPlugin{
+public:
+ AudioPlugin( QDialog *dialog, const char *name, const QStringList & );
+ ~AudioPlugin();
+ virtual bool initialize( KIO::RenameDlg_Mode /*mod*/, const QString &/*_src*/, const QString &/*_dest*/,
+ const QString &/*mimeSrc*/,
+ const QString &/*mimeDest*/,
+ KIO::filesize_t /*sizeSrc*/,
+ KIO::filesize_t /*sizeDest*/,
+ time_t /*ctimeSrc*/,
+ time_t /*ctimeDest*/,
+ time_t /*mtimeSrc*/,
+ time_t /*mtimeDest*/ );
+};
+
+AudioPlugin::AudioPlugin( QDialog *dialog, const char *name, const QStringList &list ) : RenameDlgPlugin( dialog, name, list) {
+ qWarning("loaded" );
+}
+AudioPlugin::~AudioPlugin()
+{
+}
+bool AudioPlugin::initialize( KIO::RenameDlg_Mode mode, const QString &_src, const QString &_dest,
+ const QString &mimeSrc,
+ const QString &mimeDest,
+ KIO::filesize_t /*sizeSrc*/,
+ KIO::filesize_t /*sizeDest*/,
+ time_t /*ctimeSrc*/,
+ time_t /*ctimeDest*/,
+ time_t mtimeSrc,
+ time_t mtimeDest ) {
+ QGridLayout *lay = new QGridLayout(this, 4, 3, 5);
+ if( mode & KIO::M_OVERWRITE ){
+ QLabel *label_head = new QLabel(this);
+ QLabel *label_src = new QLabel(this);
+ QLabel *label_dst = new QLabel(this);
+ QLabel *label_ask = new QLabel(this);
+
+ QString sentence1;
+ QString dest = KURL::fromPathOrURL(_dest).pathOrURL();
+ if (mtimeDest < mtimeSrc)
+ sentence1 = i18n("An older file named '%1' already exists.\n").arg(dest);
+ else if (mtimeDest == mtimeSrc)
+ sentence1 = i18n("A similar file named '%1' already exists.\n").arg(dest);
+ else
+ sentence1 = i18n("A newer file named '%1' already exists.\n").arg(dest);
+ label_head->setText(sentence1);
+ label_src->setText(i18n("Source File"));
+ label_dst->setText(i18n("Existing File"));
+ label_ask->setText(i18n("Would you like to replace the existing file with the one on the right?") );
+ label_head->adjustSize();
+ label_src->adjustSize();
+ label_dst->adjustSize();
+ label_ask->adjustSize();
+ lay->addMultiCellWidget(label_head, 0, 0, 0, 2, Qt::AlignLeft);
+ lay->addWidget(label_dst, 1, 0, Qt::AlignLeft);
+ lay->addWidget(label_src, 1, 2, Qt::AlignLeft);
+ lay->addMultiCellWidget(label_ask, 3, 3, 0, 2, Qt::AlignLeft);
+ adjustSize();
+ }
+ AudioPreview *left= new AudioPreview(this, "Preview Left", _dest, mimeDest );
+ AudioPreview *right = new AudioPreview( this, "Preview Right", _src, mimeSrc);
+ lay->addWidget(left, 2, 0 );
+ lay->addWidget(right, 2, 2 );
+ adjustSize();
+ return true;
+}
+
+typedef KGenericFactory<AudioPlugin, QDialog> AudioPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( librenaudioplugin, AudioPluginFactory("audiorename_plugin") )
diff --git a/renamedlgplugins/audio/audiopreview.cpp b/renamedlgplugins/audio/audiopreview.cpp
new file mode 100644
index 0000000..e9c6f26
--- /dev/null
+++ b/renamedlgplugins/audio/audiopreview.cpp
@@ -0,0 +1,135 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Fabian Wolf <fabianw@gmx.net>
+
+ 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; version 2
+ of the License.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kfilemetainfo.h>
+#include <klocale.h>
+#include <kmimetype.h>
+#include <kurl.h>
+#include <qvbox.h>
+#include <qlabel.h>
+#include <qpixmap.h>
+#include <kio/netaccess.h>
+#include <kurllabel.h>
+#include <kmimetype.h>
+#include <kmediaplayer/player.h>
+#include <kparts/componentfactory.h>
+#include <ksqueezedtextlabel.h>
+
+#include "audiopreview.h"
+
+AudioPreview::AudioPreview( QWidget *parent, const char *name, const QString &fileName, const QString &mimeType)
+ : QVBox( parent, name )
+{
+ m_isTempFile = false;
+ pic = 0;
+ m_player = 0L;
+ description = 0;
+ // fileName is created by KUrl::prettyURL()
+ KURL url( fileName );
+ setSpacing( 0 );
+ if( url.isValid() && url.isLocalFile() ) {
+ m_localFile = url.path();
+ pic = new QLabel(this);
+ pic->setPixmap(KMimeType::pixmapForURL( url ));
+ pic->adjustSize();
+ initView( mimeType );
+ } else if( !url.isLocalFile() ) {
+ KURLLabel *label = new KURLLabel( this );
+ label->setText(i18n("This audio file isn't stored\non the local host.\nClick on this label to load it.\n" ) );
+ label->setURL( url.prettyURL() );
+ connect(label, SIGNAL(leftClickedURL(const QString&)), SLOT(downloadFile(const QString&)));
+ pic = label;
+ } else {
+ description = new QLabel(this );
+ description->setText(i18n("Unable to load audio file") );
+ }
+}
+
+AudioPreview::~AudioPreview()
+{
+ if ( m_isTempFile )
+ KIO::NetAccess::removeTempFile( m_localFile );
+
+ delete m_player;
+}
+
+void AudioPreview::initView( const QString& mimeType )
+{
+ KURL url = KURL::fromPathOrURL( m_localFile );
+ pic->setText( QString::null );
+ pic->setPixmap(KMimeType::pixmapForURL( url ));
+ pic->adjustSize();
+
+ KFileMetaInfo info(m_localFile);
+ KMimeType::Ptr mimeptr = KMimeType::mimeType(mimeType);
+
+ QString desc;
+ if (info.isValid())
+ {
+ if (mimeptr->is("audio/x-mp3") || mimeptr->is("application/ogg"))
+ {
+ // following 3 infos might be very long; make sure they get squeezed
+ // TODO: when string-freeze is over, eliminate trailing '\n' as it's no longer needed
+ KSqueezedTextLabel *sl;
+
+ sl = new KSqueezedTextLabel(this);
+ sl->setText(i18n("Artist: %1\n").arg(info.item("Artist").value().toString()));
+
+ sl = new KSqueezedTextLabel(this);
+ sl->setText(i18n("Title: %1\n").arg(info.item("Title").value().toString()));
+
+ sl = new KSqueezedTextLabel(this);
+ sl->setText(i18n("Comment: %1\n").arg(info.item("Comment").value().toString()));
+
+ desc.append(i18n("Biterate: 160 kbits/s", "Bitrate: %1 %2\n").arg( info.item("Bitrate").value().toString() ).arg( info.item("Bitrate").suffix() ));
+ }
+ desc.append(i18n("Sample rate: %1 %2\n").arg( info.item("Sample Rate").value().toString() ).arg( info.item("Sample Rate").suffix() ));
+ desc.append(i18n("Length: "));
+
+ /* Calculate length in mm:ss format */
+ int length = info.item("Length").value().toInt();
+ if (length/60 < 10)
+ desc.append("0");
+ desc.append(QString("%1:").arg(length/60, 0, 10));
+ if (length%60 < 10)
+ desc.append("0");
+ desc.append(QString("%1\n").arg(length%60, 0, 10));
+ }
+
+ description = new QLabel(this);
+ description->setText( desc );
+ description->adjustSize();
+ m_player = KParts::ComponentFactory::createInstanceFromQuery<KMediaPlayer::Player>( "KMediaPlayer/Player", QString::null, this );
+ if ( m_player )
+ {
+ static_cast<KParts::ReadOnlyPart*>(m_player)->openURL( url );
+ m_player->widget()->show();
+ }
+}
+
+void AudioPreview::downloadFile( const QString& url )
+{
+ if( KIO::NetAccess::download( KURL::fromPathOrURL( url ), m_localFile , topLevelWidget()) )
+ {
+ m_isTempFile = true;
+ initView( KMimeType::findByPath( m_localFile )->name() );
+ }
+}
+
+#include <audiopreview.moc>
diff --git a/renamedlgplugins/audio/audiopreview.h b/renamedlgplugins/audio/audiopreview.h
new file mode 100644
index 0000000..635a81b
--- /dev/null
+++ b/renamedlgplugins/audio/audiopreview.h
@@ -0,0 +1,75 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Fabian Wolf <fabianw@gmx.net>
+
+ 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; version 2
+ of the License.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef audiopreview_h
+#define audiopreview_h
+
+#include <qvbox.h>
+
+namespace KMediaPlayer
+{
+ class Player;
+}
+
+class QPixmap;
+class QLabel;
+class AudioPreview : public QVBox
+{
+ Q_OBJECT
+public:
+ AudioPreview(QWidget *parent, const char *name, const QString &fileName, const QString &mimeType);
+ ~AudioPreview();
+
+private slots:
+ void downloadFile(const QString& url);
+
+private:
+ void initView(const QString& mimeType);
+
+ QLabel *pic;
+ QLabel *description;
+ QString m_localFile;
+ bool m_isTempFile;
+
+ KMediaPlayer::Player *m_player;
+};
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/renamedlgplugins/audio/renaudiodlg.desktop b/renamedlgplugins/audio/renaudiodlg.desktop
new file mode 100644
index 0000000..cee4bdd
--- /dev/null
+++ b/renamedlgplugins/audio/renaudiodlg.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Name=Audio Preview
+Name[ar]=معاينة صوتية
+Name[az]=Audio Nümayişi
+Name[bg]=Прослушване на аудио
+Name[br]=Rakgwel klevet
+Name[bs]=Audio pregled
+Name[ca]=Escolta una mostra de so
+Name[cs]=Náhled zvuku
+Name[cy]=Rhagolwg Sain
+Name[da]=Lydforhåndsvisning
+Name[de]=Audio-Vorschau
+Name[el]=Προεπισκόπηση ήχου
+Name[eo]=Sonantaŭrigardo
+Name[es]=Reproducir audio
+Name[et]=Audiofailide eelvaatlus
+Name[eu]=Audio aurrebista
+Name[fa]=پیش‌نمایش صوتی
+Name[fi]=Musiikkiesikatselu
+Name[fr]=Aperçu audio
+Name[fy]=Audiofoarbyld
+Name[ga]=Réamhléargas Fuaime
+Name[gl]=Antevisión Áudio
+Name[he]=תצוגה מקדימה של שמע
+Name[hi]=आडियो पूर्वावलोकन
+Name[hr]=Pregled zvučne datoteke
+Name[hu]=Hangos betekintő
+Name[is]=Hljóðforsýn
+Name[it]=Anteprima audio
+Name[ja]=オーディオプレビュー
+Name[ka]=აუდიო წინასწარ ნახვა
+Name[kk]=Аудио файлымен алдын ала таңыстыру
+Name[km]= មើល​ជា​មុន​ដោយ​ស្វ័យប្រវត្តិ
+Name[lt]=Audio perklausaa
+Name[mk]=Преглед на звук
+Name[nb]=Lydforhåndsvisning
+Name[nds]=Klang-Vöransicht
+Name[ne]=अडियो पूर्वावलोकन
+Name[nl]=Audiovoorbeeld
+Name[nn]=Lydførehandsvisning
+Name[pa]=ਆਡੀਓ ਝਲਕ
+Name[pl]=Podgląd plików audio
+Name[pt]=Previsão Áudio
+Name[pt_BR]=Previsão de Áudio
+Name[ro]=Previzualizare audio
+Name[ru]=Аудиоознакомление
+Name[sk]=Automatický náhľad
+Name[sl]=Ogled zvoka
+Name[sr]=Преглед аудија
+Name[sr@Latn]=Pregled audija
+Name[sv]=Ljudförhandsgranskning
+Name[ta]=ஒலி முன்னோட்டம்
+Name[tg]=Аудиошиносоӣ
+Name[tr]=Audio Önizleme
+Name[uk]=Перегляд аудіо
+Name[uz]=Audio koʻrib chiqish
+Name[uz@cyrillic]=Аудио кўриб чиқиш
+Name[vi]=Xem thử âm thanh
+Name[zh_CN]=音频预览
+Name[zh_TW]=音效預覽
+X-KDE-Library=librenaudioplugin
+ServiceTypes=RenameDlg/Plugin,audio/x-mp3,audio/x-wav,application/ogg