refs #335, improved voice room component

* slots for URLs
* connect signal/slots
* enabled for runtime
This commit is contained in:
Klaus Basan
2014-10-16 03:15:51 +02:00
committed by Roland Winklmeier
parent 3c4fc76094
commit c2a335977b
3 changed files with 169 additions and 11 deletions

View File

@@ -9,6 +9,13 @@
#include "voiceroomscomponent.h"
#include "ui_voiceroomscomponent.h"
#include "blackcore/context_audio.h"
#include "blackmisc/notificationsounds.h"
using namespace BlackCore;
using namespace BlackSound;
using namespace BlackMisc::Audio;
namespace BlackGui
{
@@ -20,11 +27,108 @@ namespace BlackGui
ui(new Ui::CVoiceRoomsComponent)
{
ui->setupUi(this);
this->setVoiceRoomUrlFields();
connect(ui->cb_CockpitVoiceRoom1Override, &QCheckBox::toggled, this, &CVoiceRoomsComponent::ps_voiceRoomOverrideChanged);
connect(ui->le_CockpitVoiceRoomCom1, &QLineEdit::returnPressed, this, &CVoiceRoomsComponent::ps_voiceRoomUrlsReturnPressed);
}
CVoiceRoomsComponent::~CVoiceRoomsComponent()
{ }
void CVoiceRoomsComponent::runtimeHasBeenSet()
{
this->connect(this->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CVoiceRoomsComponent::ps_updateAudioVoiceRoomsFromContext);
}
void CVoiceRoomsComponent::ps_voiceRoomOverrideChanged(bool checked)
{
Q_UNUSED(checked);
this->setVoiceRoomUrlFields();
}
void CVoiceRoomsComponent::ps_voiceRoomUrlsReturnPressed()
{
}
void CVoiceRoomsComponent::setVoiceRoomUrlFields()
{
bool c1 = ui->cb_CockpitVoiceRoom1Override->isChecked();
bool c2 = ui->cb_CockpitVoiceRoom2Override->isChecked();
this->ui->le_CockpitVoiceRoomCom1->setReadOnly(!c1);
this->ui->le_CockpitVoiceRoomCom2->setReadOnly(!c2);
}
void CVoiceRoomsComponent::ps_updateAudioVoiceRoomsFromContext(const CVoiceRoomList &selectedVoiceRooms, bool connected)
{
Q_ASSERT(selectedVoiceRooms.size() == 2);
CVoiceRoom room1 = selectedVoiceRooms[0];
CVoiceRoom room2 = selectedVoiceRooms[1];
// remark
// isAudioPlaying() is not set, as this is only a temporary value when really "something is playing"
bool changedUrl1 = (room1.getVoiceRoomUrl() == this->ui->le_CockpitVoiceRoomCom1->text());
this->ui->le_CockpitVoiceRoomCom1->setText(room1.getVoiceRoomUrl());
if (room1.isConnected())
{
this->ui->le_CockpitVoiceRoomCom1->setStyleSheet("background: green");
if (this->getIContextAudio()) this->ui->tvp_CockpitVoiceRoom1->updateContainer(this->getIContextAudio()->getCom1RoomUsers());
}
else
{
this->ui->le_CockpitVoiceRoomCom1->setStyleSheet("");
this->ui->tvp_CockpitVoiceRoom1->clear();
}
bool changedUrl2 = (room2.getVoiceRoomUrl() == this->ui->le_CockpitVoiceRoomCom2->text());
this->ui->le_CockpitVoiceRoomCom2->setText(room2.getVoiceRoomUrl());
if (room2.isConnected())
{
this->ui->le_CockpitVoiceRoomCom2->setStyleSheet("background: green");
}
else
{
this->ui->le_CockpitVoiceRoomCom2->setStyleSheet("");
this->ui->tvp_CockpitVoiceRoom2->clear();
}
if (changedUrl1 || changedUrl2)
{
this->updateVoiceRoomMembers();
// notify
if (this->getIContextAudio())
{
CNotificationSounds::Notification sound = connected ?
CNotificationSounds::NotificationVoiceRoomJoined :
CNotificationSounds::NotificationVoiceRoomLeft;
this->getIContextAudio()->playNotification(static_cast<uint>(sound), true);
}
}
}
void CVoiceRoomsComponent::updateVoiceRoomMembers()
{
if (!this->getIContextAudio()) return;
if (!this->ui->le_CockpitVoiceRoomCom1->text().trimmed().isEmpty())
{
this->ui->tvp_CockpitVoiceRoom1->updateContainer(this->getIContextAudio()->getCom1RoomUsers());
}
else
{
this->ui->tvp_CockpitVoiceRoom1->clear();
}
if (!this->ui->le_CockpitVoiceRoomCom2->text().trimmed().isEmpty())
{
this->ui->tvp_CockpitVoiceRoom2->updateContainer(this->getIContextAudio()->getCom2RoomUsers());
}
else
{
this->ui->tvp_CockpitVoiceRoom2->clear();
}
}
} // namespace
} // namespace

