Browse Source

Web API: hide and show windows, and list them

GET /sdrangel/windows lists every device, spectrum, channel and feature
window with its workspace, title and whether it is hidden; the workspace
PUTs take a hidden field alongside the index.

The Web API has no access to the GUI, so MainCore keeps a table of what
the GUI has published for each window, keyed by the DeviceAPI,
SpectrumVis, ChannelAPI or Feature it belongs to. The GUI side is a new
WorkspaceWindow base for the four window classes, which publishes on
every show and hide, on a retitle and when the workspaces are renumbered,
and takes the workspace from the window's Workspace ancestor rather than
the plugin's settings, which a settings message from the channel can
reset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
chirpmodem-v8.0.0
Jon Beniston 2 months ago
parent
commit
bc1af1e39e
  1. 26
      sdrbase/maincore.cpp
  2. 51
      sdrbase/maincore.h
  3. 171
      sdrbase/webapi/webapiadapter.cpp
  4. 15
      sdrbase/webapi/webapiadapter.h
  5. 1
      sdrbase/webapi/webapiadapterinterface.cpp
  6. 16
      sdrbase/webapi/webapiadapterinterface.h
  7. 46
      sdrbase/webapi/webapirequestmapper.cpp
  8. 1
      sdrbase/webapi/webapirequestmapper.h
  9. 2
      sdrgui/CMakeLists.txt
  10. 3
      sdrgui/channel/channelgui.cpp
  11. 9
      sdrgui/channel/channelgui.h
  12. 3
      sdrgui/device/devicegui.cpp
  13. 9
      sdrgui/device/devicegui.h
  14. 4
      sdrgui/device/deviceuiset.cpp
  15. 3
      sdrgui/feature/featuregui.cpp
  16. 9
      sdrgui/feature/featuregui.h
  17. 1
      sdrgui/feature/featureuiset.cpp
  18. 92
      sdrgui/gui/workspacewindow.cpp
  19. 57
      sdrgui/gui/workspacewindow.h
  20. 3
      sdrgui/mainspectrum/mainspectrumgui.cpp
  21. 9
      sdrgui/mainspectrum/mainspectrumgui.h
  22. 73
      sdrgui/mainwindow.cpp

26
sdrbase/maincore.cpp

@ -67,6 +67,7 @@ MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelDemodReport, Message) @@ -67,6 +67,7 @@ MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelDemodReport, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelDemodQuery, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveDeviceUIToWorkspace, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgArrangeWorkspace, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgSetWindowHidden, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveMainSpectrumUIToWorkspace, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveFeatureUIToWorkspace, Message)
MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveChannelUIToWorkspace, Message)
@ -800,3 +801,28 @@ QStringList MainCore::getChannelIds(const QString& uri) @@ -800,3 +801,28 @@ QStringList MainCore::getChannelIds(const QString& uri)
return list;
}
void MainCore::setWindowState(const void* owner, const WindowState& state)
{
QMutexLocker locker(&m_windowStatesMutex);
m_windowStates[owner] = state;
}
void MainCore::removeWindowState(const void* owner)
{
QMutexLocker locker(&m_windowStatesMutex);
m_windowStates.remove(owner);
}
bool MainCore::getWindowState(const void* owner, WindowState& state) const
{
QMutexLocker locker(&m_windowStatesMutex);
auto it = m_windowStates.constFind(owner);
if (it == m_windowStates.constEnd()) {
return false;
}
state = it.value();
return true;
}

51
sdrbase/maincore.h

