mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 18:42:55 +02:00
commit
5b2b0c47c0
9 changed files with 233 additions and 22 deletions
interface
resources/images
src
libraries/networking/src
18
interface/resources/images/address-bar-submit-active.svg
Normal file
18
interface/resources/images/address-bar-submit-active.svg
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 49 49" enable-background="new 0 0 49 49" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#333" d="M49,46c0,1.7-1.3,3-3,3H3c-1.7,0-3-1.3-3-3V3c0-1.7,1.3-3,3-3h43c1.7,0,3,1.3,3,3V46z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g id="Your_Icon_11_">
|
||||
<g>
|
||||
<polygon fill="#E7EEEE" points="23.6,19.9 15.1,19.9 15.1,27.8 23.6,27.8 23.6,33.8 33,23.9 23.6,14 "/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After (image error) Size: 759 B |
18
interface/resources/images/address-bar-submit.svg
Normal file
18
interface/resources/images/address-bar-submit.svg
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 49 49" enable-background="new 0 0 49 49" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M49,46c0,1.7-1.3,3-3,3H3c-1.7,0-3-1.3-3-3V3c0-1.7,1.3-3,3-3h43c1.7,0,3,1.3,3,3V46z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g id="Your_Icon_11_">
|
||||
<g>
|
||||
<polygon fill="#E7EEEE" points="23.6,19.9 15.1,19.9 15.1,27.8 23.6,27.8 23.6,33.8 33,23.9 23.6,14 "/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After (image error) Size: 762 B |
|
@ -921,12 +921,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
if (isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
||||
} else {
|
||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||
}
|
||||
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
||||
break;
|
||||
|
||||
case Qt::Key_Backslash:
|
||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||
break;
|
||||
|
||||
case Qt::Key_N:
|
||||
|
|
|
@ -176,7 +176,7 @@ Menu::Menu() :
|
|||
SLOT(toggleLocationList()));
|
||||
addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::AddressBar,
|
||||
Qt::CTRL | Qt::Key_Enter,
|
||||
Qt::Key_Enter,
|
||||
this,
|
||||
SLOT(toggleAddressBar()));
|
||||
|
||||
|
@ -1156,22 +1156,13 @@ void Menu::changePrivateKey() {
|
|||
}
|
||||
|
||||
void Menu::toggleAddressBar() {
|
||||
|
||||
QInputDialog addressBarDialog(Application::getInstance()->getWindow());
|
||||
addressBarDialog.setWindowTitle("Address Bar");
|
||||
addressBarDialog.setWindowFlags(Qt::Sheet);
|
||||
addressBarDialog.setLabelText("place, domain, @user, example.com, /position/orientation");
|
||||
|
||||
addressBarDialog.resize(addressBarDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW,
|
||||
addressBarDialog.size().height());
|
||||
|
||||
int dialogReturn = addressBarDialog.exec();
|
||||
if (dialogReturn == QDialog::Accepted && !addressBarDialog.textValue().isEmpty()) {
|
||||
// let the AddressManger figure out what to do with this
|
||||
AddressManager::getInstance().handleLookupString(addressBarDialog.textValue());
|
||||
if (!_addressBarDialog) {
|
||||
_addressBarDialog = new AddressBarDialog();
|
||||
}
|
||||
|
||||
sendFakeEnterEvent();
|
||||
if (!_addressBarDialog->isVisible()) {
|
||||
_addressBarDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::displayAddressOfflineMessage() {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "SpeechRecognizer.h"
|
||||
#endif
|
||||
|
||||
#include "ui/AddressBarDialog.h"
|
||||
#include "ui/ChatWindow.h"
|
||||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/JSConsole.h"
|
||||
|
@ -298,6 +299,7 @@ private:
|
|||
QPointer<PreferencesDialog> _preferencesDialog;
|
||||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||
QPointer<AnimationsDialog> _animationsDialog;
|
||||
QPointer<AddressBarDialog> _addressBarDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
bool _hasLoginDialogDisplayed;
|
||||
QAction* _chatAction;
|
||||
|
|
131
interface/src/ui/AddressBarDialog.cpp
Normal file
131
interface/src/ui/AddressBarDialog.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
//
|
||||
// AddressBarDialog.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Stojce Slavkovski on 9/22/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AddressBarDialog.h"
|
||||
#include "AddressManager.h"
|
||||
#include "Application.h"
|
||||
|
||||
const QString ADDRESSBAR_GO_BUTTON_ICON = "images/address-bar-submit.svg";
|
||||
const QString ADDRESSBAR_GO_BUTTON_ACTIVE_ICON = "images/address-bar-submit-active.svg";
|
||||
|
||||
AddressBarDialog::AddressBarDialog() :
|
||||
FramelessDialog(Application::getInstance()->getWindow(), 0, FramelessDialog::POSITION_TOP) {
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void AddressBarDialog::setupUI() {
|
||||
|
||||
const QString DIALOG_STYLESHEET = "font-family: Helvetica, Arial, sans-serif;";
|
||||
const QString ADDRESSBAR_PLACEHOLDER = "Go to: domain, @user, #location";
|
||||
const QString ADDRESSBAR_STYLESHEET = "padding: 0 10px;";
|
||||
const QString ADDRESSBAR_FONT_FAMILY = "Helvetica,Arial,sans-serif";
|
||||
const int ADDRESSBAR_FONT_SIZE = 20;
|
||||
|
||||
const int ADDRESSBAR_MIN_WIDTH = 200;
|
||||
const int ADDRESSBAR_MAX_WIDTH = 615;
|
||||
const int ADDRESSBAR_HEIGHT = 54;
|
||||
const int ADDRESSBAR_STRETCH = 60;
|
||||
|
||||
const int BUTTON_SPACER_SIZE = 10;
|
||||
const int DEFAULT_SPACER_SIZE = 20;
|
||||
const int ADDRESS_LAYOUT_RIGHT_MARGIN = 10;
|
||||
|
||||
const int GO_BUTTON_SIZE = 55;
|
||||
const int CLOSE_BUTTON_SIZE = 16;
|
||||
const QString CLOSE_BUTTON_ICON = "styles/close.svg";
|
||||
|
||||
const int DIALOG_HEIGHT = 100;
|
||||
const int DIALOG_INITIAL_WIDTH = 560;
|
||||
|
||||
setModal(true);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
setHideOnBlur(false);
|
||||
|
||||
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setSizePolicy(sizePolicy);
|
||||
setMinimumSize(QSize(DIALOG_INITIAL_WIDTH, DIALOG_HEIGHT));
|
||||
setStyleSheet(DIALOG_STYLESHEET);
|
||||
|
||||
_verticalLayout = new QVBoxLayout(this);
|
||||
|
||||
_addressLayout = new QHBoxLayout();
|
||||
_addressLayout->setContentsMargins(0, 0, ADDRESS_LAYOUT_RIGHT_MARGIN, 0);
|
||||
|
||||
_leftSpacer = new QSpacerItem(DEFAULT_SPACER_SIZE,
|
||||
DEFAULT_SPACER_SIZE,
|
||||
QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Minimum);
|
||||
|
||||
_addressLayout->addItem(_leftSpacer);
|
||||
|
||||
_addressLineEdit = new QLineEdit(this);
|
||||
_addressLineEdit->setPlaceholderText(ADDRESSBAR_PLACEHOLDER);
|
||||
QSizePolicy sizePolicyLineEdit(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
sizePolicyLineEdit.setHorizontalStretch(ADDRESSBAR_STRETCH);
|
||||
_addressLineEdit->setSizePolicy(sizePolicyLineEdit);
|
||||
_addressLineEdit->setMinimumSize(QSize(ADDRESSBAR_MIN_WIDTH, ADDRESSBAR_HEIGHT));
|
||||
_addressLineEdit->setMaximumSize(QSize(ADDRESSBAR_MAX_WIDTH, ADDRESSBAR_HEIGHT));
|
||||
QFont font(ADDRESSBAR_FONT_FAMILY, ADDRESSBAR_FONT_SIZE);
|
||||
_addressLineEdit->setFont(font);
|
||||
_addressLineEdit->setStyleSheet(ADDRESSBAR_STYLESHEET);
|
||||
_addressLayout->addWidget(_addressLineEdit);
|
||||
|
||||
_buttonSpacer = new QSpacerItem(BUTTON_SPACER_SIZE, BUTTON_SPACER_SIZE, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
_addressLayout->addItem(_buttonSpacer);
|
||||
|
||||
_goButton = new QPushButton(this);
|
||||
_goButton->setSizePolicy(sizePolicy);
|
||||
_goButton->setMinimumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setMaximumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
|
||||
_goButton->setIconSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setDefault(true);
|
||||
_goButton->setFlat(true);
|
||||
_addressLayout->addWidget(_goButton);
|
||||
|
||||
_rightSpacer = new QSpacerItem(DEFAULT_SPACER_SIZE,
|
||||
DEFAULT_SPACER_SIZE,
|
||||
QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Minimum);
|
||||
|
||||
_addressLayout->addItem(_rightSpacer);
|
||||
|
||||
_closeButton = new QPushButton(this);
|
||||
_closeButton->setSizePolicy(sizePolicy);
|
||||
_closeButton->setMinimumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
|
||||
_closeButton->setMaximumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
|
||||
QIcon icon(Application::resourcesPath() + CLOSE_BUTTON_ICON);
|
||||
_closeButton->setIcon(icon);
|
||||
_closeButton->setFlat(true);
|
||||
_addressLayout->addWidget(_closeButton, 0, Qt::AlignRight);
|
||||
|
||||
_verticalLayout->addLayout(_addressLayout);
|
||||
|
||||
connect(_goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
||||
connect(_closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
}
|
||||
|
||||
void AddressBarDialog::showEvent(QShowEvent* event) {
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
|
||||
_addressLineEdit->setText(QString());
|
||||
FramelessDialog::showEvent(event);
|
||||
}
|
||||
|
||||
void AddressBarDialog::accept() {
|
||||
if (!_addressLineEdit->text().isEmpty()) {
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON));
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide);
|
||||
addressManager.handleLookupString(_addressLineEdit->text());
|
||||
}
|
||||
}
|
46
interface/src/ui/AddressBarDialog.h
Normal file
46
interface/src/ui/AddressBarDialog.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// AddressBarDialog.h
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Stojce Slavkovski on 9/22/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AddressBarDialog_h
|
||||
#define hifi_AddressBarDialog_h
|
||||
|
||||
#include "FramelessDialog.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class AddressBarDialog : public FramelessDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AddressBarDialog();
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
void showEvent(QShowEvent* event);
|
||||
|
||||
QVBoxLayout *_verticalLayout;
|
||||
QHBoxLayout *_addressLayout;
|
||||
QSpacerItem *_leftSpacer;
|
||||
QSpacerItem *_rightSpacer;
|
||||
QSpacerItem *_buttonSpacer;
|
||||
QPushButton *_goButton;
|
||||
QPushButton *_closeButton;
|
||||
QLineEdit *_addressLineEdit;
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_AddressBarDialog_h
|
|
@ -80,6 +80,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
|||
|
||||
// if this is a relative path then handle it as a relative viewpoint
|
||||
handleRelativeViewpoint(lookupUrl.path());
|
||||
emit lookupResultsFinished();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -149,6 +150,7 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
|||
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
||||
emit lookupResultIsOffline();
|
||||
}
|
||||
emit lookupResultsFinished();
|
||||
}
|
||||
|
||||
void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
||||
|
@ -157,6 +159,7 @@ void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
|||
if (errorReply.error() == QNetworkReply::ContentNotFoundError) {
|
||||
emit lookupResultIsNotFound();
|
||||
}
|
||||
emit lookupResultsFinished();
|
||||
}
|
||||
|
||||
const QString GET_PLACE = "/api/v1/places/%1";
|
||||
|
@ -164,7 +167,7 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
void AddressManager::attemptPlaceNameLookup(const QString& lookupString) {
|
||||
// assume this is a place name and see if we can get any info on it
|
||||
QString placeName = QUrl::toPercentEncoding(lookupString);
|
||||
AccountManager::getInstance().authenticatedRequest(GET_PLACE.arg(placeName),
|
||||
AccountManager::getInstance().unauthenticatedRequest(GET_PLACE.arg(placeName),
|
||||
QNetworkAccessManager::GetOperation,
|
||||
apiCallbackParameters());
|
||||
}
|
||||
|
@ -180,6 +183,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
|||
|
||||
if (hostnameRegex.indexIn(lookupString) != -1) {
|
||||
emit possibleDomainChangeRequired(hostnameRegex.cap(0));
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -187,6 +191,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
|||
|
||||
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
||||
emit possibleDomainChangeRequired(ipAddressRegex.cap(0));
|
||||
emit lookupResultsFinished();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -263,7 +268,7 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
|||
void AddressManager::goToUser(const QString& username) {
|
||||
QString formattedUsername = QUrl::toPercentEncoding(username);
|
||||
// this is a username - pull the captured name and lookup that user's location
|
||||
AccountManager::getInstance().authenticatedRequest(GET_USER_LOCATION.arg(formattedUsername),
|
||||
AccountManager::getInstance().unauthenticatedRequest(GET_USER_LOCATION.arg(formattedUsername),
|
||||
QNetworkAccessManager::GetOperation,
|
||||
apiCallbackParameters());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public slots:
|
|||
void handleAPIError(QNetworkReply& errorReply);
|
||||
void goToUser(const QString& username);
|
||||
signals:
|
||||
void lookupResultsFinished();
|
||||
void lookupResultIsOffline();
|
||||
void lookupResultIsNotFound();
|
||||
void possibleDomainChangeRequired(const QString& newHostname);
|
||||
|
|
Loading…
Reference in a new issue