Implemented new basic channel settings dialog instead of widget inside rollup

pull/60/head
f4exb 2017-08-24 02:05:48 +02:00
rodzic e2ce645c74
commit 01eed29a6f
10 zmienionych plików z 310 dodań i 67 usunięć

Wyświetl plik

@ -140,6 +140,7 @@ set(sdrbase_SOURCES
sdrbase/gui/aboutdialog.cpp
sdrbase/gui/addpresetdialog.cpp
sdrbase/gui/basicchannelsettingswidget.cpp
sdrbase/gui/basicchannelsettingsdialog.cpp
sdrbase/gui/buttonswitch.cpp
sdrbase/gui/channelwindow.cpp
sdrbase/gui/clickablelabel.cpp
@ -261,6 +262,7 @@ set(sdrbase_HEADERS
sdrbase/gui/aboutdialog.h
sdrbase/gui/addpresetdialog.h
sdrbase/gui/basicchannelsettingswidget.h
sdrbase/gui/basicchannelsettingsdialog.h
sdrbase/gui/buttonswitch.h
sdrbase/gui/channelwindow.h
sdrbase/gui/colormapper.h
@ -329,6 +331,7 @@ set(sdrbase_FORMS
sdrbase/gui/aboutdialog.ui
sdrbase/gui/addpresetdialog.ui
sdrbase/gui/basicchannelsettingswidget.ui
sdrbase/gui/basicchannelsettingsdialog.ui
sdrbase/gui/cwkeyergui.ui
sdrbase/gui/glscopegui.ui
sdrbase/gui/glscopenggui.ui

Wyświetl plik

@ -30,7 +30,7 @@
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "gui/basicchannelsettingsdialog.h"
#include "dsp/dspengine.h"
#include "mainwindow.h"
@ -289,21 +289,12 @@ void DSDDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool r
*/
}
void DSDDemodGUI::onMenuDoubleClicked()
void DSDDemodGUI::onMenuDialogCalled(const QPoint &p)
{
if (!m_basicSettingsShown)
{
m_basicSettingsShown = true;
m_bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
m_bcsw->show();
}
else
{
m_basicSettingsShown = false;
m_bcsw->hide();
delete m_bcsw;
m_bcsw = 0;
}
//qDebug("DSDDemodGUI::onMenuDialogCalled: x: %d y: %d", p.x(), p.y());
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.move(p);
dialog.exec();
}
DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) :
@ -312,7 +303,6 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
m_pluginAPI(pluginAPI),
m_deviceAPI(deviceAPI),
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true),
m_signalFormat(signalFormatNone),
m_enableCosineFiltering(false),
@ -321,14 +311,13 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
m_slot2On(false),
m_tdmaStereo(false),
m_squelchOpen(false),
m_tickCount(0),
m_bcsw(0)
m_tickCount(0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_scopeVis = new ScopeVis(ui->glScope);
m_dsdDemod = new DSDDemod(m_scopeVis);
@ -353,6 +342,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setTitle(windowTitle());
m_channelMarker.setColor(Qt::cyan);
m_channelMarker.setBandwidth(10000);
m_channelMarker.setCenterFrequency(0);
@ -372,7 +362,6 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
DSDDemodGUI::~DSDDemodGUI()
{
if (m_bcsw) delete m_bcsw;
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;

Wyświetl plik

@ -28,7 +28,6 @@
class PluginAPI;
class DeviceSourceAPI;
class BasicChannelSettingsWidget;
class ThreadedBasebandSampleSink;
class DownChannelizer;
@ -78,7 +77,7 @@ private slots:
void on_audioMute_toggled(bool checked);
void on_symbolPLLLock_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void onMenuDialogCalled(const QPoint& p);
void tick();
private:
@ -95,7 +94,6 @@ private:
PluginAPI* m_pluginAPI;
DeviceSourceAPI* m_deviceAPI;
ChannelMarker m_channelMarker;
bool m_basicSettingsShown;
bool m_doApplySettings;
char m_formatStatusText[82+1]; //!< Fixed signal format dependent status text
SignalFormat m_signalFormat;
@ -117,8 +115,6 @@ private:
float m_myLatitude;
float m_myLongitude;
BasicChannelSettingsWidget *m_bcsw;
explicit DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent = NULL);
virtual ~DSDDemodGUI();

Wyświetl plik

@ -21,7 +21,7 @@
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "gui/basicchannelsettingsdialog.h"
#include "plugin/pluginapi.h"
#include "mainwindow.h"
@ -226,13 +226,11 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
m_inPowerAvg(4, 1e-10),
m_tickCount(0),
m_channelMarker(this),
m_basicSettingsShown(false),
m_bcsw(0),
m_doApplySettings(true)
{
ui->setupUi(this);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
@ -279,7 +277,6 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
UDPSinkGUI::~UDPSinkGUI()
{
if (m_bcsw) delete m_bcsw;
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
delete m_threadedChannelizer;
@ -543,21 +540,11 @@ void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
}
}
void UDPSinkGUI::onMenuDoubleClicked()
void UDPSinkGUI::onMenuDialogCalled(const QPoint &p)
{
if (!m_basicSettingsShown)
{
m_basicSettingsShown = true;
m_bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
m_bcsw->show();
}
else
{
m_basicSettingsShown = false;
m_bcsw->hide();
delete m_bcsw;
m_bcsw = 0;
}
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.move(p);
dialog.exec();
}
void UDPSinkGUI::leaveEvent(QEvent*)

Wyświetl plik

@ -31,7 +31,6 @@ class ThreadedBasebandSampleSource;
class UpChannelizer;
class UDPSink;
class SpectrumVis;
class BasicChannelSettingsWidget;
namespace Ui {
class UDPSinkGUI;
@ -68,7 +67,7 @@ private slots:
void on_amModPercent_textEdited(const QString& arg1);
void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void onMenuDialogCalled(const QPoint& p);
void on_gain_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_squelchGate_valueChanged(int value);
@ -96,8 +95,6 @@ private:
int m_fmDeviation;
QString m_udpAddress;
int m_udpPort;
bool m_basicSettingsShown;
BasicChannelSettingsWidget *m_bcsw;
bool m_doApplySettings;
explicit UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent = NULL);

Wyświetl plik

@ -0,0 +1,68 @@
#include <QColorDialog>
#include "dsp/channelmarker.h"
#include "basicchannelsettingsdialog.h"
#include "ui_basicchannelsettingsdialog.h"
BasicChannelSettingsDialog::BasicChannelSettingsDialog(ChannelMarker* marker, QWidget *parent) :
QDialog(parent),
ui(new Ui::BasicChannelSettingsDialog),
m_channelMarker(marker)
{
ui->setupUi(this);
ui->title->setText(m_channelMarker->getTitle());
m_color = m_channelMarker->getColor();
ui->udpAddress->setText(m_channelMarker->getUDPAddress());
ui->udpPort->setText(QString("%1").arg(m_channelMarker->getUDPPort()));
paintColor();
}
BasicChannelSettingsDialog::~BasicChannelSettingsDialog()
{
delete ui;
}
void BasicChannelSettingsDialog::paintColor()
{
QPixmap pm(24, 24);
pm.fill(m_color);
ui->colorBtn->setIcon(pm);
ui->colorText->setText(tr("#%1%2%3")
.arg(m_color.red(), 2, 16, QChar('0'))
.arg(m_color.green(), 2, 16, QChar('0'))
.arg(m_color.blue(), 2, 16, QChar('0')));
}
void BasicChannelSettingsDialog::on_colorBtn_clicked()
{
QColor c = m_color;
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"));
if(c.isValid()) {
m_color = c;
paintColor();
}
}
void BasicChannelSettingsDialog::accept()
{
m_channelMarker->setTitle(ui->title->text());
if(m_color.isValid()) {
m_channelMarker->setColor(m_color);
}
m_channelMarker->setUDPAddress(ui->udpAddress->text());
bool ok;
int udpPort = ui->udpPort->text().toInt(&ok);
if((!ok) || (udpPort < 1024) || (udpPort > 65535))
{
udpPort = 9999;
}
m_channelMarker->setUDPPort(udpPort);
QDialog::accept();
}

Wyświetl plik

@ -0,0 +1,32 @@
#ifndef BASICCHANNELSETTINGSDIALOG_H
#define BASICCHANNELSETTINGSDIALOG_H
#include <QDialog>
namespace Ui {
class BasicChannelSettingsDialog;
}
class ChannelMarker;
class BasicChannelSettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit BasicChannelSettingsDialog(ChannelMarker* marker, QWidget *parent = 0);
~BasicChannelSettingsDialog();
private slots:
void on_colorBtn_clicked();
void accept();
private:
Ui::BasicChannelSettingsDialog *ui;
ChannelMarker* m_channelMarker;
QColor m_color;
void paintColor();
};
#endif // BASICCHANNELSETTINGSDIALOG_H

Wyświetl plik

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BasicChannelSettingsDialog</class>
<widget class="QDialog" name="BasicChannelSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>131</height>
</rect>
</property>
<property name="windowTitle">
<string>Basic channel settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="titleLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="title">
<property name="toolTip">
<string>Channel marker title</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="colorLayout">
<item>
<widget class="QLabel" name="colorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="colorBtn">
<property name="toolTip">
<string>Channel marker color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="colorText">
<property name="text">
<string>#ff0000</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="udpAddressLayout">
<item>
<widget class="QLabel" name="udpAddressLabel">
<property name="text">
<string>Addr</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="udpAddress">
<property name="toolTip">
<string>UDP address</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="udpPortLabel">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="udpPort">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>UDP port</string>
</property>
<property name="inputMask">
<string>00000</string>
</property>
<property name="text">
<string>9999</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>BasicChannelSettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>BasicChannelSettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Wyświetl plik

@ -100,23 +100,33 @@ int RollupWidget::arrangeRollups()
QFontMetrics fm(font());
int pos = fm.height() + 4;
for(int i = 0; i < children().count(); ++i) {
for(int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if(r != NULL) {
if(r != NULL)
{
pos += fm.height() + 2;
if(!r->isHidden()) {
if(!r->isHidden() && (r->windowTitle() != "Basic channel settings"))
{
r->move(2, pos + 3);
int h = 0;
if(r->hasHeightForWidth())
if(r->hasHeightForWidth()) {
h = r->heightForWidth(width() - 4);
else h = r->sizeHint().height();
} else {
h = r->sizeHint().height();
}
r->resize(width() - 4, h);
pos += r->height() + 5;
}
}
}
setMinimumHeight(pos);
setMaximumHeight(pos);
return pos;
}
@ -205,6 +215,8 @@ void RollupWidget::paintEvent(QPaintEvent*)
int RollupWidget::paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame)
{
if (rollup->windowTitle() == "Basic channel settings") return 0;
QFontMetrics fm(font());
int height = 1;
@ -270,7 +282,7 @@ void RollupWidget::mousePressEvent(QMouseEvent* event)
// menu box left
if(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
emit customContextMenuRequested(event->pos());
emit customContextMenuRequested(event->globalPos());
return;
}
@ -305,17 +317,6 @@ void RollupWidget::mousePressEvent(QMouseEvent* event)
}
}
void RollupWidget::mouseDoubleClickEvent(QMouseEvent* event)
{
QFontMetrics fm(font());
// menu box left
if(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
emit menuDoubleClickEvent();
return;
}
}
bool RollupWidget::event(QEvent* event)
{
if(event->type() == QEvent::ChildAdded) {

Wyświetl plik

@ -17,7 +17,6 @@ public:
signals:
void widgetRolled(QWidget* widget, bool rollDown);
void menuDoubleClickEvent();
protected:
enum {
@ -33,7 +32,6 @@ protected:
void resizeEvent(QResizeEvent* size);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
bool event(QEvent* event);
bool eventFilter(QObject* object, QEvent* event);