From: Joel Holdsworth Date: Mon, 31 Dec 2012 08:46:45 +0000 (+0000) Subject: Added empty decoder dialog X-Git-Tag: pulseview-0.2.0~318 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c8c28626464eb310255dacf542f2501cf2f74d38;p=pulseview.git Added empty decoder dialog --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 724adcd6..58365a10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ set(pulseview_SOURCES pv/data/snapshot.cpp pv/dialogs/about.cpp pv/dialogs/connect.cpp + pv/dialogs/decoder.cpp pv/dialogs/deviceoptions.cpp pv/prop/bool.cpp pv/prop/double.cpp diff --git a/pv/dialogs/decoder.cpp b/pv/dialogs/decoder.cpp new file mode 100644 index 00000000..01cec843 --- /dev/null +++ b/pv/dialogs/decoder.cpp @@ -0,0 +1,54 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * 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 "decoder.h" + +extern "C" { +/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */ +#define __STDC_FORMAT_MACROS +#include +#include +} + +namespace pv { +namespace dialogs { + +Decoder::Decoder(QWidget *parent) : + QDialog(parent), + _layout(this), + _form(this), + _form_layout(&_form), + _button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, + Qt::Horizontal, this) +{ + setWindowTitle(tr("Configure Decoder")); + + connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept())); + connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject())); + + _form.setLayout(&_form_layout); + + setLayout(&_layout); + _layout.addWidget(&_form); + _layout.addWidget(&_button_box); +} + +} // namespace dialogs +} // namespace pv diff --git a/pv/dialogs/decoder.h b/pv/dialogs/decoder.h new file mode 100644 index 00000000..9d61202f --- /dev/null +++ b/pv/dialogs/decoder.h @@ -0,0 +1,50 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * 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_DECODER_H +#define PULSEVIEW_PV_DECODER_H + +#include +#include +#include +#include +#include + +namespace pv { +namespace dialogs { + +class Decoder : public QDialog +{ +public: + Decoder(QWidget *parent); + +private: + QVBoxLayout _layout; + + QWidget _form; + QFormLayout _form_layout; + + QDialogButtonBox _button_box; +}; + +} // namespace dialogs +} // namespace pv + +#endif // PULSEVIEW_PV_DECODER_H diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 02df0ad5..9873541d 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -39,6 +39,7 @@ #include "devicemanager.h" #include "dialogs/about.h" #include "dialogs/connect.h" +#include "dialogs/decoder.h" #include "toolbars/contextbar.h" #include "toolbars/samplingbar.h" #include "view/view.h" @@ -382,7 +383,13 @@ void MainWindow::device_selected() void MainWindow::add_decoder(QObject *action) { - (void)action; + assert(action); + srd_decoder *const dec = + (srd_decoder*)((QAction*)action)->data().value(); + assert(dec); + + dialogs::Decoder dlg(this); + dlg.exec(); } void MainWindow::run_stop()