History

Merge branch 'master' of https://github.com/worklist/hifi into 19508

stojce committed 12 years ago

Commit 939c17d2 parents bd3a5a7 e8a6ab6148 files · +7302 −1476Browse files

Showing the changes to interface/src/Menu.cpp (1 of 148 files). Show all

Unified · Split

interface/src/Menu.cpp+87−15
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <QWindow>
2727
2828 #include <AccountManager.h>
29+#include <XmppClient.h>
2930 #include <UUID.h>
3031
3132 #include "Application.h"
@@ -66,7 +67,7 @@ Menu::Menu() : · 34 unmodified lines
6667 _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION),
6768 _frustumDrawMode(FRUSTUM_DRAW_MODE_ALL),
6869 _viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET),
69− _voxelStatsDialog(NULL),
70+ _octreeStatsDialog(NULL),
7071 _lodToolsDialog(NULL),
7172 _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM),
7273 _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
@@ -164,6 +165,19 @@ Menu::Menu() : · 91 unmodified lines
164165 addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
165166 addActionToQMenuAndActionHash(toolsMenu, MenuOption::FstUploader, 0, Application::getInstance(), SLOT(uploadFST()));
166167
168+ _chatAction = addActionToQMenuAndActionHash(toolsMenu,
169+ MenuOption::Chat,
170+ Qt::Key_Return,
171+ this,
172+ SLOT(showChat()));
173+#ifdef HAVE_QXMPP
174+ const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
175+ toggleChat();
176+ connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat()));
177+ connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat()));
178+#else
179+ _chatAction->setEnabled(false);
180+#endif
167181
168182 QMenu* viewMenu = addMenu("View");
169183
@@ -215,7 +229,7 @@ Menu::Menu() : · 45 unmodified lines
215229 addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Oscilloscope, 0, true);
216230 addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Bandwidth, 0, true);
217231 addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0, this, SLOT(bandwidthDetails()));
218− addActionToQMenuAndActionHash(viewMenu, MenuOption::VoxelStats, 0, this, SLOT(voxelStatsDetails()));
232+ addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0, this, SLOT(octreeStatsDetails()));
219233
220234 QMenu* developerMenu = addMenu("Developer");
221235
@@ -343,7 +357,7 @@ Menu::Menu() : · 121 unmodified lines
343357
344358 Menu::~Menu() {
345359 bandwidthDetailsClosed();
346− voxelStatsDetailsClosed();
360+ octreeStatsDetailsClosed();
347361 }
348362
349363 void Menu::loadSettings(QSettings* settings) {
@@ -701,8 +715,8 @@ void Menu::editPreferences() { · 351 unmodified lines
701715 form->addRow("Faceshift Eye Deflection:", faceshiftEyeDeflection);
702716
703717 QSpinBox* fieldOfView = new QSpinBox();
704− fieldOfView->setMaximum(180);
705− fieldOfView->setMinimum(1);
718+ fieldOfView->setMaximum(180.f);
719+ fieldOfView->setMinimum(1.f);
706720 fieldOfView->setValue(_fieldOfView);
707721 form->addRow("Vertical Field of View (Degrees):", fieldOfView);
708722
@@ -1023,6 +1037,30 @@ void Menu::showMetavoxelEditor() { · 314 unmodified lines
10231037 _MetavoxelEditor->raise();
10241038 }
10251039
1040+void Menu::showChat() {
1041+ if (!_chatWindow) {
1042+ _chatWindow = new ChatWindow();
1043+ QMainWindow* mainWindow = Application::getInstance()->getWindow();
1044+ _chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(),
1045+ mainWindow->geometry().y(),
1046+ _chatWindow->width(),
1047+ mainWindow->height());
1048+ }
1049+ if (!_chatWindow->isVisible()) {
1050+ _chatWindow->show();
1051+ }
1052+ _chatWindow->raise();
1053+}
1054+
1055+void Menu::toggleChat() {
1056+#ifdef HAVE_QXMPP
1057+ _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected());
1058+ if (!_chatAction->isEnabled() && _chatWindow) {
1059+ _chatWindow->close();
1060+ }
1061+#endif
1062+}
1063+
10261064 void Menu::audioMuteToggled() {
10271065 QAction *muteAction = _actionHash.value(MenuOption::MuteAudio);
10281066 muteAction->setChecked(Application::getInstance()->getAudio()->getMuted());
@@ -1035,21 +1073,55 @@ void Menu::bandwidthDetailsClosed() { · 6 unmodified lines
10351073 }
10361074 }
10371075
1038−void Menu::voxelStatsDetails() {
1039− if (!_voxelStatsDialog) {
1040− _voxelStatsDialog = new VoxelStatsDialog(Application::getInstance()->getGLWidget(),
1076+void Menu::octreeStatsDetails() {
1077+ if (!_octreeStatsDialog) {
1078+ _octreeStatsDialog = new OctreeStatsDialog(Application::getInstance()->getGLWidget(),
10411079 Application::getInstance()->getOcteeSceneStats());
1042− connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed()));
1043− _voxelStatsDialog->show();
1080+ connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed()));
1081+ _octreeStatsDialog->show();
1082+ }
1083+ _octreeStatsDialog->raise();
1084+}
1085+
1086+void Menu::octreeStatsDetailsClosed() {
1087+ if (_octreeStatsDialog) {
1088+ delete _octreeStatsDialog;
1089+ _octreeStatsDialog = NULL;
10441090 }
1045− _voxelStatsDialog->raise();
10461091 }
10471092
1048−void Menu::voxelStatsDetailsClosed() {
1049− if (_voxelStatsDialog) {
1050− delete _voxelStatsDialog;
1051− _voxelStatsDialog = NULL;
1093+QString Menu::getLODFeedbackText() {
1094+ // determine granularity feedback
1095+ int boundaryLevelAdjust = getBoundaryLevelAdjust();
1096+ QString granularityFeedback;
1097+
1098+ switch (boundaryLevelAdjust) {
1099+ case 0: {
1100+ granularityFeedback = QString("at standard granularity.");
1101+ } break;
1102+ case 1: {
1103+ granularityFeedback = QString("at half of standard granularity.");
1104+ } break;
1105+ case 2: {
1106+ granularityFeedback = QString("at a third of standard granularity.");
1107+ } break;
1108+ default: {
1109+ granularityFeedback = QString("at 1/%1th of standard granularity.").arg(boundaryLevelAdjust + 1);
1110+ } break;
1111+ }
1112+
1113+ // distance feedback
1114+ float voxelSizeScale = getVoxelSizeScale();
1115+ float relativeToDefault = voxelSizeScale / DEFAULT_OCTREE_SIZE_SCALE;
1116+ QString result;
1117+ if (relativeToDefault > 1.01) {
1118+ result = QString("%1 further %2").arg(relativeToDefault,8,'f',2).arg(granularityFeedback);
1119+ } else if (relativeToDefault > 0.99) {
1120+ result = QString("the default distance %1").arg(granularityFeedback);
1121+ } else {
1122+ result = QString("%1 of default %2").arg(relativeToDefault,8,'f',3).arg(granularityFeedback);
10521123 }
1124+ return result;
10531125 }
10541126
10551127 void Menu::autoAdjustLOD(float currentFPS) {