Skip to content
Snippets Groups Projects
Commit 3d5fc90c authored by Peter Albrecht's avatar Peter Albrecht
Browse files

design change: removed timer from status label (see !406)

parent 9ec5f6a3
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
Pipeline #17027 passed
...@@ -64,7 +64,7 @@ set(SOURCES ...@@ -64,7 +64,7 @@ set(SOURCES
PeriodicUpdateWidget.cpp PeriodicUpdateWidget.cpp
SkillMemoryGui.cpp SkillMemoryGui.cpp
gui_utils.cpp gui_utils.cpp
ConnectionStatusLabel.cpp StatusLabel.cpp
) )
set(HEADERS set(HEADERS
aron_tree_widget/visitors/AronTreeWidgetCreator.h aron_tree_widget/visitors/AronTreeWidgetCreator.h
...@@ -107,7 +107,7 @@ set(HEADERS ...@@ -107,7 +107,7 @@ set(HEADERS
PeriodicUpdateWidget.h PeriodicUpdateWidget.h
SkillMemoryGui.h SkillMemoryGui.h
gui_utils.h gui_utils.h
ConnectionStatusLabel.h StatusLabel.h
) )
armarx_gui_library("${LIB_NAME}" "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${LIBRARIES}") armarx_gui_library("${LIB_NAME}" "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${LIBRARIES}")
......
#include "ConnectionStatusLabel.h"
namespace armarx::skills::gui
{
ConnectionStatusLabel::ConnectionStatusLabel(int ms)
{
timer = new QTimer();
setStyleSheet("color: red");
ms_delay = ms;
}
void
ConnectionStatusLabel::handleMessage(std::string const& message)
{
// reset the timer if it is running
if (timer->isActive())
{
timer->stop();
}
setText(QString::fromStdString(message));
timer->singleShot(2000, this, &ConnectionStatusLabel::resetLabel);
}
void
ConnectionStatusLabel::resetLabel()
{
setText(QString::fromStdString(""));
}
} // namespace armarx::skills::gui
...@@ -14,7 +14,7 @@ namespace armarx::skills::gui ...@@ -14,7 +14,7 @@ namespace armarx::skills::gui
QLayout* stopAllLayout, QLayout* stopAllLayout,
QLabel* _connectionStatusLabel, QWidget* _connectionStatusLabel,
std::shared_ptr<SkillManagerWrapper> _memory) std::shared_ptr<SkillManagerWrapper> _memory)
{ {
...@@ -62,7 +62,7 @@ namespace armarx::skills::gui ...@@ -62,7 +62,7 @@ namespace armarx::skills::gui
stopAllButton = new QPushButton(QString::fromStdString(STOP_ALL_BUTTON_TEXT)); stopAllButton = new QPushButton(QString::fromStdString(STOP_ALL_BUTTON_TEXT));
stopAllLayout->addWidget(stopAllButton); stopAllLayout->addWidget(stopAllButton);
this->connectionStatusLabel = new ConnectionStatusLabel(); this->connectionStatusLabel = new StatusLabel();
armarx::gui::replaceWidget(_connectionStatusLabel, armarx::gui::replaceWidget(_connectionStatusLabel,
this->connectionStatusLabel, this->connectionStatusLabel,
_connectionStatusLabel->parentWidget()->layout()); _connectionStatusLabel->parentWidget()->layout());
...@@ -128,6 +128,6 @@ namespace armarx::skills::gui ...@@ -128,6 +128,6 @@ namespace armarx::skills::gui
connect(memory.get(), connect(memory.get(),
&SkillManagerWrapper::connectionUpdate, &SkillManagerWrapper::connectionUpdate,
connectionStatusLabel, connectionStatusLabel,
&ConnectionStatusLabel::handleMessage); &StatusLabel::handleMessage);
} }
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <ArmarXCore/core/logging/Logging.h> #include <ArmarXCore/core/logging/Logging.h>
#include "RobotAPI/libraries/skills_gui/ConnectionStatusLabel.h" #include "RobotAPI/libraries/skills_gui/StatusLabel.h"
#include "./PeriodicUpdateWidget.h" #include "./PeriodicUpdateWidget.h"
#include "./aron_tree_widget/widgets/SkillDescriptionWidget.h" #include "./aron_tree_widget/widgets/SkillDescriptionWidget.h"
...@@ -36,7 +36,7 @@ namespace armarx::skills::gui ...@@ -36,7 +36,7 @@ namespace armarx::skills::gui
QLayout* stopAllLayout, QLayout* stopAllLayout,
QLabel* connectionStatusLabel, QWidget* connectionStatusLabel,
std::shared_ptr<SkillManagerWrapper> _memory); std::shared_ptr<SkillManagerWrapper> _memory);
...@@ -72,7 +72,7 @@ namespace armarx::skills::gui ...@@ -72,7 +72,7 @@ namespace armarx::skills::gui
QPushButton* stopAllButton = nullptr; QPushButton* stopAllButton = nullptr;
ConnectionStatusLabel* connectionStatusLabel = nullptr; StatusLabel* connectionStatusLabel = nullptr;
}; };
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
......
#include "StatusLabel.h"
#include <QHBoxLayout>
namespace armarx::skills::gui
{
StatusLabel::StatusLabel()
{
this->label = new QLabel("");
this->resetButton = new QPushButton("Reset");
this->setupUi();
}
void
StatusLabel::handleMessage(const std::string& message)
{
this->label->setText(QString::fromStdString(message));
}
void
StatusLabel::resetLabel()
{
this->label->setText(QString::fromStdString(""));
}
void
StatusLabel::setupUi()
{
QHBoxLayout* layout = new QHBoxLayout();
layout->addWidget(label);
layout->addWidget(resetButton);
this->setLayout(layout);
layout->setStretch(0, 2);
connect(this->resetButton, &QPushButton::clicked, this, &StatusLabel::resetLabel);
}
} // namespace armarx::skills::gui
#pragma once #pragma once
#include <QLabel> #include <QLabel>
#include <QTimer> #include <QPushButton>
namespace armarx::skills::gui namespace armarx::skills::gui
{ {
class ConnectionStatusLabel : public QLabel class StatusLabel : public QWidget
{ {
public: public:
/** /**
* @brief Constructor for ConnectionStatusLabel * @brief Constructor for StatusLabel
* @param ms The time in [ms], for which the message appears.
*/ */
ConnectionStatusLabel(int ms = 3000); StatusLabel();
public slots: public slots:
/** /**
* @brief Display a message to indicate a connection drop. * @brief Display a message to indicate an update.
*/ */
void handleMessage(std::string const& message); void handleMessage(std::string const& message);
...@@ -27,7 +26,10 @@ namespace armarx::skills::gui ...@@ -27,7 +26,10 @@ namespace armarx::skills::gui
void resetLabel(); void resetLabel();
private: private:
QTimer* timer = nullptr; void setupUi();
int ms_delay;
// contents
QLabel* label = nullptr;
QPushButton* resetButton = nullptr;
}; };
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment