Skip to content

Commit

Permalink
port: 8 to main (#593)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Nov 8, 2023
2 parents a583fa6 + 838f6bc commit db72287
Show file tree
Hide file tree
Showing 95 changed files with 1,097 additions and 1,195 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ gz_find_package (Qt5
PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets"
)

set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR
${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins
)

set(GZ_GUI_PLUGIN_INSTALL_DIR
${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins
${CMAKE_INSTALL_PREFIX}/${GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR}
)

#============================================================================
Expand Down
9 changes: 3 additions & 6 deletions examples/plugin/custom_context_menu/CustomContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

#include "CustomContext.hh"

using namespace gz;
using namespace gui;

/////////////////////////////////////////////////
CustomContext::CustomContext()
: Plugin()
: gz::gui::Plugin()
{
}

Expand All @@ -35,5 +32,5 @@ CustomContext::~CustomContext()
}

// Register this plugin
GZ_ADD_PLUGIN(gz::gui::CustomContext,
gz::gui::Plugin);
GZ_ADD_PLUGIN(CustomContext,
gz::gui::Plugin);
22 changes: 8 additions & 14 deletions examples/plugin/custom_context_menu/CustomContext.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,15 @@
#include <gz/gui/Plugin.hh>
#endif

namespace gz
class CustomContext : public gz::gui::Plugin
{
namespace gui
{
class CustomContext : public Plugin
{
Q_OBJECT
Q_OBJECT

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

/// \brief Destructor
public: virtual ~CustomContext();
};
}
}
/// \brief Destructor
public: virtual ~CustomContext();
};

#endif
#endif // GZ_GUI_CUSTOMCONTEXTPLUGIN_HH_
9 changes: 3 additions & 6 deletions examples/plugin/dialog_from_plugin/DialogFromPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

#include "DialogFromPlugin.hh"

using namespace gz;
using namespace gui;

/////////////////////////////////////////////////
DialogFromPlugin::DialogFromPlugin()
: Plugin()
: gz::gui::Plugin()
{
}

Expand All @@ -35,5 +32,5 @@ DialogFromPlugin::~DialogFromPlugin()
}

// Register this plugin
GZ_ADD_PLUGIN(gz::gui::DialogFromPlugin,
gz::gui::Plugin);
GZ_ADD_PLUGIN(DialogFromPlugin,
gz::gui::Plugin);
22 changes: 8 additions & 14 deletions examples/plugin/dialog_from_plugin/DialogFromPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,15 @@
#include <gz/gui/Plugin.hh>
#endif

namespace gz
class DialogFromPlugin : public gz::gui::Plugin
{
namespace gui
{
class DialogFromPlugin : public Plugin
{
Q_OBJECT
Q_OBJECT

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

/// \brief Destructor
public: virtual ~DialogFromPlugin();
};
}
}
/// \brief Destructor
public: virtual ~DialogFromPlugin();
};

#endif
#endif // GZ_GUI_DIALOGFROMPLUGIN_HH_
2 changes: 1 addition & 1 deletion examples/plugin/gz_components/GzComponents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
#include "GzComponents.hh"

// Register this plugin
GZ_ADD_PLUGIN(gz::gui::GzComponents,
GZ_ADD_PLUGIN(GzComponents,
gz::gui::Plugin);
18 changes: 6 additions & 12 deletions examples/plugin/gz_components/GzComponents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@

#include <gz/gui/Plugin.hh>

namespace gz
class GzComponents : public gz::gui::Plugin
{
namespace gui
{
class GzComponents : public Plugin
{
Q_OBJECT
Q_OBJECT

/// \brief Constructor
public: GzComponents() = default;
};
}
}
/// \brief Constructor
public: GzComponents() = default;
};

#endif
#endif // GZ_GUI_EXAMPLES_PLUGIN_GZCOMPONENTS_HH_
9 changes: 3 additions & 6 deletions examples/plugin/hello_plugin/HelloPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

#include "HelloPlugin.hh"

using namespace gz;
using namespace gui;

/////////////////////////////////////////////////
HelloPlugin::HelloPlugin()
: Plugin()
: gz::gui::Plugin()
{
}

Expand Down Expand Up @@ -53,5 +50,5 @@ void HelloPlugin::OnButton()
}

// Register this plugin
GZ_ADD_PLUGIN(gz::gui::HelloPlugin,
gz::gui::Plugin);
GZ_ADD_PLUGIN(HelloPlugin,
gz::gui::Plugin);
38 changes: 16 additions & 22 deletions examples/plugin/hello_plugin/HelloPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,26 @@
#include <gz/gui/qt.h>
#include <gz/gui/Plugin.hh>

