Skip to content

Commit

Permalink
gui: Remove remaining mentions of SDL.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Nov 7, 2023
1 parent c172dcf commit 33551f8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
12 changes: 6 additions & 6 deletions doc/code/gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ qmlRegisterType<ResourceAmountLink>("yay.sfttech.openage", 1, 0, "ResourceAmount

2. Specializations `struct Wrap<ResourceAmount>` and `struct Unwrap<ResourceAmountLink>` must be defined:
```cpp
namespace qtsdl {
namespace qtgui {
template<>
struct Wrap<ResourceAmount> {
using Type = ResourceAmountLink;
Expand All @@ -61,13 +61,13 @@ template<>
struct Unwrap<ResourceAmountLink> {
using Type = ResourceAmount;
};
} // namespace qtsdl
} // namespace qtgui
```
3. Also ResourceAmount needs a public member to be added:
```cpp
public:
qtsdl::GuiItemLink *gui_link
qtgui::GuiItemLink *gui_link
```

4. Declare and implement needed properties and signals in the `ResourceAmountLink` using Qt property syntax.
Expand All @@ -78,7 +78,7 @@ There is a class `GeneratorParameters` in `libopenage/` directory.
It has a big list of parameters of different types like `generation_seed`, `player_radius`, `player_names`, etc.
So, we're not going to write a Qt property for each one:

1. `GeneratorParameters` must derive from the `qtsdl::GuiPropertyMap`.
1. `GeneratorParameters` must derive from the `qtgui::GuiPropertyMap`.

2. `GeneratorParameters` should set its initial values like so:
```cpp
Expand All @@ -96,7 +96,7 @@ qmlRegisterType<GeneratorParametersLink>("yay.sfttech.openage", 1, 0, "Generator

4. Specializations `struct Wrap<GeneratorParameters>` and `struct Unwrap<GeneratorParametersLink>` must be defined:
```cpp
namespace qtsdl {
namespace qtgui {
template<>
struct Wrap<GeneratorParameters> {
using Type = GeneratorParametersLink;
Expand All @@ -106,7 +106,7 @@ template<>
struct Unwrap<GeneratorParametersLink> {
using Type = GeneratorParameters;
};
} // namespace qtsdl
} // namespace qtgui
```
That results into a `ListModel`-like QML type with `display` and `edit` roles.
Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/gui/guisys/link/gui_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#include <QRegularExpression>

#include "renderer/gui/guisys/link/gui_item_link.h"
#include "renderer/gui/guisys/link/qtsdl_checked_static_cast.h"
#include "renderer/gui/guisys/link/qtgui_checked_static_cast.h"
#include "renderer/gui/guisys/private/livereload/deferred_initial_constant_property_values.h"


namespace qtgui {

/**
* Cleans a text from unneeded content like "qtsdl".
* Cleans a text from unneeded content like "qtgui".
*/
QString name_tidier(const char *name);

Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/gui/guisys/link/gui_item_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <type_traits>
#include <utility>

#include "renderer/gui/guisys/link/qtsdl_checked_static_cast.h"
#include "renderer/gui/guisys/link/qtgui_checked_static_cast.h"


namespace qtgui {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QDynamicPropertyChangeEvent>
#include <QVariant>

#include "renderer/gui/guisys/link/qtsdl_checked_static_cast.h"
#include "renderer/gui/guisys/link/qtgui_checked_static_cast.h"


namespace qtgui {
Expand Down
20 changes: 9 additions & 11 deletions libopenage/renderer/gui/guisys/private/gui_application_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include "gui_application_impl.h"

#include <locale>
#include <cassert>
#include <locale>

#include <QSurfaceFormat>
#include <QtGlobal>
#include <QtDebug>
#include <QtGlobal>

namespace qtgui {

Expand Down Expand Up @@ -41,22 +41,20 @@ void GuiApplicationImpl::processEvents() {
}

namespace {
int argc = 1;
char arg[] = "qtsdl";
char *argv = &arg[0];
}
int argc = 1;
char arg[] = "qtgui";
char *argv = &arg[0];
} // namespace

GuiApplicationImpl::GuiApplicationImpl()
:
GuiApplicationImpl::GuiApplicationImpl() :
#ifndef NDEBUG
owner{std::this_thread::get_id()},
#endif
app{argc, &argv}
{
app{argc, &argv} {
// Set locale back to POSIX for the decimal point parsing (see qcoreapplication.html#locale-settings).
std::locale::global(std::locale().combine<std::numpunct<char>>(std::locale::classic()));

qInfo() << "Compiled with Qt" << QT_VERSION_STR << "and run with Qt" << qVersion();
}

} // namespace qtsdl
} // namespace qtgui
8 changes: 4 additions & 4 deletions libopenage/renderer/gui/guisys/private/gui_application_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include <thread>
#include <memory>
#include <thread>

#include <QGuiApplication>

Expand All @@ -12,7 +12,7 @@ namespace qtgui {
/**
* Houses gui logic event queue.
*
* To launch it in a dedicated thread, use qtsdl::GuiDedicatedThread instead.
* To launch it in a dedicated thread, use qtgui::GuiDedicatedThread instead.
*/
class GuiApplicationImpl {
public:
Expand All @@ -25,8 +25,8 @@ class GuiApplicationImpl {
private:
GuiApplicationImpl();

GuiApplicationImpl(const GuiApplicationImpl&) = delete;
GuiApplicationImpl& operator=(const GuiApplicationImpl&) = delete;
GuiApplicationImpl(const GuiApplicationImpl &) = delete;
GuiApplicationImpl &operator=(const GuiApplicationImpl &) = delete;

#ifndef NDEBUG
const std::thread::id owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ gl_debug_parameters get_current_opengl_debug_parameters(QOpenGLContext &current_
*/
void apply_opengl_debug_parameters(gl_debug_parameters params, QOpenGLContext &current_dest_context);

} // namespace qtsdl
} // namespace qtgui
8 changes: 3 additions & 5 deletions libopenage/renderer/gui/guisys/public/gui_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

namespace qtgui {

GuiApplication::GuiApplication()
:
GuiApplication::GuiApplication() :
application{GuiApplicationImpl::get()} {
}

GuiApplication::GuiApplication(std::shared_ptr<GuiApplicationImpl> application)
:
GuiApplication::GuiApplication(std::shared_ptr<GuiApplicationImpl> application) :
application{application} {
}

Expand All @@ -24,4 +22,4 @@ void GuiApplication::process_events() {
this->application->processEvents();
}

} // namespace qtsdl
} // namespace qtgui

0 comments on commit 33551f8

Please sign in to comment.