mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:36:45 +02:00
some dialog touchups and visual changes
This commit is contained in:
parent
27ed53301b
commit
145efbda2d
1 changed files with 57 additions and 121 deletions
|
@ -8,15 +8,17 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <QMenuBar>
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QMenuBar>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
@ -728,60 +730,29 @@ void updateDSHostname(const QString& domainServerHostname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const int QLINE_MINIMUM_WIDTH = 400;
|
const int QLINE_MINIMUM_WIDTH = 400;
|
||||||
|
const float DIALOG_RATIO_OF_WINDOW = 0.30;
|
||||||
|
|
||||||
QLineEdit* lineEditForDomainHostname() {
|
|
||||||
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
|
||||||
|
|
||||||
if (NodeList::getInstance()->getDomainPort() != DEFAULT_DOMAIN_SERVER_PORT) {
|
|
||||||
// add the port to the currentDomainHostname string if it is custom
|
|
||||||
currentDomainHostname.append(QString(":%1").arg(NodeList::getInstance()->getDomainPort()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QLineEdit* domainServerLineEdit = new QLineEdit(currentDomainHostname);
|
|
||||||
domainServerLineEdit->setPlaceholderText(DEFAULT_DOMAIN_HOSTNAME);
|
|
||||||
domainServerLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
|
||||||
|
|
||||||
return domainServerLineEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Menu::login() {
|
void Menu::login() {
|
||||||
Application* applicationInstance = Application::getInstance();
|
QInputDialog loginDialog(Application::getInstance()->getWindow());
|
||||||
QDialog dialog;
|
loginDialog.setWindowTitle("Login");
|
||||||
dialog.setWindowTitle("Login");
|
loginDialog.setLabelText("Username:");
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
QString username = Application::getInstance()->getProfile()->getUsername();
|
||||||
dialog.setLayout(layout);
|
loginDialog.setTextValue(username);
|
||||||
|
loginDialog.setWindowFlags(Qt::Sheet);
|
||||||
|
loginDialog.resize(loginDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, loginDialog.size().height());
|
||||||
|
|
||||||
QFormLayout* form = new QFormLayout();
|
int dialogReturn = loginDialog.exec();
|
||||||
layout->addLayout(form, 1);
|
if (dialogReturn == QDialog::Accepted && loginDialog.textValue().isEmpty() && loginDialog.textValue() != username) {
|
||||||
|
|
||||||
QString username = applicationInstance->getProfile()->getUsername();
|
|
||||||
QLineEdit* usernameLineEdit = new QLineEdit(username);
|
|
||||||
usernameLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
|
||||||
form->addRow("Username:", usernameLineEdit);
|
|
||||||
|
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
||||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
|
||||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
|
||||||
layout->addWidget(buttons);
|
|
||||||
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if (ret != QDialog::Accepted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (usernameLineEdit->text() != username) {
|
|
||||||
// there has been a username change
|
// there has been a username change
|
||||||
// ask for a profile reset with the new username
|
// ask for a profile reset with the new username
|
||||||
applicationInstance->resetProfile(usernameLineEdit->text());
|
Application::getInstance()->resetProfile(loginDialog.textValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::editPreferences() {
|
void Menu::editPreferences() {
|
||||||
Application* applicationInstance = Application::getInstance();
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
|
||||||
QDialog dialog;
|
QDialog dialog(applicationInstance->getWindow());
|
||||||
dialog.setWindowTitle("Interface Preferences");
|
dialog.setWindowTitle("Interface Preferences");
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
dialog.setLayout(layout);
|
dialog.setLayout(layout);
|
||||||
|
@ -888,70 +859,48 @@ void Menu::editPreferences() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::goToDomain() {
|
void Menu::goToDomain() {
|
||||||
QDialog dialog;
|
|
||||||
dialog.setWindowTitle("Go To Domain");
|
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
||||||
dialog.setLayout(layout);
|
|
||||||
|
|
||||||
QFormLayout* form = new QFormLayout();
|
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
||||||
layout->addLayout(form, 1);
|
|
||||||
|
|
||||||
|
|
||||||
QLineEdit* domainServerLineEdit = lineEditForDomainHostname();
|
if (NodeList::getInstance()->getDomainPort() != DEFAULT_DOMAIN_SERVER_PORT) {
|
||||||
form->addRow("Domain server:", domainServerLineEdit);
|
// add the port to the currentDomainHostname string if it is custom
|
||||||
|
currentDomainHostname.append(QString(":%1").arg(NodeList::getInstance()->getDomainPort()));
|
||||||
|
}
|
||||||
|
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QInputDialog domainDialog(Application::getInstance()->getWindow());
|
||||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
domainDialog.setWindowTitle("Go to Domain");
|
||||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
domainDialog.setLabelText("Domain server:");
|
||||||
layout->addWidget(buttons);
|
domainDialog.setTextValue(currentDomainHostname);
|
||||||
|
domainDialog.setWindowFlags(Qt::Sheet);
|
||||||
|
domainDialog.resize(domainDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, domainDialog.size().height());
|
||||||
|
|
||||||
int ret = dialog.exec();
|
int dialogReturn = domainDialog.exec();
|
||||||
if (ret != QDialog::Accepted) {
|
if (dialogReturn == QDialog::Accepted && domainDialog.textValue().isEmpty()) {
|
||||||
return;
|
updateDSHostname(domainDialog.textValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDSHostname(domainServerLineEdit->text());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::goToLocation() {
|
void Menu::goToLocation() {
|
||||||
QDialog dialog;
|
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
|
||||||
dialog.setWindowTitle("Go To Location");
|
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
||||||
dialog.setLayout(layout);
|
|
||||||
|
|
||||||
QFormLayout* form = new QFormLayout();
|
|
||||||
layout->addLayout(form, 1);
|
|
||||||
|
|
||||||
const int QLINE_MINIMUM_WIDTH = 300;
|
|
||||||
|
|
||||||
Application* applicationInstance = Application::getInstance();
|
|
||||||
MyAvatar* myAvatar = applicationInstance->getAvatar();
|
|
||||||
glm::vec3 avatarPos = myAvatar->getPosition();
|
glm::vec3 avatarPos = myAvatar->getPosition();
|
||||||
QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x),
|
QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x),
|
||||||
QString::number(avatarPos.y), QString::number(avatarPos.z));
|
QString::number(avatarPos.y), QString::number(avatarPos.z));
|
||||||
|
|
||||||
QLineEdit* coordinates = new QLineEdit(currentLocation);
|
|
||||||
coordinates->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
QInputDialog coordinateDialog(Application::getInstance()->getWindow());
|
||||||
form->addRow("Coordinates as x,y,z:", coordinates);
|
coordinateDialog.setWindowTitle("Go to Location");
|
||||||
|
coordinateDialog.setLabelText("Coordinate as x,y,z:");
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
coordinateDialog.setTextValue(currentLocation);
|
||||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
coordinateDialog.setWindowFlags(Qt::Sheet);
|
||||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
coordinateDialog.resize(coordinateDialog.parentWidget()->size().width() * 0.30, coordinateDialog.size().height());
|
||||||
layout->addWidget(buttons);
|
|
||||||
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if (ret != QDialog::Accepted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray newCoordinates;
|
|
||||||
|
|
||||||
if (coordinates->text().size() > 0) {
|
|
||||||
// the user input a new hostname, use that
|
|
||||||
|
|
||||||
|
int dialogReturn = coordinateDialog.exec();
|
||||||
|
if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) {
|
||||||
|
QByteArray newCoordinates;
|
||||||
|
|
||||||
QString delimiterPattern(",");
|
QString delimiterPattern(",");
|
||||||
QStringList coordinateItems = coordinates->text().split(delimiterPattern);
|
QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern);
|
||||||
|
|
||||||
const int NUMBER_OF_COORDINATE_ITEMS = 3;
|
const int NUMBER_OF_COORDINATE_ITEMS = 3;
|
||||||
const int X_ITEM = 0;
|
const int X_ITEM = 0;
|
||||||
const int Y_ITEM = 1;
|
const int Y_ITEM = 1;
|
||||||
|
@ -971,32 +920,19 @@ void Menu::goToLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::goToUser() {
|
void Menu::goToUser() {
|
||||||
QDialog dialog;
|
QInputDialog userDialog(Application::getInstance()->getWindow());
|
||||||
dialog.setWindowTitle("Go To User");
|
userDialog.setWindowTitle("Go to User");
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
userDialog.setLabelText("Destination user:");
|
||||||
dialog.setLayout(layout);
|
QString username = Application::getInstance()->getProfile()->getUsername();
|
||||||
|
userDialog.setTextValue(username);
|
||||||
|
userDialog.setWindowFlags(Qt::Sheet);
|
||||||
|
userDialog.resize(userDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, userDialog.size().height());
|
||||||
|
|
||||||
QFormLayout* form = new QFormLayout();
|
int dialogReturn = userDialog.exec();
|
||||||
layout->addLayout(form, 1);
|
if (dialogReturn == QDialog::Accepted && userDialog.textValue().isEmpty()) {
|
||||||
|
|
||||||
QLineEdit* usernameLineEdit = new QLineEdit();
|
|
||||||
usernameLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
|
||||||
form->addRow("", usernameLineEdit);
|
|
||||||
|
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
||||||
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
|
||||||
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
|
||||||
layout->addWidget(buttons);
|
|
||||||
|
|
||||||
int ret = dialog.exec();
|
|
||||||
if (ret != QDialog::Accepted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!usernameLineEdit->text().isEmpty()) {
|
|
||||||
// there's a username entered by the user, make a request to the data-server
|
// there's a username entered by the user, make a request to the data-server
|
||||||
DataServerClient::getValuesForKeysAndUserString((QStringList() << DataServerKey::Domain << DataServerKey::Position),
|
DataServerClient::getValuesForKeysAndUserString((QStringList() << DataServerKey::Domain << DataServerKey::Position),
|
||||||
usernameLineEdit->text());
|
userDialog.textValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue