Enabled 'Enter' to open the chat. Deleted the now obsolete ChatEntry.

This commit is contained in:
Dimitar Dobrev 2014-03-12 19:58:08 +02:00
parent cc8d052bd9
commit 4c26f025ac
6 changed files with 14 additions and 180 deletions

View file

@ -4,22 +4,22 @@
<context>
<name>Application</name>
<message>
<location filename="src/Application.cpp" line="1373"/>
<location filename="src/Application.cpp" line="1349"/>
<source>Export Voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="1374"/>
<location filename="src/Application.cpp" line="1350"/>
<source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3558"/>
<location filename="src/Application.cpp" line="3529"/>
<source>Open Script</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3559"/>
<location filename="src/Application.cpp" line="3530"/>
<source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation>
</message>
@ -113,18 +113,18 @@
<context>
<name>Menu</name>
<message>
<location filename="src/Menu.cpp" line="418"/>
<location filename="src/Menu.cpp" line="422"/>
<source>Open .ini config file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="420"/>
<location filename="src/Menu.cpp" line="432"/>
<location filename="src/Menu.cpp" line="424"/>
<location filename="src/Menu.cpp" line="436"/>
<source>Text files (*.ini)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="430"/>
<location filename="src/Menu.cpp" line="434"/>
<source>Save .ini config file</source>
<translation type="unfinished"></translation>
</message>

View file

@ -153,7 +153,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_touchAvgY(0.0f),
_isTouchPressed(false),
_mousePressed(false),
_chatEntryOn(false),
_audio(&_audioScope, STARTUP_JITTER_SAMPLES),
_enableProcessVoxelsThread(true),
_voxelProcessor(),
@ -698,21 +697,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
}
if (activeWindow() == _window) {
if (_chatEntryOn) {
if (_chatEntry.keyPressEvent(event)) {
_myAvatar->setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
DELETE_KEY_DOWN : INSERT_KEY_DOWN);
_myAvatar->setChatMessage(string(_chatEntry.getContents().size(), SOLID_BLOCK_CHAR));
} else {
_myAvatar->setChatMessage(_chatEntry.getContents());
_chatEntry.clear();
_chatEntryOn = false;
setMenuShortcutsEnabled(true);
}
return;
}
bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
switch (event->key()) {
@ -793,10 +777,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
case Qt::Key_Return:
case Qt::Key_Enter:
_chatEntryOn = true;
_myAvatar->setKeyState(NO_KEY_DOWN);
_myAvatar->setChatMessage(string());
setMenuShortcutsEnabled(false);
Menu::getInstance()->triggerOption(MenuOption::Chat);
break;
case Qt::Key_Up:
@ -939,11 +920,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
if (activeWindow() == _window) {
if (_chatEntryOn) {
_myAvatar->setKeyState(NO_KEY_DOWN);
return;
}
switch (event->key()) {
case Qt::Key_E:
_myAvatar->setDriveKeys(UP, 0);
@ -2483,11 +2459,6 @@ void Application::displayOverlay() {
}
}
// Show chat entry field
if (_chatEntryOn) {
_chatEntry.render(_glWidget->width(), _glWidget->height());
}
// Show on-screen msec timer
if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) {
char frameTimer[10];

View file

@ -64,7 +64,6 @@
#include "renderer/TextureCache.h"
#include "renderer/VoxelShader.h"
#include "ui/BandwidthDialog.h"
#include "ui/ChatEntry.h"
#include "ui/OctreeStatsDialog.h"
#include "ui/RearMirrorTools.h"
#include "ui/LodToolsDialog.h"
@ -426,9 +425,6 @@ private:
bool _mousePressed; // true if mouse has been pressed (clear when finished)
ChatEntry _chatEntry; // chat entry field
bool _chatEntryOn; // Whether to show the chat entry
GeometryCache _geometryCache;
TextureCache _textureCache;

View file

@ -163,7 +163,11 @@ Menu::Menu() :
addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
addActionToQMenuAndActionHash(toolsMenu, MenuOption::FstUploader, 0, Application::getInstance(), SLOT(uploadFST()));
_chatAction = addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat, 0, this, SLOT(showChat()));
_chatAction = addActionToQMenuAndActionHash(toolsMenu,
MenuOption::Chat,
Qt::Key_Return,
this,
SLOT(showChat()));
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
toggleChat();

View file

@ -1,102 +0,0 @@
//
// ChatEntry.cpp
// interface
//
// Created by Andrzej Kapolka on 4/24/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
#include <QKeyEvent>
#include "ChatEntry.h"
#include "InterfaceConfig.h"
#include "Util.h"
using namespace std;
const int MAX_CONTENT_LENGTH = 80;
ChatEntry::ChatEntry() : _cursorPos(0) {
}
void ChatEntry::clear() {
_contents.clear();
_cursorPos = 0;
}
bool ChatEntry::keyPressEvent(QKeyEvent* event) {
event->accept();
switch (event->key()) {
case Qt::Key_Return:
case Qt::Key_Enter:
return false;
case Qt::Key_Escape:
clear();
return false;
case Qt::Key_Backspace:
if (_cursorPos != 0) {
_contents.erase(_cursorPos - 1, 1);
_cursorPos--;
}
return true;
case Qt::Key_Delete:
if (_cursorPos < (int)_contents.size()) {
_contents.erase(_cursorPos, 1);
}
return true;
case Qt::Key_Left:
if (_cursorPos != 0) {
_cursorPos--;
}
return true;
case Qt::Key_Right:
if (_cursorPos != _contents.size()) {
_cursorPos++;
}
return true;
default:
QString text = event->text();
if (text.isEmpty()) {
event->ignore();
return true;
}
if (_contents.size() < MAX_CONTENT_LENGTH) {
_contents.insert(_cursorPos, 1, text.at(0).toLatin1());
_cursorPos++;
}
return true;
}
}
const float ALL_WHITE[] = { 1.0f, 1.0f, 1.0f };
void ChatEntry::render(int screenWidth, int screenHeight) {
// draw a gray background so that we can actually see what we're typing
int bottom = screenHeight - 150, top = screenHeight - 165;
int left = 20, right = left + 600;
glColor3f(0.2f, 0.2f, 0.2f);
glBegin(GL_QUADS);
glVertex2f(left - 5, bottom + 7);
glVertex2f(right + 5, bottom + 7);
glVertex2f(right + 5, top - 3);
glVertex2f(left - 5, top - 3);
glEnd();
drawText(left, bottom, 0.10f, 0, 2, _contents.c_str(), ALL_WHITE);
float width = 0;
for (string::iterator it = _contents.begin(), end = it + _cursorPos; it != end; it++) {
width += widthChar(0.10f, 0, *it);
}
glDisable(GL_LINE_SMOOTH);
glBegin(GL_LINE_STRIP);
glVertex2f(left + width, top + 2);
glVertex2f(left + width, bottom + 2);
glEnd();
}

View file

@ -1,35 +0,0 @@
//
// ChatEntry.h
// interface
//
// Created by Andrzej Kapolka on 4/24/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__ChatEntry__
#define __interface__ChatEntry__
#include <string>
class QKeyEvent;
class ChatEntry {
public:
ChatEntry();
const std::string& getContents() const { return _contents; }
void clear();
bool keyPressEvent(QKeyEvent* event);
void render(int screenWidth, int screenHeight);
private:
std::string _contents;
int _cursorPos;
};
#endif /* defined(__interface__ChatEntry__) */