History

Merge upstream/master into andrew/inertia

Andrew Meadows committed 12 years ago

Commit 5ffd3072 parents 301c3c5 5f2f3db159 files · +8117 −1301Browse files

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

Unified · Split

interface/src/Menu.cpp+53−73
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include "ui/InfoView.h"
4141 #include "ui/MetavoxelEditor.h"
4242 #include "ui/ModelsBrowser.h"
43+#include "ui/LoginDialog.h"
4344
4445
4546 Menu* Menu::_instance = NULL;
@@ -169,12 +170,12 @@ Menu::Menu() : · 123 unmodified lines
169170
170171
171172 QMenu* editMenu = addMenu("Edit");
172−
173+
173174 QUndoStack* undoStack = Application::getInstance()->getUndoStack();
174175 QAction* undoAction = undoStack->createUndoAction(editMenu);
175176 undoAction->setShortcut(Qt::CTRL | Qt::Key_Z);
176177 addActionToQMenuAndActionHash(editMenu, undoAction);
177−
178+
178179 QAction* redoAction = undoStack->createRedoAction(editMenu);
179180 redoAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Z);
180181 addActionToQMenuAndActionHash(editMenu, redoAction);
@@ -279,8 +280,9 @@ Menu::Menu() : · 98 unmodified lines
279280
280281 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, false);
281282 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true);
282− addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true);
283+ addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, false);
283284 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true);
285+ addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Models, 0, true);
284286 addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
285287
286288 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options");
@@ -320,7 +322,7 @@ Menu::Menu() : · 33 unmodified lines
320322 addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true,
321323 appInstance->getVisage(), SLOT(updateEnabled()));
322324 #endif
323−
325+
324326 addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::GlowWhenSpeaking, 0, true);
325327 addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false);
326328
@@ -334,7 +336,6 @@ Menu::Menu() : · 7 unmodified lines
334336 SLOT(setFilter(bool)));
335337 addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHands, 0, true);
336338 addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
337− addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false);
338339 addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false);
339340 addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
340341 addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::AlignForearmsWithWrists, 0, true);
@@ -723,31 +724,31 @@ QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, · 382 unmodified lines
723724 QAction::MenuRole role,
724725 int menuItemLocation) {
725726 QAction* actionBefore = NULL;
726−
727+
727728 if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) {
728729 actionBefore = destinationMenu->actions()[menuItemLocation];
729730 }
730−
731+
731732 if (!actionName.isEmpty()) {
732733 action->setText(actionName);
733734 }
734−
735+
735736 if (shortcut != 0) {
736737 action->setShortcut(shortcut);
737738 }
738−
739+
739740 if (role != QAction::NoRole) {
740741 action->setMenuRole(role);
741742 }
742−
743+
743744 if (!actionBefore) {
744745 destinationMenu->addAction(action);
745746 } else {
746747 destinationMenu->insertAction(actionBefore, action);
747748 }
748−
749+
749750 _actionHash.insert(action->text(), action);
750−
751+
751752 return action;
752753 }
753754
@@ -813,42 +814,12 @@ void sendFakeEnterEvent() { · 59 unmodified lines
813814 QCoreApplication::sendEvent(glWidget, &enterEvent);
814815 }
815816
816−const int QLINE_MINIMUM_WIDTH = 400;
817817 const float DIALOG_RATIO_OF_WINDOW = 0.30f;
818818
819819 void Menu::loginForCurrentDomain() {
820− QDialog loginDialog(Application::getInstance()->getWindow());
821− loginDialog.setWindowTitle("Login");
822−
823− QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
824− loginDialog.setLayout(layout);
825− loginDialog.setWindowFlags(Qt::Sheet);
826−
827− QFormLayout* form = new QFormLayout();
828− layout->addLayout(form, 1);
829−
830− QLineEdit* loginLineEdit = new QLineEdit();
831− loginLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
832− form->addRow("Login:", loginLineEdit);
833−
834− QLineEdit* passwordLineEdit = new QLineEdit();
835− passwordLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
836− passwordLineEdit->setEchoMode(QLineEdit::Password);
837− form->addRow("Password:", passwordLineEdit);
838−
839− QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
840− loginDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
841− loginDialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
842− layout->addWidget(buttons);
843−
844− int dialogReturn = loginDialog.exec();
845−
846− if (dialogReturn == QDialog::Accepted && !loginLineEdit->text().isEmpty() && !passwordLineEdit->text().isEmpty()) {
847− // attempt to get an access token given this username and password
848− AccountManager::getInstance().requestAccessToken(loginLineEdit->text(), passwordLineEdit->text());
849− }
850−
851− sendFakeEnterEvent();
820+ LoginDialog* loginDialog = new LoginDialog(Application::getInstance()->getWindow());
821+ loginDialog->show();
822+ loginDialog->resizeAndPosition(false);
852823 }
853824
854825 void Menu::editPreferences() {
@@ -927,42 +898,51 @@ void Menu::goTo() { · 72 unmodified lines
927898 int dialogReturn = gotoDialog.exec();
928899 if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
929900 QString desiredDestination = gotoDialog.textValue();
901+ if (!goToURL(desiredDestination)) {;
902+ goTo(desiredDestination);
903+ }
904+ }
905+ sendFakeEnterEvent();
906+}
930907
931− if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {
932− QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
908+bool Menu::goToURL(QString location) {
909+ if (location.startsWith(CUSTOM_URL_SCHEME + "//")) {
910+ QStringList urlParts = location.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
933911
934− if (urlParts.count() > 1) {
935− // if url has 2 or more parts, the first one is domain name
936− QString domain = urlParts[0];
912+ if (urlParts.count() > 1) {
913+ // if url has 2 or more parts, the first one is domain name
914+ QString domain = urlParts[0];
937915
938− // second part is either a destination coordinate or
939− // a place name
940− QString destination = urlParts[1];
916+ // second part is either a destination coordinate or
917+ // a place name
918+ QString destination = urlParts[1];
941919
942− // any third part is an avatar orientation.
943− QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
920+ // any third part is an avatar orientation.
921+ QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
944922
945− goToDomain(domain);
946−
947− // goto either @user, #place, or x-xx,y-yy,z-zz
948− // style co-ordinate.
949− goTo(destination);
923+ goToDomain(domain);
950924
951− if (!orientation.isEmpty()) {
952− // location orientation
953− goToOrientation(orientation);
954− }
955− } else if (urlParts.count() == 1) {
956− // location coordinates or place name
957− QString destination = urlParts[0];
958− goTo(destination);
925+ // goto either @user, #place, or x-xx,y-yy,z-zz
926+ // style co-ordinate.
927+ goTo(destination);
928+
929+ if (!orientation.isEmpty()) {
930+ // location orientation
931+ goToOrientation(orientation);
959932 }
933+ } else if (urlParts.count() == 1) {
934+ QString destination = urlParts[0];
960935
961− } else {
962− goToUser(gotoDialog.textValue());
936+ // If this starts with # or @, treat it as a user/location, otherwise treat it as a domain
937+ if (destination[0] == '#' || destination[0] == '@') {
938+ goTo(destination);
939+ } else {
940+ goToDomain(destination);
941+ }
963942 }
943+ return true;
964944 }
965− sendFakeEnterEvent();
945+ return false;
966946 }
967947
968948 void Menu::goToUser(const QString& user) {
@@ -1119,7 +1099,7 @@ void Menu::toggleLoginMenuItem() { · 150 unmodified lines
11191099
11201100 if (accountManager.isLoggedIn()) {
11211101 // change the menu item to logout
1122− _loginAction->setText("Logout " + accountManager.getUsername());
1102+ _loginAction->setText("Logout " + accountManager.getAccountInfo().getUsername());
11231103 connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout);
11241104 } else {
11251105 // change the menu item to login
@@ -1274,7 +1254,7 @@ void Menu::autoAdjustLOD(float currentFPS) { · 148 unmodified lines
12741254 _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
12751255 }
12761256 }
1277−
1257+
12781258 bool changed = false;
12791259 quint64 elapsed = now - _lastAdjust;
12801260