From a849e93804c5662d68c478e3b6fb9ea301795809 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 19 Sep 2009 15:11:58 +0000 Subject: enabled vorbis plugin, fixed translation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1234 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/CMakeLists.txt | 2 +- src/plugins/Input/mad/mpegmetadatamodel.h | 1 + .../Input/mad/translations/mad_plugin_uk_UA.ts | 22 ++- src/plugins/Input/vorbis/CMakeLists.txt | 4 +- src/plugins/Input/vorbis/decoder_vorbis.cpp | 12 +- src/plugins/Input/vorbis/decoder_vorbis.h | 6 +- src/plugins/Input/vorbis/decodervorbisfactory.cpp | 21 ++- src/plugins/Input/vorbis/decodervorbisfactory.h | 11 +- src/plugins/Input/vorbis/detailsdialog.cpp | 104 ------------- src/plugins/Input/vorbis/detailsdialog.h | 44 ------ .../Input/vorbis/translations/vorbis_plugin_cs.ts | 56 +++---- .../Input/vorbis/translations/vorbis_plugin_de.ts | 56 +++---- .../Input/vorbis/translations/vorbis_plugin_it.ts | 52 +++---- .../Input/vorbis/translations/vorbis_plugin_lt.ts | 46 +++--- .../Input/vorbis/translations/vorbis_plugin_pl.ts | 54 +++---- .../Input/vorbis/translations/vorbis_plugin_ru.ts | 46 +++--- .../Input/vorbis/translations/vorbis_plugin_tr.ts | 46 +++--- .../vorbis/translations/vorbis_plugin_uk_UA.ts | 58 +++---- .../vorbis/translations/vorbis_plugin_zh_CN.ts | 46 +++--- .../vorbis/translations/vorbis_plugin_zh_TW.ts | 46 +++--- src/plugins/Input/vorbis/vorbis.pro | 4 +- src/plugins/Input/vorbis/vorbismetadatamodel.cpp | 167 +++++++++++++++++++++ src/plugins/Input/vorbis/vorbismetadatamodel.h | 61 ++++++++ 23 files changed, 532 insertions(+), 433 deletions(-) delete mode 100644 src/plugins/Input/vorbis/detailsdialog.cpp delete mode 100644 src/plugins/Input/vorbis/detailsdialog.h create mode 100644 src/plugins/Input/vorbis/vorbismetadatamodel.cpp create mode 100644 src/plugins/Input/vorbis/vorbismetadatamodel.h (limited to 'src/plugins/Input') diff --git a/src/plugins/Input/CMakeLists.txt b/src/plugins/Input/CMakeLists.txt index 6ac96c92a..a22de859b 100644 --- a/src/plugins/Input/CMakeLists.txt +++ b/src/plugins/Input/CMakeLists.txt @@ -3,7 +3,7 @@ INCLUDE(FindPkgConfig) SET(USE_MAD TRUE CACHE BOOL "enable/disable mad plugin") #SET(USE_FLAC TRUE CACHE BOOL "enable/disable flac plugin") -#SET(USE_VORBIS TRUE CACHE BOOL "enable/disable ogg vorbis plugin") +SET(USE_VORBIS TRUE CACHE BOOL "enable/disable ogg vorbis plugin") #SET(USE_FFMPEG TRUE CACHE BOOL "enable/disable ffmpeg plugin") #SET(USE_MPC TRUE CACHE BOOL "enable/disable mpc plugin") #SET(USE_SNDFILE TRUE CACHE BOOL "enable/disable sndfile plugin") diff --git a/src/plugins/Input/mad/mpegmetadatamodel.h b/src/plugins/Input/mad/mpegmetadatamodel.h index 0b134fd3f..06ba24735 100644 --- a/src/plugins/Input/mad/mpegmetadatamodel.h +++ b/src/plugins/Input/mad/mpegmetadatamodel.h @@ -28,6 +28,7 @@ class QTextCodec; class MPEGMetaDataModel : public MetaDataModel { +Q_OBJECT public: MPEGMetaDataModel(const QString &path, QObject *parent); ~MPEGMetaDataModel(); diff --git a/src/plugins/Input/mad/translations/mad_plugin_uk_UA.ts b/src/plugins/Input/mad/translations/mad_plugin_uk_UA.ts index b58ae0985..ca00fc666 100644 --- a/src/plugins/Input/mad/translations/mad_plugin_uk_UA.ts +++ b/src/plugins/Input/mad/translations/mad_plugin_uk_UA.ts @@ -1,6 +1,6 @@ - - + + DecoderMADFactory @@ -67,6 +67,9 @@ Гц + + + Mode Режим @@ -82,26 +85,33 @@ Розмір файла + Protection Захищено + + Yes Так + + No Ні + Copyright Авторське право + Original Оригінал @@ -110,11 +120,15 @@ SettingsDialog + + ID3v1 + + ID3v2 @@ -145,11 +159,15 @@ Перший: + + APE APE + + Disabled Вимкнути diff --git a/src/plugins/Input/vorbis/CMakeLists.txt b/src/plugins/Input/vorbis/CMakeLists.txt index 5b10c736b..18b9e9226 100644 --- a/src/plugins/Input/vorbis/CMakeLists.txt +++ b/src/plugins/Input/vorbis/CMakeLists.txt @@ -34,13 +34,13 @@ link_directories(${VORBIS_LIBRARY_DIRS} ${TAGLIB_LIBRARY_DIRS}) SET(libvorbis_SRCS decoder_vorbis.cpp decodervorbisfactory.cpp - detailsdialog.cpp + vorbismetadatamodel.cpp ) SET(libvorbis_MOC_HDRS decodervorbisfactory.h decoder_vorbis.h - detailsdialog.h + vorbismetadatamodel.h ) SET(libvorbis_RCCS translations/translations.qrc) diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index 7325967b0..33836f016 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -58,7 +58,7 @@ static int oggseek(void *src, int64_t offset, int whence) static int oggclose(void *src) { DecoderVorbis *dogg = (DecoderVorbis *) src; - dogg->input()->close(); + //dogg->input()->close(); return 0; } @@ -73,8 +73,8 @@ static long oggtell(void *src) // Decoder class -DecoderVorbis::DecoderVorbis(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o) - : Decoder(parent, d, i, o) +DecoderVorbis::DecoderVorbis(QIODevice *i) + : Decoder(i) { inited = FALSE; m_totalTime = 0; @@ -220,15 +220,15 @@ void DecoderVorbis::updateTags() + strlen ("discnumber=")))); } - stateHandler()->dispatch(metaData); + StateHandler::instance()->dispatch(metaData); } -void DecoderVorbis::seekAudio(qint64 time) +void DecoderVorbis::seek(qint64 time) { ov_time_seek(&oggfile, (double) time/1000); } -qint64 DecoderVorbis::readAudio(char *data, qint64 maxSize) +qint64 DecoderVorbis::read(char *data, qint64 maxSize) { len = -1; while (len < 0) diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h index b20b26ab7..eeac19c07 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.h +++ b/src/plugins/Input/vorbis/decoder_vorbis.h @@ -15,7 +15,7 @@ class DecoderVorbis : public Decoder { public: - DecoderVorbis(QObject *, DecoderFactory *, QIODevice *, Output *); + DecoderVorbis(QIODevice *); virtual ~DecoderVorbis(); // Standard Decoder API @@ -24,8 +24,8 @@ public: int bitrate(); private: - virtual qint64 readAudio(char *data, qint64 maxSize); - void seekAudio(qint64 time); + virtual qint64 read(char *data, qint64 maxSize); + virtual void seek(qint64 time); // helper functions void deinit(); diff --git a/src/plugins/Input/vorbis/decodervorbisfactory.cpp b/src/plugins/Input/vorbis/decodervorbisfactory.cpp index 8dcd738c7..ae81e46fa 100644 --- a/src/plugins/Input/vorbis/decodervorbisfactory.cpp +++ b/src/plugins/Input/vorbis/decodervorbisfactory.cpp @@ -22,8 +22,8 @@ #include #include -#include "detailsdialog.h" #include "decoder_vorbis.h" +#include "vorbismetadatamodel.h" #include "decodervorbisfactory.h" @@ -54,13 +54,19 @@ const DecoderProperties DecoderVorbisFactory::properties() const properties.contentType = "application/ogg;audio/x-vorbis+ogg"; properties.hasAbout = TRUE; properties.hasSettings = FALSE; + properties.noInput = FALSE; return properties; } -Decoder *DecoderVorbisFactory::create(QObject *parent, QIODevice *input, - Output *output, const QString&) +Decoder *DecoderVorbisFactory::create(const QString &path, QIODevice *input) { - return new DecoderVorbis(parent, this, input, output); + Q_UNUSED(path); + return new DecoderVorbis(input); +} + +MetaDataModel* DecoderVorbisFactory::createMetaDataModel(const QString &path, QObject *parent) +{ + return new VorbisMetaDataModel(path, parent); } QList DecoderVorbisFactory::createPlayList(const QString &fileName, bool useMetaData) @@ -105,13 +111,6 @@ QList DecoderVorbisFactory::createPlayList(const QString &fileName, return list; } -QObject* DecoderVorbisFactory::showDetails(QWidget *parent, const QString &path) -{ - DetailsDialog *d = new DetailsDialog(parent, path); - d -> show(); - return d; -} - void DecoderVorbisFactory::showSettings(QWidget *) {} diff --git a/src/plugins/Input/vorbis/decodervorbisfactory.h b/src/plugins/Input/vorbis/decodervorbisfactory.h index 5a80c26d8..9d940c855 100644 --- a/src/plugins/Input/vorbis/decodervorbisfactory.h +++ b/src/plugins/Input/vorbis/decodervorbisfactory.h @@ -29,10 +29,11 @@ #include #include #include +#include - - - +/** + @author Ilya Kotov +*/ class DecoderVorbisFactory : public QObject, DecoderFactory { @@ -43,8 +44,8 @@ public: bool supports(const QString &source) const; bool canDecode(QIODevice *input) const; const DecoderProperties properties() const; - Decoder *create(QObject *, QIODevice *, Output *, const QString &); - //FileInfo *createFileInfo(const QString &source); + Decoder *create(const QString &path, QIODevice *input); + MetaDataModel* createMetaDataModel(const QString &path, QObject *parent = 0); QList createPlayList(const QString &fileName, bool useMetaData); QObject* showDetails(QWidget *parent, const QString &path); void showSettings(QWidget *parent); diff --git a/src/plugins/Input/vorbis/detailsdialog.cpp b/src/plugins/Input/vorbis/detailsdialog.cpp deleted file mode 100644 index d3f1095c3..000000000 --- a/src/plugins/Input/vorbis/detailsdialog.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * 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 of the License, 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. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include - -#include "detailsdialog.h" - -#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) -#define TStringToQString_qt4(s) QString::fromUtf8(s.toCString(TRUE)).trimmed() - -DetailsDialog::DetailsDialog(QWidget *parent, const QString &path) - : AbstractDetailsDialog(parent) -{ - m_path = path; - if (QFile::exists(m_path)) - { - loadVorbisInfo(); - loadTags(); - blockSaveButton(!QFileInfo(m_path).isWritable()); - } - else - blockSaveButton(); -} - -DetailsDialog::~DetailsDialog() -{} - -void DetailsDialog::loadVorbisInfo() -{ - TagLib::Ogg::Vorbis::File f (m_path.toLocal8Bit()); - QMap ap; - QString text = QString("%1").arg(f.audioProperties()->length()/60); - text +=":"+QString("%1").arg(f.audioProperties()->length()%60,2,10,QChar('0')); - ap.insert(tr("Length"), text); - ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(f.audioProperties()->sampleRate())); - ap.insert(tr("Channels"), QString("%1").arg(f.audioProperties()->channels())); - ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(f.audioProperties()->bitrate())); - ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(f.length()/1024)); - setAudioProperties(ap); -} - -void DetailsDialog::loadTags() -{ - TagLib::FileRef f (m_path.toLocal8Bit()); - setMetaData(Qmmp::TITLE, TStringToQString_qt4(f.tag()->title())); - setMetaData(Qmmp::ARTIST, TStringToQString_qt4(f.tag()->artist())); - setMetaData(Qmmp::ALBUM, TStringToQString_qt4(f.tag()->album())); - setMetaData(Qmmp::COMMENT, TStringToQString_qt4(f.tag()->comment())); - setMetaData(Qmmp::GENRE, TStringToQString_qt4(f.tag()->genre())); - setMetaData(Qmmp::YEAR, f.tag()->year()); - setMetaData(Qmmp::TRACK, f.tag()->track()); - setMetaData(Qmmp::URL, m_path); - TagLib::Ogg::Vorbis::File *file = dynamic_cast(f.file()); - TagLib::StringList fld; - if(file->tag() && !(fld = file->tag()->fieldListMap()["COMPOSER"]).isEmpty()) - setMetaData(Qmmp::COMPOSER, TStringToQString_qt4(fld.toString())); - if(file->tag() && !(fld = file->tag()->fieldListMap()["DISCNUMBER"]).isEmpty()) - setMetaData(Qmmp::DISCNUMBER, TStringToQString_qt4(fld.toString())); -} - -void DetailsDialog::writeTags() -{ - TagLib::FileRef f (m_path.toLocal8Bit()); - f.tag()->setTitle(QStringToTString_qt4(strMetaData(Qmmp::TITLE))); - f.tag()->setArtist(QStringToTString_qt4(strMetaData(Qmmp::ARTIST))); - f.tag()->setAlbum(QStringToTString_qt4(strMetaData(Qmmp::ALBUM))); - f.tag()->setComment(QStringToTString_qt4(strMetaData(Qmmp::COMMENT))); - f.tag()->setGenre(QStringToTString_qt4(strMetaData(Qmmp::GENRE))); - f.tag()->setYear(intMetaData(Qmmp::YEAR)); - f.tag()->setTrack(intMetaData(Qmmp::TRACK)); - TagLib::Ogg::Vorbis::File *file = dynamic_cast(f.file()); - strMetaData(Qmmp::COMPOSER).isEmpty() ? - file->tag()->removeField("COMPOSER"): - file->tag()->addField("COMPOSER", QStringToTString_qt4(strMetaData(Qmmp::COMPOSER)), TRUE); - intMetaData(Qmmp::DISCNUMBER) == 0 ? - file->tag()->removeField("DISCNUMBER"): - file->tag()->addField("DISCNUMBER", - QStringToTString_qt4(strMetaData(Qmmp::DISCNUMBER)), TRUE); - f.save(); -} diff --git a/src/plugins/Input/vorbis/detailsdialog.h b/src/plugins/Input/vorbis/detailsdialog.h deleted file mode 100644 index 2504108bc..000000000 --- a/src/plugins/Input/vorbis/detailsdialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * 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 of the License, 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. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef DETAILSDIALOG_H -#define DETAILSDIALOG_H - -#include - -/** - @author Ilya Kotov -*/ -class DetailsDialog : public AbstractDetailsDialog -{ -Q_OBJECT -public: - DetailsDialog(QWidget *parent = 0, const QString &path = 0); - - ~DetailsDialog(); - -private: - void loadVorbisInfo(); - void loadTags(); - void writeTags(); - QString m_path; - -}; - -#endif diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_cs.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_cs.ts index 13d62f3dd..a53e7bb22 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_cs.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_cs.ts @@ -14,67 +14,67 @@ Soubory Ogg-Vorbis - + About Ogg Vorbis Audio Plugin O modulu Ogg-Vorbis - + Qmmp Ogg Vorbis Audio Plugin Vstupní modul Qmmp Ogg-Vorbis - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilja Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Zdrojový kód je založen na projektu mq3 - DetailsDialog - - - kbps - kbps - - - - Hz - Hz - + VorbisMetaDataModel - + Length - Délka + Délka - + Sample rate - Vzorkovací frekvence + Vzorkovací frekvence + + + + Hz + Hz - + Channels - Počet kanálů + Počet kanálů - + Bitrate - Datový tok + Datový tok - - KB - KB + + kbps + kbps - + File size - Velikost souboru + Velikost souboru + + + + KB + KB diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_de.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_de.ts index c3274f221..5dcb3d7c9 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_de.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_de.ts @@ -14,67 +14,67 @@ Ogg-Vorbis-Dateien - + About Ogg Vorbis Audio Plugin Über Ogg-Vorbis-Audio-Modul - + Qmmp Ogg Vorbis Audio Plugin Qmmp Ogg-Vorbis-Audio-Modul - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Quellcode basiert auf dem mq3-Projekt - DetailsDialog - - - kbps - kbps - - - - Hz - Hz - + VorbisMetaDataModel - + Length - Länge + Länge - + Sample rate - Abtastrate + Abtastrate + + + + Hz + Hz - + Channels - Kanäle + Kanäle - + Bitrate - Bitrate + Bitrate - - KB - KB + + kbps + kbps - + File size - Dateigröße + Dateigröße + + + + KB + KB diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_it.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_it.ts index 0438b2859..bdb34081b 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_it.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_it.ts @@ -14,67 +14,67 @@ Brani Ogg Vorbis - + About Ogg Vorbis Audio Plugin Info sul modulo audio Ogg Vorbis - + Qmmp Ogg Vorbis Audio Plugin Modulo audio Ogg Vorbis per Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autore: Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Codice sorgente basato sul Progetto mq3 - DetailsDialog - - - kbps - kbps - - - - Hz - Hz - + VorbisMetaDataModel - + Length - + Sample rate - + + Hz + Hz + + + Channels - Canali + Canali - + Bitrate - Campionamento bit + Campionamento bit - - KB - KB + + kbps + kbps - + File size - Dimensione file + Dimensione file + + + + KB + KB diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_lt.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_lt.ts index 857a793a4..1f6cc045f 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_lt.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_lt.ts @@ -14,67 +14,67 @@ Ogg Vorbis bylos - + About Ogg Vorbis Audio Plugin Apie Ogg Vorbis audio įskiepį - + Qmmp Ogg Vorbis Audio Plugin Qmmp Ogg Vorbis audio įskiepis - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Sukūrė: Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Išvesties kodas sukurtas mq3 pagrindu - DetailsDialog + VorbisMetaDataModel - - Hz - Hz - - - + Length - + Sample rate - - Channels - + + Hz + Hz - - kbps - kbps + + Channels + - + Bitrate - - KB - KB + + kbps + kbps - + File size + + + KB + KB + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_pl.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_pl.ts index a5a290b59..dfd604381 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_pl.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_pl.ts @@ -14,67 +14,67 @@ Pliki Ogg Vorbis - + About Ogg Vorbis Audio Plugin O wtyczce Ogg Vorbis Audio - + Qmmp Ogg Vorbis Audio Plugin Wtyczka Ogg Vorbis dla Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilja Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Kod źródłowy oparty jest na projekcie mq3 - DetailsDialog + VorbisMetaDataModel - + Length - Długość - - - - Hz - + Długość - + Sample rate - Próbkowanie + Próbkowanie - - Channels - Kanały + + Hz + - - kbps - + + Channels + Kanały - + Bitrate - Szybkość transmisji + Szybkość transmisji - - KB - + + kbps + - + File size - Wielkość pliku + Wielkość pliku + + + + KB + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts index 1cac01d3b..c27ae7eef 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_ru.ts @@ -14,67 +14,67 @@ Файлы Ogg Vorbis - + About Ogg Vorbis Audio Plugin Об аудио-модуле Ogg Vorbis - + Qmmp Ogg Vorbis Audio Plugin Аудио-модуль Ogg Vorbis для Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Разработчик: Илья Котов <forkotov02@hotmail.ru> - + Source code based on mq3 progect Исходный код основан на проекте mq3 - DetailsDialog + VorbisMetaDataModel - - Hz - Гц - - - + Length Длительность - + Sample rate Дискретизация - - Channels - Каналов + + Hz + Гц - - kbps - Кб/с + + Channels + Каналов - + Bitrate Битовая частота - - KB - Кб + + kbps + Кб/с - + File size Размер файла + + + KB + Кб + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_tr.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_tr.ts index 0a6c3c920..28a6315ae 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_tr.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_tr.ts @@ -14,67 +14,67 @@ Ogg Vorbis Dosyaları - + About Ogg Vorbis Audio Plugin Ogg Vorbis Ses Eklentisi Hakkında - + Qmmp Ogg Vorbis Audio Plugin Qmmp Ogg Vorbis Ses Eklentisi - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Yazan: Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect Kaynak kodu mq3 projesi temellidir - DetailsDialog + VorbisMetaDataModel - + Length - - Hz - Hz - - - + Sample rate - - Channels - + + Hz + Hz - - kbps - kbps + + Channels + - + Bitrate - - KB - KB + + kbps + kbps - + File size + + + KB + KB + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_uk_UA.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_uk_UA.ts index 3780314f5..93cbba72b 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_uk_UA.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_uk_UA.ts @@ -1,6 +1,6 @@ - - + + DecoderVorbisFactory @@ -14,67 +14,67 @@ Файли Ogg Vorbis - + About Ogg Vorbis Audio Plugin Про аудіо-модуль Ogg Vorbis - + Qmmp Ogg Vorbis Audio Plugin Аудіо-модуль Ogg Vorbis для Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Розробник: Ілля Котов <forkotov02@hotmail.ru> - + Source code based on mq3 progect Вихідний код базується на проекті mq3 - DetailsDialog - - - Hz - Гц - + VorbisMetaDataModel - + Length - Тривалість + Тривалість - + Sample rate - Частота + Частота - - Channels - Канали + + Hz + Гц - - kbps - Кб/с + + Channels + Канали - + Bitrate - Бітрейт + Бітрейт - - KB - Кб + + kbps + Кб/с - + File size - Розмір файлу + Розмір файлу + + + + KB + Кб diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_CN.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_CN.ts index 392a252e4..5ac594d04 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_CN.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_CN.ts @@ -14,67 +14,67 @@ Ogg Vorbis 文件 - + About Ogg Vorbis Audio Plugin 关于 Ogg Vorbis 音频插件 - + Qmmp Ogg Vorbis Audio Plugin Qmmp Ogg Vorbis 音频插件 - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> 作者:Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect 源代码基于 mq3 项目 - DetailsDialog + VorbisMetaDataModel - - Hz - Hz - - - + Length - + Sample rate - - Channels - + + Hz + Hz - - kbps - kbps + + Channels + - + Bitrate - - KB - KB + + kbps + kbps - + File size + + + KB + KB + diff --git a/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_TW.ts b/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_TW.ts index 34f32f6eb..9b5d16014 100644 --- a/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_TW.ts +++ b/src/plugins/Input/vorbis/translations/vorbis_plugin_zh_TW.ts @@ -14,67 +14,67 @@ Ogg Vorbis 檔案 - + About Ogg Vorbis Audio Plugin 關於 Ogg Vorbis 聲訊插件 - + Qmmp Ogg Vorbis Audio Plugin Qmmp Ogg Vorbis 聲訊插件 - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> 作者:Ilya Kotov <forkotov02@hotmail.ru> - + Source code based on mq3 progect 源碼基於 mq3 項目 - DetailsDialog + VorbisMetaDataModel - - Hz - Hz - - - + Length - + Sample rate - - Channels - + + Hz + Hz - - kbps - kbps + + Channels + - + Bitrate - - KB - KB + + kbps + kbps - + File size + + + KB + KB + diff --git a/src/plugins/Input/vorbis/vorbis.pro b/src/plugins/Input/vorbis/vorbis.pro index 08ae89b20..68e61c464 100644 --- a/src/plugins/Input/vorbis/vorbis.pro +++ b/src/plugins/Input/vorbis/vorbis.pro @@ -2,10 +2,10 @@ include(../../plugins.pri) FORMS += HEADERS += decodervorbisfactory.h \ decoder_vorbis.h \ - detailsdialog.h + vorbismetadatamodel.h SOURCES += decoder_vorbis.cpp \ decodervorbisfactory.cpp \ - detailsdialog.cpp + vorbismetadatamodel.cpp TARGET = $$PLUGINS_PREFIX/Input/vorbis QMAKE_CLEAN = $$PLUGINS_PREFIX/Input/libvorbis.so INCLUDEPATH += ../../../ diff --git a/src/plugins/Input/vorbis/vorbismetadatamodel.cpp b/src/plugins/Input/vorbis/vorbismetadatamodel.cpp new file mode 100644 index 000000000..71b8d2de7 --- /dev/null +++ b/src/plugins/Input/vorbis/vorbismetadatamodel.cpp @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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 of the License, 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include "vorbismetadatamodel.h" + +#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) +#define TStringToQString_qt4(s) QString::fromUtf8(s.toCString(TRUE)).trimmed() + +VorbisMetaDataModel::VorbisMetaDataModel(const QString &path, QObject *parent) : MetaDataModel(parent) +{ + m_path = path; + m_tags << new VorbisCommentModel(path); +} + +VorbisMetaDataModel::~VorbisMetaDataModel() +{ + while(!m_tags.isEmpty()) + delete m_tags.takeFirst(); +} + +QHash VorbisMetaDataModel::audioProperties() +{ + QHash ap; + TagLib::Ogg::Vorbis::File f (m_path.toLocal8Bit()); + QString text = QString("%1").arg(f.audioProperties()->length()/60); + text +=":"+QString("%1").arg(f.audioProperties()->length()%60,2,10,QChar('0')); + ap.insert(tr("Length"), text); + ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(f.audioProperties()->sampleRate())); + ap.insert(tr("Channels"), QString("%1").arg(f.audioProperties()->channels())); + ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(f.audioProperties()->bitrate())); + ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(f.length()/1024)); + return ap; +} + +QList VorbisMetaDataModel::tags() +{ + return m_tags; +} + +VorbisCommentModel::VorbisCommentModel(const QString &path) : TagModel(TagModel::Save) +{ + m_file = new TagLib::Ogg::Vorbis::File (path.toLocal8Bit().constData()); + m_tag = m_file->tag(); +} + +VorbisCommentModel::~VorbisCommentModel() +{ + delete m_file; +} + +const QString VorbisCommentModel::name() +{ + return "Vorbis Comment"; +} + +const QString VorbisCommentModel::value(Qmmp::MetaData key) +{ + if(!m_tag) + return QString(); + switch((int) key) + { + case Qmmp::TITLE: + return TStringToQString_qt4(m_tag->title()); + case Qmmp::ARTIST: + return TStringToQString_qt4(m_tag->artist()); + case Qmmp::ALBUM: + return TStringToQString_qt4(m_tag->album()); + case Qmmp::COMMENT: + return TStringToQString_qt4(m_tag->comment()); + case Qmmp::GENRE: + return TStringToQString_qt4(m_tag->genre()); + case Qmmp::COMPOSER: + if(m_tag->fieldListMap()["COMPOSER"].isEmpty()) + return QString(); + else + return TStringToQString_qt4(m_tag->fieldListMap()["COMPOSER"].front()); + case Qmmp::YEAR: + return QString::number(m_tag->year()); + case Qmmp::TRACK: + return QString::number(m_tag->track()); + case Qmmp::DISCNUMBER: + if(m_tag->fieldListMap()["DISCNUMBER"].isEmpty()) + return QString(); + else + return TStringToQString_qt4(m_tag->fieldListMap()["DISCNUMBER"].front()); + } + return QString(); +} + +void VorbisCommentModel::setValue(Qmmp::MetaData key, const QString &value) +{ + if(!m_tag) + return; + + TagLib::String str = QStringToTString_qt4(value); + + switch((int) key) + { + case Qmmp::TITLE: + m_tag->setTitle(str); + return; + case Qmmp::ARTIST: + m_tag->setArtist(str); + return; + case Qmmp::ALBUM: + m_tag->setAlbum(str); + return; + case Qmmp::COMMENT: + m_tag->setComment(str); + return; + case Qmmp::GENRE: + m_tag->setGenre(str); + return; + case Qmmp::COMPOSER: + value.isEmpty() ? + m_tag->removeField("COMPOSER"): + m_tag->addField("COMPOSER", str, TRUE); + return; + case Qmmp::YEAR: + m_tag->setYear(value.toInt()); + return; + case Qmmp::DISCNUMBER: + value.isEmpty() ? + m_tag->removeField("DISCNUMBER"): + m_tag->addField("DISCNUMBER", str, TRUE); + } +} + +bool VorbisCommentModel::exists() +{ + return TRUE; +} + +void VorbisCommentModel::create() +{ + m_tag = m_file->tag(); +} + +void VorbisCommentModel::remove() +{} + +void VorbisCommentModel::save() +{ + m_file->save(); +} diff --git a/src/plugins/Input/vorbis/vorbismetadatamodel.h b/src/plugins/Input/vorbis/vorbismetadatamodel.h new file mode 100644 index 000000000..33420ddd5 --- /dev/null +++ b/src/plugins/Input/vorbis/vorbismetadatamodel.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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 of the License, 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef MPEGMETADATAMODEL_H +#define MPEGMETADATAMODEL_H + +#include +#include +#include + +class VorbisMetaDataModel : public MetaDataModel +{ +Q_OBJECT +public: + VorbisMetaDataModel(const QString &path, QObject *parent); + ~VorbisMetaDataModel(); + QHash audioProperties(); + QList tags(); + +private: + QString m_path; + QList m_tags; +}; + +class VorbisCommentModel : public TagModel +{ +public: + VorbisCommentModel(const QString &path); + ~VorbisCommentModel(); + const QString name(); + //QList keys(); + const QString value(Qmmp::MetaData key); + void setValue(Qmmp::MetaData key, const QString &value); + bool exists(); + void create(); + void remove(); + void save(); + +private: + TagLib::Ogg::Vorbis::File *m_file; + TagLib::Ogg::XiphComment *m_tag; +}; + +#endif // MPEGMETADATAMODEL_H -- cgit v1.2.3-13-gbd6f