aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/mad/decodermadfactory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Input/mad/decodermadfactory.h')
0 files changed, 0 insertions, 0 deletions
10-09-18 16:50:38 +0000 committer trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2010-09-18 16:50:38 +0000 added --status and --nowplaying command line option (Closes issue 266)' href='/qmmp/commit/src/plugins/CommandLineOptions/StatusOption/statusoption.cpp?h=main&id=5717444b38b4f45ad185bbc6ea81cdb141befb8c'>5717444b3
c154161f2

5717444b3
c154161f2
5717444b3




























878e12329
5717444b3




























5f22b110d
5717444b3







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
















                                                                            
                                                                            



















                                                                             

                                                                                      
                                                                                               
                                                                                          




























                                                                                     
                                 




























                                                                       
                                                       







































                                                                          
/***************************************************************************
 *   Copyright (C) 2010 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.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QtPlugin>
#include <QTranslator>
#include <QLocale>
#include <QMap>
#include <qmmp/soundcore.h>
#include <qmmpui/metadataformatter.h>
#include "statusoption.h"

bool StatusOption::identify(const QString &str) const
{
    QStringList opts;
    opts << "--status" << "--nowplaying" << "--nowplaying-syntax";
    return opts.contains(str);
}

const QString StatusOption::helpString() const
{
    QString help;
    help += QString("--status                 ") + tr("Print playback status") + "\n";
    help += QString("--nowplaying <fmt>       ")
            + tr("Print formatted track name (example: qmmp --nowplaying \"%t - %a\")") + "\n";
    help += QString("--nowplaying-syntax      ") + tr("Print --nowplaying syntax") + "\n";
    return  help;
}

QString StatusOption::executeCommand(const QString &opt_str, const QStringList &args)
{
    SoundCore *core = SoundCore::instance();
    QString out;
    if(opt_str == "--status")
    {
        QMap<int, QString> state_names;
        state_names.insert(Qmmp::Playing, "[playing]");
        state_names.insert(Qmmp::Paused, "[paused]");
        state_names.insert(Qmmp::Stopped, "[stopped]");
        state_names.insert(Qmmp::Buffering, "[buffering]");
        state_names.insert(Qmmp::NormalError, "[error]");
        state_names.insert(Qmmp::FatalError, "[error]");
        out += state_names[core->state()];

        if(core->state() == Qmmp::Playing || core->state() == Qmmp::Paused)
        {
            out += " ";
            out += genProgressBar() + "\n";
            out += "ARTIST = %p\n";
            out += "TITLE = %t\n";
            out += "ALBUM = %a\n";
            out += "COMMENT = %c\n";
            out += "GENRE = %g\n";
            out += "YEAR = %y\n";
            out += "TRACK = %n\n";
            out += "FILE = %f\n";
            MetaDataFormatter formatter(out);
            out = formatter.parse(core->metaData(), core->totalTime());
        }
        else
            out += "\n";
    }
    else if(opt_str == "--nowplaying")
    {
        QString t = args.join(" ");
        MetaDataFormatter formatter(t);
        out = formatter.parse(core->metaData(), core->totalTime());
        out += "\n";
    }
    else if(opt_str == "--nowplaying-syntax")
    {
        out += tr("Syntax:") + "\n";
        out += tr("%p - artist") + "\n";
        out += tr("%a - album") + "\n";
        out += tr("%t - title") + "\n";
        out += tr("%n - track") + "\n";
        out += tr("%NN - 2-digit track") + "\n";
        out += tr("%g - genre") + "\n";
        out += tr("%c - comment") + "\n";
        out += tr("%C - composer") + "\n";
        out += tr("%D - disc number") + "\n";
        out += tr("%f - file name") + "\n";
        out += tr("%F - full path") + "\n";
        out += tr("%y - year") + "\n";
        out += tr("%l - duration") + "\n";
        out += tr("%if(A&B&C,D,E) - condition") + "\n";
    }
    return out;
}

const QString StatusOption::name() const
{
    return "StatusOption";
}

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

QString StatusOption::genProgressBar()
{
    SoundCore *core = SoundCore::instance();
    QString totalTime = QString("%1:%2").arg(core->totalTime()/60000)
            .arg(core->totalTime()%60000/1000, 2, 10, QChar('0'));
    QString currentTime = QString("%1:%2").arg(core->elapsed()/60000)
            .arg(core->elapsed()%60000/1000, 2, 10, QChar('0'));
    QString out = currentTime;
    if(core->totalTime())
    {
        out.clear();
        int played_count = 22 * (double)core->elapsed()/core->totalTime();