View File

@@ -12,6 +12,8 @@
#ifndef BLACKGUI_VOICEROOMSCOMPONENT_H
#define BLACKGUI_VOICEROOMSCOMPONENT_H
#include "enableforruntime.h"
#include "blackmisc/voiceroomlist.h"
#include <QFrame>
#include <QScopedPointer>
@@ -23,7 +25,8 @@ namespace BlackGui
{
//! Displays the voice rooms
class CVoiceRoomsComponent :
public QFrame
public QFrame,
public CEnableForRuntime
{
Q_OBJECT
@@ -34,7 +37,28 @@ namespace BlackGui
//! Destructor
~CVoiceRoomsComponent();
protected:
//! \copydoc CEnableForRuntime::runtimeHasBeenSet
virtual void runtimeHasBeenSet() override;
private slots:
//! Override for voice was changed
void ps_voiceRoomOverrideChanged(bool checked);
//! Return pressed
void ps_voiceRoomUrlsReturnPressed();
//! set the voice room url fields (checkboxes, line edits)
void ps_updateAudioVoiceRoomsFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected);
private:
//! Set the URL fields
void setVoiceRoomUrlFields();
//! Update voice room views
void updateVoiceRoomMembers();
QScopedPointer<Ui::CVoiceRoomsComponent> ui;
};

View File

@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>522</width>
<height>226</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
<string>Voice rooms</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@@ -19,7 +19,7 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_voiceRoomsComponent">
<layout class="QVBoxLayout" name="vl_VoiceRoomsComponent">
<property name="spacing">
<number>0</number>
</property>
@@ -38,8 +38,8 @@
<item>
<layout class="QGridLayout" name="ql_CockpitVoiceRooms">
<item row="0" column="1">
<widget class="QWidget" name="qi_CokpitViewRoom2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<widget class="QWidget" name="qi_CockpitViewRoom2" native="true">
<layout class="QHBoxLayout" name="hl_CockpitRoom1">
<property name="spacing">
<number>2</number>
</property>
@@ -57,6 +57,12 @@
</property>
<item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
@@ -69,8 +75,14 @@
</property>
</widget>
</item>
<item>
<item alignment="Qt::AlignRight">
<widget class="QCheckBox" name="cb_CockpitVoiceRoom2Override">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ovr.</string>
</property>
@@ -80,8 +92,8 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="qi_CokpitViewRoom1" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<widget class="QWidget" name="qi_CockpitViewRoom1" native="true">
<layout class="QHBoxLayout" name="hl_CockpitViewRoom1">
<property name="spacing">
<number>2</number>
</property>
@@ -99,6 +111,12 @@
</property>
<item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
@@ -111,7 +129,7 @@
</property>
</widget>
</item>
<item>
<item alignment="Qt::AlignRight">
<widget class="QCheckBox" name="cb_CockpitVoiceRoom1Override">
<property name="text">
<string>Ovr.</string>
@@ -123,6 +141,12 @@
</item>
<item row="1" column="0">
<widget class="BlackGui::Views::CUserView" name="tvp_CockpitVoiceRoom1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
@@ -136,6 +160,12 @@
</item>
<item row="1" column="1">
<widget class="BlackGui::Views::CUserView" name="tvp_CockpitVoiceRoom2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>