-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding local camera window and json configuration (#61)
* Add camera window widget and json configuration * Hide and show size grip based on focus of the widget * Add Json properties documentation and corrected the default values of the json properties * Add icons in .qrc file * Correction of a bug where the camera visibility button appeared when it shouldn't have * Add parameter name to the gui readme * General code corrections and improvements * Correct wrong comparison for default camera window position * Correct a bug where the camera's position didnt set properly * Add camera style enum for readability, remove useless forward declarations and correct code style * Change setLocalCameraStyle to use CameraStyle enum
- Loading branch information
Showing
22 changed files
with
926 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +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.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(); | ||
} | ||
|
||
void ConfigDialog::setOpacitySliderValue(int value) | ||
{ | ||
if (value == 0) | ||
{ | ||
m_lastOpacityValue = m_ui.opacitySlider->value(); | ||
} | ||
if (m_ui.opacitySlider->value() == 0) | ||
{ | ||
value = m_lastOpacityValue; | ||
} | ||
m_ui.opacitySlider->setValue(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include "LocalCameraWindow.h" | ||
#include "MainWindow.h" | ||
|
||
LocalCameraWindow::LocalCameraWindow(MainWindow* parent) : QDialog{parent}, m_parent{parent} | ||
{ | ||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowTitleHint | Qt::Tool | Qt::Dialog); | ||
setAttribute(Qt::WA_DeleteOnClose); | ||
setAttribute(Qt::WA_TranslucentBackground); | ||
setFocusPolicy(Qt::StrongFocus); | ||
setWindowOpacity(m_parent->m_deviceProperties.defaultLocalCameraOpacity / 100); | ||
QVBoxLayout* layout = new QVBoxLayout(); | ||
layout->setMargin(0); | ||
setLayout(layout); | ||
setVisible(false); | ||
resize(m_parent->m_deviceProperties.defaultLocalCameraWidth, m_parent->m_deviceProperties.defaultLocalCameraHeight); | ||
} | ||
|
||
void LocalCameraWindow::addCamera(QWidget* cameraView) | ||
{ | ||
layout()->addWidget(cameraView); | ||
moveToDefaultPosition(); | ||
setVisible(true); | ||
} | ||
|
||
void LocalCameraWindow::removeCamera(QWidget* cameraView) | ||
{ | ||
layout()->removeWidget(cameraView); | ||
setVisible(false); | ||
} | ||
|
||
void LocalCameraWindow::moveToDefaultPosition() | ||
{ | ||
QRect mainWindowRect = m_parent->getCameraSpace(); | ||
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) | ||
{ | ||
QPoint destination(pos().x(), pos().y() + (newWindowSize.height() - oldWindowSize.height())); | ||
destination = adjustPositionToBorders(destination); | ||
move(destination); | ||
} | ||
|
||
void LocalCameraWindow::followMainWindow(QPoint positionDiff) | ||
{ | ||
move(pos() + positionDiff); | ||
} | ||
|
||
void LocalCameraWindow::mousePressEvent(QMouseEvent* event) | ||
{ | ||
m_pos = event->pos(); | ||
if (event->buttons() & Qt::LeftButton) | ||
{ | ||
setSizeGripEnabled(true); | ||
} | ||
} | ||
|
||
void LocalCameraWindow::focusOutEvent(QFocusEvent* event) | ||
{ | ||
if (isSizeGripEnabled()) | ||
{ | ||
setSizeGripEnabled(false); | ||
} | ||
} | ||
|
||
void LocalCameraWindow::mouseMoveEvent(QMouseEvent* event) | ||
{ | ||
if (event->buttons() & Qt::LeftButton) | ||
{ | ||
QPoint diff = event->pos() - m_pos; | ||
move(adjustPositionToBorders(pos() + diff)); | ||
} | ||
} | ||
|
||
QPoint LocalCameraWindow::adjustPositionToBorders(QPoint pos) | ||
{ | ||
QRect mainWindowRect = m_parent->getCameraSpace(); | ||
if (pos.x() < mainWindowRect.left()) | ||
{ | ||
pos.setX(mainWindowRect.left()); | ||
} | ||
else if (pos.x() > mainWindowRect.right() - width()) | ||
{ | ||
pos.setX(mainWindowRect.right() - width()); | ||
} | ||
|
||
if (pos.y() < mainWindowRect.top()) | ||
{ | ||
pos.setY(mainWindowRect.top()); | ||
} | ||
else if (pos.y() > mainWindowRect.bottom() - height()) | ||
{ | ||
pos.setY(mainWindowRect.bottom() - height()); | ||
} | ||
|
||
setMaximumWidth(mainWindowRect.right() - pos.x()); | ||
setMaximumHeight(mainWindowRect.bottom() - pos.y()); | ||
|
||
return pos; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef _LOCAL_CAMERA_WINDOW_H_ | ||
#define _LOCAL_CAMERA_WINDOW_H_ | ||
|
||
#include <QDialog> | ||
|
||
class MainWindow; | ||
|
||
class LocalCameraWindow : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
LocalCameraWindow(MainWindow* parent = nullptr); | ||
|
||
void addCamera(QWidget* cameraView); | ||
void removeCamera(QWidget* cameraView); | ||
void moveToDefaultPosition(); | ||
void adjustPositionFromBottomLeft(QSize oldWindowSize, QSize newWindowSize); | ||
void followMainWindow(QPoint positionDiff); | ||
|
||
protected: | ||
void mousePressEvent(QMouseEvent* event) override; | ||
void mouseMoveEvent(QMouseEvent* event) override; | ||
void focusOutEvent(QFocusEvent* event) override; | ||
|
||
private: | ||
QPoint m_pos; | ||
MainWindow* m_parent; | ||
|
||
QPoint adjustPositionToBorders(QPoint pos); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.