Changeset - 3a0d0d3df434
[Not reviewed]
new-reader
0 0 6
Hasan Yavuz ÖZDERYA - 9 years ago 2016-05-22 08:07:08
hy@ozderya.net
adding number format selection and endianness selection as separate widgets

tested but not yet used in code
6 files changed with 366 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/endiannessbox.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "endiannessbox.h"
 
#include "ui_endiannessbox.h"
 

	
 
EndiannessBox::EndiannessBox(QWidget *parent) :
 
    QGroupBox(parent),
 
    ui(new Ui::EndiannessBox)
 
{
 
    ui->setupUi(this);
 

	
 
    connect(ui->rbLittleE, &QRadioButton::toggled, [this](bool checked)
 
            {
 
                emit selectionChanged(currentSelection());
 
            });
 
}
 

	
 
EndiannessBox::~EndiannessBox()
 
{
 
    delete ui;
 
}
 

	
 
Endianness EndiannessBox::currentSelection()
 
{
 
    if (ui->rbLittleE->isChecked())
 
    {
 
        return LittleEndian;
 
    }
 
    else
 
    {
 
        return BigEndian;
 
    }
 
}
src/endiannessbox.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef ENDIANNESSBOX_H
 
#define ENDIANNESSBOX_H
 

	
 
#include <QGroupBox>
 

	
 
namespace Ui {
 
class EndiannessBox;
 
}
 

	
 
enum Endianness
 
{
 
    LittleEndian,
 
    BigEndian
 
};
 

	
 
class EndiannessBox : public QGroupBox
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit EndiannessBox(QWidget *parent = 0);
 
    ~EndiannessBox();
 

	
 
    Endianness currentSelection(); ///< currently selected endianness
 

	
 
signals:
 
    /// Signaled when endianness selection is changed
 
    void selectionChanged(Endianness endianness);
 

	
 
private:
 
    Ui::EndiannessBox *ui;
 
};
 

	
 
#endif // ENDIANNESSBOX_H
src/endiannessbox.ui
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ui version="4.0">
 
 <class>EndiannessBox</class>
 
 <widget class="QGroupBox" name="EndiannessBox">
 
  <property name="geometry">
 
   <rect>
 
    <x>0</x>
 
    <y>0</y>
 
    <width>131</width>
 
    <height>86</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
   <string>GroupBox</string>
 
  </property>
 
  <property name="title">
 
   <string>Byte Order:</string>
 
  </property>
 
  <layout class="QVBoxLayout" name="verticalLayout">
 
   <item>
 
    <widget class="QRadioButton" name="rbLittleE">
 
     <property name="toolTip">
 
      <string>least significant byte first</string>
 
     </property>
 
     <property name="text">
 
      <string>Little Endian</string>
 
     </property>
 
     <property name="checked">
 
      <bool>true</bool>
 
     </property>
 
    </widget>
 
   </item>
 
   <item>
 
    <widget class="QRadioButton" name="rbBigE">
 
     <property name="toolTip">
 
      <string>most significant byte first</string>
 
     </property>
 
     <property name="text">
 
      <string>Big Endian</string>
 
     </property>
 
    </widget>
 
   </item>
 
  </layout>
 
 </widget>
 
 <resources/>
 
 <connections/>
 
</ui>
src/numberformatbox.cpp
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "numberformatbox.h"
 
#include "ui_numberformatbox.h"
 

	
 
NumberFormatBox::NumberFormatBox(QWidget *parent) :
 
    QGroupBox(parent),
 
    ui(new Ui::NumberFormatBox)
 
{
 
    ui->setupUi(this);
 

	
 
    // setup buttons
 
    buttonGroup.addButton(ui->rbUint8,  NumberFormat_uint8);
 
    buttonGroup.addButton(ui->rbUint16, NumberFormat_uint16);
 
    buttonGroup.addButton(ui->rbUint32, NumberFormat_uint32);
 
    buttonGroup.addButton(ui->rbInt8,   NumberFormat_int8);
 
    buttonGroup.addButton(ui->rbInt16,  NumberFormat_int16);
 
    buttonGroup.addButton(ui->rbInt32,  NumberFormat_int32);
 
    buttonGroup.addButton(ui->rbFloat,  NumberFormat_float);
 

	
 
    QObject::connect(
 
        &buttonGroup, SIGNAL(buttonToggled(int, bool)),
 
        this, SLOT(onButtonToggled(int, bool)));
 
}
 

	
 
