Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix miscellaneous issues and warnings #652

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/plugins/image_display/ImageDisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,33 @@ class ImageDisplay::Implementation

/// \brief To provide images for QML.
public: ImageProvider *provider{nullptr};

/// \brief Holds the provider name unique to this plugin instance
public: QString providerName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <Qstring> and <QStringList>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in ImageDisplay.hh since they are needed there as well.

};

/////////////////////////////////////////////////
ImageDisplay::ImageDisplay()
: dataPtr(gz::utils::MakeUniqueImpl<Implementation>())
{
this->dataPtr->provider = new ImageProvider();
}

/////////////////////////////////////////////////
ImageDisplay::~ImageDisplay()
{
App()->Engine()->removeImageProvider(
this->CardItem()->objectName() + "imagedisplay");
App()->Engine()->removeImageProvider(this->ImageProviderName());
}

void ImageDisplay::RegisterImageProvider(const QString &_uniqueName)
{
this->dataPtr->providerName = _uniqueName;
App()->Engine()->addImageProvider(_uniqueName,
this->dataPtr->provider);
}

QString ImageDisplay::ImageProviderName() {
return this->dataPtr->providerName;
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -95,13 +109,11 @@ void ImageDisplay::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
this->PluginItem()->setProperty("showPicker", topicPicker);

if (!topic.empty())
this->OnTopic(QString::fromStdString(topic));
{
this->SetTopicList({QString::fromStdString(topic)});
}
else
this->OnRefresh();

this->dataPtr->provider = new ImageProvider();
App()->Engine()->addImageProvider(
this->CardItem()->objectName() + "imagedisplay", this->dataPtr->provider);
}

/////////////////////////////////////////////////
Expand Down
15 changes: 11 additions & 4 deletions src/plugins/image_display/ImageDisplay.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#ifndef GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_
#define GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_

#include <algorithm>
#include <memory>
#include <QImage>
#include <QString>
#include <QStringList>
#include <QQuickImageProvider>

#include <gz/msgs/image.pb.h>
Expand Down Expand Up @@ -53,8 +54,7 @@ namespace gz::gui::plugins
if (!this->img.isNull())
{
// Must return a copy
QImage copy(this->img);
return copy;
return this->img;
}

// Placeholder in case we have no image yet
Expand Down Expand Up @@ -115,6 +115,13 @@ namespace gz::gui::plugins
/// \param[in] _topicList Message type
public: Q_INVOKABLE void SetTopicList(const QStringList &_topicList);

/// \brief Register the image provider with the given name
/// \param[in] _uniqueName Unique name for the provider to be registered
public: Q_INVOKABLE void RegisterImageProvider(const QString &_uniqueName);

/// \brief Get the provider name unique to this plugin instance
public: Q_INVOKABLE QString ImageProviderName();

/// \brief Notify that topic list has changed
signals: void TopicListChanged();

Expand Down
1 change: 1 addition & 0 deletions src/plugins/image_display/ImageDisplay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Rectangle {
return;

uniqueName = parent.card().objectName + "imagedisplay";
ImageDisplay.RegisterImageProvider(uniqueName);
image.reload();
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/world_stats/WorldStats.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Rectangle {
}
PropertyChanges {
target: hideButton
x: worldStats.width - hideToolButton.width - compactLabel.width - 10
x: worldStats.width - hideToolButton.width - compactLabel.implicitWidth - 10
}
PropertyChanges {
target: compactLabel
Expand Down