You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
4.8 KiB
178 lines
4.8 KiB
/*
|
|
* UBPodcastRecordingPalette.cpp
|
|
*
|
|
* Created on: 1 oct. 2009
|
|
* Author: Luc
|
|
*/
|
|
|
|
#include "UBPodcastRecordingPalette.h"
|
|
|
|
#include "UBPodcastController.h"
|
|
|
|
#include "core/UBApplication.h"
|
|
|
|
#include "gui/UBResources.h"
|
|
|
|
#include "core/UBSettings.h"
|
|
|
|
#include "gui/UBMainWindow.h"
|
|
|
|
|
|
UBPodcastRecordingPalette::UBPodcastRecordingPalette(QWidget *parent)
|
|
: UBActionPalette(Qt::Horizontal, parent)
|
|
{
|
|
addAction(UBApplication::mainWindow->actionPodcastRecord);
|
|
|
|
mTimerLabel = new QLabel(this);
|
|
mTimerLabel->setStyleSheet(QString("QLabel {color: white; font-size: 14px; font-weight: bold; font-family: Arial; background-color: transparent; border: none}"));
|
|
recordingProgressChanged(0);
|
|
|
|
layout()->addWidget(mTimerLabel);
|
|
|
|
mLevelMeter = new UBVuMeter(this);
|
|
mLevelMeter->setMinimumSize(6, 32);
|
|
|
|
layout()->addWidget(mLevelMeter);
|
|
|
|
addAction(UBApplication::mainWindow->actionPodcastConfig);
|
|
|
|
foreach(QWidget* menuWidget, UBApplication::mainWindow->actionPodcastConfig->associatedWidgets())
|
|
{
|
|
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
|
|
|
|
tb->setIconSize(QSize(16, 16));
|
|
|
|
if (tb && !tb->menu())
|
|
{
|
|
tb->setObjectName("ubButtonMenu");
|
|
tb->setPopupMode(QToolButton::InstantPopup);
|
|
QMenu* menu = new QMenu(this);
|
|
|
|
foreach(QAction* audioInputAction, UBPodcastController::instance()->audioRecordingDevicesActions())
|
|
{
|
|
menu->addAction(audioInputAction);
|
|
}
|
|
|
|
menu->addSeparator();
|
|
|
|
foreach(QAction* videoSizeAction, UBPodcastController::instance()->videoSizeActions())
|
|
{
|
|
menu->addAction(videoSizeAction);
|
|
}
|
|
|
|
menu->addSeparator();
|
|
|
|
QList<QAction*> podcastPublication = UBPodcastController::instance()->podcastPublicationActions();
|
|
|
|
foreach(QAction* publicationAction, podcastPublication)
|
|
{
|
|
menu->addAction(publicationAction);
|
|
}
|
|
|
|
tb->setMenu(menu);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
UBPodcastRecordingPalette::~UBPodcastRecordingPalette()
|
|
{
|
|
// NOOP
|
|
}
|
|
|
|
|
|
void UBPodcastRecordingPalette::recordingStateChanged(UBPodcastController::RecordingState state)
|
|
{
|
|
if (state == UBPodcastController::Recording)
|
|
{
|
|
UBApplication::mainWindow->actionPodcastRecord->setChecked(true);
|
|
UBApplication::mainWindow->actionPodcastRecord->setEnabled(true);
|
|
|
|
UBApplication::mainWindow->actionPodcastPause->setChecked(false);
|
|
UBApplication::mainWindow->actionPodcastPause->setEnabled(true);
|
|
|
|
//UBApplication::mainWindow->actionPodcastMic->setEnabled(false);
|
|
|
|
UBApplication::mainWindow->actionPodcastConfig->setEnabled(false);
|
|
}
|
|
else if (state == UBPodcastController::Stopped)
|
|
{
|
|
UBApplication::mainWindow->actionPodcastRecord->setChecked(false);
|
|
UBApplication::mainWindow->actionPodcastRecord->setEnabled(true);
|
|
|
|
UBApplication::mainWindow->actionPodcastPause->setChecked(false);
|
|
UBApplication::mainWindow->actionPodcastPause->setEnabled(false);
|
|
|
|
//UBApplication::mainWindow->actionPodcastMic->setEnabled(true);
|
|
UBApplication::mainWindow->actionPodcastConfig->setEnabled(true);
|
|
}
|
|
else if (state == UBPodcastController::Paused)
|
|
{
|
|
UBApplication::mainWindow->actionPodcastRecord->setChecked(true);
|
|
UBApplication::mainWindow->actionPodcastRecord->setEnabled(true);
|
|
|
|
UBApplication::mainWindow->actionPodcastPause->setChecked(true);
|
|
UBApplication::mainWindow->actionPodcastPause->setEnabled(true);
|
|
|
|
//UBApplication::mainWindow->actionPodcastMic->setEnabled(false);
|
|
UBApplication::mainWindow->actionPodcastConfig->setEnabled(false);
|
|
}
|
|
else
|
|
{
|
|
UBApplication::mainWindow->actionPodcastRecord->setEnabled(false);
|
|
UBApplication::mainWindow->actionPodcastPause->setEnabled(false);
|
|
UBApplication::mainWindow->actionPodcastConfig->setEnabled(false);
|
|
}
|
|
}
|
|
|
|
|
|
void UBPodcastRecordingPalette::recordingProgressChanged(qint64 ms)
|
|
{
|
|
int min = ms / 60000;
|
|
int seconds = (ms / 1000) % 60;
|
|
|
|
mTimerLabel->setText(QString("%1:%2").arg(min, 3, 10, QChar(' ')).arg(seconds, 2, 10, QChar('0')));
|
|
}
|
|
|
|
|
|
void UBPodcastRecordingPalette::audioLevelChanged(quint8 level)
|
|
{
|
|
mLevelMeter->setVolume(level);
|
|
}
|
|
|
|
|
|
UBVuMeter::UBVuMeter(QWidget* pParent)
|
|
: QWidget(pParent)
|
|
, mVolume(0)
|
|
{
|
|
// NOOP
|
|
}
|
|
|
|
|
|
UBVuMeter::~UBVuMeter()
|
|
{
|
|
// NOOP
|
|
}
|
|
|
|
void UBVuMeter::setVolume(quint8 pVolume)
|
|
{
|
|
if (mVolume != pVolume)
|
|
{
|
|
mVolume = pVolume;
|
|
update();
|
|
}
|
|
}
|
|
|
|
|
|
void UBVuMeter::paintEvent(QPaintEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
|
|
QPainter painter(this);
|
|
|
|
int h = (height() - 8) * mVolume / 255;
|
|
QRectF rect(0, height() - 4 - h, width(), h);
|
|
|
|
painter.fillRect(rect, UBSettings::documentViewLightColor);
|
|
}
|
|
|
|
|