File: mainconsole.cpp

package info (click to toggle)
qjackrcd 1.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 352 kB
  • sloc: cpp: 1,052; sh: 42; makefile: 5
file content (79 lines) | stat: -rw-r--r-- 2,618 bytes parent folder | download | duplicates (2)
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
#include "mainconsole.h"
#include <QCoreApplication>

MainConsole::MainConsole(Recorder *recorder, QObject *parent) : QObject(parent), qout(stdout), qin(stdin), qinNotifier(fileno(stdin), QSocketNotifier::Read, this)
{
    // the recorder given by the application.
    this->recorder = recorder;
    application = QCoreApplication::instance();

    qout << application->applicationName() << " " << tr("running in console mode") << endl;
    qout << tr("Congiguration:") << endl;
    qout << "pauseLevel(DB)" << "\t" << recorder->getPauseLevel() << endl;
    qout << "pauseDelay(sec)" << "\t" << recorder->getPauseActivationDelay() << endl;
    qout << "splitMode" << "\t" << toBoolText(recorder->isSplitMode()) << endl;
    qout << "recordAtLaunch" << "\t" << toBoolText(recorder->isRecordAtLaunch()) << endl;
    qout << "connections1" << "\t" << recorder->getJackCns1() << endl;
    qout << "connections2" << "\t" << recorder->getJackCns2() << endl;
    qout << "outputDir" << "\t" << recorder->getOutputDir().absolutePath() << endl;
    qout << "processCmdLine" << "\t" << recorder->getProcessCmdLine() << endl;
    qout << "jackAutoMode" << "\t" << toBoolText(recorder->isJackAutoMode()) << endl;
    qout << "jackTransMode" << "\t" << toBoolText(recorder->isJackTransMode()) << endl;

    connect(recorder, SIGNAL(statusChanged()), this, SLOT(onRecorderStatusChanged()));
    connect(&qinNotifier, SIGNAL(activated(int)), this, SLOT(onInput()));
    connect(this, SIGNAL(quit()), application, SLOT(quit()));
}


MainConsole::~MainConsole()
{

}

void MainConsole::onRecorderStatusChanged()
{
    qout << "\r";

    if (recorder->isRecording()) {
        if (recorder->isPaused()) {
            qout << tr("Waiting for sound...");
        }
        else {
            qout << tr("Recording...");
        }

    }
    else if (!recorder->isRecordEnabled()) {
        qout << tr("Disabled");
    }
    else {
        qout << tr("Ready");
    }
    qout << " ";
    qout << recorder->getCurrentRecordSize()/1024 << "KB - ";
    qout << recorder->getTotalRecordSize()/1024 << "KB ";

    qout << "> " << toGraphText((recorder->getLeftLevel() + recorder->getRightLevel()) / 2, recorder->getPauseLevel());
    qout.flush();
}
void MainConsole::onInput()
{
    qout << tr("Quit") << endl;
    emit quit();
}

QString MainConsole::toGraphText(float level, float fixedLevel)
{
    QString str;
    int min = -40;
    int max = 3;

    for (int i = min; i<=max; i++)
    {
        if (i == (int)fixedLevel) str.append("|");
        else if (i <= level) str.append("#");
        else str.append(".");
    }
    return str;
}