Commit c24fe538 authored by Yang Wang's avatar Yang Wang Committed by Andreas Traczyk

record widget: add volume meter display

Change-Id: I4cced5abd46424df4b8388fed3985131de1351db
parent 426c7be8
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z" fill="white"/><path d="M0 0h24v24H0z" fill="none"/></svg>
\ No newline at end of file
......@@ -20,6 +20,7 @@
#include "ui_recordoverlay.h"
#include "recordwidget.h"
#include "lrcinstance.h"
#include "utils.h"
RecordOverlay::RecordOverlay(RecordWidget* recordWidget) :
......@@ -40,7 +41,19 @@ RecordOverlay::RecordOverlay(RecordWidget* recordWidget) :
ui->recordOverlayPlayBtn->setVisible(false);
ui->recordOverlayStopPlayingBtn->setVisible(false);
setUpRecorderStatus(RecorderStatus::aboutToRecord);
connect(&LRCInstance::avModel(), &lrc::api::AVModel::audioMeter,
ui->levelMeter,
[this](const std::string& /*id*/, float level) {
ui->levelMeter->setLevel(level);
});
ui->inputIcon->setVisible(false);
ui->inputIcon->setPixmap(Utils::pixmapFromSvg(
QString(":/images/icons/av_icons/mic-24px.svg"),
ui->inputIcon->size()));
setRecorderState(RecorderState::aboutToRecord);
}
RecordOverlay::~RecordOverlay()
......@@ -49,30 +62,24 @@ RecordOverlay::~RecordOverlay()
}
void
RecordOverlay::setUpRecorderStatus(RecorderStatus status, bool isTimerToBeInvolved, bool isAimationToBeInvolved)
RecordOverlay::setRecorderState(RecorderState state)
{
status_ = status;
switch(status) {
case RecorderStatus::aboutToRecord:
reinitializeTimer();
recorderState_ = state;
switch(recorderState_) {
case RecorderState::aboutToRecord:
switchToAboutToRecordPage();
if(isTimerToBeInvolved) {reinitializeTimer();}
if(isAimationToBeInvolved) {stopRedDotBlink();}
ui->redDotBlinkable->stop();
break;
case RecorderStatus::recording:
case RecorderState::recording:
switchToRecordingPage();
if(isTimerToBeInvolved) {
reinitializeTimer();
recordTimer_.start(1000);
}
if(isAimationToBeInvolved) {
stopRedDotBlink();
startRedDotBlink();
}
recordTimer_.start(1000);
ui->redDotBlinkable->stop();
ui->redDotBlinkable->start();
break;
case RecorderStatus::recorded:
case RecorderState::recorded:
switchToRecordedPage();
if(isTimerToBeInvolved) {reinitializeTimer();}
if(isAimationToBeInvolved) {stopRedDotBlink();}
ui->redDotBlinkable->stop();
break;
}
}
......@@ -133,66 +140,72 @@ RecordOverlay::reinitializeTimer()
currentTime_ = 0;
}
void
RecordOverlay::startRedDotBlink()
{
ui->redDotBlinkable->start();
}
void
RecordOverlay::stopRedDotBlink()
{
ui->redDotBlinkable->stop();
}
void
RecordOverlay::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
setUpRecorderStatus(RecorderStatus::aboutToRecord);
if(recordWidget_->isAudio()) {
ui->inputIcon->setVisible(true);
ui->levelMeter->setVisible(true);
ui->levelMeter->start();
LRCInstance::startAudioMeter(true);
} else {
ui->inputIcon->setVisible(false);
ui->levelMeter->setVisible(false);
ui->levelMeter->stop();
LRCInstance::stopAudioMeter(true);
}
setRecorderState(RecorderState::aboutToRecord);
}
void
RecordOverlay::hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
if(recordWidget_->isAudio()) {
ui->levelMeter->stop();
ui->levelMeter->setVisible(false);
ui->inputIcon->setVisible(false);
LRCInstance::stopAudioMeter(true);
}
// set the page to about record page
setUpRecorderStatus(RecorderStatus::aboutToRecord);
setRecorderState(RecorderState::aboutToRecord);
}
void
RecordOverlay::on_recordOverlayStartOrFinishRecordingBtn_toggled(bool checked)
{
if(status_ == RecorderStatus::aboutToRecord) {
if(recorderState_ == RecorderState::aboutToRecord) {
// start record function call, if call succeed, switch the page to recording page and start the timer
if(recordWidget_->startRecording()) {
setUpRecorderStatus(RecorderStatus::recording);
setRecorderState(RecorderState::recording);
} else {
ui->recordOverlayStartOrFinishRecordingBtn->setOverlayButtonChecked(!checked);
qDebug() << "The recording does not start properly";
}
} else if(status_ == RecorderStatus::recording) {
} else if(recorderState_ == RecorderState::recording) {
// finish the record, if it succeed, switch the page and re-initialize the timer
if(recordWidget_->finishRecording()) {
setUpRecorderStatus(RecorderStatus::recorded);
setRecorderState(RecorderState::recorded);
} else {
ui->recordOverlayStartOrFinishRecordingBtn->setOverlayButtonChecked(!checked);
qDebug() << "The recording does not finish properly";
}
} else {
ui->recordOverlayStartOrFinishRecordingBtn->setOverlayButtonChecked(!checked);
qDebug() << "This button should not appear on current page";
}
}
void
RecordOverlay::on_recordOverlaySendBtn_pressed()
{
if(status_ != RecorderStatus::recorded) {
if(recorderState_ != RecorderState::recorded) {
qDebug() << "The contented is not recorded and cannot be sent out";
return;
}
if(recordWidget_->sendRecording()) {
setUpRecorderStatus(RecorderStatus::aboutToRecord);
setRecorderState(RecorderState::aboutToRecord);
// define what to do when the record is sent out
recordWidget_->getContainer()->accept();
}
......@@ -201,24 +214,24 @@ RecordOverlay::on_recordOverlaySendBtn_pressed()
void
RecordOverlay::on_recordOverlayDeleteBtn_pressed()
{
if(status_ != RecorderStatus::recorded) {
if(recorderState_ != RecorderState::recorded) {
qDebug() << "The content is not recorded and cannot be deleted";
return;
}
recordWidget_->deleteRecording();
setUpRecorderStatus(RecorderStatus::aboutToRecord);
setRecorderState(RecorderState::aboutToRecord);
}
void
RecordOverlay::on_recordOverlayRerecordBtn_pressed()
{
if(status_ != RecorderStatus::recording) {
if(recorderState_ != RecorderState::recording) {
qDebug() << "it's not on the recording page and thus there's cannot re-record";
return;
}
recordWidget_->recordAgain();
// re-initialize the timer at the same time
setUpRecorderStatus(RecorderStatus::recording);
setRecorderState(RecorderState::recording);
}
void
......
......@@ -29,10 +29,10 @@ class RecordWidget;
class RecordOverlay : public VignetteWidget
{
Q_OBJECT
Q_PROPERTY(QPixmap pixRedDot READ getOriginPix WRITE setOriginPix DESIGNABLE true NOTIFY originPixChanged);
Q_PROPERTY(QPixmap pixRedDot READ getOriginPix WRITE setOriginPix DESIGNABLE true);
public:
enum class RecorderStatus
enum class RecorderState
{
aboutToRecord,
recording,
......@@ -42,17 +42,11 @@ public:
QPixmap getOriginPix();
void setOriginPix(QPixmap);
signals:
void originPixChanged(QPixmap);
public:
explicit RecordOverlay(RecordWidget *recordWidget);
~RecordOverlay();
void setUpRecorderStatus(RecorderStatus status, bool isTimerToBeInvolved = true, bool isAimationToBeInvolved = true);
void startRedDotBlink();
void stopRedDotBlink();
void setRecorderState(RecorderState status);
private:
void switchToAboutToRecordPage();
......@@ -77,7 +71,7 @@ private:
Ui::RecordOverlay* ui;
RecordWidget* recordWidget_;
RecorderStatus status_;
RecorderState recorderState_;
int currentTime_ = 0;
QTimer recordTimer_;
QPixmap redDotPix_;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>258</height>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -25,10 +25,7 @@
<property name="pixRedDot" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/fiber_manual_record-24px.svg</pixmap>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
......@@ -41,38 +38,38 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0,1,1,1">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>3</number>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Blinkable" name="redDotBlinkable" native="true">
<property name="sizePolicy">
......@@ -95,405 +92,463 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timerLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_7">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>20</height>
<width>20</width>
<height>52</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="timerLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
</spacer>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="inputIcon">
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/mic-24px.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="LevelMeter" name="levelMeter">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>82</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="volumeMeterDisplayLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>83</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>7</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<spacer name="horizontalSpacer">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
<width>20</width>
<height>38</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="OverlayButton" name="recordOverlayRerecordBtn">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="toolTip">
<string>Re-record Video</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="originPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/re-record-24px.svg</pixmap>
</property>
<property name="checkedPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/re-record-24px.svg</pixmap>
</property>
<property name="tintColor" stdset="0">
<color>
<red>0</red>
<green>170</green>
<blue>255</blue>
</color>
</property>
</widget>
</item>
<item>
<widget class="OverlayButton" name="recordOverlayStartOrFinishRecordingBtn">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="originPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/fiber_manual_record-24px.svg</pixmap>
</property>
<property name="checkedPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/stop-24px-red.svg</pixmap>
</property>
<property name="tintColor" stdset="0">
<color>
<red>244</red>
<green>163</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item>
<widget class="OverlayButton" name="recordOverlayDeleteBtn">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="toolTip">
<string>Delete Recorded File</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="originPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/delete-24px.svg</pixmap>
</property>
<property name="checkedPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/delete-24px.svg</pixmap>
</property>
<property name="tintColor" stdset="0">
<color>
<red>0</red>
<green>170</green>
<blue>255</blue>
</color>
</property>
</widget>
</item>
<item>
<widget class="OverlayButton" name="recordOverlayPlayBtn">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="toolTip">
<string>Play Recorded Video</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="originPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/play_circle_outline-24px.svg</pixmap>
</property>
<property name="checkedPix" stdset="0">
<pixmap resource="ressources.qrc">:/images/icons/av_icons/pause-24px.svg</pixmap>
</property>
<property name="tintColor" stdset="0">
<color>
<red>0</red>
<green>170</green>
<blue>255</blue>