Showing the changes to interface/src/Menu.cpp (1 of 159 files). Show all
Unified · Split
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | #include "ui/InfoView.h" |
| 41 | 41 | #include "ui/MetavoxelEditor.h" |
| 42 | 42 | #include "ui/ModelsBrowser.h" |
| 43 | +#include "ui/LoginDialog.h" | |
| 43 | 44 | |
| 44 | 45 | |
| 45 | 46 | Menu* Menu::_instance = NULL; |
| @@ -169,12 +170,12 @@ Menu::Menu() : · 123 unmodified lines | ||
| 169 | 170 | |
| 170 | 171 | |
| 171 | 172 | QMenu* editMenu = addMenu("Edit"); |
| 172 | − | |
| 173 | + | |
| 173 | 174 | QUndoStack* undoStack = Application::getInstance()->getUndoStack(); |
| 174 | 175 | QAction* undoAction = undoStack->createUndoAction(editMenu); |
| 175 | 176 | undoAction->setShortcut(Qt::CTRL | Qt::Key_Z); |
| 176 | 177 | addActionToQMenuAndActionHash(editMenu, undoAction); |
| 177 | − | |
| 178 | + | |
| 178 | 179 | QAction* redoAction = undoStack->createRedoAction(editMenu); |
| 179 | 180 | redoAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Z); |
| 180 | 181 | addActionToQMenuAndActionHash(editMenu, redoAction); |
| @@ -279,8 +280,9 @@ Menu::Menu() : · 98 unmodified lines | ||
| 279 | 280 | |
| 280 | 281 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, false); |
| 281 | 282 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Metavoxels, 0, true); |
| 282 | − addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, true); | |
| 283 | + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::BuckyBalls, 0, false); | |
| 283 | 284 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Particles, 0, true); |
| 285 | + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Models, 0, true); | |
| 284 | 286 | addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); |
| 285 | 287 | |
| 286 | 288 | QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxel Options"); |
| @@ -320,7 +322,7 @@ Menu::Menu() : · 33 unmodified lines | ||
| 320 | 322 | addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true, |
| 321 | 323 | appInstance->getVisage(), SLOT(updateEnabled())); |
| 322 | 324 | #endif |
| 323 | − | |
| 325 | + | |
| 324 | 326 | addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::GlowWhenSpeaking, 0, true); |
| 325 | 327 | addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false); |
| 326 | 328 | |
| @@ -334,7 +336,6 @@ Menu::Menu() : · 7 unmodified lines | ||
| 334 | 336 | SLOT(setFilter(bool))); |
| 335 | 337 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHands, 0, true); |
| 336 | 338 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); |
| 337 | − addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false); | |
| 338 | 339 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false); |
| 339 | 340 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false); |
| 340 | 341 | addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::AlignForearmsWithWrists, 0, true); |
| @@ -723,31 +724,31 @@ QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, · 382 unmodified lines | ||
| 723 | 724 | QAction::MenuRole role, |
| 724 | 725 | int menuItemLocation) { |
| 725 | 726 | QAction* actionBefore = NULL; |
| 726 | − | |
| 727 | + | |
| 727 | 728 | if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { |
| 728 | 729 | actionBefore = destinationMenu->actions()[menuItemLocation]; |
| 729 | 730 | } |
| 730 | − | |
| 731 | + | |
| 731 | 732 | if (!actionName.isEmpty()) { |
| 732 | 733 | action->setText(actionName); |
| 733 | 734 | } |
| 734 | − | |
| 735 | + | |
| 735 | 736 | if (shortcut != 0) { |
| 736 | 737 | action->setShortcut(shortcut); |
| 737 | 738 | } |
| 738 | − | |
| 739 | + | |
| 739 | 740 | if (role != QAction::NoRole) { |
| 740 | 741 | action->setMenuRole(role); |
| 741 | 742 | } |
| 742 | − | |
| 743 | + | |
| 743 | 744 | if (!actionBefore) { |
| 744 | 745 | destinationMenu->addAction(action); |
| 745 | 746 | } else { |
| 746 | 747 | destinationMenu->insertAction(actionBefore, action); |
| 747 | 748 | } |
| 748 | − | |
| 749 | + | |
| 749 | 750 | _actionHash.insert(action->text(), action); |
| 750 | − | |
| 751 | + | |
| 751 | 752 | return action; |
| 752 | 753 | } |
| 753 | 754 | |
| @@ -813,42 +814,12 @@ void sendFakeEnterEvent() { · 59 unmodified lines | ||
| 813 | 814 | QCoreApplication::sendEvent(glWidget, &enterEvent); |
| 814 | 815 | } |
| 815 | 816 | |
| 816 | −const int QLINE_MINIMUM_WIDTH = 400; | |
| 817 | 817 | const float DIALOG_RATIO_OF_WINDOW = 0.30f; |
| 818 | 818 | |
| 819 | 819 | 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); | |
| 852 | 823 | } |
| 853 | 824 | |
| 854 | 825 | void Menu::editPreferences() { |
| @@ -927,42 +898,51 @@ void Menu::goTo() { · 72 unmodified lines | ||
| 927 | 898 | int dialogReturn = gotoDialog.exec(); |
| 928 | 899 | if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) { |
| 929 | 900 | QString desiredDestination = gotoDialog.textValue(); |
| 901 | + if (!goToURL(desiredDestination)) {; | |
| 902 | + goTo(desiredDestination); | |
| 903 | + } | |
| 904 | + } | |
| 905 | + sendFakeEnterEvent(); | |
| 906 | +} | |
| 930 | 907 | |
| 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); | |
| 933 | 911 | |
| 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]; | |
| 937 | 915 | |
| 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]; | |
| 941 | 919 | |
| 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(); | |
| 944 | 922 | |
| 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); | |
| 950 | 924 | |
| 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); | |
| 959 | 932 | } |
| 933 | + } else if (urlParts.count() == 1) { | |
| 934 | + QString destination = urlParts[0]; | |
| 960 | 935 | |
| 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 | + } | |
| 963 | 942 | } |
| 943 | + return true; | |
| 964 | 944 | } |
| 965 | − sendFakeEnterEvent(); | |
| 945 | + return false; | |
| 966 | 946 | } |
| 967 | 947 | |
| 968 | 948 | void Menu::goToUser(const QString& user) { |
| @@ -1119,7 +1099,7 @@ void Menu::toggleLoginMenuItem() { · 150 unmodified lines | ||
| 1119 | 1099 | |
| 1120 | 1100 | if (accountManager.isLoggedIn()) { |
| 1121 | 1101 | // change the menu item to logout |
| 1122 | − _loginAction->setText("Logout " + accountManager.getUsername()); | |
| 1102 | + _loginAction->setText("Logout " + accountManager.getAccountInfo().getUsername()); | |
| 1123 | 1103 | connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout); |
| 1124 | 1104 | } else { |
| 1125 | 1105 | // change the menu item to login |
| @@ -1274,7 +1254,7 @@ void Menu::autoAdjustLOD(float currentFPS) { · 148 unmodified lines | ||
| 1274 | 1254 | _avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE); |
| 1275 | 1255 | } |
| 1276 | 1256 | } |
| 1277 | − | |
| 1257 | + | |
| 1278 | 1258 | bool changed = false; |
| 1279 | 1259 | quint64 elapsed = now - _lastAdjust; |
| 1280 | 1260 | |