]> sigrok.org Git - pulseview.git/commitdiff
Created DecoderGroupBox widget
authorJoel Holdsworth <redacted>
Sat, 30 Nov 2013 16:02:45 +0000 (16:02 +0000)
committerJoel Holdsworth <redacted>
Sat, 30 Nov 2013 18:14:05 +0000 (18:14 +0000)
CMakeLists.txt
icons/decoder-delete.svg [new file with mode: 0644]
pulseview.qrc
pv/view/decodetrace.cpp
pv/widgets/decodergroupbox.cpp [new file with mode: 0644]
pv/widgets/decodergroupbox.h [new file with mode: 0644]
test/CMakeLists.txt

index 5072c4521be4fdf80f0b7458614263335e7bf90f..443dea6a304b53ffcc27d2fb8fc412db02d8e702 100644 (file)
@@ -145,6 +145,7 @@ set(pulseview_SOURCES
        pv/view/decode/annotation.cpp
        pv/widgets/colourbutton.cpp
        pv/widgets/colourpopup.cpp
+       pv/widgets/decodergroupbox.cpp
        pv/widgets/decodermenu.cpp
        pv/widgets/popup.cpp
        pv/widgets/popuptoolbutton.cpp
@@ -181,6 +182,7 @@ set(pulseview_HEADERS
        pv/view/viewport.h
        pv/widgets/colourbutton.h
        pv/widgets/colourpopup.h
+       pv/widgets/decodergroupbox.h
        pv/widgets/decodermenu.h
        pv/widgets/popup.h
        pv/widgets/popuptoolbutton.h
diff --git a/icons/decoder-delete.svg b/icons/decoder-delete.svg
new file mode 100644 (file)
index 0000000..b9db4ea
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg id="svg2989" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <metadata id="metadata2994">
+  <rdf:RDF>
+   <cc:Work rdf:about="">
+    <dc:format>image/svg+xml</dc:format>
+    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+    <dc:title/>
+   </cc:Work>
+  </rdf:RDF>
+ </metadata>
+ <g id="layer1" stroke-linejoin="miter" style="stroke-dasharray:none;" transform="translate(0,-1036.3622)" stroke="#000" stroke-linecap="square" stroke-miterlimit="4" stroke-width="2" fill="none">
+  <path id="path3007" style="stroke-dasharray:none;" d="m11,1047.4-6-6"/>
+  <path id="path2986" style="stroke-dasharray:none;" d="m5,1047.4,6-6"/>
+ </g>
+</svg>
index a1577d6dd2619dd194a400881ea2d20de8ca7866..a7108b48b278ea93a86c4b66aa851e580a4b6a71 100644 (file)
@@ -2,6 +2,7 @@
     <qresource prefix="/" >
        <file>icons/application-exit.png</file>
        <file>icons/configure.png</file>
+       <file>icons/decoder-delete.svg</file>
        <file>icons/document-open.png</file>
        <file>icons/probes.svg</file>
        <file>icons/sigrok-logo-notext.png</file>
index d3d10b6981953eaf02651a572c30d4f53e89cec9..3e78e6ed2a669811e85e890ef31ad7c50f999bf5 100644 (file)
@@ -41,6 +41,7 @@ extern "C" {
 #include <pv/view/logicsignal.h>
 #include <pv/view/view.h>
 #include <pv/view/decode/annotation.h>
+#include <pv/widgets/decodergroupbox.h>
 #include <pv/widgets/decodermenu.h>
 
 using namespace boost;
@@ -207,7 +208,10 @@ void DecodeTrace::create_decoder_form(shared_ptr<data::decode::Decoder> &dec,
        const srd_decoder *const decoder = dec->decoder();
        assert(decoder);
 
-       form->addRow(new QLabel(tr("<h3>%1</h3>").arg(decoder->name), parent));
+       pv::widgets::DecoderGroupBox *const group =
+               new pv::widgets::DecoderGroupBox(decoder->name);
+       QFormLayout *const decoder_form = new QFormLayout;
+       group->add_layout(decoder_form);
 
        // Add the mandatory probes
        for(probe = decoder->probes; probe; probe = probe->next) {
@@ -216,7 +220,7 @@ void DecodeTrace::create_decoder_form(shared_ptr<data::decode::Decoder> &dec,
                QComboBox *const combo = create_probe_selector(parent, dec, p);
                connect(combo, SIGNAL(currentIndexChanged(int)),
                        this, SLOT(on_probe_selected(int)));
-               form->addRow(tr("<b>%1</b> (%2) *")
+               decoder_form->addRow(tr("<b>%1</b> (%2) *")
                        .arg(p->name).arg(p->desc), combo);
 
                const ProbeSelector s = {combo, dec, p};
@@ -230,7 +234,7 @@ void DecodeTrace::create_decoder_form(shared_ptr<data::decode::Decoder> &dec,
                QComboBox *const combo = create_probe_selector(parent, dec, p);
                connect(combo, SIGNAL(currentIndexChanged(int)),
                        this, SLOT(on_probe_selected(int)));
-               form->addRow(tr("<b>%1</b> (%2)")
+               decoder_form->addRow(tr("<b>%1</b> (%2)")
                        .arg(p->name).arg(p->desc), combo);
 
                const ProbeSelector s = {combo, dec, p};
@@ -240,9 +244,11 @@ void DecodeTrace::create_decoder_form(shared_ptr<data::decode::Decoder> &dec,
        // Add the options
        shared_ptr<prop::binding::DecoderOptions> binding(
                new prop::binding::DecoderOptions(_decoder_stack, dec));
-       binding->add_properties_to_form(form, true);
+       binding->add_properties_to_form(decoder_form, true);
 
        _bindings.push_back(binding);
+
+       form->addRow(group);
 }
 
 QComboBox* DecodeTrace::create_probe_selector(
diff --git a/pv/widgets/decodergroupbox.cpp b/pv/widgets/decodergroupbox.cpp
new file mode 100644 (file)
index 0000000..4cf6a08
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include "decodergroupbox.h"
+
+#include <QAction>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QToolBar>
+#include <QVBoxLayout>
+
+#include <assert.h>
+
+namespace pv {
+namespace widgets {
+
+DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
+       QWidget(parent),
+       _layout(new QGridLayout)
+{
+       _layout->setContentsMargins(0, 0, 0, 0);
+       setLayout(_layout);
+
+       _layout->addWidget(new QLabel(QString("<h2>%1</h2><hl/>").arg(title)),
+               0, 0);
+       _layout->setColumnStretch(0, 1);
+
+       QToolBar *const toolbar = new QToolBar;
+       toolbar->setIconSize(QSize(16, 16));
+       _layout->addWidget(toolbar, 0, 1);
+
+       QAction *const delete_action = new QAction(
+               QIcon(":/icons/decoder-delete.svg"), tr("Delete"), this);
+       connect(delete_action, SIGNAL(triggered()),
+               this, SIGNAL(delete_decoder()));
+       toolbar->addAction(delete_action);
+}
+
+void DecoderGroupBox::add_layout(QLayout *layout)
+{
+       assert(layout);
+       _layout->addLayout(layout, 1, 0, 1, 2);
+}
+
+} // widgets
+} // pv
diff --git a/pv/widgets/decodergroupbox.h b/pv/widgets/decodergroupbox.h
new file mode 100644 (file)
index 0000000..7b6bc93
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_WIDGETS_DECODERGROUPBox_H
+#define PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H
+
+#include <QWidget>
+
+class QGridLayout;
+class QToolBar;
+
+namespace pv {
+namespace widgets {
+
+class DecoderGroupBox : public QWidget
+{
+       Q_OBJECT
+
+public:
+       DecoderGroupBox(QString title, QWidget *parent = NULL);
+
+       void add_layout(QLayout *layout);
+
+signals:
+       void delete_decoder();
+
+private:
+       QGridLayout *const _layout;
+};
+
+} // widgets
+} // pv
+
+#endif // PULSEVIEW_PV_WIDGETS_DECODERGROUPBOX_H
index f8715043555211ed727b883ab32d1a709b08f514..752e809c73f3ed4bcb61042e333348d7b348b0aa 100644 (file)
@@ -70,6 +70,7 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/view/decode/annotation.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
+       ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
        ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp
@@ -100,6 +101,7 @@ set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/view/viewport.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.h
+       ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/popup.h
        ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.h