Merge pull request #2311 from ey6es/master

Make the chat window a Qt dock widget; that seems to be what it was trying to emulate.  This fixes the issue on startup that Ryan and I experienced.
This commit is contained in:
Brad Hefta-Gaub 2014-03-14 13:05:16 -07:00
commit 8d3da1ba70
8 changed files with 46 additions and 46 deletions

View file

@ -4,22 +4,22 @@
<context> <context>
<name>Application</name> <name>Application</name>
<message> <message>
<location filename="src/Application.cpp" line="1362"/> <location filename="src/Application.cpp" line="1354"/>
<source>Export Voxels</source> <source>Export Voxels</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="1363"/> <location filename="src/Application.cpp" line="1355"/>
<source>Sparse Voxel Octree Files (*.svo)</source> <source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3573"/> <location filename="src/Application.cpp" line="3565"/>
<source>Open Script</source> <source>Open Script</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/Application.cpp" line="3574"/> <location filename="src/Application.cpp" line="3566"/>
<source>JavaScript Files (*.js)</source> <source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -45,7 +45,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="124"/> <location filename="src/ui/ChatWindow.cpp" line="128"/>
<source>day</source> <source>day</source>
<translation> <translation>
<numerusform>%n day</numerusform> <numerusform>%n day</numerusform>
@ -53,7 +53,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="124"/> <location filename="src/ui/ChatWindow.cpp" line="128"/>
<source>hour</source> <source>hour</source>
<translation> <translation>
<numerusform>%n hour</numerusform> <numerusform>%n hour</numerusform>
@ -61,7 +61,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="124"/> <location filename="src/ui/ChatWindow.cpp" line="128"/>
<source>minute</source> <source>minute</source>
<translation> <translation>
<numerusform>%n minute</numerusform> <numerusform>%n minute</numerusform>
@ -76,7 +76,7 @@
</translation> </translation>
</message> </message>
<message> <message>
<location filename="src/ui/ChatWindow.cpp" line="179"/> <location filename="src/ui/ChatWindow.cpp" line="183"/>
<source>%1 online now:</source> <source>%1 online now:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -27,7 +27,6 @@
#include <QColorDialog> #include <QColorDialog>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QCheckBox> #include <QCheckBox>
#include <QHBoxLayout>
#include <QImage> #include <QImage>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMainWindow> #include <QMainWindow>
@ -292,14 +291,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
ResourceCache::setNetworkAccessManager(_networkAccessManager); ResourceCache::setNetworkAccessManager(_networkAccessManager);
ResourceCache::setRequestLimit(3); ResourceCache::setRequestLimit(3);
QWidget* centralWidget = new QWidget(); _window->setCentralWidget(_glWidget);
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
centralWidget->setLayout(mainLayout);
_glWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
centralWidget->layout()->addWidget(_glWidget);
_window->setCentralWidget(centralWidget);
restoreSizeAndPosition(); restoreSizeAndPosition();

View file

