Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding local camera window and json configuration #61

Merged
merged 12 commits into from
Dec 13, 2022
Merged
8 changes: 3 additions & 5 deletions opentera_webrtc_robot_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,9 @@ install(TARGETS ${PROJECT_NAME}_node
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
install(FILES src/resources/DeviceProperties.json
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/src/resources
)

#############
## Testing ##
Expand Down
37 changes: 16 additions & 21 deletions opentera_webrtc_robot_gui/src/ConfigDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
#include "ConfigDialog.h"
#include "MainWindow.h"

#include "ui_ConfigDialog.h"

ConfigDialog::ConfigDialog(MainWindow* parent) : m_ui(new Ui::ConfigDialog())
ConfigDialog::ConfigDialog(MainWindow* parent)
{
m_ui->setupUi(this);
m_ui.setupUi(this);
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowTitleHint);

// Sliders
m_ui->micVolumeSlider->setValue(100);
connect(m_ui->micVolumeSlider, &QSlider::valueChanged, parent, &MainWindow::onMicVolumeSliderValueChanged);
m_ui->volumeSlider->setValue(100);
connect(m_ui->volumeSlider, &QSlider::valueChanged, parent, &MainWindow::onVolumeSliderValueChanged);
m_ui->opacitySlider->setValue(parent->m_defaultLocalCameraOpacity);
connect(m_ui->opacitySlider, &QSlider::valueChanged, parent, &MainWindow::onOpacitySliderValueChanged);
m_ui.micVolumeSlider->setValue(100);
connect(m_ui.micVolumeSlider, &QSlider::valueChanged, parent, &MainWindow::onMicVolumeSliderValueChanged);
m_ui.volumeSlider->setValue(100);
connect(m_ui.volumeSlider, &QSlider::valueChanged, parent, &MainWindow::onVolumeSliderValueChanged);
m_ui.opacitySlider->setValue(parent->m_deviceProperties.defaultLocalCameraOpacity);
connect(m_ui.opacitySlider, &QSlider::valueChanged, parent, &MainWindow::onOpacitySliderValueChanged);
}

ConfigDialog::~ConfigDialog() {}


int ConfigDialog::getMicVolumeSliderValue()
{
return m_ui->micVolumeSlider->value();
return m_ui.micVolumeSlider->value();
}

void ConfigDialog::setMicVolumeSliderValue(int value)
{
m_ui->micVolumeSlider->setValue(value);
m_ui.micVolumeSlider->setValue(value);
}

int ConfigDialog::getVolumeSliderValue()
{
return m_ui->volumeSlider->value();
return m_ui.volumeSlider->value();
}

void ConfigDialog::setVolumeSliderValue(int value)
{
m_ui->volumeSlider->setValue(value);
m_ui.volumeSlider->setValue(value);
}

int ConfigDialog::getOpacitySliderValue()
{
return m_ui->opacitySlider->value();
return m_ui.opacitySlider->value();
}

void ConfigDialog::setOpacitySliderValue(int value)
{
if (value == 0)
{
m_lastOpacityValue = m_ui->opacitySlider->value();
m_lastOpacityValue = m_ui.opacitySlider->value();
}
if (m_ui->opacitySlider->value() == 0)
if (m_ui.opacitySlider->value() == 0)
{
value = m_lastOpacityValue;
}
m_ui->opacitySlider->setValue(value);
m_ui.opacitySlider->setValue(value);
}
5 changes: 3 additions & 2 deletions opentera_webrtc_robot_gui/src/ConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _CONFIG_DIALOG_H_

#include <QDialog>
#include "ui_ConfigDialog.h"

QT_BEGIN_NAMESPACE
namespace Ui
joli-1801 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -18,7 +19,7 @@ class ConfigDialog : public QDialog

public:
ConfigDialog(MainWindow* parent = nullptr);
~ConfigDialog();
~ConfigDialog() = default;

int getMicVolumeSliderValue();
void setMicVolumeSliderValue(int value);
Expand All @@ -28,7 +29,7 @@ class ConfigDialog : public QDialog
void setOpacitySliderValue(int value);

protected:
Ui::ConfigDialog* m_ui;
Ui::ConfigDialog m_ui;

private:
int m_lastOpacityValue;
Expand Down
33 changes: 9 additions & 24 deletions opentera_webrtc_robot_gui/src/LocalCameraWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#include "LocalCameraWindow.h"
#include "MainWindow.h"

LocalCameraWindow::LocalCameraWindow(MainWindow* parent) : QDialog(parent)
LocalCameraWindow::LocalCameraWindow(MainWindow* parent) : QDialog{parent}, m_parent(parent)
joli-1801 marked this conversation as resolved.
Show resolved Hide resolved
{
m_parent = parent;

setWindowFlags(Qt::FramelessWindowHint | Qt::WindowTitleHint | Qt::Tool | Qt::Dialog);
setAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_QuitOnClose);
setAttribute(Qt::WA_TranslucentBackground);
setFocusPolicy(Qt::StrongFocus);
setWindowOpacity(m_parent->m_defaultLocalCameraOpacity / 100);
setWindowOpacity(m_parent->m_deviceProperties.defaultLocalCameraOpacity / 100);
QVBoxLayout* layout = new QVBoxLayout();
layout->setMargin(0);
setLayout(layout);
setVisible(false);
resize(m_parent->m_defaultLocalCameraWidth, m_parent->m_defaultLocalCameraHeight);
resize(m_parent->m_deviceProperties.defaultLocalCameraWidth, m_parent->m_deviceProperties.defaultLocalCameraHeight);
}

void LocalCameraWindow::addCamera(QWidget* cameraView)
Expand All @@ -34,24 +31,12 @@ void LocalCameraWindow::removeCamera(QWidget* cameraView)
void LocalCameraWindow::moveToDefaultPosition()
{
QRect mainWindowRect = m_parent->getCameraSpace();
int x = m_parent->m_defaultLocalCameraX;
int y = m_parent->m_defaultLocalCameraY;
if (x > 0 && y > 0)
{
move(mainWindowRect.left() + x, mainWindowRect.top() + y);
}
else if (x < 0 && y > 0)
{
move(mainWindowRect.right() - width() + x, mainWindowRect.top() + y);
}
else if (x > 0 && y < 0)
{
move(mainWindowRect.left() + x, mainWindowRect.bottom() - height() + y);
}
else
{
move(mainWindowRect.right() - width() + x, mainWindowRect.bottom() - height() + y);
}
int x = m_parent->m_deviceProperties.defaultLocalCameraX;
int y = m_parent->m_deviceProperties.defaultLocalCameraY;

int newX = (x >= 0) ? mainWindowRect.left() + x : mainWindowRect.right() - width() + x;
int newY = (y >= 0) ? mainWindowRect.top() + y : mainWindowRect.bottom() - height() + y;
move(newX, newY);
}

void LocalCameraWindow::adjustPositionFromBottomLeft(QSize oldWindowSize, QSize newWindowSize)
Expand Down
Loading