Showing the changes to interface/src/Menu.cpp (1 of 63 files). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <QWindow> |
| 27 | 27 | |
| 28 | 28 | #include <AccountManager.h> |
| 29 | +#include <XmppClient.h> | |
| 29 | 30 | #include <UUID.h> |
| 30 | 31 | |
| 31 | 32 | #include "Application.h" |
| @@ -66,7 +67,7 @@ Menu::Menu() : · 34 unmodified lines | ||
| 66 | 67 | _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION), |
| 67 | 68 | _frustumDrawMode(FRUSTUM_DRAW_MODE_ALL), |
| 68 | 69 | _viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET), |
| 69 | − _voxelStatsDialog(NULL), | |
| 70 | + _octreeStatsDialog(NULL), | |
| 70 | 71 | _lodToolsDialog(NULL), |
| 71 | 72 | _maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM), |
| 72 | 73 | _voxelSizeScale(DEFAULT_OCTREE_SIZE_SCALE), |
| @@ -162,6 +163,15 @@ Menu::Menu() : · 89 unmodified lines | ||
| 162 | 163 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor())); |
| 163 | 164 | addActionToQMenuAndActionHash(toolsMenu, MenuOption::FstUploader, 0, Application::getInstance(), SLOT(uploadFST())); |
| 164 | 165 | |
| 166 | + _chatAction = addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat, 0, this, SLOT(showChat())); | |
| 167 | +#ifdef HAVE_QXMPP | |
| 168 | + const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); | |
| 169 | + toggleChat(); | |
| 170 | + connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat())); | |
| 171 | + connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat())); | |
| 172 | +#else | |
| 173 | + _chatAction->setEnabled(false); | |
| 174 | +#endif | |
| 165 | 175 | |
| 166 | 176 | QMenu* viewMenu = addMenu("View"); |
| 167 | 177 | |
| @@ -213,7 +223,7 @@ Menu::Menu() : · 45 unmodified lines | ||
| 213 | 223 | addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Oscilloscope, 0, true); |
| 214 | 224 | addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Bandwidth, 0, true); |
| 215 | 225 | addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0, this, SLOT(bandwidthDetails())); |
| 216 | − addActionToQMenuAndActionHash(viewMenu, MenuOption::VoxelStats, 0, this, SLOT(voxelStatsDetails())); | |
| 226 | + addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0, this, SLOT(octreeStatsDetails())); | |
| 217 | 227 | |
| 218 | 228 | QMenu* developerMenu = addMenu("Developer"); |
| 219 | 229 | |
| @@ -341,7 +351,7 @@ Menu::Menu() : · 121 unmodified lines | ||
| 341 | 351 | |
| 342 | 352 | Menu::~Menu() { |
| 343 | 353 | bandwidthDetailsClosed(); |
| 344 | − voxelStatsDetailsClosed(); | |
| 354 | + octreeStatsDetailsClosed(); | |
| 345 | 355 | } |
| 346 | 356 | |
| 347 | 357 | void Menu::loadSettings(QSettings* settings) { |
| @@ -1021,6 +1031,33 @@ void Menu::showMetavoxelEditor() { · 673 unmodified lines | ||
| 1021 | 1031 | _MetavoxelEditor->raise(); |
| 1022 | 1032 | } |
| 1023 | 1033 | |
| 1034 | +void Menu::showChat() { | |
| 1035 | + if (!_chatWindow) { | |
| 1036 | + _chatWindow = new ChatWindow(); | |
| 1037 | + QMainWindow* mainWindow = Application::getInstance()->getWindow(); | |
| 1038 | + | |
| 1039 | + // the height of the title bar is given by frameGeometry().height() - geometry().height() | |
| 1040 | + // however, frameGeometry() is initialised after showing (Qt queries the OS windowing system) | |
| 1041 | + // on the other hand, moving a window after showing it flickers; so just use some reasonable value | |
| 1042 | + int titleBarHeight = 16; | |
| 1043 | + _chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(), | |
| 1044 | + mainWindow->geometry().y() + titleBarHeight, | |
| 1045 | + _chatWindow->width(), | |
| 1046 | + mainWindow->height() - titleBarHeight); | |
| 1047 | + _chatWindow->show(); | |
| 1048 | + } | |
| 1049 | + _chatWindow->raise(); | |
| 1050 | +} | |
| 1051 | + | |
| 1052 | +void Menu::toggleChat() { | |
| 1053 | +#ifdef HAVE_QXMPP | |
| 1054 | + _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); | |
| 1055 | + if (!_chatAction->isEnabled() && _chatWindow) { | |
| 1056 | + _chatWindow->close(); | |
| 1057 | + } | |
| 1058 | +#endif | |
| 1059 | +} | |
| 1060 | + | |
| 1024 | 1061 | void Menu::audioMuteToggled() { |
| 1025 | 1062 | QAction *muteAction = _actionHash.value(MenuOption::MuteAudio); |
| 1026 | 1063 | muteAction->setChecked(Application::getInstance()->getAudio()->getMuted()); |
| @@ -1033,20 +1070,20 @@ void Menu::bandwidthDetailsClosed() { · 6 unmodified lines | ||
| 1033 | 1070 | } |
| 1034 | 1071 | } |
| 1035 | 1072 | |
| 1036 | −void Menu::voxelStatsDetails() { | |
| 1037 | − if (!_voxelStatsDialog) { | |
| 1038 | − _voxelStatsDialog = new VoxelStatsDialog(Application::getInstance()->getGLWidget(), | |
| 1073 | +void Menu::octreeStatsDetails() { | |
| 1074 | + if (!_octreeStatsDialog) { | |
| 1075 | + _octreeStatsDialog = new OctreeStatsDialog(Application::getInstance()->getGLWidget(), | |
| 1039 | 1076 | Application::getInstance()->getOcteeSceneStats()); |
| 1040 | − connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed())); | |
| 1041 | − _voxelStatsDialog->show(); | |
| 1077 | + connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed())); | |
| 1078 | + _octreeStatsDialog->show(); | |
| 1042 | 1079 | } |
| 1043 | − _voxelStatsDialog->raise(); | |
| 1080 | + _octreeStatsDialog->raise(); | |
| 1044 | 1081 | } |
| 1045 | 1082 | |
| 1046 | −void Menu::voxelStatsDetailsClosed() { | |
| 1047 | − if (_voxelStatsDialog) { | |
| 1048 | − delete _voxelStatsDialog; | |
| 1049 | − _voxelStatsDialog = NULL; | |
| 1083 | +void Menu::octreeStatsDetailsClosed() { | |
| 1084 | + if (_octreeStatsDialog) { | |
| 1085 | + delete _octreeStatsDialog; | |
| 1086 | + _octreeStatsDialog = NULL; | |
| 1050 | 1087 | } |
| 1051 | 1088 | } |
| 1052 | 1089 | |