aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Ui/skinned/mainwindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* libqmmpui: added URL dialog implementation, added PlayListDownloadertrialuser022012-12-221-2/+1
| | | | | | | class git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3089 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF headerstrialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2845 90c681e8-e032-0410-971d-27865f9a5e38
* fixed FSF address (trunk)trialuser022012-07-311-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2844 90c681e8-e032-0410-971d-27865f9a5e38
* updated yeartrialuser022012-01-191-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2551 90c681e8-e032-0410-971d-27865f9a5e38
* fixed plugin hotkeys (Closes issue 511)trialuser022011-11-281-0/+3
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2519 90c681e8-e032-0410-971d-27865f9a5e38
* fixed 'jump to' shortcuttrialuser022011-10-251-3/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2450 90c681e8-e032-0410-971d-27865f9a5e38
* refactoringtrialuser022011-10-251-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2442 90c681e8-e032-0410-971d-27865f9a5e38
* fixed possible memory leaktrialuser022011-10-251-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2438 90c681e8-e032-0410-971d-27865f9a5e38
* added equalizer presets (improted from Amarok) (Thanks to Panagiotistrialuser022011-09-121-2/+2
| | | | | | | Papadopoulos) (Closes issue 471) git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2347 90c681e8-e032-0410-971d-27865f9a5e38
* improved "hide on close" featuretrialuser022011-09-101-10/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2344 90c681e8-e032-0410-971d-27865f9a5e38
* updated about dialogtrialuser022011-08-021-4/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2285 90c681e8-e032-0410-971d-27865f9a5e38
* removed useless codetrialuser022011-07-121-5/+0
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2273 90c681e8-e032-0410-971d-27865f9a5e38
* added configuration dialogtrialuser022011-07-121-2/+8
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2270 90c681e8-e032-0410-971d-27865f9a5e38
* added jump-to-track api functiontrialuser022011-07-041-11/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2268 90c681e8-e032-0410-971d-27865f9a5e38
* changed configuration keystrialuser022011-07-031-30/+18
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2267 90c681e8-e032-0410-971d-27865f9a5e38
* added playlist functionstrialuser022011-07-031-51/+10
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2265 90c681e8-e032-0410-971d-27865f9a5e38
* added some api fuctionstrialuser022011-07-031-14/+4
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2262 90c681e8-e032-0410-971d-27865f9a5e38
* some api changestrialuser022011-07-031-3/+0
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2261 90c681e8-e032-0410-971d-27865f9a5e38
* renamed GeneralHandlertrialuser022011-07-031-3/+3
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2260 90c681e8-e032-0410-971d-27865f9a5e38
* fixed command line option, removed unused codetrialuser022011-07-021-32/+0
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2259 90c681e8-e032-0410-971d-27865f9a5e38
* fixed playback resume featuretrialuser022011-07-021-16/+3
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2258 90c681e8-e032-0410-971d-27865f9a5e38
* moved skinned ui to separate plugintrialuser022011-07-011-0/+616
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2252 90c681e8-e032-0410-971d-27865f9a5e38
e>
                                                                                        

                                                                
                                                                                        













                                                              
                                                                         








                                                                  
/***************************************************************************
 *   Copyright (C) 2013-2016 by Ilya Kotov                                 *
 *   forkotov02@ya.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.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QMessageBox>
#include <QTranslator>
#include <taglib/tag.h>
#include <taglib/fileref.h>
#include <taglib/opusfile.h>
#include "replaygainreader.h"
#include "decoder_opus.h"
#include "opusmetadatamodel.h"
#include "decoderopusfactory.h"

// DecoderOpusFactory
bool DecoderOpusFactory::canDecode(QIODevice *input) const
{
    char buf[36];
    if (input->peek(buf, 36) == 36 && !memcmp(buf, "OggS", 4)
            && !memcmp(buf + 28, "OpusHead", 8))
        return true;
    return false;
}

const DecoderProperties DecoderOpusFactory::properties() const
{
    DecoderProperties properties;
    properties.name = tr("Opus Plugin");
    properties.shortName = "opus";
    properties.filters << "*.opus";
    properties.description = tr("Ogg Opus Files");
    properties.contentTypes << "audio/opus";
    properties.hasAbout = true;
    properties.hasSettings = false;
    properties.noInput = false;
    return properties;
}

Decoder *DecoderOpusFactory::create(const QString &url, QIODevice *input)
{
    Decoder *d = new DecoderOpus(url, input);
    if(!url.contains("://")) //local file
    {
        ReplayGainReader rg(url);
        d->setReplayGainInfo(rg.replayGainInfo());
    }
    return d;
}

MetaDataModel* DecoderOpusFactory::createMetaDataModel(const QString &path, QObject *parent)
{
    return new OpusMetaDataModel(path, parent);
}

QList<FileInfo *> DecoderOpusFactory::createPlayList(const QString &fileName, bool useMetaData, QStringList *)
{
    FileInfo *info = new FileInfo(fileName);

    TagLib::Ogg::Opus::File fileRef(QStringToFileName(fileName));
    TagLib::Ogg::XiphComment *tag = useMetaData ? fileRef.tag() : 0;

    if (tag && !tag->isEmpty())
    {
        info->setMetaData(Qmmp::ALBUM,
                          QString::fromUtf8(tag->album().toCString(true)).trimmed());
        info->setMetaData(Qmmp::ARTIST,
                          QString::fromUtf8(tag->artist().toCString(true)).trimmed());
        info->setMetaData(Qmmp::COMMENT,
                          QString::fromUtf8(tag->comment().toCString(true)).trimmed());
        info->setMetaData(Qmmp::GENRE,
                          QString::fromUtf8(tag->genre().toCString(true)).trimmed());
        info->setMetaData(Qmmp::TITLE,
                          QString::fromUtf8(tag->title().toCString(true)).trimmed());
        info->setMetaData(Qmmp::YEAR, tag->year());
        info->setMetaData(Qmmp::TRACK, tag->track());
    }

    if (fileRef.audioProperties())
        info->setLength(fileRef.audioProperties()->length());
    //additional metadata
    if(tag)
    {
        TagLib::StringList fld;
        if(!(fld = tag->fieldListMap()["ALBUMARTIST"]).isEmpty())
            info->setMetaData(Qmmp::ALBUMARTIST,
                              QString::fromUtf8(fld.front().toCString(true)).trimmed());
        if(!(fld = tag->fieldListMap()["COMPOSER"]).isEmpty())
            info->setMetaData(Qmmp::COMPOSER,
                              QString::fromUtf8(fld.front().toCString(true)).trimmed());
        if(!(fld = tag->fieldListMap()["DISCNUMBER"]).isEmpty())
            info->setMetaData(Qmmp::DISCNUMBER,
                              QString::fromUtf8(fld.front().toCString(true)).trimmed());
    }

    QList <FileInfo*> list;
    list << info;
    return list;
}

void DecoderOpusFactory::showSettings(QWidget *)
{}

void DecoderOpusFactory::showAbout(QWidget *parent)
{
    QMessageBox::about (parent, tr("About Opus Audio Plugin"),
                        tr("Qmmp Opus Audio Plugin")+"\n"+
                        tr("Written by: Ilya Kotov <forkotov02@ya.ru>"));
}

QTranslator *DecoderOpusFactory::createTranslator(QObject *parent)
{
    QTranslator *translator = new QTranslator(parent);
    QString locale = Qmmp::systemLanguageID();
    translator->load(QString(":/opus_plugin_") + locale);
    return translator;
}