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

Tidy namespaces #590

Merged
merged 10 commits into from
Nov 2, 2023
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
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 @@ -214,11 +212,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_
17 changes: 7 additions & 10 deletions include/gz/gui/Conversions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
#include "gz/gui/qt.h"
#include "gz/gui/Export.hh"

namespace gz
namespace gz::common
{
namespace common
{
class MouseEvent;
}
class MouseEvent;
}

namespace gui
{
namespace gz::gui
{
/// \brief Return the equivalent Qt color
/// \param[in] _color Gazebo color to convert
/// \return Qt color value
Expand Down Expand Up @@ -95,6 +93,5 @@ namespace gz
/// \return Gazebo key event
GZ_GUI_VISIBLE
common::KeyEvent convert(const QKeyEvent &_e);
}
}
#endif
} // namespace gz::gui
#endif // GZ_GUI_CONVERSIONS_HH_
9 changes: 3 additions & 6 deletions include/gz/gui/Dialog.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
#pragma warning(disable: 4251)
#endif

namespace gz
namespace gz::gui
{
namespace gui
{
class DialogPrivate;

/// \brief Gui plugin
Expand Down Expand Up @@ -94,11 +92,10 @@ namespace gz
/// \brief Private data pointer
private: std::unique_ptr<DialogPrivate> dataPtr;
};
}
}
} // namespace gz::gui

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif
#endif // GZ_GUI_DIALOG_HH_
Loading