summaryrefslogtreecommitdiffstats
path: root/utils/regtools
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-09-27 13:29:44 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-12-15 22:52:45 +0100
commitb08620dd304f54943c057405da49d44102ebcc77 (patch)
tree55d53f7bb87b50e76941622c1115a23762536367 /utils/regtools
parent3b4e63173d5f762a368d159e21f76e2df3fcf8ab (diff)
downloadrockbox-b08620dd304f54943c057405da49d44102ebcc77.tar.gz
rockbox-b08620dd304f54943c057405da49d44102ebcc77.tar.bz2
rockbox-b08620dd304f54943c057405da49d44102ebcc77.zip
qeditor: introduce a message widget to display non-interactive messages
Change-Id: Iad43efa1f09428389fbd09403c1ae20d2805f1c5 Reviewed-on: http://gerrit.rockbox.org/987 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'utils/regtools')
-rw-r--r--utils/regtools/qeditor/regtab.cpp10
-rw-r--r--utils/regtools/qeditor/regtab.h2
-rw-r--r--utils/regtools/qeditor/utils.cpp80
-rw-r--r--utils/regtools/qeditor/utils.h28
4 files changed, 120 insertions, 0 deletions
diff --git a/utils/regtools/qeditor/regtab.cpp b/utils/regtools/qeditor/regtab.cpp
index c92dad49d5..32d08a73d3 100644
--- a/utils/regtools/qeditor/regtab.cpp
+++ b/utils/regtools/qeditor/regtab.cpp
@@ -149,8 +149,10 @@ RegTab::RegTab(Backend *backend, QWidget *parent)
data_sel_layout->addWidget(m_data_sel_reload);
data_sel_group->setLayout(data_sel_layout);
m_data_soc_label->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
+ m_msg = new MessageWidget(this);
m_right_panel->addWidget(data_sel_group, 0);
+ m_right_panel->addWidget(m_msg, 0);
m_right_content = 0;
SetPanel(new EmptyRegTabPanel);
QWidget *w = new QWidget;
@@ -176,6 +178,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,
+ "You can browse the registers. Select a data source to analyse the values.");
+
OnSocListChanged();
SetDataSocName("");
UpdateTabName();
@@ -310,6 +315,11 @@ void RegTab::DisplaySoc(const SocRef& ref)
SetPanel(new SocDisplayPanel(this, ref));
}
+void RegTab::SetMessage(MessageWidget::MessageType type, const QString& msg)
+{
+ m_msg->SetMessage(type, msg);
+}
+
void RegTab::SetPanel(RegTabPanel *panel)
{
delete m_right_content;
diff --git a/utils/regtools/qeditor/regtab.h b/utils/regtools/qeditor/regtab.h
index c19af0aeba..f088e7a8df 100644
--- a/utils/regtools/qeditor/regtab.h
+++ b/utils/regtools/qeditor/regtab.h
@@ -78,6 +78,7 @@ protected:
void SetPanel(RegTabPanel *panel);
void UpdateSocFilename();
void UpdateTabName();
+ void SetMessage(MessageWidget::MessageType type, const QString& msg);
QComboBox *m_soc_selector;
BackendSelector *m_backend_selector;
@@ -93,6 +94,7 @@ protected:
IoBackend *m_io_backend;
QTabWidget *m_type_selector;
QListWidget *m_analysers_list;
+ MessageWidget *m_msg;
private slots:
void SetReadOnlyIndicator();
diff --git a/utils/regtools/qeditor/utils.cpp b/utils/regtools/qeditor/utils.cpp
index cf8f104334..677d24dd7f 100644
--- a/utils/regtools/qeditor/utils.cpp
+++ b/utils/regtools/qeditor/utils.cpp
@@ -964,3 +964,83 @@ void BackendSelector::ChangeBackend(IoBackend *new_backend)
delete m_io_backend;
m_io_backend = new_backend;
}
+
+/**
+ * MessageWidget
+ */
+MessageWidget::MessageWidget(QWidget *parent)
+ :QFrame(parent)
+{
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+ m_icon = new QLabel(this);
+ m_icon->hide();
+ m_text = new QLabel(this);
+ m_text->setTextFormat(Qt::RichText);
+ m_close = new QToolButton(this);
+ m_close->setText("close");
+ m_close->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
+ m_close->setAutoRaise(true);
+
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->addWidget(m_icon, 0);
+ layout->addWidget(m_text, 1);
+ layout->addWidget(m_close, 0);
+
+ connect(m_close, SIGNAL(clicked(bool)), this, SLOT(OnClose(bool)));
+
+ hide();
+}
+
+MessageWidget::~MessageWidget()
+{
+}
+
+void MessageWidget::UpdateType()
+{
+ /* style stolen from KMessageWidget */
+ QColor bg, border;
+ switch(m_type)
+ {
+ case Positive:
+ bg.setRgb(140, 228, 124);
+ border.setRgb(56, 175, 58);
+ break;
+ case Information:
+ bg.setRgb(161, 178, 202);
+ border.setRgb(59, 79, 175);
+ break;
+ case Warning:
+ bg.setRgb(228, 227, 127);
+ border.setRgb(175, 169, 61);
+ break;
+ case Error:
+ bg.setRgb(233, 199, 196);
+ border.setRgb(175, 74, 60);
+ break;
+ default:
+ break;
+ }
+ setStyleSheet(QString(
+ "QFrame { background-color: %1;"
+ "border-radius: 5px;"
+ "border: 1px solid %2;"
+ "}"
+ "QLabel { border: none; }")
+ .arg(bg.name())
+ .arg(border.name()));
+}
+
+void MessageWidget::SetMessage(MessageType type, const QString& msg)
+{
+ m_type = type;
+ m_text->setText(msg);
+ UpdateType();
+ show();
+}
+
+void MessageWidget::OnClose(bool clicked)
+{
+ Q_UNUSED(clicked);
+ hide();
+}
diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h
index 8bb1a70d7f..ec3175b5da 100644
--- a/utils/regtools/qeditor/utils.h
+++ b/utils/regtools/qeditor/utils.h
@@ -338,4 +338,32 @@ private slots:
void OnDataSelChanged(int index);
};
+class MessageWidget : public QFrame
+{
+ Q_OBJECT
+public:
+ enum MessageType
+ {
+ Positive,
+ Information,
+ Warning,
+ Error
+ };
+
+ MessageWidget(QWidget *parent = 0);
+ virtual ~MessageWidget();
+ void SetMessage(MessageType type, const QString& msg);
+
+protected:
+ void UpdateType();
+
+ QLabel *m_icon;
+ QLabel *m_text;
+ QToolButton *m_close;
+ MessageType m_type;
+
+private slots:
+ void OnClose(bool clicked);
+};
+
#endif /* AUX_H */