From 045652f5cb8c6b6e95f6af497d3106035d6085dd Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 5 Nov 2017 05:50:01 +0100 Subject: [PATCH] Added exernal clock dialog and button and implemented it in LimeSDR plugins GUIs --- .../limesdroutput/limesdroutputgui.ui | 9 +- .../limesdrinput/limesdrinputgui.ui | 9 +- sdrgui/CMakeLists.txt | 5 + sdrgui/gui/externalclockbutton.cpp | 55 ++++++ sdrgui/gui/externalclockbutton.h | 57 ++++++ sdrgui/gui/externalclockdialog.cpp | 49 +++++ sdrgui/gui/externalclockdialog.h | 48 +++++ sdrgui/gui/externalclockdialog.ui | 168 ++++++++++++++++++ sdrgui/sdrgui.pro | 5 + 9 files changed, 401 insertions(+), 4 deletions(-) create mode 100644 sdrgui/gui/externalclockbutton.cpp create mode 100644 sdrgui/gui/externalclockbutton.h create mode 100644 sdrgui/gui/externalclockdialog.cpp create mode 100644 sdrgui/gui/externalclockdialog.h create mode 100644 sdrgui/gui/externalclockdialog.ui diff --git a/plugins/samplesink/limesdroutput/limesdroutputgui.ui b/plugins/samplesink/limesdroutput/limesdroutputgui.ui index ca347eea3..487855139 100644 --- a/plugins/samplesink/limesdroutput/limesdroutputgui.ui +++ b/plugins/samplesink/limesdroutput/limesdroutputgui.ui @@ -281,9 +281,9 @@ - + - External clock source selection + External clock dialog @@ -933,6 +933,11 @@ QToolTip{background-color: white; color: black;} QToolButton
gui/buttonswitch.h
+ + ExternalClockButton + QToolButton +
gui/externalclockbutton.h
+
diff --git a/plugins/samplesource/limesdrinput/limesdrinputgui.ui b/plugins/samplesource/limesdrinput/limesdrinputgui.ui index 69170950d..80c5b34ef 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputgui.ui +++ b/plugins/samplesource/limesdrinput/limesdrinputgui.ui @@ -326,9 +326,9 @@
- + - External clock source selection + External clock dialog @@ -1161,6 +1161,11 @@ QToolTip{background-color: white; color: black;} QToolButton
gui/buttonswitch.h
+ + ExternalClockButton + QToolButton +
gui/externalclockbutton.h
+
diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index efb8149df..e9e8e4846 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -11,6 +11,8 @@ set(sdrgui_SOURCES gui/clickablelabel.cpp gui/colormapper.cpp gui/cwkeyergui.cpp + gui/externalclockbutton.cpp + gui/externalclockdialog.cpp gui/glscope.cpp gui/glscopegui.cpp gui/glscopeng.cpp @@ -57,6 +59,8 @@ set(sdrgui_HEADERS gui/channelwindow.h gui/colormapper.h gui/cwkeyergui.h + gui/externalclockbutton.h + gui/externalclockdialog.h gui/glscope.h gui/glscopegui.h gui/glscopeng.h @@ -106,6 +110,7 @@ set(sdrgui_FORMS gui/basicchannelsettingswidget.ui gui/basicchannelsettingsdialog.ui gui/cwkeyergui.ui + gui/externalclockdialog.ui gui/glscopegui.ui gui/glscopenggui.ui gui/glscopemultigui.ui diff --git a/sdrgui/gui/externalclockbutton.cpp b/sdrgui/gui/externalclockbutton.cpp new file mode 100644 index 000000000..f57ab0b40 --- /dev/null +++ b/sdrgui/gui/externalclockbutton.cpp @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// OpenGL interface modernization. // +// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html // +// // +// 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 as version 3 of the License, or // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "externalclockdialog.h" +#include "externalclockbutton.h" + +ExternalClockButton::ExternalClockButton(QWidget* parent) : + QPushButton(parent), + m_externalClockFrequency(0), + m_externalClockFrequencyActive(false) +{ + setObjectName("ExternalClockButton"); + connect(this, SIGNAL(clicked()), this, SLOT(onClicked())); +} + +void ExternalClockButton::onClicked() +{ + ExternalClockDialog externalClockDialog(m_externalClockFrequency, m_externalClockFrequencyActive, this); + externalClockDialog.exec(); + updateState(); +} + +void ExternalClockButton::updateState() +{ + setToolTip(tr("External clock dialog. External clock frequency %1 MHz %2") + .arg(m_externalClockFrequency/1000000.0) + .arg(m_externalClockFrequencyActive ? "enabled" : "disabled")); + + if(m_externalClockFrequencyActive) + { + setStyleSheet("ExternalClockButton { background:rgb(128, 70, 0); }"); + } + else + { + setStyleSheet("ExternalClockButton { background:rgb(48, 48, 48); }"); + } + +} diff --git a/sdrgui/gui/externalclockbutton.h b/sdrgui/gui/externalclockbutton.h new file mode 100644 index 000000000..d83714749 --- /dev/null +++ b/sdrgui/gui/externalclockbutton.h @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// OpenGL interface modernization. // +// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html // +// // +// 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 as version 3 of the License, or // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_GUI_EXTERNALCLOCKBUTTON_H_ +#define SDRBASE_GUI_EXTERNALCLOCKBUTTON_H_ + +#include + +class ExternalClockButton : public QPushButton { + Q_OBJECT + +public: + ExternalClockButton(QWidget* parent = 0); + qint64 getExternalClockFrequency() const { return m_externalClockFrequency; } + bool getExternalClockFrequencyActive() const { return m_externalClockFrequencyActive; } + + void setExternalClockFrequency(qint64 deltaFrequency) + { + m_externalClockFrequency = deltaFrequency; + updateState(); + } + + void setExternalcClockFrequencyActive(bool active) + { + m_externalClockFrequencyActive = active; + updateState(); + } + +private slots: + void onClicked(); + +private: + qint64 m_externalClockFrequency; + bool m_externalClockFrequencyActive; + + void updateState(); +}; + + +#endif /* SDRBASE_GUI_EXTERNALCLOCKBUTTON_H_ */ diff --git a/sdrgui/gui/externalclockdialog.cpp b/sdrgui/gui/externalclockdialog.cpp new file mode 100644 index 000000000..34fddb3c9 --- /dev/null +++ b/sdrgui/gui/externalclockdialog.cpp @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// OpenGL interface modernization. // +// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html // +// // +// 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 as version 3 of the License, or // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "externalclockdialog.h" +#include "ui_externalclockdialog.h" + + +ExternalClockDialog::ExternalClockDialog(qint64& externalClockFrequency, bool& externalClockFrequencyActive, QWidget* parent) : + QDialog(parent), + ui(new Ui::ExternalClockDialog), + m_externalClockFrequency(externalClockFrequency), + m_externalClockFrequencyActive(externalClockFrequencyActive) +{ + ui->setupUi(this); + ui->externalClockFrequencyLabel->setText("f"); + ui->externalClockFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); + ui->externalClockFrequency->setValueRange(true, 9, 5000000L, 300000000L); + ui->externalClockFrequency->setValue(externalClockFrequency); + ui->externalClockFrequencyActive->setChecked(externalClockFrequencyActive); +} + +ExternalClockDialog::~ExternalClockDialog() +{ + delete ui; +} + +void ExternalClockDialog::accept() +{ + m_externalClockFrequency = ui->externalClockFrequency->getValueNew(); + m_externalClockFrequencyActive = ui->externalClockFrequencyActive->isChecked(); + QDialog::accept(); +} diff --git a/sdrgui/gui/externalclockdialog.h b/sdrgui/gui/externalclockdialog.h new file mode 100644 index 000000000..448bc4de0 --- /dev/null +++ b/sdrgui/gui/externalclockdialog.h @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// OpenGL interface modernization. // +// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html // +// // +// 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 as version 3 of the License, or // +// // +// 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 V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_GUI_EXTERNALCLOCKDIALOG_H_ +#define SDRBASE_GUI_EXTERNALCLOCKDIALOG_H_ + +#include + +namespace Ui { + class ExternalClockDialog; +} + +class ExternalClockDialog : public QDialog { + Q_OBJECT + +public: + explicit ExternalClockDialog(qint64& externalClockFrequency, bool& externalClockFrequencyActive, QWidget* parent = 0); + ~ExternalClockDialog(); + +private: + Ui::ExternalClockDialog* ui; + qint64& m_externalClockFrequency; + bool& m_externalClockFrequencyActive; + +private slots: + void accept(); +}; + + + +#endif /* SDRBASE_GUI_EXTERNALCLOCKDIALOG_H_ */ diff --git a/sdrgui/gui/externalclockdialog.ui b/sdrgui/gui/externalclockdialog.ui new file mode 100644 index 000000000..9efa481d3 --- /dev/null +++ b/sdrgui/gui/externalclockdialog.ui @@ -0,0 +1,168 @@ + + + ExternalClockDialog + + + + 0 + 0 + 324 + 81 + + + + + Sans Serif + 9 + + + + External Clock + + + + + + + + + + f + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + + + External clock frequency (Hz) + + + + + + + Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Enable or disable external clock + + + + + + + :/checkmark.png:/checkmark.png + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+
+ + terminateBox + + + + + + + terminateBox + accepted() + ExternalClockDialog + accept() + + + 257 + 194 + + + 157 + 203 + + + + + terminateBox + rejected() + ExternalClockDialog + reject() + + + 314 + 194 + + + 286 + 203 + + + + +
diff --git a/sdrgui/sdrgui.pro b/sdrgui/sdrgui.pro index 8a060c1e0..b2f52709f 100644 --- a/sdrgui/sdrgui.pro +++ b/sdrgui/sdrgui.pro @@ -49,6 +49,8 @@ SOURCES += mainwindow.cpp\ gui/clickablelabel.cpp\ gui/colormapper.cpp\ gui/cwkeyergui.cpp\ + gui/externalclockbutton.cpp\ + gui/externalclockdialog.cpp\ gui/glscope.cpp\ gui/glscopegui.cpp\ gui/glscopeng.cpp\ @@ -92,6 +94,8 @@ HEADERS += mainwindow.h\ gui/clickablelabel.h\ gui/colormapper.h\ gui/cwkeyergui.h\ + gui/externalclockbutton.h\ + gui/externalclockdialog.h\ gui/glscope.h\ gui/glscopegui.h\ gui/glscopeng.h\ @@ -122,6 +126,7 @@ FORMS += mainwindow.ui\ gui/basicchannelsettingswidget.ui\ gui/basicchannelsettingsdialog.ui\ gui/cwkeyergui.ui\ + gui/externalclockdialog.ui\ gui/audiodialog.ui\ gui/glscopegui.ui\ gui/glscopenggui.ui\