left click on lua status now opens scripts list

Dieser Commit ist enthalten in:
Reinder Feenstra 2024-01-01 22:00:01 +01:00
Ursprung 516e49033e
Commit 231cfb59cf
4 geänderte Dateien mit 37 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2023 Reinder Feenstra
* Copyright (C) 2019-2024 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -391,7 +391,7 @@ MainWindow::MainWindow(QWidget* parent) :
m_menuObjects->addAction(Theme::getIcon("clock"), Locale::tr("world:clock") + "...", [this](){ showObject("world.clock", Locale::tr("world:clock")); });
trainsAction = m_menuObjects->addAction(Theme::getIcon("train"), Locale::tr("world:trains") + "...", [this](){ showObject("world.trains", Locale::tr("world:trains")); });
m_menuObjects->addAction(Locale::tr("world:rail_vehicles") + "...", [this](){ showObject("world.rail_vehicles", Locale::tr("world:rail_vehicles")); });
m_actionLuaScript = m_menuObjects->addAction(Theme::getIcon("lua"), Locale::tr("world:lua_scripts") + "...", [this](){ showObject("world.lua_scripts", Locale::tr("world:lua_scripts")); });
m_actionLuaScript = m_menuObjects->addAction(Theme::getIcon("lua"), Locale::tr("world:lua_scripts") + "...", this, &MainWindow::showLuaScriptsList);
menu = menuBar()->addMenu(Locale::tr("qtapp.mainmenu:tools"));
menu->addAction(Locale::tr("qtapp.mainmenu:settings") + "...",
@ -571,6 +571,11 @@ const ObjectPtr& MainWindow::world() const
return m_connection ? m_connection->world() : null;
}
void MainWindow::showLuaScriptsList()
{
showObject("world.lua_scripts", Locale::tr("world:lua_scripts"));
}
void MainWindow::connectToServer(const QString& url)
{
if(m_connection)

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2023 Reinder Feenstra
* Copyright (C) 2019-2024 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -129,6 +129,8 @@ class MainWindow : public QMainWindow
const ObjectPtr& world() const;
const ObjectPtr& worldClock() const { return m_clock; }
void showLuaScriptsList();
public slots:
void connectToServer(const QString& url = QString());
void showObject(const ObjectPtr& object, SubWindowType flags = SubWindowType::Object);

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2023 Reinder Feenstra
* Copyright (C) 2023-2024 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -30,6 +30,7 @@
#include "../../network/object.hpp"
#include "../../network/property.hpp"
#include "../../theme/theme.hpp"
#include "../../mainwindow.hpp"
LuaStatusWidget::LuaStatusWidget(const ObjectPtr& object, QWidget* parent)
: QWidget(parent)
@ -99,6 +100,27 @@ void LuaStatusWidget::errorChanged()
labelChanged();
}
void LuaStatusWidget::mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
m_mouseLeftButtonPressed = true;
}
}
void LuaStatusWidget::mouseReleaseEvent(QMouseEvent* event)
{
if(m_mouseLeftButtonPressed && event->button() == Qt::LeftButton)
{
m_mouseLeftButtonPressed = false;
if(rect().contains(event->pos()))
{
MainWindow::instance->showLuaScriptsList();
}
}
}
void LuaStatusWidget::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2023 Reinder Feenstra
* Copyright (C) 2023-2024 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -36,12 +36,15 @@ class LuaStatusWidget : public QWidget
QSvgWidget* m_svg;
QLabel* m_runningLabel;
QLabel* m_errorLabel;
bool m_mouseLeftButtonPressed = false;
void labelChanged();
void runningChanged();
void errorChanged();
protected:
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
public: