mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
UI
add statusbar
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "ui_slider.hpp"
|
||||
#include "ui_spinbox.hpp"
|
||||
#include "ui_stacked_widget.hpp"
|
||||
#include "ui_status_bar.hpp"
|
||||
#include "ui_tab_widget.hpp"
|
||||
#include "ui_table.hpp"
|
||||
#include "ui_textbox.hpp"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "ui_status_bar.hpp"
|
||||
|
||||
UI_status_bar::UI_status_bar(QObject *parent) : UI_item{UI_STATUS_BAR_TYPE, parent}
|
||||
{
|
||||
}
|
||||
|
||||
UI_status_bar::UI_status_bar(std::string message, QObject *parent)
|
||||
: UI_item(UI_STATUS_BAR_TYPE, parent), m_current_message(message)
|
||||
{
|
||||
}
|
||||
|
||||
void UI_status_bar::show_message(std::string message, size_t timeout)
|
||||
{
|
||||
m_current_message = message;
|
||||
m_timeout = timeout;
|
||||
emit ui_changed();
|
||||
}
|
||||
|
||||
std::string UI_status_bar::message() const
|
||||
{
|
||||
return m_current_message;
|
||||
}
|
||||
|
||||
void UI_status_bar::from_json(const json &j)
|
||||
{
|
||||
UI_item::from_json(j);
|
||||
m_current_message = j.at("current_message");
|
||||
m_timeout = j.at("timeout");
|
||||
}
|
||||
|
||||
json UI_status_bar::to_json(size_t id) const
|
||||
{
|
||||
json j = UI_item::to_json(id);
|
||||
j["current_message"] = m_current_message;
|
||||
j["timeout"] = m_timeout;
|
||||
return j;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef UI_STATUS_BAR_HPP
|
||||
#define UI_STATUS_BAR_HPP
|
||||
|
||||
#include "ui_item.hpp"
|
||||
#define UI_STATUS_BAR_TYPE std::string("ui_status_bar")
|
||||
|
||||
class UI_status_bar : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UI_status_bar(QObject *parent = nullptr);
|
||||
UI_status_bar(std::string message, QObject *parent = nullptr);
|
||||
|
||||
void show_message(std::string message, size_t timeout = 0);
|
||||
std::string message() const;
|
||||
|
||||
void from_json(const json &j) override;
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
std::string m_current_message;
|
||||
size_t m_timeout;
|
||||
};
|
||||
|
||||
#endif // UI_STATUS_BAR_HPP
|
||||
Reference in New Issue
Block a user