Skip to content

Commit 399aa2a

Browse files
committed
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
1 parent eb73681 commit 399aa2a

16 files changed

+76
-165
lines changed

examples/config/scene3d.config

-43
Original file line numberDiff line numberDiff line change
@@ -72,46 +72,3 @@
7272
<property key="showTitleBar" type="bool">false</property>
7373
</gz-gui>
7474
</plugin>
75-
<plugin filename="WorldControl">
76-
<gz-gui>
77-
<title>Controls</title>
78-
<property type="bool" key="showTitleBar">false</property>
79-
<property type="bool" key="resizable">false</property>
80-
<property type="double" key="height">72</property>
81-
<property type="double" key="width">121</property>
82-
<property type="double" key="z">1</property>
83-
84-
<property type="string" key="state">floating</property>
85-
<anchors target="View 1">
86-
<line own="left" target="left"/>
87-
<line own="bottom" target="bottom"/>
88-
</anchors>
89-
</gz-gui>
90-
<play_pause>true</play_pause>
91-
<step>true</step>
92-
<start_paused>false</start_paused>
93-
<service>/world_control</service>
94-
<stats_topic>/world_stats</stats_topic>
95-
</plugin>
96-
97-
<plugin filename="WorldStats">
98-
<gz-gui>
99-
<title>Stats</title>
100-
<property type="bool" key="showTitleBar">false</property>
101-
<property type="bool" key="resizable">false</property>
102-
<property type="double" key="height">110</property>
103-
<property type="double" key="width">290</property>
104-
<property type="double" key="z">1</property>
105-
106-
<property type="string" key="state">floating</property>
107-
<anchors target="View 1">
108-
<line own="right" target="right"/>
109-
<line own="bottom" target="bottom"/>
110-
</anchors>
111-
</gz-gui>
112-
<sim_time>true</sim_time>
113-
<real_time>true</real_time>
114-
<real_time_factor>true</real_time_factor>
115-
<iterations>true</iterations>
116-
<topic>/world_stats</topic>
117-
</plugin>

include/gz/gui/qml/GzCard.qml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*
1616
*/
1717
import QtQuick 2.9
18-
import QtQuick.Controls 1.4 as QQC1
1918
import QtQuick.Controls 2.2
2019
import QtQuick.Controls.Material 2.1
2120
import QtQuick.Layouts 1.3

include/gz/gui/qml/GzCardSettings.qml

+12-11
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import QtQuick 2.9
18-
import QtQuick.Controls 2.2
19-
import QtQuick.Layouts 1.3
20-
import QtQuick.Window 2.2
21-
import QtQuick.Dialogs 1.0
17+
import QtQuick
18+
import QtQuick.Controls
19+
import QtQuick.Layouts
20+
import QtQuick.Window
21+
import QtQuick.Dialogs
2222
import "qrc:/qml"
2323

2424
Dialog {
@@ -135,7 +135,7 @@ Dialog {
135135

136136
GzSpinBox {
137137
visible: !cardPane.anchored
138-
maximumValue: cardPane.parent ? cardPane.parent.width - cardPane.width : minSize
138+
to: cardPane.parent ? cardPane.parent.width - cardPane.width : from
139139
onVisibleChanged: value = cardPane.x
140140
onValueChanged: {
141141
cardPane.x = value;
@@ -147,7 +147,7 @@ Dialog {
147147
}
148148
GzSpinBox {
149149
visible: !cardPane.anchored
150-
maximumValue: cardPane.parent ? cardPane.parent.height - cardPane.height : minSize
150+
to: cardPane.parent ? cardPane.parent.height - cardPane.height : from
151151
onVisibleChanged: value = cardPane.y
152152
onValueChanged: {
153153
cardPane.y = value;
@@ -159,7 +159,7 @@ Dialog {
159159
}
160160
GzSpinBox {
161161
visible: !cardPane.anchored
162-
maximumValue: 10000
162+
to: 10000
163163
onVisibleChanged: value = cardPane.z
164164
onValueChanged: {
165165
cardPane.z = value;
@@ -177,7 +177,7 @@ Dialog {
177177
text: ""
178178
}
179179
GzSpinBox {
180-
maximumValue: cardPane.parent ? cardPane.parent.width : minSize
180+
to: cardPane.parent ? cardPane.parent.width : from
181181
onVisibleChanged: {
182182
if (cardPane)
183183
value = cardPane.width
@@ -190,7 +190,8 @@ Dialog {
190190
text: "Width"
191191
}
192192
GzSpinBox {
193-
maximumValue: cardPane.parent ? cardPane.parent.height : minSize
193+
to: cardPane.parent ? cardPane.parent.height : from
194+
194195
onVisibleChanged: {
195196
if (cardPane)
196197
value = cardPane.height
@@ -208,7 +209,7 @@ Dialog {
208209
ColorDialog {
209210
id: colorDialog
210211
title: "Please choose a color"
211-
showAlphaChannel : true
212+
options: [ColorDialog.ShowAlphaChannel]
212213
onAccepted: {
213214
content.color = colorDialog.color
214215
bgColor.color = colorDialog.color

include/gz/gui/qml/GzSnackBar.qml

+1-8
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
*
1616
*/
1717

18-
import QtGraphicalEffects 1.0
1918
import QtQuick 2.9
2019
import QtQuick.Controls 2.2
2120
import QtQuick.Controls.Material 2.2
22-
import QtQuick.Dialogs 1.0
21+
import QtQuick.Dialogs
2322
import QtQuick.Layouts 1.3
2423
import QtQuick.Window 2.2
2524

@@ -70,12 +69,6 @@ Popup {
7069
background: Rectangle {
7170
color: Material.background
7271
layer.enabled: true
73-
layer.effect: DropShadow {
74-
color: "#aa000000"
75-
samples: 9
76-
spread: 0
77-
radius: 8.0
78-
}
7972
}
8073

8174
// this function is called when notify() or notifyWithDuration() are called

include/gz/gui/qml/GzSpinBox.qml

+6-9
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import QtQuick 2.9
18-
import QtQuick.Controls 1.4
19-
import QtQuick.Controls.Styles 1.4
17+
import QtQuick
18+
import QtQuick.Controls
2019

2120
SpinBox {
22-
style: SpinBoxStyle{
23-
background: Rectangle {
24-
implicitWidth: 70
25-
implicitHeight: 40
26-
border.color: "gray"
27-
}
21+
background: Rectangle {
22+
implicitWidth: 70
23+
implicitHeight: 40
24+
border.color: "gray"
2825
}
2926
}

include/gz/gui/qml/GzSplit.qml

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*
1616
*/
1717
import QtQuick 2.9
18-
import QtQuick.Controls 1.1
19-
import QtQuick.Controls 2.2
18+
import QtQuick.Controls
2019
import QtQuick.Controls.Material 2.1
2120
import QtQuick.Layouts 1.3
2221

@@ -382,4 +381,3 @@ SplitView {
382381
}
383382
}
384383
}
385-

include/gz/gui/qml/Main.qml

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import QtQuick 2.9
1818
import QtQuick.Controls 2.2
1919
import QtQuick.Controls.Material 2.1
20-
import QtQuick.Dialogs 1.0
20+
import QtQuick.Dialogs
2121
import QtQuick.Layouts 1.3
2222
import ExitAction 1.0
2323
import "qrc:/qml"
@@ -295,10 +295,7 @@ ApplicationWindow
295295
FileDialog {
296296
id: loadFileDialog
297297
title: "Load configuration"
298-
folder: shortcuts.home
299298
nameFilters: [ "Config files (*.config)" ]
300-
selectMultiple: false
301-
selectExisting: true
302299
onAccepted: {
303300
MainWindow.OnLoadConfig(fileUrl)
304301
}
@@ -310,10 +307,7 @@ ApplicationWindow
310307
FileDialog {
311308
id: saveFileDialog
312309
title: "Save configuration"
313-
folder: shortcuts.home
314310
nameFilters: [ "Config files (*.config)" ]
315-
selectMultiple: false
316-
selectExisting: false
317311
onAccepted: {
318312
var selected = fileUrl.toString();
319313

include/gz/gui/qml/StyleDialog.qml

+1-22
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import QtQuick 2.9
1818
import QtQuick.Controls 2.2
1919
import QtQuick.Controls.Material 2.1
20-
import QtQuick.Dialogs 1.0
20+
import QtQuick.Dialogs
2121

2222
/**
2323
* Style dialog
@@ -309,9 +309,6 @@ Dialog {
309309
text: modelData
310310
width: parent.width
311311
}
312-
onCurrentTextChanged: {
313-
updateTheme();
314-
}
315312
}
316313

317314
Label {
@@ -322,15 +319,6 @@ Dialog {
322319
id: materialPrimaryDialog
323320
title: "Primary color"
324321
// options: ColorDialog.NoButtons
325-
onCurrentColorChanged: {
326-
327-
// Avoiding pure black because for some reason it is set to that as the
328-
// dialog opens
329-
if (currentColor == "#000000")
330-
return;
331-
332-
updatePrimary(colorToHex(currentColor))
333-
}
334322
}
335323

336324
Row {
@@ -368,15 +356,6 @@ Dialog {
368356
id: materialAccentDialog
369357
title: "Accent color"
370358
// options: ColorDialog.NoButtons
371-
onCurrentColorChanged: {
372-
373-
// Avoiding pure black because for some reason it is set to that as the
374-
// dialog opens
375-
if (currentColor == "#000000")
376-
return;
377-
378-
updateAccent(colorToHex(currentColor))
379-
}
380359
}
381360

382361
Row {

src/Application.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type,
108108
#ifdef __APPLE__
109109
AvailableAPIs api = AvailableAPIs::Metal;
110110
#else
111-
AvailableAPIs api = AvailableAPIs::OpenGL;
111+
AvailableAPIs api = AvailableAPIs::Vulkan;
112112
#endif
113113
if (_renderEngineGuiApiBackend)
114114
{
@@ -147,8 +147,6 @@ Application::Application(int &_argc, char **_argv, const WindowType _type,
147147

148148
if (api == AvailableAPIs::Vulkan)
149149
{
150-
gzdbg << "Qt using Vulkan graphics interface" << std::endl;
151-
152150
# ifdef GZ_USE_VULKAN_DEBUG_EXT
153151
qputenv("QT_VULKAN_INSTANCE_EXTENSIONS",
154152
"VK_EXT_debug_report;VK_EXT_debug_utils");
@@ -161,9 +159,8 @@ Application::Application(int &_argc, char **_argv, const WindowType _type,
161159
# endif
162160
);
163161

164-
# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan)
165162
QQuickWindow::setGraphicsApi(QSGRendererInterface::VulkanRhi);
166-
# endif
163+
gzdbg << "Qt using Vulkan graphics interface" << std::endl;
167164
}
168165
else
169166
{

src/Plugin.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,15 @@ QQuickItem *Plugin::CardItem() const
421421
return this->dataPtr->cardItem;
422422

423423
// Instantiate a card
424-
std::string qmlFile(":qml/GzCard.qml");
424+
std::string qmlFile(":/qml/GzCard.qml");
425425
QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile));
426426
auto *cardItem = qobject_cast<QQuickItem *>(cardComp.create());
427+
428+
if (cardComp.isError())
429+
{
430+
qWarning() << cardComp.errors();
431+
}
432+
427433
if (!cardItem)
428434
{
429435
gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile

src/cmd/gui_main.cc

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <gz/common/Console.hh>
1919

2020
#include <gz/gui/Application.hh>
21+
#include <gz/gui/MainWindow.hh>
2122

2223
#include <gz/utils/cli/CLI.hpp>
2324
#include <gz/utils/cli/GzFormatter.hpp>
@@ -60,6 +61,9 @@ void runGuiCommand(const GuiOptions &_opt)
6061
char* g_argv[] = {"./gz"};
6162
gz::gui::Application app(g_argc, g_argv);
6263

64+
auto *mainWindow = app.findChild<gz::gui::MainWindow *>();
65+
// Set the render engine GUI name
66+
mainWindow->SetRenderEngine("ogre2");
6367
app.LoadPlugin("MinimalScene");
6468

6569
gz::gui::Application::exec();
+18-28
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
11
set(SOURCES
22
MinimalScene.cc
3+
MinimalScene.hh
34
MinimalSceneRhi.cc
5+
MinimalSceneRhi.hh
46
MinimalSceneRhiOpenGL.cc
7+
MinimalSceneRhiOpenGL.hh
58
MinimalSceneRhiVulkan.cc
9+
MinimalSceneRhiVulkan.hh
610
EngineToQtInterface.cc
11+
EngineToQtInterface.hh
712
)
813

9-
# Objective-C sources for macOS
10-
if (APPLE)
11-
set(SOURCES
12-
${SOURCES}
13-
MinimalSceneRhiMetal.mm
14-
)
15-
16-
set(PROJECT_LINK_LIBS
17-
"-framework AppKit"
18-
"-framework Metal"
19-
)
20-
endif()
14+
qt6_add_qml_module(MinimalScene
15+
URI MinimalScene
16+
VERSION 1.0
17+
SOURCES ${SOURCES}
18+
QML_FILES MinimalScene.qml
19+
)
2120

22-
gz_gui_add_plugin(MinimalScene
23-
SOURCES
24-
${SOURCES}
25-
EngineToQtInterface.hh
26-
QT_HEADERS
27-
MinimalScene.hh
28-
PUBLIC_LINK_LIBS
21+
target_link_libraries(MinimalScene PRIVATE
2922
gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER}
3023
gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER}
24+
gz-plugin${GZ_PLUGIN_VER}::register
25+
Qt6::Gui
26+
Qt6::Widgets
27+
Qt6::Quick
28+
Qt6::QuickControls2
3129
)
3230

33-
# Enable ARC on selected source files
34-
if (APPLE)
35-
set_source_files_properties(
36-
MinimalSceneRhiMetal.mm
37-
PROPERTIES
38-
COMPILE_FLAGS
39-
"-fobjc-arc -Wno-nullability-completeness"
40-
)
41-
endif()
31+
install (TARGETS MinimalScene DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR})

0 commit comments

Comments
 (0)