mirror of
https://github.com/overte-org/overte.git
synced 2025-06-26 13:09:33 +02:00
fix some OS X warnings, add description to tooltip
This commit is contained in:
parent
1a523297ba
commit
c6df573933
10 changed files with 113 additions and 77 deletions
|
@ -42,7 +42,7 @@ Hifi.Tooltip {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
font.pixelSize: hifi.fonts.pixelSize / 2
|
font.pixelSize: hifi.fonts.pixelSize / 2
|
||||||
text: root.text
|
text: root.title
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
|
|
||||||
/* Uncomment for debugging to see the extent of the
|
/* Uncomment for debugging to see the extent of the
|
||||||
|
@ -68,7 +68,7 @@ Hifi.Tooltip {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
font.pixelSize: hifi.fonts.pixelSize / 2
|
font.pixelSize: hifi.fonts.pixelSize / 2
|
||||||
text: root.text
|
text: root.description
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
|
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,22 @@ ApplicationCompositor::ApplicationCompositor() {
|
||||||
_hoverItemId = entityItemID;
|
_hoverItemId = entityItemID;
|
||||||
_hoverItemEnterUsecs = usecTimestampNow();
|
_hoverItemEnterUsecs = usecTimestampNow();
|
||||||
auto properties = entityScriptingInterface->getEntityProperties(_hoverItemId);
|
auto properties = entityScriptingInterface->getEntityProperties(_hoverItemId);
|
||||||
_hoverItemHref = properties.getHref();
|
|
||||||
|
// check the format of this href string before we parse it
|
||||||
|
QString hrefString = properties.getHref();
|
||||||
|
if (!hrefString.startsWith("hifi:")) {
|
||||||
|
hrefString.prepend("hifi://");
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse out a QUrl from the hrefString
|
||||||
|
QUrl href = QUrl(hrefString);
|
||||||
|
|
||||||
|
_hoverItemTitle = href.host();
|
||||||
|
_hoverItemDescription = properties.getDescription();
|
||||||
|
|
||||||
auto cursor = Cursor::Manager::instance().getCursor();
|
auto cursor = Cursor::Manager::instance().getCursor();
|
||||||
if (!_hoverItemHref.isEmpty()) {
|
|
||||||
|
if (!href.isEmpty()) {
|
||||||
cursor->setIcon(Cursor::Icon::LINK);
|
cursor->setIcon(Cursor::Icon::LINK);
|
||||||
} else {
|
} else {
|
||||||
cursor->setIcon(Cursor::Icon::DEFAULT);
|
cursor->setIcon(Cursor::Icon::DEFAULT);
|
||||||
|
@ -141,7 +154,10 @@ ApplicationCompositor::ApplicationCompositor() {
|
||||||
connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, [=](const EntityItemID& entityItemID, const MouseEvent& event) {
|
connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, [=](const EntityItemID& entityItemID, const MouseEvent& event) {
|
||||||
if (_hoverItemId == entityItemID) {
|
if (_hoverItemId == entityItemID) {
|
||||||
_hoverItemId = _noItemId;
|
_hoverItemId = _noItemId;
|
||||||
_hoverItemHref.clear();
|
|
||||||
|
_hoverItemTitle.clear();
|
||||||
|
_hoverItemDescription.clear();
|
||||||
|
|
||||||
auto cursor = Cursor::Manager::instance().getCursor();
|
auto cursor = Cursor::Manager::instance().getCursor();
|
||||||
cursor->setIcon(Cursor::Icon::DEFAULT);
|
cursor->setIcon(Cursor::Icon::DEFAULT);
|
||||||
if (!_tooltipId.isEmpty()) {
|
if (!_tooltipId.isEmpty()) {
|
||||||
|
@ -754,10 +770,10 @@ glm::vec2 ApplicationCompositor::overlayToScreen(const glm::vec2& overlayPos) co
|
||||||
void ApplicationCompositor::updateTooltips() {
|
void ApplicationCompositor::updateTooltips() {
|
||||||
if (_hoverItemId != _noItemId) {
|
if (_hoverItemId != _noItemId) {
|
||||||
quint64 hoverDuration = usecTimestampNow() - _hoverItemEnterUsecs;
|
quint64 hoverDuration = usecTimestampNow() - _hoverItemEnterUsecs;
|
||||||
if (_hoverItemEnterUsecs != UINT64_MAX && !_hoverItemHref.isEmpty() && hoverDuration > TOOLTIP_DELAY) {
|
if (_hoverItemEnterUsecs != UINT64_MAX && !_hoverItemTitle.isEmpty() && hoverDuration > TOOLTIP_DELAY) {
|
||||||
// TODO Enable and position the tooltip
|
// TODO Enable and position the tooltip
|
||||||
_hoverItemEnterUsecs = UINT64_MAX;
|
_hoverItemEnterUsecs = UINT64_MAX;
|
||||||
_tooltipId = Tooltip::showTip("URL: " + _hoverItemHref);
|
_tooltipId = Tooltip::showTip(_hoverItemTitle, _hoverItemDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,10 @@ private:
|
||||||
|
|
||||||
// Support for hovering and tooltips
|
// Support for hovering and tooltips
|
||||||
static EntityItemID _noItemId;
|
static EntityItemID _noItemId;
|
||||||
EntityItemID _hoverItemId{ _noItemId };
|
EntityItemID _hoverItemId { _noItemId };
|
||||||
QString _hoverItemHref;
|
QString _hoverItemTitle;
|
||||||
quint64 _hoverItemEnterUsecs{ 0 };
|
QString _hoverItemDescription;
|
||||||
|
quint64 _hoverItemEnterUsecs { 0 };
|
||||||
|
|
||||||
float _hmdUIAngularSize = DEFAULT_HMD_UI_ANGULAR_SIZE;
|
float _hmdUIAngularSize = DEFAULT_HMD_UI_ANGULAR_SIZE;
|
||||||
float _textureFov{ glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE) };
|
float _textureFov{ glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE) };
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
#ifndef hifi_ProgramObject_h
|
#ifndef hifi_ProgramObject_h
|
||||||
#define hifi_ProgramObject_h
|
#define hifi_ProgramObject_h
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QGLShaderProgram>
|
#include <QGLShaderProgram>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ using glm::vec3;
|
||||||
using glm::vec4;
|
using glm::vec4;
|
||||||
using glm::quat;
|
using glm::quat;
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ using glm::quat;
|
||||||
#include <QtGui/QMatrix4x4>
|
#include <QtGui/QMatrix4x4>
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,25 @@ Tooltip::Tooltip(QQuickItem* parent) : QQuickItem(parent) {
|
||||||
Tooltip::~Tooltip() {
|
Tooltip::~Tooltip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Tooltip::text() const {
|
const QString& Tooltip::getTitle() const {
|
||||||
return _text;
|
return _title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tooltip::setText(const QString& arg) {
|
const QString& Tooltip::getDescription() const {
|
||||||
if (arg != _text) {
|
return _description;
|
||||||
_text = arg;
|
}
|
||||||
emit textChanged();
|
|
||||||
|
void Tooltip::setTitle(const QString& title) {
|
||||||
|
if (title != _title) {
|
||||||
|
_title = title;
|
||||||
|
emit titleChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tooltip::setDescription(const QString& description) {
|
||||||
|
if (description != _description) {
|
||||||
|
_description = description;
|
||||||
|
emit descriptionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +44,14 @@ void Tooltip::setVisible(bool visible) {
|
||||||
QQuickItem::setVisible(visible);
|
QQuickItem::setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Tooltip::showTip(const QString& text) {
|
QString Tooltip::showTip(const QString& title, const QString& description) {
|
||||||
const QString newTipId = QUuid().createUuid().toString();
|
const QString newTipId = QUuid().createUuid().toString();
|
||||||
|
|
||||||
|
qDebug() << "THE NEW TIP ID IS" << newTipId;
|
||||||
Tooltip::show([&](QQmlContext*, QObject* object) {
|
Tooltip::show([&](QQmlContext*, QObject* object) {
|
||||||
object->setObjectName(newTipId);
|
object->setObjectName(newTipId);
|
||||||
object->setProperty("text", text);
|
object->setProperty("title", title);
|
||||||
|
object->setProperty("description", description);
|
||||||
});
|
});
|
||||||
return newTipId;
|
return newTipId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,26 +20,31 @@ class Tooltip : public QQuickItem
|
||||||
HIFI_QML_DECL
|
HIFI_QML_DECL
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
Q_PROPERTY(QString title READ getTitle WRITE setTitle NOTIFY titleChanged)
|
||||||
|
Q_PROPERTY(QString description READ getDescription WRITE setDescription NOTIFY descriptionChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tooltip(QQuickItem* parent = 0);
|
Tooltip(QQuickItem* parent = 0);
|
||||||
virtual ~Tooltip();
|
virtual ~Tooltip();
|
||||||
|
|
||||||
QString text() const;
|
const QString& getTitle() const;
|
||||||
|
const QString& getDescription() const;
|
||||||
|
|
||||||
static QString showTip(const QString& text);
|
static QString showTip(const QString& title, const QString& description);
|
||||||
static void closeTip(const QString& tipId);
|
static void closeTip(const QString& tipId);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setVisible(bool v);
|
virtual void setVisible(bool v);
|
||||||
void setText(const QString& arg);
|
void setTitle(const QString& title);
|
||||||
|
void setDescription(const QString& description);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged();
|
void titleChanged();
|
||||||
|
void descriptionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _text;
|
QString _title;
|
||||||
|
QString _description;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Tooltip_h
|
#endif // hifi_Tooltip_h
|
||||||
|
|
Loading…
Reference in a new issue