[client] added createImageWidget function, the new TileWidget will replace the ObjectEditWidget in the near future

Dieser Commit ist enthalten in:
Reinder Feenstra 2025-12-30 17:38:22 +01:00
Ursprung a5cb57e360
Commit 5cba0a53c4
4 geänderte Dateien mit 71 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,35 @@
/**
* This file is part of Traintastic,
* see <https://github.com/traintastic/traintastic>.
*
* Copyright (C) 2025 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "createimagewidget.hpp"
#include "../network/object.hpp"
#include "tile/tileimagewidget.hpp"
QWidget* createImageWidget(const ObjectPtr& object, QWidget* parent)
{
if(object->classId().startsWith("board_tile."))
{
return new TileImageWidget(object, parent);
}
return nullptr; // no image
}

Datei anzeigen

@ -0,0 +1,31 @@
/**
* This file is part of Traintastic,
* see <https://github.com/traintastic/traintastic>.
*
* Copyright (C) 2025 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TRAINTASTIC_CLIENT_WIDGET_CREATEIMAGEWIDGET_HPP
#define TRAINTASTIC_CLIENT_WIDGET_CREATEIMAGEWIDGET_HPP
#include "../network/objectptr.hpp"
class QWidget;
QWidget* createImageWidget(const ObjectPtr& object, QWidget* parent = nullptr);
#endif

Datei anzeigen

@ -30,6 +30,7 @@
#include "../../theme/theme.hpp"
#include "../../utils/settabwidget.hpp"
#include "../interfaceitemnamelabel.hpp"
#include "../createimagewidget.hpp"
#include "../createform.hpp"
#include "../createwidget.hpp"
#include "tileimagewidget.hpp"
@ -38,13 +39,15 @@ TileWidget::TileWidget(ObjectPtr object, QWidget* parent)
: QWidget(parent)
, m_object{std::move(object)}
, m_tabs{new QTabWidget(this)}
, m_image{new TileImageWidget(m_object, this)}
{
Theme::setWindowIcon(*this, m_object->classId());
auto* grid = new QGridLayout();
grid->setContentsMargins(2, 2, 2, 2);
grid->addWidget(m_image, 0, 0);
if(auto* image = createImageWidget(m_object, this))
{
grid->addWidget(image, 0, 0);
}
// Window title:
if(auto* name = m_object->getProperty(QStringLiteral("name")))

Datei anzeigen

@ -26,7 +26,6 @@
#include "../../network/objectptr.hpp"
class QTabWidget;
class TileImageWidget;
class TileWidget : public QWidget
{
@ -35,7 +34,6 @@ class TileWidget : public QWidget
protected:
ObjectPtr m_object;
QTabWidget* m_tabs;
TileImageWidget* m_image;
public:
explicit TileWidget(ObjectPtr object, QWidget* parent = nullptr);