mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
added address bar dialog
This commit is contained in:
parent
76f78e77d1
commit
466dbdcee5
7 changed files with 153 additions and 24 deletions
|
@ -923,12 +923,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_CapsLock:
|
||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||
break;
|
||||
|
||||
case Qt::Key_N:
|
||||
|
|
|
@ -173,7 +173,7 @@ Menu::Menu() :
|
|||
SLOT(toggleLocationList()));
|
||||
addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::AddressBar,
|
||||
Qt::CTRL | Qt::Key_Enter,
|
||||
Qt::Key_Enter,
|
||||
this,
|
||||
SLOT(toggleAddressBar()));
|
||||
|
||||
|
@ -1154,22 +1154,10 @@ 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();
|
||||
_addressBarDialog->show();
|
||||
}
|
||||
|
||||
sendFakeEnterEvent();
|
||||
}
|
||||
|
||||
void Menu::displayAddressOfflineMessage() {
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#endif
|
||||
|
||||
#include "location/LocationManager.h"
|
||||
|
||||
#include "ui/AddressBarDialog.h"
|
||||
#include "ui/ChatWindow.h"
|
||||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/JSConsole.h"
|
||||
|
@ -299,6 +301,7 @@ private:
|
|||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||
QPointer<AnimationsDialog> _animationsDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
QPointer<AddressBarDialog> _addressBarDialog;
|
||||
bool _hasLoginDialogDisplayed;
|
||||
QAction* _chatAction;
|
||||
QString _snapshotsLocation;
|
||||
|
|
91
interface/src/ui/AddressBarDialog.cpp
Normal file
91
interface/src/ui/AddressBarDialog.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
// 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"
|
||||
|
||||
AddressBarDialog::AddressBarDialog() :
|
||||
FramelessDialog(Application::getInstance()->getWindow(), 0, FramelessDialog::POSITION_TOP){
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void AddressBarDialog::setupUI() {
|
||||
|
||||
setModal(true);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
setHideOnBlur(false);
|
||||
|
||||
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setSizePolicy(sizePolicy);
|
||||
setMinimumSize(QSize(560, 100));
|
||||
setStyleSheet("font-family: Helvetica, Arial, sans-serif;");
|
||||
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
|
||||
addressLayout = new QHBoxLayout();
|
||||
addressLayout->setContentsMargins(0, 0, 10, 0);
|
||||
|
||||
leftSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(leftSpacer);
|
||||
|
||||
addressLineEdit = new QLineEdit(this);
|
||||
addressLineEdit->setPlaceholderText("Go to: domain, @user, #location");
|
||||
QSizePolicy sizePolicyLineEdit(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
sizePolicyLineEdit.setHorizontalStretch(60);
|
||||
addressLineEdit->setSizePolicy(sizePolicyLineEdit);
|
||||
addressLineEdit->setMinimumSize(QSize(200, 50));
|
||||
addressLineEdit->setMaximumSize(QSize(615, 50));
|
||||
QFont font("Helvetica,Arial,sans-serif", 20);
|
||||
addressLineEdit->setFont(font);
|
||||
addressLineEdit->setStyleSheet("padding: 0 10px;");
|
||||
addressLayout->addWidget(addressLineEdit);
|
||||
|
||||
buttonSpacer = new QSpacerItem(10, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(buttonSpacer);
|
||||
|
||||
goButton = new QPushButton(this);
|
||||
goButton->setSizePolicy(sizePolicy);
|
||||
goButton->setMinimumSize(QSize(54, 54));
|
||||
goButton->setFont(font);
|
||||
goButton->setText("➡");
|
||||
goButton->setStyleSheet("background: #0e7077; color: #e7eeee; border-radius: 4px;");
|
||||
goButton->setIconSize(QSize(32, 32));
|
||||
goButton->setDefault(true);
|
||||
goButton->setFlat(true);
|
||||
addressLayout->addWidget(goButton);
|
||||
|
||||
rightSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(rightSpacer);
|
||||
|
||||
closeButton = new QPushButton(this);
|
||||
closeButton->setSizePolicy(sizePolicy);
|
||||
closeButton->setMinimumSize(QSize(16, 16));
|
||||
closeButton->setMaximumSize(QSize(16, 16));
|
||||
closeButton->setStyleSheet("color: #333");
|
||||
QIcon icon(Application::resourcesPath() + "styles/close.svg");
|
||||
closeButton->setIcon(icon);
|
||||
closeButton->setFlat(true);
|
||||
addressLayout->addWidget(closeButton, 0, Qt::AlignRight);
|
||||
|
||||
verticalLayout->addLayout(addressLayout);
|
||||
|
||||
connect(addressLineEdit, &QLineEdit::returnPressed, this, &AddressBarDialog::accept);
|
||||
connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
||||
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
}
|
||||
|
||||
void AddressBarDialog::accept() {
|
||||
// let the AddressManger figure out what to do with this
|
||||
if (AddressManager::getInstance().handleLookupString(addressLineEdit->text())) {
|
||||
close();
|
||||
}
|
||||
}
|
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();
|
||||
|
||||
QVBoxLayout *verticalLayout;
|
||||
QHBoxLayout *addressLayout;
|
||||
QSpacerItem *leftSpacer;
|
||||
QLineEdit *addressLineEdit;
|
||||
QSpacerItem *buttonSpacer;
|
||||
QPushButton *goButton;
|
||||
QSpacerItem *rightSpacer;
|
||||
QPushButton *closeButton;
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_AddressBarDialog_h
|
|
@ -85,7 +85,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void AddressManager::handleLookupString(const QString& lookupString) {
|
||||
bool AddressManager::handleLookupString(const QString& lookupString) {
|
||||
if (!lookupString.isEmpty()) {
|
||||
// make this a valid hifi URL and handle it off to handleUrl
|
||||
QString sanitizedString = lookupString;
|
||||
|
@ -100,8 +100,10 @@ void AddressManager::handleLookupString(const QString& lookupString) {
|
|||
lookupURL = QUrl(lookupString);
|
||||
}
|
||||
|
||||
handleUrl(lookupURL);
|
||||
return handleUrl(lookupURL);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
void attemptPlaceNameLookup(const QString& lookupString);
|
||||
public slots:
|
||||
void handleLookupString(const QString& lookupString);
|
||||
bool handleLookupString(const QString& lookupString);
|
||||
|
||||
void handleAPIResponse(const QJsonObject& jsonObject);
|
||||
void handleAPIError(QNetworkReply& errorReply);
|
||||
|
|
Loading…
Reference in a new issue