mirror of
https://github.com/overte-org/overte.git
synced 2025-06-25 06:49:28 +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.right: parent.right
|
||||
font.pixelSize: hifi.fonts.pixelSize / 2
|
||||
text: root.text
|
||||
text: root.title
|
||||
wrapMode: Text.WrapAnywhere
|
||||
|
||||
/* Uncomment for debugging to see the extent of the
|
||||
|
@ -68,7 +68,7 @@ Hifi.Tooltip {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
font.pixelSize: hifi.fonts.pixelSize / 2
|
||||
text: root.text
|
||||
text: root.description
|
||||
wrapMode: Text.WrapAnywhere
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
|
||||
#include <QScriptEngine>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -128,9 +128,22 @@ ApplicationCompositor::ApplicationCompositor() {
|
|||
_hoverItemId = entityItemID;
|
||||
_hoverItemEnterUsecs = usecTimestampNow();
|
||||
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();
|
||||
if (!_hoverItemHref.isEmpty()) {
|
||||
|
||||
if (!href.isEmpty()) {
|
||||
cursor->setIcon(Cursor::Icon::LINK);
|
||||
} else {
|
||||
cursor->setIcon(Cursor::Icon::DEFAULT);
|
||||
|
@ -141,7 +154,10 @@ ApplicationCompositor::ApplicationCompositor() {
|
|||
connect(entityScriptingInterface.data(), &EntityScriptingInterface::hoverLeaveEntity, [=](const EntityItemID& entityItemID, const MouseEvent& event) {
|
||||
if (_hoverItemId == entityItemID) {
|
||||
_hoverItemId = _noItemId;
|
||||
_hoverItemHref.clear();
|
||||
|
||||
_hoverItemTitle.clear();
|
||||
_hoverItemDescription.clear();
|
||||
|
||||
auto cursor = Cursor::Manager::instance().getCursor();
|
||||
cursor->setIcon(Cursor::Icon::DEFAULT);
|
||||
if (!_tooltipId.isEmpty()) {
|
||||
|
@ -754,10 +770,10 @@ glm::vec2 ApplicationCompositor::overlayToScreen(const glm::vec2& overlayPos) co
|
|||
void ApplicationCompositor::updateTooltips() {
|
||||
if (_hoverItemId != _noItemId) {
|
||||
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
|
||||
_hoverItemEnterUsecs = UINT64_MAX;
|
||||
_tooltipId = Tooltip::showTip("URL: " + _hoverItemHref);
|
||||
_tooltipId = Tooltip::showTip(_hoverItemTitle, _hoverItemDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,9 +83,10 @@ private:
|
|||
|
||||
// Support for hovering and tooltips
|
||||
static EntityItemID _noItemId;
|
||||
EntityItemID _hoverItemId{ _noItemId };
|
||||
QString _hoverItemHref;
|
||||
quint64 _hoverItemEnterUsecs{ 0 };
|
||||
EntityItemID _hoverItemId { _noItemId };
|
||||
QString _hoverItemTitle;
|
||||
QString _hoverItemDescription;
|
||||
quint64 _hoverItemEnterUsecs { 0 };
|
||||
|
||||
float _hmdUIAngularSize = DEFAULT_HMD_UI_ANGULAR_SIZE;
|
||||
float _textureFov{ glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE) };
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include <QTextBlock>
|
||||
#include <QtGui>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <QByteArray>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
#ifndef hifi_ProgramObject_h
|
||||
#define hifi_ProgramObject_h
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
||||
#include <QGLShaderProgram>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ using glm::vec3;
|
|||
using glm::vec4;
|
||||
using glm::quat;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
@ -37,7 +37,7 @@ using glm::quat;
|
|||
#include <QtGui/QMatrix4x4>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,14 +18,25 @@ Tooltip::Tooltip(QQuickItem* parent) : QQuickItem(parent) {
|
|||
Tooltip::~Tooltip() {
|
||||
}
|
||||
|
||||
QString Tooltip::text() const {
|
||||
return _text;
|
||||
const QString& Tooltip::getTitle() const {
|
||||
return _title;
|
||||
}
|
||||
|
||||
void Tooltip::setText(const QString& arg) {
|
||||
if (arg != _text) {
|
||||
_text = arg;
|
||||
emit textChanged();
|
||||
const QString& Tooltip::getDescription() const {
|
||||
return _description;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
QString Tooltip::showTip(const QString& text) {
|
||||
QString Tooltip::showTip(const QString& title, const QString& description) {
|
||||
const QString newTipId = QUuid().createUuid().toString();
|
||||
|
||||
qDebug() << "THE NEW TIP ID IS" << newTipId;
|
||||
Tooltip::show([&](QQmlContext*, QObject* object) {
|
||||
object->setObjectName(newTipId);
|
||||
object->setProperty("text", text);
|
||||
object->setProperty("title", title);
|
||||
object->setProperty("description", description);
|
||||
});
|
||||
return newTipId;
|
||||
}
|
||||
|
|
|
@ -20,26 +20,31 @@ class Tooltip : public QQuickItem
|
|||
HIFI_QML_DECL
|
||||
|
||||
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:
|
||||
Tooltip(QQuickItem* parent = 0);
|
||||
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);
|
||||
|
||||
public slots:
|
||||
virtual void setVisible(bool v);
|
||||
void setText(const QString& arg);
|
||||
void setTitle(const QString& title);
|
||||
void setDescription(const QString& description);
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
void titleChanged();
|
||||
void descriptionChanged();
|
||||
|
||||
private:
|
||||
QString _text;
|
||||
QString _title;
|
||||
QString _description;
|
||||
};
|
||||
|
||||
#endif // hifi_Tooltip_h
|
||||
|
|
Loading…
Reference in a new issue