@ -25,6 +25,8 @@ @@ -25,6 +25,8 @@
#include <vector>
#include <QMap>
#include <QHash>
#include <QMutex>
#include <QTimer>
#include <QElapsedTimer>
#include <QDateTime>
@ -647,6 +649,36 @@ public: @@ -647,6 +649,36 @@ public:
{ }
};
class SDRBASE_API MsgSetWindowHidden : public Message {
MESSAGE_CLASS_DECLARATION
public:
enum Kind { Device, Spectrum, Channel, Feature };
Kind getKind() const { return m_kind; }
int getDeviceSetIndex() const { return m_deviceSetIndex; } //!< Unused for a feature
int getIndex() const { return m_index; } //!< Channel or feature index; unused for a device or spectrum
bool getHidden() const { return m_hidden; }
static MsgSetWindowHidden* create(Kind kind, int deviceSetIndex, int index, bool hidden) {
return new MsgSetWindowHidden(kind, deviceSetIndex, index, hidden);
}
private:
Kind m_kind;
int m_deviceSetIndex;
int m_index;
bool m_hidden;
MsgSetWindowHidden(Kind kind, int deviceSetIndex, int index, bool hidden) :
Message(),
m_kind(kind),
m_deviceSetIndex(deviceSetIndex),
m_index(index),
m_hidden(hidden)
{ }
};
class SDRBASE_API MsgMoveMainSpectrumUIToWorkspace : public Message {
MESSAGE_CLASS_DECLARATION
@ -977,7 +1009,26 @@ signals: @@ -977,7 +1009,26 @@ signals:
void featureAdded(int featureSetIndex, Feature *feature);
void featureRemoved(int featureSetIndex, Feature *oldFeature);
public:
// What the GUI shows of a window, kept here so that the Web API, which has no access to
// the GUI and runs on its own threads, can answer for it. Keyed by the object the window
// belongs to (DeviceAPI, SpectrumVis, ChannelAPI or Feature) rather than an index, as
// indices renumber when a lower one is removed. The GUI publishes on every show, hide,
// move and retitle, and removes the entry when the window goes. Empty in the server
struct WindowState
{
int m_workspaceIndex = -1;
bool m_hidden = false;
QString m_title;
};
void setWindowState(const void *owner, const WindowState& state);
void removeWindowState(const void *owner);
bool getWindowState(const void *owner, WindowState& state) const; //!< False when the GUI has published nothing for it
private:
mutable QMutex m_windowStatesMutex;
QHash<const void *, WindowState> m_windowStates;
MainSettings m_settings;
qtwebapp::LoggerWithFile *m_logger;
MessageQueue *m_mainMessageQueue;

171
sdrbase/webapi/webapiadapter.cpp

@ -73,6 +73,8 @@ @@ -73,6 +73,8 @@
#include "SWGDeviceActions.h"
#include "SWGWorkspaceInfo.h"
#include "SWGWorkspaceActions.h"
#include "SWGWindowList.h"
#include "SWGWindowInfo.h"
#include "SWGChannelsDetail.h"
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
@ -1782,6 +1784,118 @@ int WebAPIAdapter::workspaceActionsPost( @@ -1782,6 +1784,118 @@ int WebAPIAdapter::workspaceActionsPost(
return 202;
}
void WebAPIAdapter::applyWindowState(const void *owner, SWGSDRangel::SWGWorkspaceInfo& response)
{
MainCore::WindowState state;
// The GUI's word for the workspace is taken over the channel's own, which channel plugins
// update only when their settings are next applied
if (m_mainCore->getWindowState(owner, state))
{
if (state.m_workspaceIndex >= 0) {
response.setIndex(state.m_workspaceIndex);
}
response.setHidden(state.m_hidden ? 1 : 0);
}
}
int WebAPIAdapter::channelWorkspaceGet(ChannelAPI *channelAPI, SWGSDRangel::SWGWorkspaceInfo& response, QString& errorMessage)
{
int status = channelAPI->webapiWorkspaceGet(response, errorMessage);
if (status / 100 == 2) {
applyWindowState(channelAPI, response);
}
return status;
}
bool WebAPIAdapter::postWindowHidden(MainCore::MsgSetWindowHidden::Kind kind, int deviceSetIndex, int index, const SWGSDRangel::SWGWorkspaceInfo& query)
{
// The validator passes -1 for a field the request did not carry
const int hidden = const_cast<SWGSDRangel::SWGWorkspaceInfo&>(query).getHidden();
if (hidden < 0) {
return false;
}
m_mainCore->m_mainMessageQueue->push(MainCore::MsgSetWindowHidden::create(kind, deviceSetIndex, index, hidden != 0));
return true;
}
int WebAPIAdapter::instanceWindowsGet(
SWGSDRangel::SWGWindowList& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) error;
response.init();
QList<SWGSDRangel::SWGWindowInfo*> *windows = response.getWindows();
auto add = [&](const QString& kind, int deviceSetIndex, int index, const QString& fallbackTitle, int fallbackWorkspace, const void *owner)
{
MainCore::WindowState state;
const bool published = m_mainCore->getWindowState(owner, state);
SWGSDRangel::SWGWindowInfo *window = new SWGSDRangel::SWGWindowInfo();
window->init();
window->setKind(new QString(kind));
if (deviceSetIndex >= 0) {
window->setDeviceSetIndex(deviceSetIndex);
}
if (index >= 0) {
window->setIndex(index);
}
window->setTitle(new QString(published && !state.m_title.isEmpty() ? state.m_title : fallbackTitle));
window->setWorkspaceIndex(published && (state.m_workspaceIndex >= 0) ? state.m_workspaceIndex : fallbackWorkspace);
window->setHidden(published && state.m_hidden ? 1 : 0);
windows->append(window);
};
for (int i = 0; i < (int) m_mainCore->m_deviceSets.size(); i++)
{
DeviceSet *deviceSet = m_mainCore->m_deviceSets[i];
add("device", i, -1, deviceSet->m_deviceAPI->getSamplingDeviceDisplayName(), deviceSet->m_deviceAPI->getWorkspaceIndex(), deviceSet->m_deviceAPI);
add("spectrum", i, -1, "Spectrum", deviceSet->m_spectrumVis->getWorkspaceIndex(), deviceSet->m_spectrumVis);
for (int c = 0; c < deviceSet->getNumberOfChannels(); c++)
{
ChannelAPI *channel = deviceSet->getChannelAt(c);
if (!channel) {
continue;
}
QString title;
channel->getTitle(title);
SWGSDRangel::SWGWorkspaceInfo info;
QString ignored;
info.init();
int workspace = (channel->webapiWorkspaceGet(info, ignored) / 100 == 2) ? info.getIndex() : -1;
add("channel", i, c, title.isEmpty() ? channel->getIdentifier() : title, workspace, channel);
}
}
if (!m_mainCore->m_featureSets.empty())
{
const FeatureSet *featureSet = m_mainCore->m_featureSets[0];
for (int f = 0; f < featureSet->getNumberOfFeatures(); f++)
{
const Feature *feature = featureSet->getFeatureAt(f);
if (feature) {
add("feature", -1, f, feature->getIdentifier(), feature->getWorkspaceIndex(), feature);
}
}
}
response.setWindowCount(windows->size());
return 200;
}
int WebAPIAdapter::devicesetGet(
int deviceSetIndex,
SWGSDRangel::SWGDeviceSet& response,
@ -1985,6 +2099,7 @@ int WebAPIAdapter::devicesetSpectrumWorkspaceGet( @@ -1985,6 +2099,7 @@ int WebAPIAdapter::devicesetSpectrumWorkspaceGet(
{
const DeviceSet *deviceSet = m_mainCore->m_deviceSets[deviceSetIndex];
response.setIndex(deviceSet->m_spectrumVis->getWorkspaceIndex());
applyWindowState(deviceSet->m_spectrumVis, response);
return 200;
}
else
@ -2004,10 +2119,16 @@ int WebAPIAdapter::devicesetSpectrumWorkspacePut( @@ -2004,10 +2119,16 @@ int WebAPIAdapter::devicesetSpectrumWorkspacePut(
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore->m_deviceSets.size()))
{
int workspaceIndex = query.getIndex();
MainCore::MsgMoveMainSpectrumUIToWorkspace *msg = MainCore::MsgMoveMainSpectrumUIToWorkspace::create(deviceSetIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
if (workspaceIndex >= 0)
{
MainCore::MsgMoveMainSpectrumUIToWorkspace *msg = MainCore::MsgMoveMainSpectrumUIToWorkspace::create(deviceSetIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
}
postWindowHidden(MainCore::MsgSetWindowHidden::Spectrum, deviceSetIndex, -1, query);
response.init();
*response.getMessage() = QString("Message to move a main spectrum to workspace (MsgMoveMainSpectrumUIToWorkspace) was submitted successfully");
*response.getMessage() = QString("Message to move or show a main spectrum window (MsgMoveMainSpectrumUIToWorkspace, MsgSetWindowHidden) was submitted successfully");
return 202;
}
else
@ -2282,6 +2403,7 @@ int WebAPIAdapter::devicesetDeviceWorkspaceGet( @@ -2282,6 +2403,7 @@ int WebAPIAdapter::devicesetDeviceWorkspaceGet(
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore->m_deviceSets.size()))
{
response.setIndex(m_mainCore->m_deviceSets[deviceSetIndex]->m_deviceAPI->getWorkspaceIndex());
applyWindowState(m_mainCore->m_deviceSets[deviceSetIndex]->m_deviceAPI, response);
return 200;
}
else
@ -2301,10 +2423,16 @@ int WebAPIAdapter::devicesetDeviceWorkspacePut( @@ -2301,10 +2423,16 @@ int WebAPIAdapter::devicesetDeviceWorkspacePut(
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore->m_deviceSets.size()))
{
int workspaceIndex = query.getIndex();
MainCore::MsgMoveDeviceUIToWorkspace *msg = MainCore::MsgMoveDeviceUIToWorkspace::create(deviceSetIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
if (workspaceIndex >= 0)
{
MainCore::MsgMoveDeviceUIToWorkspace *msg = MainCore::MsgMoveDeviceUIToWorkspace::create(deviceSetIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
}
postWindowHidden(MainCore::MsgSetWindowHidden::Device, deviceSetIndex, -1, query);
response.init();
*response.getMessage() = QString("Message to move a device UI to workspace (MsgMoveDeviceUIToWorkspace) was submitted successfully");
*response.getMessage() = QString("Message to move or show a device window (MsgMoveDeviceUIToWorkspace, MsgSetWindowHidden) was submitted successfully");
return 202;
}
else
@ -3208,7 +3336,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet( @@ -3208,7 +3336,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet(
}
else
{
return channelAPI->webapiWorkspaceGet(response, *error.getMessage());
return channelWorkspaceGet(channelAPI, response, *error.getMessage());
}
}
else if (deviceSet->m_deviceSinkEngine) // Single Tx
@ -3222,7 +3350,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet( @@ -3222,7 +3350,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet(
}
else
{
return channelAPI->webapiWorkspaceGet(response, *error.getMessage());
return channelWorkspaceGet(channelAPI, response, *error.getMessage());
}
}
else if (deviceSet->m_deviceMIMOEngine) // MIMO
@ -3252,7 +3380,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet( @@ -3252,7 +3380,7 @@ int WebAPIAdapter::devicesetChannelWorkspaceGet(
if (channelAPI)
{
return channelAPI->webapiWorkspaceGet(response, *error.getMessage());
return channelWorkspaceGet(channelAPI, response, *error.getMessage());
}
else
{
@ -3289,10 +3417,16 @@ int WebAPIAdapter::devicesetChannelWorkspacePut( @@ -3289,10 +3417,16 @@ int WebAPIAdapter::devicesetChannelWorkspacePut(
if ((channelIndex >= 0) && (channelIndex < deviceSet->getNumberOfChannels()))
{
int workspaceIndex = query.getIndex();
MainCore::MsgMoveChannelUIToWorkspace *msg = MainCore::MsgMoveChannelUIToWorkspace::create(deviceSetIndex, channelIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
if (workspaceIndex >= 0)
{
MainCore::MsgMoveChannelUIToWorkspace *msg = MainCore::MsgMoveChannelUIToWorkspace::create(deviceSetIndex, channelIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
}
postWindowHidden(MainCore::MsgSetWindowHidden::Channel, deviceSetIndex, channelIndex, query);
response.init();
*response.getMessage() = QString("Message to move a channel UI to workspace (MsgMoveChannelUIToWorkspace) was submitted successfully");
*response.getMessage() = QString("Message to move or show a channel window (MsgMoveChannelUIToWorkspace, MsgSetWindowHidden) was submitted successfully");
return 202;
}
else
@ -3900,6 +4034,7 @@ int WebAPIAdapter::featuresetFeatureWorkspaceGet( @@ -3900,6 +4034,7 @@ int WebAPIAdapter::featuresetFeatureWorkspaceGet(
FeatureSet *featureSet = m_mainCore->m_featureSets[0];
Feature *feature = featureSet->getFeatureAt(featureIndex);
response.setIndex(feature->getWorkspaceIndex());
applyWindowState(feature, response);
return 200;
}
else
@ -3919,10 +4054,16 @@ int WebAPIAdapter::featuresetFeatureWorkspacePut( @@ -3919,10 +4054,16 @@ int WebAPIAdapter::featuresetFeatureWorkspacePut(
if ((featureIndex >= 0) && (m_mainCore->m_featureSets.size() > 0) && (featureIndex < m_mainCore->m_featureSets[0]->getNumberOfFeatures()))
{
int workspaceIndex = query.getIndex();
MainCore::MsgMoveFeatureUIToWorkspace *msg = MainCore::MsgMoveFeatureUIToWorkspace::create(featureIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
if (workspaceIndex >= 0)
{
MainCore::MsgMoveFeatureUIToWorkspace *msg = MainCore::MsgMoveFeatureUIToWorkspace::create(featureIndex, workspaceIndex);
m_mainCore->m_mainMessageQueue->push(msg);
}
postWindowHidden(MainCore::MsgSetWindowHidden::Feature, -1, featureIndex, query);
response.init();
*response.getMessage() = QString("Message to move a feature UI to workspace (MsgMoveFeatureUIToWorkspace) was submitted successfully");
*response.getMessage() = QString("Message to move or show a feature window (MsgMoveFeatureUIToWorkspace, MsgSetWindowHidden) was submitted successfully");
return 202;
}
else

15
sdrbase/webapi/webapiadapter.h

@ -26,9 +26,9 @@ @@ -26,9 +26,9 @@
#include <QtGlobal>
#include "webapi/webapiadapterinterface.h"
#include "maincore.h"
#include "export.h"
class MainCore;
class DeviceSet;
class FeatureSet;
@ -236,6 +236,10 @@ public: @@ -236,6 +236,10 @@ public:
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int instanceWindowsGet(
SWGSDRangel::SWGWindowList& response,
SWGSDRangel::SWGErrorResponse& error);
virtual int devicesetGet(
int deviceSetIndex,
SWGSDRangel::SWGDeviceSet& response,
@ -523,6 +527,15 @@ public: @@ -523,6 +527,15 @@ public:
private:
MainCore *m_mainCore;
//!< Overlays what the GUI has published for the window on the response: its workspace as
//!< the GUI has it, and whether it is hidden. Leaves a response for a window the GUI has
//!< not published (the server) as it was
void applyWindowState(const void *owner, SWGSDRangel::SWGWorkspaceInfo& response);
//!< A channel's workspace information from the plugin, with the GUI's state overlaid
int channelWorkspaceGet(ChannelAPI *channelAPI, SWGSDRangel::SWGWorkspaceInfo& response, QString& errorMessage);
//!< Posts the show or hide a PUT asks for, if it asks for one. Returns whether it did
bool postWindowHidden(MainCore::MsgSetWindowHidden::Kind kind, int deviceSetIndex, int index, const SWGSDRangel::SWGWorkspaceInfo& query);
void getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList);
void getDeviceSet(SWGSDRangel::SWGDeviceSet *swgDeviceSet, const DeviceSet* deviceSet, int deviceSetIndex);
void getChannelsDetail(SWGSDRangel::SWGChannelsDetail *channelsDetail, const DeviceSet* deviceSet);

1
sdrbase/webapi/webapiadapterinterface.cpp

@ -46,6 +46,7 @@ QString WebAPIAdapterInterface::instanceFeaturePresetURL = "/sdrangel/featurepre @@ -46,6 +46,7 @@ QString WebAPIAdapterInterface::instanceFeaturePresetURL = "/sdrangel/featurepre
QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets";
QString WebAPIAdapterInterface::instanceDeviceSetURL = "/sdrangel/deviceset";
QString WebAPIAdapterInterface::instanceWorkspaceURL = "/sdrangel/workspace";
QString WebAPIAdapterInterface::instanceWindowsURL = "/sdrangel/windows";
QString WebAPIAdapterInterface::featuresetURL("/sdrangel/featureset");
QString WebAPIAdapterInterface::featuresetFeatureURL("/sdrangel/featureset/feature");
QString WebAPIAdapterInterface::featuresetPresetURL("/sdrangel/featureset/preset");

16
sdrbase/webapi/webapiadapterinterface.h

@ -68,6 +68,7 @@ namespace SWGSDRangel @@ -68,6 +68,7 @@ namespace SWGSDRangel
class SWGDeviceActions;
class SWGWorkspaceInfo;
class SWGWorkspaceActions;
class SWGWindowList;
class SWGChannelsDetail;
class SWGChannelSettings;
class SWGChannelReport;
@ -811,6 +812,20 @@ public: @@ -811,6 +812,20 @@ public:
return 501;
}
/**
* Handler of /sdrangel/windows (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceWindowsGet
* returns the Http status code (default 501: not implemented)
*/
virtual int instanceWindowsGet(
SWGSDRangel::SWGWindowList& response,
SWGSDRangel::SWGErrorResponse& error)
{
(void) response;
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/workspace/{workspaceIndex}/actions (POST) swagger/sdrangel/code/html2/index.html#api-Default-workspaceActionsPost
* returns the Http status code (default 501: not implemented)
@ -1783,6 +1798,7 @@ public: @@ -1783,6 +1798,7 @@ public:
static QString instanceDeviceSetsURL;
static QString instanceDeviceSetURL;
static QString instanceWorkspaceURL;
static QString instanceWindowsURL;
static QString featuresetURL;
static QString featuresetFeatureURL;
static QString featuresetPresetURL;

46
sdrbase/webapi/webapirequestmapper.cpp

@ -54,6 +54,7 @@ @@ -54,6 +54,7 @@
#include "SWGDeviceActions.h"
#include "SWGWorkspaceInfo.h"
#include "SWGWorkspaceActions.h"
#include "SWGWindowList.h"
#include "SWGChannelsDetail.h"
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
@ -169,6 +170,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http @@ -169,6 +170,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
instanceDeviceSetService(request, response);
} else if (path == WebAPIAdapterInterface::instanceWorkspaceURL) {
instanceWorkspaceService(request, response);
} else if (path == WebAPIAdapterInterface::instanceWindowsURL) {
instanceWindowsService(request, response);
} else if (path == WebAPIAdapterInterface::featuresetURL) {
featuresetService(request, response);
} else if (path == WebAPIAdapterInterface::featuresetFeatureURL) {
@ -1730,6 +1733,33 @@ void WebAPIRequestMapper::instanceWorkspaceService(qtwebapp::HttpRequest& reques @@ -1730,6 +1733,33 @@ void WebAPIRequestMapper::instanceWorkspaceService(qtwebapp::HttpRequest& reques
}
}
void WebAPIRequestMapper::instanceWindowsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
response.setHeader("Content-Type", "application/json");
response.setHeader("Access-Control-Allow-Origin", "*");
if (request.getMethod() == "GET")
{
SWGSDRangel::SWGWindowList normalResponse;
int status = m_adapter->instanceWindowsGet(normalResponse, errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(normalResponse.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(405,"Invalid HTTP method");
errorResponse.init();
*errorResponse.getMessage() = "Invalid HTTP method";
response.write(errorResponse.asJson().toUtf8());
}
}
void WebAPIRequestMapper::devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
@ -4377,13 +4407,19 @@ bool WebAPIRequestMapper::validateWorkspaceActions(SWGSDRangel::SWGWorkspaceActi @@ -4377,13 +4407,19 @@ bool WebAPIRequestMapper::validateWorkspaceActions(SWGSDRangel::SWGWorkspaceActi
bool WebAPIRequestMapper::validateWorkspaceInfo(SWGSDRangel::SWGWorkspaceInfo& workspaceInfo, QJsonObject& jsonObject)
{
if (jsonObject.contains("index"))
{
workspaceInfo.setIndex(jsonObject["index"].toInt());
return true;
// Either field on its own is a request: index moves the window, hidden shows or hides it.
// What is absent is passed on as -1, since the object carries no other sign of absence
// that the adapter can read
const bool hasIndex = jsonObject.contains("index") && jsonObject["index"].isDouble();
const bool hasHidden = jsonObject.contains("hidden") && jsonObject["hidden"].isDouble();
if (!hasIndex && !hasHidden) {
return false;
}
return false;
workspaceInfo.setIndex(hasIndex ? jsonObject["index"].toInt() : -1);
workspaceInfo.setHidden(hasHidden ? (jsonObject["hidden"].toInt() != 0 ? 1 : 0) : -1);
return true;
}
bool WebAPIRequestMapper::validateConfig(

1
sdrbase/webapi/webapirequestmapper.h

@ -82,6 +82,7 @@ private: @@ -82,6 +82,7 @@ private:
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceWorkspaceService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceWindowsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetSpectrumSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);

2
sdrgui/CMakeLists.txt

@ -105,6 +105,7 @@ set(sdrgui_SOURCES @@ -105,6 +105,7 @@ set(sdrgui_SOURCES
gui/welcomedialog.cpp
gui/workspace.cpp
gui/workspaceselectiondialog.cpp
gui/workspacewindow.cpp
gui/wsspectrumsettingsdialog.cpp
gui/wrappingdatetimeedit.cpp
gui/wrappingdial.cpp
@ -241,6 +242,7 @@ set(sdrgui_HEADERS @@ -241,6 +242,7 @@ set(sdrgui_HEADERS
gui/welcomedialog.h
gui/workspace.h
gui/workspaceselectiondialog.h
gui/workspacewindow.h
gui/wsspectrumsettingsdialog.h
gui/wrappingdatetimeedit.h
gui/wrappingdial.h

3
sdrgui/channel/channelgui.cpp

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
#include "channelgui.h"
ChannelGUI::ChannelGUI(QWidget *parent) :
QMdiSubWindow(parent),
WorkspaceWindow(parent),
m_resizer(this),
m_contextMenuType(ContextMenuType::ContextMenuNone),
m_deviceType(DeviceType::DeviceRx),
@ -459,6 +459,7 @@ void ChannelGUI::shrinkWindow() @@ -459,6 +459,7 @@ void ChannelGUI::shrinkWindow()
void ChannelGUI::setTitle(const QString& title)
{
m_titleLabel->setText(title);
publishWindowState();
}
void ChannelGUI::setTitleColor(const QColor& c)

9
sdrgui/channel/channelgui.h

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include "gui/qtcompatibility.h"
#include "gui/framelesswindowresizer.h"
#include "gui/workspacewindow.h"
#include "settings/serializableinterface.h"
#include "export.h"
@ -39,7 +40,7 @@ class QSizeGrip; @@ -39,7 +40,7 @@ class QSizeGrip;
class RollupContents;
class ChannelMarker;
class SDRGUI_API ChannelGUI : public QMdiSubWindow, public SerializableInterface
class SDRGUI_API ChannelGUI : public WorkspaceWindow, public SerializableInterface
{
Q_OBJECT
public:
@ -61,11 +62,11 @@ public: @@ -61,11 +62,11 @@ public:
virtual void resetToDefaults() = 0;
// Data saved in the derived settings
virtual void setWorkspaceIndex(int index)= 0;
virtual int getWorkspaceIndex() const = 0;
virtual void setWorkspaceIndex(int index) override = 0;
virtual int getWorkspaceIndex() const override = 0;
virtual void setGeometryBytes(const QByteArray& blob) = 0;
virtual QByteArray getGeometryBytes() const = 0;
virtual QString getTitle() const = 0;
virtual QString getTitle() const override = 0;
virtual QColor getTitleColor() const = 0;
virtual void zetHidden(bool hidden) = 0;
virtual bool getHidden() const = 0;

3
sdrgui/device/devicegui.cpp

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
#include "devicegui.h"
DeviceGUI::DeviceGUI(QWidget *parent) :
QMdiSubWindow(parent),
WorkspaceWindow(parent),
m_deviceUISet(nullptr),
m_deviceType(DeviceRx),
m_deviceSetIndex(0),
@ -426,6 +426,7 @@ void DeviceGUI::setTitle(const QString& title) @@ -426,6 +426,7 @@ void DeviceGUI::setTitle(const QString& title)
{
setWindowTitle(title + " Device");
m_titleLabel->setText(title);
publishWindowState();
}
QString DeviceGUI::getTitle() const

9
sdrgui/device/devicegui.h

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include "gui/channeladddialog.h"
#include "gui/framelesswindowresizer.h"
#include "gui/workspacewindow.h"
#include "settings/serializableinterface.h"
#include "export.h"
@ -43,7 +44,7 @@ class QHBoxLayout; @@ -43,7 +44,7 @@ class QHBoxLayout;
class QSizeGrip;
class DeviceUISet;
class SDRGUI_API DeviceGUI : public QMdiSubWindow, public SerializableInterface {
class SDRGUI_API DeviceGUI : public WorkspaceWindow, public SerializableInterface {
Q_OBJECT
public:
enum DeviceType
@ -63,8 +64,8 @@ public: @@ -63,8 +64,8 @@ public:
~DeviceGUI() override;
virtual void resetToDefaults() = 0;
void setWorkspaceIndex(int index);
int getWorkspaceIndex() const { return m_workspaceIndex; }
void setWorkspaceIndex(int index) override;
int getWorkspaceIndex() const override { return m_workspaceIndex; }
virtual MessageQueue* getInputMessageQueue() = 0;
@ -73,7 +74,7 @@ public: @@ -73,7 +74,7 @@ public:
void setDeviceType(DeviceType type);
DeviceType getDeviceType() const { return m_deviceType; }
void setTitle(const QString& title);
QString getTitle() const;
QString getTitle() const override;
void setDefaultTitle(const QString& title) { m_defaultTitle = title; }
QString getDefaultTitle() const { return m_defaultTitle; }
void setToolTip(const QString& tooltip);

4
sdrgui/device/deviceuiset.cpp

@ -56,6 +56,7 @@ DeviceUISet::DeviceUISet(int deviceSetIndex, DeviceSet *deviceSet) @@ -56,6 +56,7 @@ DeviceUISet::DeviceUISet(int deviceSetIndex, DeviceSet *deviceSet)
m_spectrumGUI = new GLSpectrumGUI;
m_spectrumGUI->setBuddies(m_spectrumVis, m_spectrum);
m_mainSpectrumGUI = new MainSpectrumGUI(m_spectrum, m_spectrumGUI);
m_mainSpectrumGUI->setWindowOwner(m_spectrumVis);
// m_channelWindow = new ChannelWindow;
m_deviceAPI = nullptr;
m_deviceGUI = nullptr;
@ -111,6 +112,7 @@ void DeviceUISet::removeChannelMarker(ChannelMarker* channelMarker) @@ -111,6 +112,7 @@ void DeviceUISet::removeChannelMarker(ChannelMarker* channelMarker)
void DeviceUISet::registerRxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{
channelGUI->setWindowOwner(channelAPI);
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelAPI, channelGUI, 0));
m_deviceSet->addChannelInstance(channelAPI);
QObject::connect(
@ -124,6 +126,7 @@ void DeviceUISet::registerRxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* @@ -124,6 +126,7 @@ void DeviceUISet::registerRxChannelInstance(ChannelAPI *channelAPI, ChannelGUI*
void DeviceUISet::registerTxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{
channelGUI->setWindowOwner(channelAPI);
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelAPI, channelGUI, 1));
m_deviceSet->addChannelInstance(channelAPI);
QObject::connect(
@ -137,6 +140,7 @@ void DeviceUISet::registerTxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* @@ -137,6 +140,7 @@ void DeviceUISet::registerTxChannelInstance(ChannelAPI *channelAPI, ChannelGUI*
void DeviceUISet::registerChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{
channelGUI->setWindowOwner(channelAPI);
m_channelInstanceRegistrations.append(ChannelInstanceRegistration( channelAPI, channelGUI, 2));
m_deviceSet->addChannelInstance(channelAPI);
QObject::connect(

3
sdrgui/feature/featuregui.cpp

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
#include "featuregui.h"
FeatureGUI::FeatureGUI(QWidget *parent) :
QMdiSubWindow(parent),
WorkspaceWindow(parent),
m_featureIndex(0),
m_contextMenuType(ContextMenuNone),
m_resizer(this),
@ -443,6 +443,7 @@ void FeatureGUI::shrinkWindow() @@ -443,6 +443,7 @@ void FeatureGUI::shrinkWindow()
void FeatureGUI::setTitle(const QString& title)
{
m_titleLabel->setText(title);
publishWindowState();
}
QString FeatureGUI::getTitle() const

9
sdrgui/feature/featuregui.h

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include <QMap>
#include "gui/framelesswindowresizer.h"
#include "gui/workspacewindow.h"
#include "gui/rollupcontents.h"
#include "settings/serializableinterface.h"
#include "export.h"
@ -39,7 +40,7 @@ class QHBoxLayout; @@ -39,7 +40,7 @@ class QHBoxLayout;
class QSizeGrip;
class Feature;
class SDRGUI_API FeatureGUI : public QMdiSubWindow, public SerializableInterface
class SDRGUI_API FeatureGUI : public WorkspaceWindow, public SerializableInterface
{
Q_OBJECT
public:
@ -55,8 +56,8 @@ public: @@ -55,8 +56,8 @@ public:
virtual void resetToDefaults() = 0;
// Data saved in the derived settings
virtual void setWorkspaceIndex(int index)= 0;
virtual int getWorkspaceIndex() const = 0;
virtual void setWorkspaceIndex(int index) override = 0;
virtual int getWorkspaceIndex() const override = 0;
virtual void setGeometryBytes(const QByteArray& blob) = 0;
virtual QByteArray getGeometryBytes() const = 0;
@ -66,7 +67,7 @@ public: @@ -66,7 +67,7 @@ public:
void sizeToContents();
void setTitleColor(const QColor&) {} // not implemented for a feature
void setTitle(const QString& title);
QString getTitle() const;
QString getTitle() const override;
void setIndex(int index);
int getIndex() const { return m_featureIndex; }
void setDisplayedame(const QString& name);

1
sdrgui/feature/featureuiset.cpp

@ -40,6 +40,7 @@ FeatureUISet::~FeatureUISet() @@ -40,6 +40,7 @@ FeatureUISet::~FeatureUISet()
void FeatureUISet::registerFeatureInstance(FeatureGUI* featureGUI, Feature *feature)
{
featureGUI->setWindowOwner(feature);
m_featureInstanceRegistrations.append(FeatureInstanceRegistration(featureGUI, feature));
m_featureSet->addFeatureInstance(feature);
QObject::connect(

92
sdrgui/gui/workspacewindow.cpp

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <QShowEvent>
#include <QHideEvent>
#include "maincore.h"
#include "workspace.h"
#include "workspacewindow.h"
WorkspaceWindow::WorkspaceWindow(QWidget *parent) :
QMdiSubWindow(parent),
m_windowOwner(nullptr)
{
}
WorkspaceWindow::~WorkspaceWindow()
{
if (m_windowOwner) {
MainCore::instance()->removeWindowState(m_windowOwner);
}
}
void WorkspaceWindow::setWindowOwner(const void *owner)
{
m_windowOwner = owner;
publishWindowState();
}
void WorkspaceWindow::publishWindowState()
{
if (!m_windowOwner) {
return;
}
MainCore::WindowState state;
state.m_workspaceIndex = workspaceIndexFromParent();
state.m_hidden = isHidden();
state.m_title = getTitle();
MainCore::instance()->setWindowState(m_windowOwner, state);
}
// The workspace the window is actually in. Preferred to getWorkspaceIndex(), as channel
// plugins keep that in their settings, where a settings message from the channel, which
// was never told about a move, can overwrite it with the workspace the channel started in
int WorkspaceWindow::workspaceIndexFromParent() const
{
for (const QWidget *widget = parentWidget(); widget; widget = widget->parentWidget())
{
const Workspace *workspace = qobject_cast<const Workspace*>(widget);
if (workspace) {
return workspace->getIndex();
}
}
return getWorkspaceIndex();
}
// Spontaneous show and hide events come from the window system, as when the main window is
// minimised, and do not change whether the window itself is hidden
void WorkspaceWindow::showEvent(QShowEvent *event)
{
QMdiSubWindow::showEvent(event);
if (!event->spontaneous()) {
publishWindowState();
}
}
void WorkspaceWindow::hideEvent(QHideEvent *event)
{
QMdiSubWindow::hideEvent(event);
if (!event->spontaneous()) {
publishWindowState();
}
}

57
sdrgui/gui/workspacewindow.h

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_WORKSPACEWINDOW_H_
#define SDRGUI_GUI_WORKSPACEWINDOW_H_
#include <QMdiSubWindow>
#include "export.h"
// A window in a workspace: the device, spectrum, channel and feature windows. What is common
// to them is here, which is mostly telling MainCore where the window is and whether it is
// hidden, so that the Web API, which has no access to the GUI, can answer for it.
class SDRGUI_API WorkspaceWindow : public QMdiSubWindow
{
Q_OBJECT
public:
explicit WorkspaceWindow(QWidget *parent = nullptr);
virtual ~WorkspaceWindow();
virtual int getWorkspaceIndex() const = 0;
virtual void setWorkspaceIndex(int index) = 0;
virtual QString getTitle() const = 0;
//!< The object the window belongs to (DeviceAPI, SpectrumVis, ChannelAPI or Feature),
//!< which is the key its state is published under.
void setWindowOwner(const void *owner);
//!< Tells MainCore which workspace this window is in, whether it is hidden and what its
//!< title is. Called on every show and hide, which covers a move between workspaces;
//!< call it after anything else that changes one of them, as a retitle or a renumbering
void publishWindowState();
protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
private:
int workspaceIndexFromParent() const;
const void *m_windowOwner;
};
#endif // SDRGUI_GUI_WORKSPACEWINDOW_H_

3
sdrgui/mainspectrum/mainspectrumgui.cpp

@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
#include "mainspectrumgui.h"
MainSpectrumGUI::MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGUI, QWidget *parent) :
QMdiSubWindow(parent),
WorkspaceWindow(parent),
m_spectrum(spectrum),
m_spectrumGUI(spectrumGUI),
m_deviceType(DeviceRx),
@ -315,6 +315,7 @@ void MainSpectrumGUI::setTitle(const QString& title) @@ -315,6 +315,7 @@ void MainSpectrumGUI::setTitle(const QString& title)
{
setWindowTitle(title + " Spectrum");
m_titleLabel->setText(title);
publishWindowState();
}
QString MainSpectrumGUI::getTitle() const

9
sdrgui/mainspectrum/mainspectrumgui.h

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include <QByteArray>
#include "gui/framelesswindowresizer.h"
#include "gui/workspacewindow.h"
#include "export.h"
class GLSpectrum;
@ -35,7 +36,7 @@ class QVBoxLayout; @@ -35,7 +36,7 @@ class QVBoxLayout;
class QHBoxLayout;
class QSizeGrip;
class SDRGUI_API MainSpectrumGUI : public QMdiSubWindow
class SDRGUI_API MainSpectrumGUI : public WorkspaceWindow
{
Q_OBJECT
public:
@ -52,12 +53,12 @@ public: @@ -52,12 +53,12 @@ public:
void setDeviceType(DeviceType type);
DeviceType getDeviceType() const { return m_deviceType; }
void setTitle(const QString& title);
QString getTitle() const;
QString getTitle() const override;
void setToolTip(const QString& tooltip);
void setIndex(int index);
int getIndex() const { return m_deviceSetIndex; }
void setWorkspaceIndex(int index);
int getWorkspaceIndex() const { return m_workspaceIndex; }
void setWorkspaceIndex(int index) override;
int getWorkspaceIndex() const override { return m_workspaceIndex; }
void setGeometryBytes(const QByteArray& blob) { m_geometryBytes = blob; }
const QByteArray& getGeometryBytes() const { return m_geometryBytes; }

73
sdrgui/mainwindow.cpp

@ -1407,6 +1407,7 @@ void MainWindow::sampleSourceCreateUI( @@ -1407,6 +1407,7 @@ void MainWindow::sampleSourceCreateUI(
deviceAPI->getSampleSource()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
deviceUISet->m_deviceGUI = deviceGUI;
deviceGUI->setWindowOwner(deviceAPI);
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex); // FIXME: Why not use samplingDevice?
deviceUISet->m_selectedDeviceId = selectedDevice->id;
@ -1564,6 +1565,7 @@ void MainWindow::sampleSinkCreateUI( @@ -1564,6 +1565,7 @@ void MainWindow::sampleSinkCreateUI(
deviceAPI->getSampleSink()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
deviceUISet->m_deviceGUI = deviceGUI;
deviceGUI->setWindowOwner(deviceAPI);
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(deviceIndex);
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex); // FIXME: Why getRxSamplingDevice?
deviceUISet->m_selectedDeviceId = selectedDevice->id;
@ -1702,6 +1704,7 @@ void MainWindow::sampleMIMOCreateUI( @@ -1702,6 +1704,7 @@ void MainWindow::sampleMIMOCreateUI(
deviceAPI->getSampleMIMO()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
deviceUISet->m_deviceGUI = deviceGUI;
deviceGUI->setWindowOwner(deviceAPI);
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(deviceIndex);
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex); // FIXME: Why getRxSamplingDevice?
deviceUISet->m_selectedDeviceId = selectedDevice->id;
@ -2479,6 +2482,58 @@ bool MainWindow::handleMessage(const Message& cmd) @@ -2479,6 +2482,58 @@ bool MainWindow::handleMessage(const Message& cmd)
return true;
}
else if (MainCore::MsgSetWindowHidden::match(cmd))
{
auto& notif = (const MainCore::MsgSetWindowHidden&) cmd;
QMdiSubWindow *window = nullptr;
int workspaceIndex = -1;
const int deviceSetIndex = notif.getDeviceSetIndex();
const bool haveDeviceSet = (deviceSetIndex >= 0) && (deviceSetIndex < (int) m_deviceUIs.size());
switch (notif.getKind())
{
case MainCore::MsgSetWindowHidden::Device:
if (haveDeviceSet && m_deviceUIs[deviceSetIndex]->m_deviceGUI)
{
window = m_deviceUIs[deviceSetIndex]->m_deviceGUI;
workspaceIndex = m_deviceUIs[deviceSetIndex]->m_deviceGUI->getWorkspaceIndex();
}
break;
case MainCore::MsgSetWindowHidden::Spectrum:
if (haveDeviceSet && m_deviceUIs[deviceSetIndex]->m_mainSpectrumGUI)
{
window = m_deviceUIs[deviceSetIndex]->m_mainSpectrumGUI;
workspaceIndex = m_deviceUIs[deviceSetIndex]->m_mainSpectrumGUI->getWorkspaceIndex();
}
break;
case MainCore::MsgSetWindowHidden::Channel:
if (haveDeviceSet && (notif.getIndex() >= 0) && (notif.getIndex() < m_deviceUIs[deviceSetIndex]->getNumberOfChannels()))
{
ChannelGUI *gui = m_deviceUIs[deviceSetIndex]->getChannelGUIAt(notif.getIndex());
window = gui;
workspaceIndex = gui ? gui->getWorkspaceIndex() : -1;
}
break;
case MainCore::MsgSetWindowHidden::Feature:
if (!m_featureUIs.empty() && (notif.getIndex() >= 0) && (notif.getIndex() < m_featureUIs[0]->getNumberOfFeatures()))
{
FeatureGUI *gui = m_featureUIs[0]->getFeatureGuiAt(notif.getIndex());
window = gui;
workspaceIndex = gui ? gui->getWorkspaceIndex() : -1;
}
break;
}
if (!window) {
qWarning("MainWindow::handleMessages: MsgSetWindowHidden: no such window");
} else if (notif.getHidden()) {
window->hide();
} else {
showWindow(window, workspaceIndex);
}
return true;
}
else if (MainCore::MsgArrangeWorkspace::match(cmd))
{
auto& notif = (const MainCore::MsgArrangeWorkspace&) cmd;
@ -2915,20 +2970,12 @@ void MainWindow::removeEmptyWorkspaces() @@ -2915,20 +2970,12 @@ void MainWindow::removeEmptyWorkspaces()
for (auto& subWindow : subWindows)
{
if (qobject_cast<DeviceGUI*>(subWindow)) {
qobject_cast<DeviceGUI*>(subWindow)->setWorkspaceIndex(i);
}
if (qobject_cast<MainSpectrumGUI*>(subWindow)) {
qobject_cast<MainSpectrumGUI*>(subWindow)->setWorkspaceIndex(i);
}
WorkspaceWindow *window = qobject_cast<WorkspaceWindow*>(subWindow);
if (qobject_cast<ChannelGUI*>(subWindow)) {
qobject_cast<ChannelGUI*>(subWindow)->setWorkspaceIndex(i);
}
if (qobject_cast<FeatureGUI*>(subWindow)) {
qobject_cast<FeatureGUI*>(subWindow)->setWorkspaceIndex(i);
if (window)
{
window->setWorkspaceIndex(i);
window->publishWindowState();
}
}
}

Loading…
Cancel
Save