mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
refs #335, improved voice room component
* slots for URLs * connect signal/slots * enabled for runtime
This commit is contained in:
committed by
Roland Winklmeier
parent
3c4fc76094
commit
c2a335977b
@@ -9,6 +9,13 @@
|
|||||||
|
|
||||||
#include "voiceroomscomponent.h"
|
#include "voiceroomscomponent.h"
|
||||||
#include "ui_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
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -20,11 +27,108 @@ namespace BlackGui
|
|||||||
ui(new Ui::CVoiceRoomsComponent)
|
ui(new Ui::CVoiceRoomsComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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()
|
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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#ifndef BLACKGUI_VOICEROOMSCOMPONENT_H
|
#ifndef BLACKGUI_VOICEROOMSCOMPONENT_H
|
||||||
#define BLACKGUI_VOICEROOMSCOMPONENT_H
|
#define BLACKGUI_VOICEROOMSCOMPONENT_H
|
||||||
|
|
||||||
|
#include "enableforruntime.h"
|
||||||
|
#include "blackmisc/voiceroomlist.h"
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
@@ -23,7 +25,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
//! Displays the voice rooms
|
//! Displays the voice rooms
|
||||||
class CVoiceRoomsComponent :
|
class CVoiceRoomsComponent :
|
||||||
public QFrame
|
public QFrame,
|
||||||
|
public CEnableForRuntime
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -34,7 +37,28 @@ namespace BlackGui
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
~CVoiceRoomsComponent();
|
~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:
|
private:
|
||||||
|
//! Set the URL fields
|
||||||
|
void setVoiceRoomUrlFields();
|
||||||
|
|
||||||
|
//! Update voice room views
|
||||||
|
void updateVoiceRoomMembers();
|
||||||
|
|
||||||
|
|
||||||
QScopedPointer<Ui::CVoiceRoomsComponent> ui;
|
QScopedPointer<Ui::CVoiceRoomsComponent> ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>522</width>
|
||||||
<height>300</height>
|
<height>226</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Frame</string>
|
<string>Voice rooms</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="vl_voiceRoomsComponent">
|
<layout class="QVBoxLayout" name="vl_VoiceRoomsComponent">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="ql_CockpitVoiceRooms">
|
<layout class="QGridLayout" name="ql_CockpitVoiceRooms">
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QWidget" name="qi_CokpitViewRoom2" native="true">
|
<widget class="QWidget" name="qi_CockpitViewRoom2" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="hl_CockpitRoom1">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -57,6 +57,12 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom2">
|
<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">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@@ -69,8 +75,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item alignment="Qt::AlignRight">
|
||||||
<widget class="QCheckBox" name="cb_CockpitVoiceRoom2Override">
|
<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">
|
<property name="text">
|
||||||
<string>Ovr.</string>
|
<string>Ovr.</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -80,8 +92,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QWidget" name="qi_CokpitViewRoom1" native="true">
|
<widget class="QWidget" name="qi_CockpitViewRoom1" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="hl_CockpitViewRoom1">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -99,6 +111,12 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom1">
|
<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">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@@ -111,7 +129,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item alignment="Qt::AlignRight">
|
||||||
<widget class="QCheckBox" name="cb_CockpitVoiceRoom1Override">
|
<widget class="QCheckBox" name="cb_CockpitVoiceRoom1Override">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ovr.</string>
|
<string>Ovr.</string>
|
||||||
@@ -123,6 +141,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="BlackGui::Views::CUserView" name="tvp_CockpitVoiceRoom1">
|
<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">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -136,6 +160,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="BlackGui::Views::CUserView" name="tvp_CockpitVoiceRoom2">
|
<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">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user