NumberFormatBox::~NumberFormatBox()
 
{
 
    delete ui;
 
}
 

	
 
void NumberFormatBox::onButtonToggled(int numberFormatId, bool checked)
 
{
 
    if (checked) emit selectionChanged((NumberFormat) numberFormatId);
 
}
 

	
 
NumberFormat NumberFormatBox::currentSelection()
 
{
 
    return (NumberFormat) buttonGroup.checkedId();
 
}
src/numberformatbox.h
Show inline comments
 
new file 100644
 
/*
 
  Copyright © 2016 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot 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 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot 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 serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#ifndef NUMBERFORMATBOX_H
 
#define NUMBERFORMATBOX_H
 

	
 
#include <QGroupBox>
 
#include <QButtonGroup>
 

	
 
namespace Ui {
 
class NumberFormatBox;
 
}
 

	
 
enum NumberFormat
 
{
 
    NumberFormat_uint8,
 
    NumberFormat_uint16,
 
    NumberFormat_uint32,
 
    NumberFormat_int8,
 
    NumberFormat_int16,
 
    NumberFormat_int32,
 
    NumberFormat_float,
 
};
 

	
 
class NumberFormatBox : public QGroupBox
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit NumberFormatBox(QWidget *parent = 0);
 
    ~NumberFormatBox();
 

	
 
    NumberFormat currentSelection(); ///< returns the currently selected number format
 

	
 
signals:
 
    /// Signaled when number format selection is changed
 
    void selectionChanged(NumberFormat numberFormat);
 

	
 
private:
 
    Ui::NumberFormatBox *ui;
 
    QButtonGroup buttonGroup;
 

	
 
private slots:
 
    void onButtonToggled(int numberFormatId, bool checked);
 
};
 

	
 
#endif // NUMBERFORMATBOX_H
src/numberformatbox.ui
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ui version="4.0">
 
 <class>NumberFormatBox</class>
 
 <widget class="QGroupBox" name="NumberFormatBox">
 
  <property name="geometry">
 
   <rect>
 
    <x>0</x>
 
    <y>0</y>
 
    <width>158</width>
 
    <height>142</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
   <string>GroupBox</string>
 
  </property>
 
  <property name="title">
 
   <string>Number Format:</string>
 
  </property>
 
  <layout class="QGridLayout" name="gridLayout">
 
   <item row="0" column="0">
 
    <widget class="QRadioButton" name="rbUint8">
 
     <property name="toolTip">
 
      <string>unsigned 1 byte integer</string>
 
     </property>
 
     <property name="text">
 
      <string>uint8</string>
 
     </property>
 
     <property name="checked">
 
      <bool>true</bool>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="0" column="1">
 
    <widget class="QRadioButton" name="rbInt8">
 
     <property name="toolTip">
 
      <string>signed 1 byte integer</string>
 
     </property>
 
     <property name="text">
 
      <string>int8</string>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="1" column="0">
 
    <widget class="QRadioButton" name="rbUint16">
 
     <property name="toolTip">
 
      <string>unsigned 2 bytes integer</string>
 
     </property>
 
     <property name="text">
 
      <string>uint16</string>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="1" column="1">
 
    <widget class="QRadioButton" name="rbInt16">
 
     <property name="toolTip">
 
      <string>signed 2 bytes integer</string>
 
     </property>
 
     <property name="text">
 
      <string>int16</string>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="2" column="0">
 
    <widget class="QRadioButton" name="rbUint32">
 
     <property name="toolTip">
 
      <string>unsigned 4 bytes integer</string>
 
     </property>
 
     <property name="text">
 
      <string>uint32</string>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="2" column="1">
 
    <widget class="QRadioButton" name="rbInt32">
 
     <property name="toolTip">
 
      <string>signed 4 bytes integer</string>
 
     </property>
 
     <property name="text">
 
      <string>int32</string>
 
     </property>
 
    </widget>
 
   </item>
 
   <item row="3" column="0">
 
    <widget class="QRadioButton" name="rbFloat">
 
     <property name="toolTip">
 
      <string>4 bytes floating point number</string>
 
     </property>
 
     <property name="text">
 
      <string>float</string>
 
     </property>
 
    </widget>
 
   </item>
 
  </layout>
 
 </widget>
 
 <resources/>
 
 <connections/>
 
</ui>
0 comments (0 inline, 0 general)