Browse Source
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
22 changed files with 550 additions and 54 deletions
@ -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(); |
||||
} |
||||
} |
||||
@ -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_
|
||||
Loading…
Reference in new issue