mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Improved hifi:// style URL scheme handling.
First steps towards implementing #1463. - Moved url parsing code from Application::event to Menu::goTo(QString). - Handle destination component of URL as either a @username, #place, or x-xx,y-yy,z-zz style coordinate. - Added support for entering hifi:// style URL into @ invoked goto menu option.
This commit is contained in:
parent
89cb1ad527
commit
19b8f101d8
5 changed files with 51 additions and 29 deletions
|
@ -4,22 +4,22 @@
|
|||
<context>
|
||||
<name>Application</name>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="1381"/>
|
||||
<location filename="src/Application.cpp" line="1362"/>
|
||||
<source>Export Voxels</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="1382"/>
|
||||
<location filename="src/Application.cpp" line="1363"/>
|
||||
<source>Sparse Voxel Octree Files (*.svo)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="3623"/>
|
||||
<location filename="src/Application.cpp" line="3604"/>
|
||||
<source>Open Script</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Application.cpp" line="3624"/>
|
||||
<location filename="src/Application.cpp" line="3605"/>
|
||||
<source>JavaScript Files (*.js)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -112,8 +112,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D
|
|||
|
||||
const int STATS_PELS_PER_LINE = 20;
|
||||
|
||||
const QString CUSTOM_URL_SCHEME = "hifi:";
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
if (message.size() > 0) {
|
||||
QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
|
||||
|
@ -676,30 +674,13 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod
|
|||
}
|
||||
|
||||
bool Application::event(QEvent* event) {
|
||||
|
||||
|
||||
// handle custom URL
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
||||
if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {
|
||||
QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);
|
||||
QStringList urlParts = destination.split('/', QString::SkipEmptyParts);
|
||||
|
||||
if (urlParts.count() > 1) {
|
||||
// if url has 2 or more parts, the first one is domain name
|
||||
Menu::getInstance()->goToDomain(urlParts[0]);
|
||||
|
||||
// location coordinates
|
||||
Menu::getInstance()->goToDestination(urlParts[1]);
|
||||
if (urlParts.count() > 2) {
|
||||
|
||||
// location orientation
|
||||
Menu::getInstance()->goToOrientation(urlParts[2]);
|
||||
}
|
||||
} else if (urlParts.count() == 1) {
|
||||
|
||||
// location coordinates
|
||||
Menu::getInstance()->goToDestination(urlParts[0]);
|
||||
}
|
||||
bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
|
||||
if (isHifiSchemeURL) {
|
||||
Menu::getInstance()->goTo(fileEvent->url().toString());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -93,6 +93,7 @@ static const float NODE_KILLED_GREEN = 0.0f;
|
|||
static const float NODE_KILLED_BLUE = 0.0f;
|
||||
|
||||
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||
static const QString CUSTOM_URL_SCHEME = "hifi:";
|
||||
|
||||
static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees
|
||||
static const float BILLBOARD_DISTANCE = 5.0f; // meters
|
||||
|
|
|
@ -912,19 +912,58 @@ bool Menu::goToDestination(QString destination) {
|
|||
return LocationManager::getInstance().goToDestination(destination);
|
||||
}
|
||||
|
||||
void Menu::goTo(QString destination) {
|
||||
LocationManager::getInstance().goTo(destination);
|
||||
}
|
||||
|
||||
void Menu::goTo() {
|
||||
|
||||
QInputDialog gotoDialog(Application::getInstance()->getWindow());
|
||||
gotoDialog.setWindowTitle("Go to");
|
||||
gotoDialog.setLabelText("Destination:");
|
||||
gotoDialog.setLabelText("Destination or URL:\n @user, #place, hifi://domain/location/orientation");
|
||||
QString destination = QString();
|
||||
|
||||
gotoDialog.setTextValue(destination);
|
||||
gotoDialog.setWindowFlags(Qt::Sheet);
|
||||
gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
|
||||
|
||||
int dialogReturn = gotoDialog.exec();
|
||||
if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
|
||||
goToUser(gotoDialog.textValue());
|
||||
QString desiredDestination = gotoDialog.textValue();
|
||||
|
||||
if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {
|
||||
QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
|
||||
|
||||
if (urlParts.count() > 1) {
|
||||
// if url has 2 or more parts, the first one is domain name
|
||||
QString domain = urlParts[0];
|
||||
|
||||
// second part is either a destination coordinate or
|
||||
// a place name
|
||||
QString destination = urlParts[1];
|
||||
|
||||
// any third part is an avatar orientation.
|
||||
QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
|
||||
|
||||
goToDomain(domain);
|
||||
|
||||
// goto either @user, #place, or x-xx,y-yy,z-zz
|
||||
// style co-ordinate.
|
||||
goTo(destination);
|
||||
|
||||
if (!orientation.isEmpty()) {
|
||||
// location orientation
|
||||
goToOrientation(orientation);
|
||||
}
|
||||
} else if (urlParts.count() == 1) {
|
||||
// location coordinates or place name
|
||||
QString destination = urlParts[0];
|
||||
goTo(destination);
|
||||
}
|
||||
|
||||
} else {
|
||||
goToUser(gotoDialog.textValue());
|
||||
}
|
||||
}
|
||||
sendFakeEnterEvent();
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
bool goToDestination(QString destination);
|
||||
void goToOrientation(QString orientation);
|
||||
void goToDomain(const QString newDomain);
|
||||
void goTo(QString destination);
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
Loading…
Reference in a new issue