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

Add AboutDialogHandler #609

Merged
merged 7 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
85 changes: 85 additions & 0 deletions src/gui/AboutDialogHandler.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
chapulina marked this conversation as resolved.
Show resolved Hide resolved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "AboutDialogHandler.hh"

#include <ignition/common/Console.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/gui/Application.hh>

using namespace ignition;
using namespace gazebo;
using namespace gazebo::gui;

/////////////////////////////////////////////////
AboutDialogHandler::AboutDialogHandler()
{
aboutText += std::string(IGNITION_GAZEBO_VERSION_HEADER);
aboutText += "<table class='nostyle'>"
"<tr>"
"<td style='padding-right: 10px;'>Documentation:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/libs/gazebo' style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/libs/gazebo"
"</a>"
"</td>"
"</tr>"
"<tr>"
"<td style='padding-right: 10px;'>"
"Tutorials:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/docs/citadel/tutorials' style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/docs/"
"</a>"
"</td>"
"</tr>"
"<tr>"
"<td style='padding-right: 10px;'>"
"Ignition SDFormat:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/libs/sdformat' style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/libs/sdformat"
"</a>"
"</td>"
"</tr>"
"<tr>"
"<td style='padding-right: 10px;'>"
"Ignition Messages:"
"</td>"
"<td>"
"<a href='https://ignitionrobotics.org/libs/msgs' style='text-decoration: none; color: #f58113'>"
"https://ignitionrobotics.org/libs/msgs"
"</a>"
chapulina marked this conversation as resolved.
Show resolved Hide resolved
"</td>"
"</tr>"
"</table>";
}

/////////////////////////////////////////////////
QString AboutDialogHandler::getVersionInformation()
{
return QString::fromStdString(this->aboutText);
}

/////////////////////////////////////////////////
void AboutDialogHandler::openURL(QString _url)
{
QDesktopServices::openUrl(QUrl(_url));
}
58 changes: 58 additions & 0 deletions src/gui/AboutDialogHandler.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
chapulina marked this conversation as resolved.
Show resolved Hide resolved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_GAZEBO_GUI_ABOUTDIALOGHANDLER_HH_
#define IGNITION_GAZEBO_GUI_ABOUTDIALOGHANDLER_HH_

#include <QtCore>
#include <QDesktopServices>
#include <string>

#include "ignition/gazebo/EntityComponentManager.hh"
#include "ignition/gazebo/Export.hh"

namespace ignition
{
namespace gazebo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
namespace gui
{
/// \brief Class for handling about dialog
class IGNITION_GAZEBO_VISIBLE AboutDialogHandler : public QObject
{
Q_OBJECT

/// \brief Constructor
public: AboutDialogHandler();

/// \brief Get version information
/// \return Version information in rich text format
Q_INVOKABLE QString getVersionInformation();

/// \brief Function called from QML when user clicks on a link
/// \param[in] _url Url to web page.
Q_INVOKABLE void openURL(QString _url);

/// \brief Version information and links to online resources
private: std::string aboutText;
};
}
}
}
}
#endif
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set (gui_sources
Gui.cc
AboutDialogHandler.cc
chapulina marked this conversation as resolved.
Show resolved Hide resolved
GuiFileHandler.cc
GuiRunner.cc
PathManager.cc
Expand Down
5 changes: 5 additions & 0 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ignition/gazebo/gui/TmpIface.hh"

#include "ignition/gazebo/gui/Gui.hh"
#include "AboutDialogHandler.hh"
#include "GuiFileHandler.hh"
#include "PathManager.hh"

Expand Down Expand Up @@ -63,6 +64,9 @@ std::unique_ptr<ignition::gui::Application> createGui(
auto tmp = new ignition::gazebo::TmpIface();
tmp->setParent(app->Engine());

auto aboutDialogHandler = new ignition::gazebo::gui::AboutDialogHandler();
aboutDialogHandler->setParent(app->Engine());

auto guiFileHandler = new ignition::gazebo::gui::GuiFileHandler();
guiFileHandler->setParent(app->Engine());

Expand Down Expand Up @@ -102,6 +106,7 @@ std::unique_ptr<ignition::gui::Application> createGui(
// Let QML files use TmpIface' functions and properties
auto context = new QQmlContext(app->Engine()->rootContext());
context->setContextProperty("TmpIface", tmp);
context->setContextProperty("AboutDialogHandler", aboutDialogHandler);
context->setContextProperty("GuiFileHandler", guiFileHandler);

// Instantiate GazeboDrawer.qml file into a component
Expand Down
55 changes: 45 additions & 10 deletions src/gui/resources/GazeboDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Rectangle {
case "loadWorld":
loadWorldDialog.open();
break
case "aboutDialog":
aboutDialog.open();
break
// Forward others to default drawer
default:
parent.onAction(_action);
Expand All @@ -73,46 +76,50 @@ Rectangle {
// Custom action which calls custom C++ code
/*ListElement {
title: "New world"
action: "newWorld"
actionElement: "newWorld"
type: "world"
}
ListElement {
title: "Load world"
action: "loadWorld"
actionElement: "loadWorld"
type: "world"
}*/
ListElement {
title: "Save world"
action: "saveWorld"
actionElement: "saveWorld"
enabled: false
type: "world"
}
ListElement {
title: "Save world as..."
action: "saveWorldAs"
actionElement: "saveWorldAs"
type: "world"
}

// Actions provided by Ignition GUI, with custom titles
ListElement {
title: "Load client configuration"
action: "loadConfig"
actionElement: "loadConfig"
}
ListElement {
title: "Save client configuration"
action: "saveConfig"
actionElement: "saveConfig"
}
ListElement {
title: "Save client configuration as"
action: "saveConfigAs"
actionElement: "saveConfigAs"
}
ListElement {
title: "Style settings"
action: "styleSettings"
actionElement: "styleSettings"
}
ListElement {
title: "About"
actionElement: "aboutDialog"
}
ListElement {
title: "Quit"
action: "close"
actionElement: "close"
}
}

Expand All @@ -125,7 +132,7 @@ Rectangle {
text: title
highlighted: ListView.isCurrentItem
onClicked: {
customDrawer.onAction(action);
customDrawer.onAction(actionElement);
customDrawer.parent.closeDrawer();
}
}
Expand Down Expand Up @@ -165,6 +172,34 @@ Rectangle {
}
}

/**
* About dialog
*/
Dialog {
id: aboutDialog
title: "Ignition Gazebo"

modal: true
focus: true
parent: ApplicationWindow.overlay
width: parent.width / 4
chapulina marked this conversation as resolved.
Show resolved Hide resolved
x: (parent.width - width) / 2
y: (parent.height - height) / 2
closePolicy: Popup.CloseOnEscape
standardButtons: StandardButton.Ok

Text {
anchors.fill: parent
id: aboutMessage
wrapMode: Text.Wrap
verticalAlignment: Text.AlignVCenter
color: Material.theme == Material.Light ? "black" : "white"
textFormat: Text.RichText
text: AboutDialogHandler.getVersionInformation()
onLinkActivated: AboutDialogHandler.openURL(link)
chapulina marked this conversation as resolved.
Show resolved Hide resolved
}
}

/**
* Dialog with configurations for SDF generation
*/
Expand Down