@ -1044,13 +1044,11 @@ void Menu::showMetavoxelEditor() {
void Menu::showChat() { void Menu::showChat() {
if (!_chatWindow) { if (!_chatWindow) {
_chatWindow = new ChatWindow(); Application::getInstance()->getWindow()->addDockWidget(Qt::RightDockWidgetArea, _chatWindow = new ChatWindow());
QMainWindow* mainWindow = Application::getInstance()->getWindow();
QBoxLayout* boxLayout = static_cast<QBoxLayout*>(mainWindow->centralWidget()->layout());
boxLayout->addWidget(_chatWindow, 0, Qt::AlignRight);
} else { } else {
if (!_chatWindow->isVisible()) { if (!_chatWindow->toggleViewAction()->isChecked()) {
_chatWindow->show(); _chatWindow->toggleViewAction()->trigger();
} }
} }
} }
@ -1058,8 +1056,8 @@ void Menu::showChat() {
void Menu::toggleChat() { void Menu::toggleChat() {
#ifdef HAVE_QXMPP #ifdef HAVE_QXMPP
_chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected());
if (!_chatAction->isEnabled() && _chatWindow) { if (!_chatAction->isEnabled() && _chatWindow && _chatWindow->toggleViewAction()->isChecked()) {
_chatWindow->hide(); _chatWindow->toggleViewAction()->trigger();
} }
#endif #endif
} }

View file

@ -36,9 +36,9 @@ Head::Head(Avatar* owningAvatar) :
_leftEyeBlinkVelocity(0.0f), _leftEyeBlinkVelocity(0.0f),
_rightEyeBlinkVelocity(0.0f), _rightEyeBlinkVelocity(0.0f),
_timeWithoutTalking(0.0f), _timeWithoutTalking(0.0f),
_tweakedPitch(0.f), _pitchTweak(0.f),
_tweakedYaw(0.f), _yawTweak(0.f),
_tweakedRoll(0.f), _rollTweak(0.f),
_isCameraMoving(false), _isCameraMoving(false),
_faceModel(this) _faceModel(this)
{ {
@ -202,15 +202,15 @@ glm::vec3 Head::getScalePivot() const {
} }
float Head::getTweakedYaw() const { float Head::getTweakedYaw() const {
return glm::clamp(_yaw + _tweakedYaw, MIN_HEAD_YAW, MAX_HEAD_YAW); return glm::clamp(_yaw + _yawTweak, MIN_HEAD_YAW, MAX_HEAD_YAW);
} }
float Head::getTweakedPitch() const { float Head::getTweakedPitch() const {
return glm::clamp(_pitch + _tweakedPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); return glm::clamp(_pitch + _pitchTweak, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
} }
float Head::getTweakedRoll() const { float Head::getTweakedRoll() const {
return glm::clamp(_roll + _tweakedRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); return glm::clamp(_roll + _rollTweak, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
} }
void Head::applyCollision(CollisionInfo& collision) { void Head::applyCollision(CollisionInfo& collision) {

View file

@ -70,10 +70,15 @@ public:
/// Returns the point about which scaling occurs. /// Returns the point about which scaling occurs.
glm::vec3 getScalePivot() const; glm::vec3 getScalePivot() const;
void tweakPitch(float pitch) { _tweakedPitch = pitch; } void setPitchTweak(float pitch) { _pitchTweak = pitch; }
void tweakYaw(float yaw) { _tweakedYaw = yaw; } float getPitchTweak() const { return _pitchTweak; }
void tweakRoll(float roll) { _tweakedRoll = roll; }
void setYawTweak(float yaw) { _yawTweak = yaw; }
float getYawTweak() const { return _yawTweak; }
void setRollTweak(float roll) { _rollTweak = roll; }
float getRollTweak() const { return _rollTweak; }
virtual float getTweakedPitch() const; virtual float getTweakedPitch() const;
virtual float getTweakedYaw() const; virtual float getTweakedYaw() const;
virtual float getTweakedRoll() const; virtual float getTweakedRoll() const;
@ -104,9 +109,9 @@ private:
float _timeWithoutTalking; float _timeWithoutTalking;
// tweaked angles affect the rendered head, but not the camera // tweaked angles affect the rendered head, but not the camera
float _tweakedPitch; float _pitchTweak;
float _tweakedYaw; float _yawTweak;
float _tweakedRoll; float _rollTweak;
bool _isCameraMoving; bool _isCameraMoving;
FaceModel _faceModel; FaceModel _faceModel;

View file

@ -363,8 +363,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
// restore rotation, lean to neutral positions // restore rotation, lean to neutral positions
const float RESTORE_PERIOD = 1.f; // seconds const float RESTORE_PERIOD = 1.f; // seconds
float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f); float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f);
head->setYaw(glm::mix(head->getYaw(), 0.0f, restorePercentage)); head->setPitchTweak(glm::mix(head->getPitchTweak(), 0.0f, restorePercentage));
head->setRoll(glm::mix(head->getRoll(), 0.0f, restorePercentage)); head->setYawTweak(glm::mix(head->getYawTweak(), 0.0f, restorePercentage));
head->setRollTweak(glm::mix(head->getRollTweak(), 0.0f, restorePercentage));
head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage)); head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage));
head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage)); head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage));
return; return;
@ -375,9 +376,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f; const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f; const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f; const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
head->tweakPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); head->setPitchTweak(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
head->tweakYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); head->setYawTweak(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
head->tweakRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); head->setRollTweak(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
// Update torso lean distance based on accelerometer data // Update torso lean distance based on accelerometer data
const float TORSO_LENGTH = 0.5f; const float TORSO_LENGTH = 0.5f;

View file

@ -28,17 +28,21 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20;
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)"); const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
ChatWindow::ChatWindow() : ChatWindow::ChatWindow() :
QWidget(),
ui(new Ui::ChatWindow), ui(new Ui::ChatWindow),
numMessagesAfterLastTimeStamp(0) numMessagesAfterLastTimeStamp(0)
{ {
ui->setupUi(this); QWidget* widget = new QWidget();
setWidget(widget);
ui->setupUi(widget);
FlowLayout* flowLayout = new FlowLayout(0, 4, 4); FlowLayout* flowLayout = new FlowLayout(0, 4, 4);
ui->usersWidget->setLayout(flowLayout); ui->usersWidget->setLayout(flowLayout);
ui->messagePlainTextEdit->installEventFilter(this); ui->messagePlainTextEdit->installEventFilter(this);
ui->closeButton->hide();
#ifdef HAVE_QXMPP #ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
if (xmppClient.isConnected()) { if (xmppClient.isConnected()) {

View file

@ -10,8 +10,8 @@
#define __interface__ChatWindow__ #define __interface__ChatWindow__
#include <QDateTime> #include <QDateTime>
#include <QDockWidget>
#include <QTimer> #include <QTimer>
#include <QWidget>
#include <Application.h> #include <Application.h>
@ -26,7 +26,7 @@ namespace Ui {
class ChatWindow; class ChatWindow;
} }
class ChatWindow : public QWidget { class ChatWindow : public QDockWidget {
Q_OBJECT Q_OBJECT
public: public: