@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QGlobalStatic> |
||||
|
||||
#include "util/messagequeue.h" |
||||
|
||||
#include "messagepipeslegacygcworker.h" |
||||
#include "messagepipeslegacy.h" |
||||
#include "pipeendpoint.h" |
||||
|
||||
MessagePipesLegacy::MessagePipesLegacy() |
||||
{ |
||||
m_gcWorker = new MessagePipesLegacyGCWorker(); |
||||
m_gcWorker->setC2FRegistrations( |
||||
m_registrations.getMutex(), |
||||
m_registrations.getElements(), |
||||
m_registrations.getConsumers() |
||||
); |
||||
m_gcWorker->moveToThread(&m_gcThread); |
||||
startGC(); |
||||
} |
||||
|
||||
MessagePipesLegacy::~MessagePipesLegacy() |
||||
{ |
||||
if (m_gcWorker->isRunning()) { |
||||
stopGC(); |
||||
} |
||||
} |
||||
|
||||
MessageQueue *MessagePipesLegacy::registerChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type) |
||||
{ |
||||
qDebug("MessagePipesLegacy::registerChannelToFeature: %p %p %s", source, dest, qPrintable(type)); |
||||
return m_registrations.registerProducerToConsumer(source, dest, type); |
||||
} |
||||
|
||||
MessageQueue *MessagePipesLegacy::unregisterChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type) |
||||
{ |
||||
qDebug("MessagePipesLegacy::unregisterChannelToFeature: %p %p %s", source, dest, qPrintable(type)); |
||||
MessageQueue *messageQueue = m_registrations.unregisterProducerToConsumer(source, dest, type); |
||||
m_gcWorker->addMessageQueueToDelete(messageQueue); |
||||
return messageQueue; |
||||
} |
||||
|
||||
QList<MessageQueue*>* MessagePipesLegacy::getMessageQueues(const PipeEndPoint *source, const QString& type) |
||||
{ |
||||
//qDebug("MessagePipesLegacy::getMessageQueues: %p %s", source, qPrintable(type));
|
||||
return m_registrations.getElements(source, type); |
||||
} |
||||
|
||||
void MessagePipesLegacy::startGC() |
||||
{ |
||||
qDebug("MessagePipesLegacy::startGC"); |
||||
m_gcWorker->startWork(); |
||||
m_gcThread.start(); |
||||
} |
||||
|
||||
void MessagePipesLegacy::stopGC() |
||||
{ |
||||
qDebug("MessagePipesLegacy::stopGC"); |
||||
m_gcWorker->stopWork(); |
||||
m_gcThread.quit(); |
||||
m_gcThread.wait(); |
||||
} |
||||
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_ |
||||
#define SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_ |
||||
|
||||
#include <QObject> |
||||
#include <QHash> |
||||
#include <QMap> |
||||
#include <QMutex> |
||||
#include <QThread> |
||||
|
||||
#include "export.h" |
||||
|
||||
#include "messagepipeslegacycommon.h" |
||||
#include "elementpipesregistrations.h" |
||||
|
||||
class PipeEndPoint; |
||||
class MessagePipesLegacyGCWorker; |
||||
class MessageQueue; |
||||
|
||||
class SDRBASE_API MessagePipesLegacy : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
MessagePipesLegacy(); |
||||
MessagePipesLegacy(const MessagePipesLegacy&) = delete; |
||||
MessagePipesLegacy& operator=(const MessagePipesLegacy&) = delete; |
||||
~MessagePipesLegacy(); |
||||
|
||||
// FIXME: Names of these functions should probably change, as we now support channel or feature at either end
|
||||
MessageQueue *registerChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type); |
||||
MessageQueue *unregisterChannelToFeature(const PipeEndPoint *source, PipeEndPoint *dest, const QString& type); |
||||
QList<MessageQueue*>* getMessageQueues(const PipeEndPoint *source, const QString& type); |
||||
|
||||
private: |
||||
ElementPipesRegistrations<PipeEndPoint, PipeEndPoint, MessageQueue> m_registrations; |
||||
QThread m_gcThread; //!< Garbage collector thread
|
||||
MessagePipesLegacyGCWorker *m_gcWorker; //!< Garbage collector
|
||||
|
||||
void startGC(); //!< Start garbage collector
|
||||
void stopGC(); //!< Stop garbage collector
|
||||
}; |
||||
|
||||
#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACY_H_
|
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "messagepipeslegacycommon.h" |
||||
|
||||
MESSAGE_CLASS_DEFINITION(MessagePipesLegacyCommon::MsgReportChannelDeleted, Message) |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_ |
||||
#define SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_ |
||||
|
||||
#include <QHash> |
||||
#include <QMap> |
||||
#include <QMutex> |
||||
|
||||
#include "export.h" |
||||
#include "util/message.h" |
||||
#include "elementpipescommon.h" |
||||
|
||||
class PipeEndPoint; |
||||
class MessageQueue; |
||||
|
||||
class SDRBASE_API MessagePipesLegacyCommon |
||||
{ |
||||
public: |
||||
typedef ElementPipesCommon::RegistrationKey<PipeEndPoint> ChannelRegistrationKey; |
||||
|
||||
/** Send this message to stakeholders when the garbage collector finds that a channel was deleted */ |
||||
class SDRBASE_API MsgReportChannelDeleted : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
const MessageQueue *getMessageQueue() const { return m_messageQueue; } |
||||
const ChannelRegistrationKey& getChannelRegistrationKey() const { return m_channelRegistrationKey; } |
||||
|
||||
static MsgReportChannelDeleted* create(const MessageQueue *messageQueue, const ChannelRegistrationKey& channelRegistrationKey) { |
||||
return new MsgReportChannelDeleted(messageQueue, channelRegistrationKey); |
||||
} |
||||
|
||||
private: |
||||
const MessageQueue *m_messageQueue; |
||||
ChannelRegistrationKey m_channelRegistrationKey; |
||||
|
||||
MsgReportChannelDeleted(const MessageQueue *messageQueue, const ChannelRegistrationKey& channelRegistrationKey) : |
||||
Message(), |
||||
m_messageQueue(messageQueue), |
||||
m_channelRegistrationKey(channelRegistrationKey) |
||||
{ } |
||||
}; |
||||
}; |
||||
|
||||
#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACYCOMON_H_
|
||||
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "channel/channelapi.h" |
||||
#include "feature/feature.h" |
||||
#include "util/messagequeue.h" |
||||
#include "maincore.h" |
||||
#include "messagepipeslegacycommon.h" |
||||
#include "messagepipeslegacygcworker.h" |
||||
|
||||
bool MessagePipesLegacyGCWorker::MessagePipesGC::existsProducer(const PipeEndPoint *pipeEndPoint) |
||||
{ |
||||
return MainCore::instance()->existsChannel((const ChannelAPI *)pipeEndPoint) |
||||
|| MainCore::instance()->existsFeature((const Feature *)pipeEndPoint); |
||||
} |
||||
|
||||
bool MessagePipesLegacyGCWorker::MessagePipesGC::existsConsumer(const PipeEndPoint *pipeEndPoint) |
||||
{ |
||||
return MainCore::instance()->existsChannel((const ChannelAPI *)pipeEndPoint) |
||||
|| MainCore::instance()->existsFeature((const Feature *)pipeEndPoint); |
||||
} |
||||
|
||||
void MessagePipesLegacyGCWorker::MessagePipesGC::sendMessageToConsumer( |
||||
const MessageQueue *, |
||||
MessagePipesLegacyCommon::ChannelRegistrationKey, |
||||
PipeEndPoint *) |
||||
{ |
||||
} |
||||
|
||||
MessagePipesLegacyGCWorker::MessagePipesLegacyGCWorker() : |
||||
m_running(false) |
||||
{} |
||||
|
||||
MessagePipesLegacyGCWorker::~MessagePipesLegacyGCWorker() |
||||
{} |
||||
|
||||
void MessagePipesLegacyGCWorker::startWork() |
||||
{ |
||||
connect(&m_gcTimer, SIGNAL(timeout()), this, SLOT(processGC())); |
||||
m_gcTimer.start(10000); // collect garbage every 10s
|
||||
m_running = true; |
||||
} |
||||
|
||||
void MessagePipesLegacyGCWorker::stopWork() |
||||
{ |
||||
m_running = false; |
||||
m_gcTimer.stop(); |
||||
disconnect(&m_gcTimer, SIGNAL(timeout()), this, SLOT(processGC())); |
||||
} |
||||
|
||||
void MessagePipesLegacyGCWorker::addMessageQueueToDelete(MessageQueue *messageQueue) |
||||
{ |
||||
if (messageQueue) |
||||
{ |
||||
m_gcTimer.start(10000); // restart GC to make sure deletion is postponed
|
||||
m_messagePipesGC.addElementToDelete(messageQueue); |
||||
} |
||||
} |
||||
|
||||
void MessagePipesLegacyGCWorker::processGC() |
||||
{ |
||||
// qDebug("MessagePipesLegacyGCWorker::processGC");
|
||||
m_messagePipesGC.processGC(); |
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_ |
||||
#define SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_ |
||||
|
||||
#include <QObject> |
||||
#include <QTimer> |
||||
|
||||
#include "export.h" |
||||
|
||||
#include "messagepipeslegacycommon.h" |
||||
#include "elementpipesgc.h" |
||||
|
||||
class QMutex; |
||||
|
||||
class SDRBASE_API MessagePipesLegacyGCWorker : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
MessagePipesLegacyGCWorker(); |
||||
~MessagePipesLegacyGCWorker(); |
||||
|
||||
void setC2FRegistrations( |
||||
QMutex *c2fMutex, |
||||
QMap<MessagePipesLegacyCommon::ChannelRegistrationKey, QList<MessageQueue*>> *c2fQueues, |
||||
QMap<MessagePipesLegacyCommon::ChannelRegistrationKey, QList<PipeEndPoint*>> *c2fPipeEndPoints |
||||
) |
||||
{ |
||||
m_messagePipesGC.setRegistrations(c2fMutex, c2fQueues, c2fPipeEndPoints); |
||||
} |
||||
|
||||
void startWork(); |
||||
void stopWork(); |
||||
void addMessageQueueToDelete(MessageQueue *messageQueue); |
||||
bool isRunning() const { return m_running; } |
||||
|
||||
private: |
||||
class MessagePipesGC : public ElementPipesGC<PipeEndPoint, PipeEndPoint, MessageQueue> |
||||
{ |
||||
private: |
||||
virtual bool existsProducer(const PipeEndPoint *pipeEndPoint); |
||||
virtual bool existsConsumer(const PipeEndPoint *pipeEndPoint); |
||||
virtual void sendMessageToConsumer(const MessageQueue *messageQueue, MessagePipesLegacyCommon::ChannelRegistrationKey key, PipeEndPoint *pipeEndPoint); |
||||
}; |
||||
|
||||
MessagePipesGC m_messagePipesGC; |
||||
bool m_running; |
||||
QTimer m_gcTimer; |
||||
|
||||
private slots: |
||||
void processGC(); //!< Collect garbage
|
||||
}; |
||||
|
||||
#endif // SDRBASE_PIPES_MESSAGEPIPESLEGACYGCWORKER_H_
|
||||
@ -0,0 +1,185 @@
@@ -0,0 +1,185 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <vector> |
||||
|
||||
#include <QRegExp> |
||||
#include <QDebug> |
||||
|
||||
#include "dsp/dspengine.h" |
||||
#include "device/deviceset.h" |
||||
#include "channel/channelapi.h" |
||||
#include "feature/featureset.h" |
||||
#include "feature/feature.h" |
||||
#include "maincore.h" |
||||
|
||||
#include "pipeendpoint.h" |
||||
|
||||
MESSAGE_CLASS_DEFINITION(PipeEndPoint::MsgReportPipes, Message) |
||||
|
||||
QList<PipeEndPoint::AvailablePipeSource> PipeEndPoint::updateAvailablePipeSources(QString pipeName, QStringList pipeTypes, QStringList pipeURIs, PipeEndPoint *destination) |
||||
{ |
||||
MainCore *mainCore = MainCore::instance(); |
||||
MessagePipesLegacy& messagePipes = mainCore->getMessagePipesLegacy(); |
||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets(); |
||||
QHash<PipeEndPoint *, AvailablePipeSource> availablePipes; |
||||
|
||||
// Source is a channel
|
||||
int deviceIndex = 0; |
||||
for (std::vector<DeviceSet*>::const_iterator it = deviceSets.begin(); it != deviceSets.end(); ++it, deviceIndex++) |
||||
{ |
||||
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine; |
||||
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine; |
||||
|
||||
if (deviceSourceEngine || deviceSinkEngine) |
||||
{ |
||||
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++) |
||||
{ |
||||
ChannelAPI *channel = (*it)->getChannelAt(chi); |
||||
int i = pipeURIs.indexOf(channel->getURI()); |
||||
|
||||
if (i >= 0) |
||||
{ |
||||
if (!availablePipes.contains(channel)) |
||||
{ |
||||
MessageQueue *messageQueue = messagePipes.registerChannelToFeature(channel, destination, pipeName); |
||||
if (MainCore::instance()->existsFeature((const Feature *)destination)) |
||||
{ |
||||
// Destination is feature
|
||||
Feature *featureDest = (Feature *)destination; |
||||
QObject::connect( |
||||
messageQueue, |
||||
&MessageQueue::messageEnqueued, |
||||
featureDest, |
||||
[=](){ featureDest->handlePipeMessageQueue(messageQueue); }, |
||||
Qt::QueuedConnection |
||||
); |
||||
} |
||||
else |
||||
{ |
||||
// Destination is a channel
|
||||
// Can't use Qt::QueuedConnection because ChannelAPI isn't a QObject
|
||||
ChannelAPI *channelDest = (ChannelAPI *)destination; |
||||
QObject::connect( |
||||
messageQueue, |
||||
&MessageQueue::messageEnqueued, |
||||
[=](){ channelDest->handlePipeMessageQueue(messageQueue); } |
||||
); |
||||
} |
||||
} |
||||
|
||||
AvailablePipeSource availablePipe = |
||||
AvailablePipeSource{ |
||||
deviceSinkEngine != nullptr ? AvailablePipeSource::TX : AvailablePipeSource::RX, |
||||
deviceIndex, |
||||
chi, |
||||
channel, |
||||
pipeTypes.at(i) |
||||
}; |
||||
availablePipes[channel] = availablePipe; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Source is a feature
|
||||
std::vector<FeatureSet*>& featureSets = mainCore->getFeatureeSets(); |
||||
int featureIndex = 0; |
||||
for (std::vector<FeatureSet*>::const_iterator it = featureSets.begin(); it != featureSets.end(); ++it, featureIndex++) |
||||
{ |
||||
for (int fi = 0; fi < (*it)->getNumberOfFeatures(); fi++) |
||||
{ |
||||
Feature *feature = (*it)->getFeatureAt(fi); |
||||
int i = pipeURIs.indexOf(feature->getURI()); |
||||
|
||||
if (i >= 0) |
||||
{ |
||||
if (!availablePipes.contains(feature)) |
||||
{ |
||||
MessageQueue *messageQueue = messagePipes.registerChannelToFeature(feature, destination, pipeName); |
||||
if (MainCore::instance()->existsFeature((const Feature *)destination)) |
||||
{ |
||||
// Destination is feature
|
||||
Feature *featureDest = (Feature *)destination; |
||||
QObject::connect( |
||||
messageQueue, |
||||
&MessageQueue::messageEnqueued, |
||||
featureDest, |
||||
[=](){ featureDest->handlePipeMessageQueue(messageQueue); }, |
||||
Qt::QueuedConnection |
||||
); |
||||
} |
||||
else |
||||
{ |
||||
// Destination is a channel
|
||||
// Can't use Qt::QueuedConnection because ChannelAPI isn't a QObject
|
||||
ChannelAPI *channelDest = (ChannelAPI *)destination; |
||||
QObject::connect( |
||||
messageQueue, |
||||
&MessageQueue::messageEnqueued, |
||||
[=](){ channelDest->handlePipeMessageQueue(messageQueue); } |
||||
); |
||||
} |
||||
} |
||||
|
||||
AvailablePipeSource availablePipe = |
||||
AvailablePipeSource{ |
||||
AvailablePipeSource::Feature, |
||||
featureIndex, |
||||
fi, |
||||
feature, |
||||
pipeTypes.at(i) |
||||
}; |
||||
availablePipes[feature] = availablePipe; |
||||
} |
||||
} |
||||
} |
||||
|
||||
QList<AvailablePipeSource> availablePipeList; |
||||
QHash<PipeEndPoint*, AvailablePipeSource>::iterator it = availablePipes.begin(); |
||||
|
||||
for (; it != availablePipes.end(); ++it) { |
||||
availablePipeList.push_back(*it); |
||||
} |
||||
return availablePipeList; |
||||
} |
||||
|
||||
PipeEndPoint *PipeEndPoint::getPipeEndPoint(const QString name, const QList<AvailablePipeSource> &availablePipeSources) |
||||
{ |
||||
QRegExp re("([TRF])([0-9]+):([0-9]+) ([a-zA-Z0-9]+)"); |
||||
if (re.exactMatch(name)) |
||||
{ |
||||
QString type = re.capturedTexts()[1]; |
||||
int setIndex = re.capturedTexts()[2].toInt(); |
||||
int index = re.capturedTexts()[3].toInt(); |
||||
QString id = re.capturedTexts()[4]; |
||||
|
||||
QListIterator<AvailablePipeSource> itr(availablePipeSources); |
||||
while (itr.hasNext()) |
||||
{ |
||||
AvailablePipeSource p = itr.next(); |
||||
if ((p.m_setIndex == setIndex) && (p.m_index == index) && (id == p.m_id)) { |
||||
return p.m_source; |
||||
} |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "PipeEndPoint::getPipeEndPoint: " << name << " is malformed"; |
||||
} |
||||
return nullptr; |
||||
} |
||||
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// Parent for ChannelAPI and Features, where either can be used. //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_PIPES_PIPEENDPOINT_H_ |
||||
#define SDRBASE_PIPES_PIPEENDPOINT_H_ |
||||
|
||||
#include <QList> |
||||
#include <QString> |
||||
#include <QStringList> |
||||
|
||||
#include "util/message.h" |
||||
#include "export.h" |
||||
|
||||
class Feature; |
||||
|
||||
class SDRBASE_API PipeEndPoint { |
||||
public: |
||||
|
||||
// Used by pipe sinks (channels or features) to record details about available pipe sources (channels or features)
|
||||
struct AvailablePipeSource |
||||
{ |
||||
enum {RX, TX, Feature} m_type; |
||||
int m_setIndex; |
||||
int m_index; |
||||
PipeEndPoint *m_source; |
||||
QString m_id; |
||||
|
||||
AvailablePipeSource() = default; |
||||
AvailablePipeSource(const AvailablePipeSource&) = default; |
||||
AvailablePipeSource& operator=(const AvailablePipeSource&) = default; |
||||
friend bool operator==(const AvailablePipeSource &lhs, const AvailablePipeSource &rhs) |
||||
{ |
||||
return (lhs.m_type == rhs.m_type) |
||||
&& (lhs.m_setIndex == rhs.m_setIndex) |
||||
&& (lhs.m_source == rhs.m_source) |
||||
&& (lhs.m_id == rhs.m_id); |
||||
} |
||||
|
||||
QString getTypeName() const |
||||
{ |
||||
QStringList typeNames = {"R", "T", "F"}; |
||||
return typeNames[m_type]; |
||||
} |
||||
|
||||
// Name for use in GUI combo boxes and WebAPI
|
||||
QString getName() const |
||||
{ |
||||
QString type; |
||||
|
||||
return QString("%1%2:%3 %4").arg(getTypeName()) |
||||
.arg(m_setIndex) |
||||
.arg(m_index) |
||||
.arg(m_id); |
||||
} |
||||
}; |
||||
|
||||
class SDRBASE_API MsgReportPipes : public Message { |
||||
MESSAGE_CLASS_DECLARATION |
||||
|
||||
public: |
||||
QList<AvailablePipeSource>& getAvailablePipes() { return m_availablePipes; } |
||||
|
||||
static MsgReportPipes* create() { |
||||
return new MsgReportPipes(); |
||||
} |
||||
|
||||
private: |
||||
QList<AvailablePipeSource> m_availablePipes; |
||||
|
||||
MsgReportPipes() : |
||||
Message() |
||||
{} |
||||
}; |
||||
|
||||
|
||||
protected: |
||||
|
||||
// Utility functions for pipe sinks to manage list of sources
|
||||
QList<AvailablePipeSource> updateAvailablePipeSources(QString pipeName, QStringList pipeTypes, QStringList pipeURIs, PipeEndPoint *destination); |
||||
PipeEndPoint *getPipeEndPoint(const QString name, const QList<AvailablePipeSource> &availablePipeSources); |
||||
|
||||
}; |
||||
|
||||
#endif // SDRBASE_PIPES_PIPEENDPOINT_H_
|
||||
@ -0,0 +1,601 @@
@@ -0,0 +1,601 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QEvent> |
||||
#include <QPainter> |
||||
#include <QPainterPath> |
||||
#include <QMouseEvent> |
||||
#include <QDialog> |
||||
#include <QDesktopServices> |
||||
|
||||
#include "gui/rollupcontents.h" |
||||
#include "settings/rollupstate.h" |
||||
#include "ui_glspectrumgui.h" |
||||
|
||||
RollupContents::RollupContents(QWidget* parent) : |
||||
QWidget(parent), |
||||
m_highlighted(false), |
||||
m_streamIndicator("S"), |
||||
// m_channelWidget(true),
|
||||
m_newHeight(0) |
||||
{ |
||||
setMinimumSize(250, 150); |
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
||||
setBackgroundRole(QPalette::Window); |
||||
|
||||
setAutoFillBackground(false); |
||||
setAttribute(Qt::WA_OpaquePaintEvent, true); |
||||
} |
||||
|
||||
// QByteArray RollupWidget::saveState(int version) const
|
||||
// {
|
||||
// QByteArray state;
|
||||
// QDataStream stream(&state, QIODevice::WriteOnly);
|
||||
// int count = 0;
|
||||
|
||||
// for (int i = 0; i < children().count(); ++i)
|
||||
// {
|
||||
// QWidget* r = qobject_cast<QWidget*>(children()[i]);
|
||||
|
||||
// if (r) {
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// stream << VersionMarker;
|
||||
// stream << version;
|
||||
// stream << count;
|
||||
|
||||
// for (int i = 0; i < children().count(); ++i)
|
||||
// {
|
||||
// QWidget* r = qobject_cast<QWidget*>(children()[i]);
|
||||
|
||||
// if (r)
|
||||
// {
|
||||
// stream << r->objectName();
|
||||
|
||||
// if (r->isHidden()) {
|
||||
// stream << (int) 0;
|
||||
// } else {
|
||||
// stream << (int) 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return state;
|
||||
// }
|
||||
|
||||
void RollupContents::saveState(RollupState &state) const |
||||
{ |
||||
QList<RollupState::RollupChildState>& childrenStates = state.getChildren(); |
||||
childrenStates.clear(); |
||||
|
||||
for (const auto &child : children()) |
||||
{ |
||||
QWidget* r = qobject_cast<QWidget*>(child); |
||||
|
||||
if (r && isRollupChild(r)) { |
||||
childrenStates.push_back({r->objectName(), r->isHidden()}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// bool RollupWidget::restoreState(const QByteArray& state, int version)
|
||||
// {
|
||||
// if (state.isEmpty()) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// QByteArray sd = state;
|
||||
// QDataStream stream(&sd, QIODevice::ReadOnly);
|
||||
// int marker, v;
|
||||
// stream >> marker;
|
||||
// stream >> v;
|
||||
|
||||
// if ((stream.status() != QDataStream::Ok) || (marker != VersionMarker) || (v != version)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// int count;
|
||||
// stream >> count;
|
||||
|
||||
// if (stream.status() != QDataStream::Ok) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < count; ++i)
|
||||
// {
|
||||
// QString name;
|
||||
// int visible;
|
||||
|
||||
// stream >> name;
|
||||
// stream >> visible;
|
||||
|
||||
// if (stream.status() != QDataStream::Ok) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// for (int j = 0; j < children().count(); ++j)
|
||||
// {
|
||||
// QWidget* r = qobject_cast<QWidget*>(children()[j]);
|
||||
|
||||
// if (r)
|
||||
// {
|
||||
// if (r->objectName() == name)
|
||||
// {
|
||||
// if (visible) {
|
||||
// r->show();
|
||||
// } else {
|
||||
// r->hide();
|
||||
// }
|
||||
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
void RollupContents::restoreState(const RollupState& state) |
||||
{ |
||||
const QList<RollupState::RollupChildState>& childrenStates = state.getChildren(); |
||||
|
||||
for (const auto &object : children()) |
||||
{ |
||||
QWidget* r = qobject_cast<QWidget*>(object); |
||||
|
||||
if (r && isRollupChild(r)) |
||||
{ |
||||
for (const auto &childState : childrenStates) |
||||
{ |
||||
if (childState.m_objectName.compare(r->objectName()) == 0) |
||||
{ |
||||
if (childState.m_isHidden) { |
||||
r->hide(); |
||||
} else { |
||||
r->show(); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void RollupContents::setHighlighted(bool highlighted) |
||||
{ |
||||
if (m_highlighted != highlighted) |
||||
{ |
||||
m_highlighted = highlighted; |
||||
update(); |
||||
} |
||||
} |
||||
|
||||
int RollupContents::arrangeRollups() |
||||
{ |
||||
QFontMetrics fm(font()); |
||||
int pos; |
||||
|
||||
// First calculate minimum height needed, to determine how much extra space
|
||||
// we have that can be split between expanding widgets
|
||||
pos = 2; // fm.height() + 4;
|
||||
int expandingChildren = 0; |
||||
for (int i = 0; i < children().count(); ++i) |
||||
{ |
||||
QWidget* r = qobject_cast<QWidget*>(children()[i]); |
||||
|
||||
if ((r != nullptr) && isRollupChild(r)) |
||||
{ |
||||
pos += fm.height() + 2; |
||||
if (!r->isHidden()) |
||||
{ |
||||
if (r->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) { |
||||
expandingChildren++; |
||||
} |
||||
int h = 0; |
||||
if (r->hasHeightForWidth()) { |
||||
h = r->heightForWidth(width() - 4); |
||||
} else { |
||||
h = r->minimumSizeHint().height(); |
||||
} |
||||
pos += h + 5; |
||||
} |
||||
} |
||||
} |
||||
|
||||
setMinimumHeight(pos); |
||||
|
||||
// Split extra space equally between widgets
|
||||
// If there's a remainder, we give it to the first widget
|
||||
// In the future, we should probably respect 'Vertical Stretch'
|
||||
int extraSpace; |
||||
int firstExtra; |
||||
if ((expandingChildren > 0) && (m_newHeight > pos)) |
||||
{ |
||||
int totalExtra = m_newHeight - pos; |
||||
extraSpace = totalExtra / expandingChildren; |
||||
firstExtra = totalExtra - (extraSpace * expandingChildren); |
||||
} |
||||
else |
||||
{ |
||||
extraSpace = 0; |
||||
firstExtra = 0; |
||||
} |
||||
|
||||
// Now reposition and resize child widgets
|
||||
pos = 2; // fm.height() + 4;
|
||||
for (int i = 0; i < children().count(); ++i) |
||||
{ |
||||
QWidget* r = qobject_cast<QWidget*>(children()[i]); |
||||
|
||||
if ((r != nullptr) && isRollupChild(r)) |
||||
{ |
||||
pos += fm.height() + 2; |
||||
|
||||
if (!r->isHidden()) |
||||
{ |
||||
r->move(2, pos + 3); |
||||
|
||||
int h = 0; |
||||
if (r->hasHeightForWidth()) { |
||||
h = r->heightForWidth(width() - 4); |
||||
} else { |
||||
h = r->minimumSizeHint().height(); |
||||
} |
||||
if (r->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) |
||||
{ |
||||
h += extraSpace; |
||||
h += firstExtra; |
||||
firstExtra = 0; |
||||
} |
||||
|
||||
r->resize(width() - 4, h); |
||||
pos += r->height() + 5; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (expandingChildren == 0) { |
||||
setMaximumHeight(pos); |
||||
} else { |
||||
setMaximumHeight(16777215); |
||||
} |
||||
updateGeometry(); |
||||
return pos; |
||||
} |
||||
|
||||
void RollupContents::paintEvent(QPaintEvent*) |
||||
{ |
||||
QPainter p(this); |
||||
QColor frame = palette().highlight().color(); |
||||
|
||||
// Eigenbau
|
||||
QFontMetrics fm(font()); |
||||
|
||||
p.setRenderHint(QPainter::Antialiasing, true); |
||||
|
||||
// Ecken (corners)
|
||||
p.setPen(Qt::NoPen); |
||||
p.setBrush(palette().base()); |
||||
p.drawRect(0, 0, 5, 5); |
||||
p.drawRect(width() - 5, 0, 5, 5); |
||||
p.drawRect(0, height() - 5, 5, 5); |
||||
p.drawRect(width() - 5, height() - 5, 5, 5); |
||||
|
||||
// Rahmen (frame)
|
||||
p.setPen(m_highlighted ? Qt::white : frame); |
||||
p.setBrush(palette().window()); |
||||
QRectF r(rect()); |
||||
r.adjust(0.5, 0.5, -0.5, -0.5); |
||||
p.drawRoundedRect(r, 3.0, 3.0, Qt::AbsoluteSize); |
||||
|
||||
// // Titel-Hintergrund (Title background)
|
||||
// p.setPen(Qt::NoPen);
|
||||
// p.setBrush(m_titleColor);
|
||||
// QPainterPath path;
|
||||
// path.moveTo(1.5, fm.height() + 2.5);
|
||||
// path.lineTo(width() - 1.5, fm.height() + 2.5);
|
||||
// path.lineTo(width() - 1.5, 3.5);
|
||||
// path.arcTo(QRectF(width() - 3.5, 0, 2.5, 2.5), 270, -90);
|
||||
// path.lineTo(3.5, 1.5);
|
||||
// path.arcTo(QRectF(1.5, 2.5, 2.5, 2.5), 90, 90);
|
||||
// p.drawPath(path);
|
||||
|
||||
// // Titel-Abschlusslinie (Title closing line)
|
||||
// p.setPen(frame);
|
||||
// p.drawLine(QPointF(0.5, 2 + fm.height() + 1.5), QPointF(width() - 1.5, 2 + fm.height() + 1.5));
|
||||
|
||||
// // Aktiv-Button links
|
||||
// p.setPen(QPen(palette().windowText().color(), 1.0));
|
||||
// p.setBrush(palette().light());
|
||||
// p.drawRoundedRect(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()), 2.0, 2.0, Qt::AbsoluteSize);
|
||||
// p.setPen(QPen(Qt::white, 1.0));
|
||||
// p.drawText(QRectF(3.5, 2.5, fm.ascent(), fm.ascent()), Qt::AlignCenter, "c");
|
||||
|
||||
// if (m_channelWidget)
|
||||
// {
|
||||
// // Stromkanal-Button links (Current channel)
|
||||
// p.setPen(QPen(palette().windowText().color(), 1.0));
|
||||
// p.setBrush(palette().light());
|
||||
// p.drawRoundedRect(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), 2.0, 2.0, Qt::AbsoluteSize);
|
||||
// p.setPen(QPen(Qt::white, 1.0));
|
||||
// p.drawText(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), Qt::AlignCenter, m_streamIndicator);
|
||||
// }
|
||||
|
||||
// // Help button
|
||||
// if (!m_helpURL.isEmpty())
|
||||
// {
|
||||
// p.setRenderHint(QPainter::Antialiasing, true);
|
||||
// p.setPen(QPen(palette().windowText().color(), 1.0));
|
||||
// p.setBrush(palette().light());
|
||||
// r = QRectF(width() - 2*(3.5 + fm.ascent()), 3.5, fm.ascent(), fm.ascent());
|
||||
// p.drawRoundedRect(r, 2.0, 2.0, Qt::AbsoluteSize);
|
||||
// p.drawText(QRectF(width() - 2*(3.5 + fm.ascent()), 5, fm.ascent(), fm.ascent() - 2), Qt::AlignCenter, "?");
|
||||
// }
|
||||
|
||||
// //p.drawLine(r.topLeft() + QPointF(1, 1), r.bottomRight() + QPointF(-1, -1));
|
||||
// //p.drawLine(r.bottomLeft() + QPointF(1, -1), r.topRight() + QPointF(-1, 1));
|
||||
|
||||
// // Schließen-Button rechts (Close button on the right)
|
||||
// p.setRenderHint(QPainter::Antialiasing, true);
|
||||
// p.setPen(QPen(palette().windowText().color(), 1.0));
|
||||
// p.setBrush(palette().light());
|
||||
// r = QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent());
|
||||
// p.drawRoundedRect(r, 2.0, 2.0, Qt::AbsoluteSize);
|
||||
// p.setPen(QPen(palette().windowText().color(), 1.5));
|
||||
// p.drawLine(r.topLeft() + QPointF(1, 1), r.bottomRight() + QPointF(-1, -1));
|
||||
// p.drawLine(r.bottomLeft() + QPointF(1, -1), r.topRight() + QPointF(-1, 1));
|
||||
|
||||
// // Titel
|
||||
// //p.setPen(palette().highlightedText().color());
|
||||
// p.setPen(m_titleTextColor);
|
||||
// p.drawText(QRect(2 + 2*fm.height() + 2, 2, width() - 6 - 3*fm.height(), fm.height()),
|
||||
// fm.elidedText(windowTitle(), Qt::ElideMiddle, width() - 6 - 3*fm.height(), 0));
|
||||
|
||||
// Rollups
|
||||
int pos = 2; // fm.height() + 4;
|
||||
|
||||
const QObjectList& c = children(); |
||||
QObjectList::ConstIterator w = c.begin(); |
||||
QObjectList::ConstIterator n = c.begin(); |
||||
|
||||
for (n = c.begin(); n != c.end(); ++n) |
||||
{ |
||||
if (qobject_cast<QWidget*>(*n) != nullptr) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
for (w = n; w != c.end(); w = n) |
||||
{ |
||||
if (n != c.end()) { |
||||
++n; |
||||
} |
||||
|
||||
for (; n != c.end(); ++n) |
||||
{ |
||||
if (qobject_cast<QWidget*>(*n) != nullptr) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
pos += paintRollup(qobject_cast<QWidget*>(*w), pos, &p, n == c.end(), frame); |
||||
} |
||||
} |
||||
|
||||
int RollupContents::paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame) |
||||
{ |
||||
QFontMetrics fm(font()); |
||||
int height = 1; |
||||
|
||||
// Titel-Abschlusslinie
|
||||
if (!rollup->isHidden()) |
||||
{ |
||||
p->setPen(palette().dark().color()); |
||||
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5)); |
||||
p->setPen(palette().light().color()); |
||||
p->drawLine(QPointF(1.5, pos + fm.height() + 2.5), QPointF(width() - 1.5, pos + fm.height() + 2.5)); |
||||
height += 2; |
||||
} |
||||
else |
||||
{ |
||||
if (!last) |
||||
{ |
||||
p->setPen(frame); |
||||
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5)); |
||||
height++; |
||||
} |
||||
} |
||||
|
||||
// Titel
|
||||
p->setPen(palette().windowText().color()); |
||||
p->drawText(QRect(2 + fm.height(), pos, width() - 4 - fm.height(), fm.height()), |
||||
fm.elidedText(rollup->windowTitle(), Qt::ElideMiddle, width() - 4 - fm.height(), 0)); |
||||
height += fm.height(); |
||||
|
||||
// Ausklapp-Icon
|
||||
p->setPen(palette().windowText().color()); |
||||
p->setBrush(palette().windowText()); |
||||
|
||||
if (!rollup->isHidden()) |
||||
{ |
||||
QPolygonF a; |
||||
a.append(QPointF(3.5, pos + 2)); |
||||
a.append(QPointF(3.5 + fm.ascent(), pos + 2)); |
||||
a.append(QPointF(3.5 + fm.ascent() / 2.0, pos + fm.height() - 2)); |
||||
p->drawPolygon(a); |
||||
} |
||||
else |
||||
{ |
||||
QPolygonF a; |
||||
a.append(QPointF(3.5, pos + 2)); |
||||
a.append(QPointF(3.5, pos + fm.height() - 2)); |
||||
a.append(QPointF(3.5 + fm.ascent(), pos + fm.height() / 2)); |
||||
p->drawPolygon(a); |
||||
} |
||||
|
||||
// Inhalt
|
||||
if (!rollup->isHidden() && (!last)) |
||||
{ |
||||
// Rollup-Abschlusslinie
|
||||
p->setPen(frame); |
||||
p->drawLine(QPointF(1.5, pos + fm.height() + rollup->height() + 6.5), |
||||
QPointF(width() - 1.5, pos + fm.height() + rollup->height() + 6.5)); |
||||
height += rollup->height() + 4; |
||||
} |
||||
|
||||
return height; |
||||
} |
||||
|
||||
void RollupContents::resizeEvent(QResizeEvent* size) |
||||
{ |
||||
m_newHeight = size->size().height(); |
||||
arrangeRollups(); |
||||
QWidget::resizeEvent(size); |
||||
} |
||||
|
||||
void RollupContents::mousePressEvent(QMouseEvent* event) |
||||
{ |
||||
QFontMetrics fm(font()); |
||||
|
||||
// // menu box left
|
||||
// if (QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos()))
|
||||
// {
|
||||
// m_contextMenuType = ContextMenuChannelSettings;
|
||||
// emit customContextMenuRequested(event->globalPos());
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (m_channelWidget)
|
||||
// {
|
||||
// // Stream channel menu left
|
||||
// if (QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0).contains(event->pos()))
|
||||
// {
|
||||
// m_contextMenuType = ContextMenuStreamSettings;
|
||||
// emit customContextMenuRequested(event->globalPos());
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // help button
|
||||
// if(!m_helpURL.isEmpty() && QRectF(width() - 2*(3.5 + fm.ascent()), 3.5, fm.ascent(), fm.ascent()).contains(event->pos()))
|
||||
// {
|
||||
// QString url;
|
||||
// if (m_helpURL.startsWith("http")) {
|
||||
// url = m_helpURL;
|
||||
// } else {
|
||||
// url = QString("https://github.com/f4exb/sdrangel/blob/master/%1").arg(m_helpURL); // Something like "plugins/channelrx/chanalyzer/readme.md"
|
||||
// }
|
||||
// QDesktopServices::openUrl(QUrl(url));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // close button right
|
||||
// if(QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
|
||||
// close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// check if we need to change a rollup widget
|
||||
int pos = 2; // fm.height() + 4;
|
||||
|
||||
for (int i = 0; i < children().count(); ++i) |
||||
{ |
||||
QWidget* r = qobject_cast<QWidget*>(children()[i]); |
||||
|
||||
if (r) |
||||
{ |
||||
if ((event->y() >= pos) && (event->y() < (pos + fm.height() + 3))) |
||||
{ |
||||
if (r->isHidden()) |
||||
{ |
||||
r->show(); |
||||
//emit widgetRolled(r, true);
|
||||
} |
||||
else |
||||
{ |
||||
r->hide(); |
||||
//emit widgetRolled(r, false);
|
||||
} |
||||
|
||||
arrangeRollups(); |
||||
repaint(); |
||||
return; |
||||
} |
||||
else |
||||
{ |
||||
pos += fm.height() + 2; |
||||
|
||||
if (!r->isHidden()) { |
||||
pos += r->height() + 5; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool RollupContents::event(QEvent* event) |
||||
{ |
||||
if (event->type() == QEvent::ChildAdded) |
||||
{ |
||||
((QChildEvent*)event)->child()->installEventFilter(this); |
||||
arrangeRollups(); |
||||
} |
||||
else if (event->type() == QEvent::ChildRemoved) |
||||
{ |
||||
((QChildEvent*)event)->child()->removeEventFilter(this); |
||||
arrangeRollups(); |
||||
} |
||||
|
||||
return QWidget::event(event); |
||||
} |
||||
|
||||
bool RollupContents::eventFilter(QObject* object, QEvent* event) |
||||
{ |
||||
if (event->type() == QEvent::Show) |
||||
{ |
||||
if (children().contains(object)) |
||||
{ |
||||
arrangeRollups(); |
||||
emit widgetRolled(qobject_cast<QWidget*>(object), true); |
||||
} |
||||
} |
||||
else if (event->type() == QEvent::Hide) |
||||
{ |
||||
if (children().contains(object)) |
||||
{ |
||||
arrangeRollups(); |
||||
emit widgetRolled(qobject_cast<QWidget*>(object), false); |
||||
} |
||||
} |
||||
else if (event->type() == QEvent::WindowTitleChange) |
||||
{ |
||||
if (children().contains(object)) { |
||||
repaint(); |
||||
} |
||||
} |
||||
|
||||
return QWidget::eventFilter(object, event); |
||||
} |
||||
|
||||
bool RollupContents::isRollupChild(QWidget *childWidget) |
||||
{ |
||||
return (qobject_cast<QDialog*>(childWidget) == nullptr); // exclude Dialogs from rollups
|
||||
} |
||||
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// API for features //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_ROLLUPCONTENTS_H |
||||
#define INCLUDE_ROLLUPCONTENTS_H |
||||
|
||||
#include <QWidget> |
||||
#include "export.h" |
||||
|
||||
class RollupState; |
||||
|
||||
class SDRGUI_API RollupContents : public QWidget { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
RollupContents(QWidget* parent = nullptr); |
||||
void setHighlighted(bool highlighted); |
||||
// void setChannelWidget(bool channelWidget) { m_channelWidget = channelWidget; }
|
||||
// QByteArray saveState(int version = 0) const;
|
||||
void saveState(RollupState& state) const; |
||||
// bool restoreState(const QByteArray& state, int version = 0);
|
||||
void restoreState(const RollupState& state); |
||||
int arrangeRollups(); |
||||
|
||||
signals: |
||||
void widgetRolled(QWidget* widget, bool rollDown); |
||||
|
||||
protected: |
||||
enum { |
||||
VersionMarker = 0xff |
||||
}; |
||||
|
||||
bool m_highlighted; |
||||
QString m_streamIndicator; |
||||
QString m_helpURL; |
||||
|
||||
void paintEvent(QPaintEvent*); |
||||
int paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame); |
||||
|
||||
void resizeEvent(QResizeEvent* size); |
||||
void mousePressEvent(QMouseEvent* event); |
||||
|
||||
bool event(QEvent* event); |
||||
bool eventFilter(QObject* object, QEvent* event); |
||||
|
||||
private: |
||||
static bool isRollupChild(QWidget *childWidget); //!< chidl is part of rollups (ex: not a dialog)
|
||||
// bool m_channelWidget;
|
||||
int m_newHeight; |
||||
}; |
||||
|
||||
#endif // INCLUDE_ROLLUPCONTENTS_H
|
||||
@ -0,0 +1,271 @@
@@ -0,0 +1,271 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QHBoxLayout> |
||||
#include <QLabel> |
||||
#include <QPushButton> |
||||
#include <QStyle> |
||||
#include <QMdiArea> |
||||
#include <QMdiSubWindow> |
||||
#include <QFrame> |
||||
|
||||
#include "workspace.h" |
||||
|
||||
Workspace::Workspace(int index, QWidget *parent, Qt::WindowFlags flags) : |
||||
QDockWidget(parent, flags), |
||||
m_index(index), |
||||
m_featureAddDialog(this) |
||||
{ |
||||
m_mdi = new QMdiArea(this); |
||||
m_mdi->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
||||
m_mdi->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
||||
setWidget(m_mdi); |
||||
|
||||
setWindowTitle(tr("W%1").arg(m_index)); |
||||
|
||||
m_titleBar = new QWidget(); |
||||
m_titleBarLayout = new QHBoxLayout(); |
||||
m_titleBarLayout->setMargin(0); |
||||
m_titleBar->setLayout(m_titleBarLayout); |
||||
|
||||
m_titleLabel = new QLabel(); |
||||
m_titleLabel->setFixedSize(32, 16); |
||||
m_titleLabel->setStyleSheet("QLabel { background-color: rgb(128, 128, 128); qproperty-alignment: AlignCenter; }"); |
||||
m_titleLabel->setText(windowTitle()); |
||||
|
||||
m_addRxDeviceButton = new QPushButton(); |
||||
QIcon addRxIcon(":/rx.png"); |
||||
m_addRxDeviceButton->setIcon(addRxIcon); |
||||
m_addRxDeviceButton->setToolTip("Add Rx device"); |
||||
m_addRxDeviceButton->setFixedSize(20, 20); |
||||
|
||||
m_addTxDeviceButton = new QPushButton(); |
||||
QIcon addTxIcon(":/tx.png"); |
||||
m_addTxDeviceButton->setIcon(addTxIcon); |
||||
m_addTxDeviceButton->setToolTip("Add Tx device"); |
||||
m_addTxDeviceButton->setFixedSize(20, 20); |
||||
|
||||
m_addMIMODeviceButton = new QPushButton(); |
||||
QIcon addMIMOIcon(":/mimo.png"); |
||||
m_addMIMODeviceButton->setIcon(addMIMOIcon); |
||||
m_addMIMODeviceButton->setToolTip("Add MIMO device"); |
||||
m_addMIMODeviceButton->setFixedSize(20, 20); |
||||
|
||||
m_vline1 = new QFrame(); |
||||
m_vline1->setFrameShape(QFrame::VLine); |
||||
m_vline1->setFrameShadow(QFrame::Sunken); |
||||
|
||||
m_addFeatureButton = new QPushButton(); |
||||
QIcon addFeatureIcon(":/tool.png"); |
||||
m_addFeatureButton->setIcon(addFeatureIcon); |
||||
m_addFeatureButton->setToolTip("Add features"); |
||||
m_addFeatureButton->setFixedSize(20, 20); |
||||
|
||||
m_featurePresetsButton = new QPushButton(); |
||||
QIcon presetsIcon(":/star.png"); |
||||
m_featurePresetsButton->setIcon(presetsIcon); |
||||
m_featurePresetsButton->setToolTip("Feature presets"); |
||||
m_featurePresetsButton->setFixedSize(20, 20); |
||||
|
||||
m_vline2 = new QFrame(); |
||||
m_vline2->setFrameShape(QFrame::VLine); |
||||
m_vline2->setFrameShadow(QFrame::Sunken); |
||||
|
||||
m_cascadeSubWindows = new QPushButton(); |
||||
QIcon cascadeSubWindowsIcon(":/cascade.png"); |
||||
m_cascadeSubWindows->setIcon(cascadeSubWindowsIcon); |
||||
m_cascadeSubWindows->setToolTip("Cascade sub windows"); |
||||
m_cascadeSubWindows->setFixedSize(20, 20); |
||||
|
||||
m_tileSubWindows = new QPushButton(); |
||||
QIcon tileSubWindowsIcon(":/tiles.png"); |
||||
m_tileSubWindows->setIcon(tileSubWindowsIcon); |
||||
m_tileSubWindows->setToolTip("Tile sub windows"); |
||||
m_tileSubWindows->setFixedSize(20, 20); |
||||
|
||||
m_normalButton = new QPushButton(); |
||||
QIcon normalIcon(":/dock.png"); |
||||
m_normalButton->setIcon(normalIcon); |
||||
m_normalButton->setToolTip("Dock/undock"); |
||||
m_normalButton->setFixedSize(20, 20); |
||||
|
||||
m_closeButton = new QPushButton(); |
||||
QIcon closeIcon(":/cross.png"); |
||||
m_closeButton->setIcon(closeIcon); |
||||
m_closeButton->setToolTip("Hide workspace"); |
||||
m_closeButton->setFixedSize(20, 20); |
||||
|
||||
m_titleBarLayout->addWidget(m_titleLabel); |
||||
m_titleBarLayout->addWidget(m_addRxDeviceButton); |
||||
m_titleBarLayout->addWidget(m_addTxDeviceButton); |
||||
m_titleBarLayout->addWidget(m_addMIMODeviceButton); |
||||
m_titleBarLayout->addWidget(m_vline1); |
||||
m_titleBarLayout->addWidget(m_addFeatureButton); |
||||
m_titleBarLayout->addWidget(m_featurePresetsButton); |
||||
m_titleBarLayout->addWidget(m_vline2); |
||||
m_titleBarLayout->addWidget(m_cascadeSubWindows); |
||||
m_titleBarLayout->addWidget(m_tileSubWindows); |
||||
m_titleBarLayout->addStretch(1); |
||||
m_titleBarLayout->addWidget(m_normalButton); |
||||
m_titleBarLayout->addWidget(m_closeButton); |
||||
setTitleBarWidget(m_titleBar); |
||||
|
||||
QObject::connect( |
||||
m_addRxDeviceButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::addRxDevice |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_addTxDeviceButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::addTxDevice |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_addMIMODeviceButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::addMIMODevice |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_addFeatureButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::addFeatureDialog |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_featurePresetsButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::featurePresetsDialog |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_cascadeSubWindows, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::cascadeSubWindows |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_tileSubWindows, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::tileSubWindows |
||||
); |
||||
|
||||
QObject::connect( |
||||
m_normalButton, |
||||
&QPushButton::clicked, |
||||
this, |
||||
&Workspace::toggleFloating |
||||
); |
||||
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(hide())); |
||||
|
||||
QObject::connect( |
||||
&m_featureAddDialog, |
||||
&FeatureAddDialog::addFeature, |
||||
this, |
||||
&Workspace::addFeatureEmitted |
||||
); |
||||
} |
||||
|
||||
Workspace::~Workspace() |
||||
{ |
||||
delete m_closeButton; |
||||
delete m_normalButton; |
||||
delete m_tileSubWindows; |
||||
delete m_cascadeSubWindows; |
||||
delete m_vline2; |
||||
delete m_vline1; |
||||
delete m_addRxDeviceButton; |
||||
delete m_addTxDeviceButton; |
||||
delete m_addMIMODeviceButton; |
||||
delete m_addFeatureButton; |
||||
delete m_featurePresetsButton; |
||||
delete m_titleLabel; |
||||
delete m_titleBarLayout; |
||||
delete m_titleBar; |
||||
delete m_mdi; |
||||
} |
||||
|
||||
void Workspace::toggleFloating() |
||||
{ |
||||
setFloating(!isFloating()); |
||||
} |
||||
|
||||
void Workspace::addRxDevice() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void Workspace::addTxDevice() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void Workspace::addMIMODevice() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void Workspace::addFeatureDialog() |
||||
{ |
||||
m_featureAddDialog.exec(); |
||||
} |
||||
|
||||
void Workspace::addFeatureEmitted(int featureIndex) |
||||
{ |
||||
if (featureIndex >= 0) { |
||||
emit addFeature(this, featureIndex); |
||||
} |
||||
} |
||||
|
||||
void Workspace::featurePresetsDialog() |
||||
{ |
||||
QPoint p = mapFromGlobal(QCursor::pos()); |
||||
emit featurePresetsDialogRequested(p, this); |
||||
} |
||||
|
||||
void Workspace::cascadeSubWindows() |
||||
{ |
||||
m_mdi->cascadeSubWindows(); |
||||
} |
||||
|
||||
void Workspace::tileSubWindows() |
||||
{ |
||||
m_mdi->tileSubWindows(); |
||||
} |
||||
|
||||
void Workspace::addToMdiArea(QMdiSubWindow *sub) |
||||
{ |
||||
sub->setParent(m_mdi); |
||||
m_mdi->addSubWindow(sub); |
||||
sub->show(); |
||||
} |
||||
|
||||
void Workspace::removeFromMdiArea(QMdiSubWindow *sub) |
||||
{ |
||||
m_mdi->removeSubWindow(sub); |
||||
} |
||||
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRGUI_GUI_WORKSPACE_H_ |
||||
#define SDRGUI_GUI_WORKSPACE_H_ |
||||
|
||||
#include <QDockWidget> |
||||
|
||||
#include "export.h" |
||||
#include "featureadddialog.h" |
||||
|
||||
class QHBoxLayout; |
||||
class QLabel; |
||||
class QPushButton; |
||||
class QStringList; |
||||
class QMdiArea; |
||||
class QMdiSubWindow; |
||||
class QFrame; |
||||
|
||||
class SDRGUI_API Workspace : public QDockWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
Workspace(int index, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); |
||||
~Workspace(); |
||||
|
||||
int getIndex() const { return m_index; } |
||||
void resetAvailableFeatures() { m_featureAddDialog.resetFeatureNames(); } |
||||
void addAvailableFeatures(const QStringList& featureNames) { m_featureAddDialog.addFeatureNames(featureNames); } |
||||
void addToMdiArea(QMdiSubWindow *sub); |
||||
void removeFromMdiArea(QMdiSubWindow *sub); |
||||
|
||||
private: |
||||
int m_index; |
||||
QPushButton *m_addRxDeviceButton; |
||||
QPushButton *m_addTxDeviceButton; |
||||
QPushButton *m_addMIMODeviceButton; |
||||
QFrame *m_vline1; |
||||
QPushButton *m_addFeatureButton; |
||||
QPushButton *m_featurePresetsButton; |
||||
QFrame *m_vline2; |
||||
QPushButton *m_cascadeSubWindows; |
||||
QPushButton *m_tileSubWindows; |
||||
QWidget *m_titleBar; |
||||
QHBoxLayout *m_titleBarLayout; |
||||
QLabel *m_titleLabel; |
||||
QPushButton *m_normalButton; |
||||
QPushButton *m_closeButton; |
||||
FeatureAddDialog m_featureAddDialog; |
||||
QMdiArea *m_mdi; |
||||
|
||||
private slots: |
||||
void addRxDevice(); |
||||
void addTxDevice(); |
||||
void addMIMODevice(); |
||||
void addFeatureDialog(); |
||||
void featurePresetsDialog(); |
||||
void cascadeSubWindows(); |
||||
void tileSubWindows(); |
||||
void addFeatureEmitted(int featureIndex); |
||||
void toggleFloating(); |
||||
|
||||
signals: |
||||
void addFeature(Workspace*, int); |
||||
void featurePresetsDialogRequested(QPoint, Workspace*); |
||||
}; |
||||
|
||||
|
||||
#endif // SDRGUI_GUI_WORKSPACE_H_
|
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QStringListModel> |
||||
|
||||
#include "workspaceselectiondialog.h" |
||||
#include "ui_workspaceselectiondialog.h" |
||||
|
||||
WorkspaceSelectionDialog::WorkspaceSelectionDialog(int numberOfWorkspaces, QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::WorkspaceSelectionDialog), |
||||
m_numberOfWorkspaces(numberOfWorkspaces), |
||||
m_hasChanged(false) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
for (int i = 0; i < m_numberOfWorkspaces; i++) { |
||||
ui->workspaceList->addItem(tr("W:%1").arg(i)); |
||||
} |
||||
} |
||||
|
||||
WorkspaceSelectionDialog::~WorkspaceSelectionDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void WorkspaceSelectionDialog::accept() |
||||
{ |
||||
m_selectedRow = ui->workspaceList->currentRow(); |
||||
m_hasChanged = true; |
||||
QDialog::accept(); |
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2022 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 //
|
||||
// (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 V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRGUI_GUI_WORKSPACESELECTIONDIALOG_H_ |
||||
#define SDRGUI_GUI_WORKSPACESELECTIONDIALOG_H_ |
||||
|
||||
#include <QDialog> |
||||
|
||||
#include "export.h" |
||||
|
||||
namespace Ui { |
||||
class WorkspaceSelectionDialog; |
||||
} |
||||
|
||||
class SDRGUI_API WorkspaceSelectionDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit WorkspaceSelectionDialog(int numberOfWorkspaces, QWidget *parent = nullptr); |
||||
~WorkspaceSelectionDialog(); |
||||
|
||||
bool hasChanged() const { return m_hasChanged; } |
||||
int getSelectedIndex() const { return m_selectedRow; } |
||||
|
||||
private: |
||||
Ui::WorkspaceSelectionDialog *ui; |
||||
int m_numberOfWorkspaces; |
||||
int m_selectedRow; |
||||
bool m_hasChanged; |
||||
|
||||
private slots: |
||||
void accept(); |
||||
}; |
||||
|
||||
#endif // SDRGUI_GUI_WORKSPACESELECTIONDIALOG_H_
|
||||
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>WorkspaceSelectionDialog</class> |
||||
<widget class="QDialog" name="WorkspaceSelectionDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>209</width> |
||||
<height>201</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Workspace</string> |
||||
</property> |
||||
<property name="modal"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QListWidget" name="workspaceList"/> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>WorkspaceSelectionDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>104</x> |
||||
<y>177</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>104</x> |
||||
<y>100</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>WorkspaceSelectionDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>104</x> |
||||
<y>177</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>104</x> |
||||
<y>100</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 5.3 KiB |