namespace gz
class HelloPlugin : public gz::gui::Plugin
{
namespace gui
{
class HelloPlugin : public Plugin
{
Q_OBJECT
Q_OBJECT

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

/// \brief Destructor
public: virtual ~HelloPlugin();
/// \brief Destructor
public: virtual ~HelloPlugin();

/// \brief Called by Gazebo GUI when plugin is instantiated.
/// \param[in] _pluginElem XML configuration for this plugin.
public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem)
override;
/// \brief Called by Gazebo GUI when plugin is instantiated.
/// \param[in] _pluginElem XML configuration for this plugin.
public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem)
override;

/// \brief Callback trigged when the button is pressed.
protected slots: void OnButton();
/// \brief Callback trigged when the button is pressed.
protected slots: void OnButton();

/// \brief Message to be printed when button is pressed.
private: std::string message{"Hello, plugin!"};
};
}
}
/// \brief Message to be printed when button is pressed.
private: std::string message{"Hello, plugin!"};
};

#endif
#endif // GZ_GUI_HELLOPLUGIN_HH_
9 changes: 3 additions & 6 deletions examples/plugin/multiple_qml/MultipleQml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

#include "MultipleQml.hh"

using namespace gz;
using namespace gui;

/////////////////////////////////////////////////
MultipleQml::MultipleQml()
: Plugin()
: gz::gui::Plugin()
{
}

Expand All @@ -41,5 +38,5 @@ void MultipleQml::OnButton(const QString &_text)
}

// Register this plugin
GZ_ADD_PLUGIN(gz::gui::MultipleQml,
gz::gui::Plugin);
GZ_ADD_PLUGIN(MultipleQml,
gz::gui::Plugin);
28 changes: 11 additions & 17 deletions examples/plugin/multiple_qml/MultipleQml.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,19 @@
#include <gz/gui/Plugin.hh>
#endif

namespace gz
class MultipleQml : public gz::gui::Plugin
{
namespace gui
{
class MultipleQml : public Plugin
{
Q_OBJECT
Q_OBJECT

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

/// \brief Destructor
public: virtual ~MultipleQml();
/// \brief Destructor
public: virtual ~MultipleQml();

/// \brief Callback trigged when the button is pressed.
/// \param[in] _text Button text.
protected slots: void OnButton(const QString &_text);
};
}
}
/// \brief Callback trigged when the button is pressed.
/// \param[in] _text Button text.
protected slots: void OnButton(const QString &_text);
};

#endif
#endif // GZ_GUI_EXAMPLES_PLUGINS_MULTIPLEQML_HH_
3 changes: 1 addition & 2 deletions examples/standalone/custom_drawer/custom_drawer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int _argc, char **_argv)
app.LoadConfig("../custom_drawer.config");

// Let QML files use CustomActions' functions and properties
gz::gui::CustomActions actions;
CustomActions actions;
auto context = new QQmlContext(app.Engine()->rootContext());
context->setContextProperty("CustomActions", &actions);

Expand Down Expand Up @@ -65,4 +65,3 @@ int main(int _argc, char **_argv)

return 0;
}

31 changes: 12 additions & 19 deletions examples/standalone/custom_drawer/custom_drawer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,18 @@
#include <gz/gui/qt.h>
#endif

namespace gz
/// \brief Object holding actions which can be triggered from the custom
/// drawer.
class CustomActions : public QObject
{
namespace gui
{
/// \brief Object holding actions which can be triggered from the custom
/// drawer.
class CustomActions : public QObject
{
Q_OBJECT

/// \brief Demonstrates a C++ function which can be called from the
/// drawer's QML code.
public: Q_INVOKABLE void cppActionFromQml() const
{
std::cout << "C++ action called from QML" << std::endl;
}
};
}
}
Q_OBJECT

#endif
/// \brief Demonstrates a C++ function which can be called from the
/// drawer's QML code.
public: Q_INVOKABLE void cppActionFromQml() const
{
std::cout << "C++ action called from QML" << std::endl;
}
};

#endif //GZ_GUI_EXAMPLES_STANDALONE_CUSTOMDRAWER_HH_
9 changes: 3 additions & 6 deletions include/gz/gui/Application.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ namespace tinyxml2
class XMLElement;
}

namespace gz
namespace gz::gui
{
namespace gui
{
class ApplicationPrivate;
class Dialog;
class MainWindow;
Expand Down Expand Up @@ -217,11 +215,10 @@ namespace gz
/// \return Pointer to running application, or nullptr if none is running.
GZ_GUI_VISIBLE
Application *App();
}
}
} // namespace gz::gui

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
#endif // GZ_GUI_APPLICATION_HH_
9 changes: 9 additions & 0 deletions include/gz/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ gz_create_core_library(SOURCES
${headers_MOC}
${resources_RCC}
)
gz_add_get_install_prefix_impl(GET_INSTALL_PREFIX_FUNCTION gz::gui::getInstallPrefix
GET_INSTALL_PREFIX_HEADER gz/gui/InstallationDirectories.hh
OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE GZ_GUI_INSTALL_PREFIX)

set_property(
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/InstallationDirectories.cc
PROPERTY COMPILE_DEFINITIONS
GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR="${GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR}"
)

target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PUBLIC
Expand Down
Loading

0 comments on commit db72287

Please sign in to comment.