From 7749c4d0e960b3e4f92194bd8f63ed70cc9bcb31 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 7 Oct 2014 14:30:24 +0200 Subject: qeditor: message widget now supports IDs, useful to clear messages Change-Id: Ibe0a8909128469a71a25415761860e06fc9f1e67 Reviewed-on: http://gerrit.rockbox.org/1006 Reviewed-by: Amaury Pouly --- utils/regtools/qeditor/regtab.cpp | 21 ++++++++++++++++++--- utils/regtools/qeditor/regtab.h | 5 ++++- utils/regtools/qeditor/utils.cpp | 11 ++++++++++- utils/regtools/qeditor/utils.h | 6 +++++- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/utils/regtools/qeditor/regtab.cpp b/utils/regtools/qeditor/regtab.cpp index b80ab57ecf..a82070e3f8 100644 --- a/utils/regtools/qeditor/regtab.cpp +++ b/utils/regtools/qeditor/regtab.cpp @@ -179,8 +179,9 @@ RegTab::RegTab(Backend *backend, QWidget *parent) connect(m_data_sel_reload, SIGNAL(clicked(bool)), this, SLOT(OnBackendReload(bool))); connect(m_type_selector, SIGNAL(currentChanged(int)), this, SLOT(OnTypeChanged(int))); - SetMessage(MessageWidget::Information, + m_msg_select_id = SetMessage(MessageWidget::Information, "You can browse the registers. Select a data source to analyse the values."); + m_msg_error_id = 0; OnSocListChanged(); SetDataSocName(""); @@ -222,6 +223,12 @@ void RegTab::OnDataSocActivated(const QString& str) int index = m_soc_selector->findText(str); if(index != -1) m_soc_selector->setCurrentIndex(index); + else if(str.size() > 0) + { + m_msg_error_id = SetMessage(MessageWidget::Error, + "Description file for this SoC is not available."); + SetPanel(new EmptyRegTabPanel); + } } void RegTab::UpdateTabName() @@ -252,6 +259,9 @@ void RegTab::UpdateTabName() void RegTab::OnBackendSelect(IoBackend *backend) { + /* Hide "Please select two SoC" and errors message */ + HideMessage(m_msg_select_id); + HideMessage(m_msg_error_id); m_io_backend = backend; SetReadOnlyIndicator(); SetDataSocName(m_io_backend->GetSocName()); @@ -316,9 +326,14 @@ void RegTab::DisplaySoc(const SocRef& ref) SetPanel(new SocDisplayPanel(this, ref)); } -void RegTab::SetMessage(MessageWidget::MessageType type, const QString& msg) +int RegTab::SetMessage(MessageWidget::MessageType type, const QString& msg) +{ + return m_msg->SetMessage(type, msg); +} + +void RegTab::HideMessage(int id) { - m_msg->SetMessage(type, msg); + m_msg->HideMessage(id); } void RegTab::SetPanel(RegTabPanel *panel) diff --git a/utils/regtools/qeditor/regtab.h b/utils/regtools/qeditor/regtab.h index f088e7a8df..a0fd5f305a 100644 --- a/utils/regtools/qeditor/regtab.h +++ b/utils/regtools/qeditor/regtab.h @@ -78,7 +78,8 @@ protected: void SetPanel(RegTabPanel *panel); void UpdateSocFilename(); void UpdateTabName(); - void SetMessage(MessageWidget::MessageType type, const QString& msg); + int SetMessage(MessageWidget::MessageType type, const QString& msg); + void HideMessage(int id); QComboBox *m_soc_selector; BackendSelector *m_backend_selector; @@ -95,6 +96,8 @@ protected: QTabWidget *m_type_selector; QListWidget *m_analysers_list; MessageWidget *m_msg; + int m_msg_select_id; + int m_msg_error_id; private slots: void SetReadOnlyIndicator(); diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp index 4f408b4765..effd79e0f6 100644 --- a/utils/regtools/qeditor/utils.cpp +++ b/utils/regtools/qeditor/utils.cpp @@ -998,6 +998,8 @@ MessageWidget::MessageWidget(QWidget *parent) layout->addWidget(m_text, 1); layout->addWidget(m_close, 0); + m_id = 0; + connect(m_close, SIGNAL(clicked(bool)), this, SLOT(OnClose(bool))); hide(); @@ -1042,12 +1044,19 @@ void MessageWidget::UpdateType() .arg(border.name())); } -void MessageWidget::SetMessage(MessageType type, const QString& msg) +int MessageWidget::SetMessage(MessageType type, const QString& msg) { m_type = type; m_text->setText(msg); UpdateType(); show(); + return ++m_id; +} + +void MessageWidget::HideMessage(int id) +{ + if(m_id == id) + OnClose(true); } void MessageWidget::OnClose(bool clicked) diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h index a2a95f1cac..529e40bde1 100644 --- a/utils/regtools/qeditor/utils.h +++ b/utils/regtools/qeditor/utils.h @@ -355,7 +355,10 @@ public: MessageWidget(QWidget *parent = 0); virtual ~MessageWidget(); - void SetMessage(MessageType type, const QString& msg); + /* returns message ID */ + int SetMessage(MessageType type, const QString& msg); + /* clear message if ID match, nop otherwise */ + void HideMessage(int id); protected: void UpdateType(); @@ -364,6 +367,7 @@ protected: QLabel *m_text; QToolButton *m_close; MessageType m_type; + int m_id; private slots: void OnClose(bool clicked); -- cgit v1.2.3