2022-04-04 04:23:52 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QMdiArea>
|
|
|
|
#include <QMdiSubWindow>
|
|
|
|
#include <QFrame>
|
2022-04-26 13:19:31 -04:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QApplication>
|
2022-12-20 11:10:11 -05:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QAction>
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
#include "gui/samplingdevicedialog.h"
|
2022-04-26 13:19:31 -04:00
|
|
|
#include "gui/rollupcontents.h"
|
2022-04-27 07:53:56 -04:00
|
|
|
#include "gui/buttonswitch.h"
|
2022-12-20 11:10:11 -05:00
|
|
|
#include "gui/crightclickenabler.h"
|
2022-04-26 13:19:31 -04:00
|
|
|
#include "channel/channelgui.h"
|
|
|
|
#include "feature/featuregui.h"
|
|
|
|
#include "device/devicegui.h"
|
2022-08-27 05:18:17 -04:00
|
|
|
#include "device/deviceset.h"
|
2022-04-26 13:19:31 -04:00
|
|
|
#include "mainspectrum/mainspectrumgui.h"
|
2022-04-04 04:23:52 -04:00
|
|
|
#include "workspace.h"
|
2022-08-27 05:18:17 -04:00
|
|
|
#include "maincore.h"
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
Workspace::Workspace(int index, QWidget *parent, Qt::WindowFlags flags) :
|
|
|
|
QDockWidget(parent, flags),
|
|
|
|
m_index(index),
|
2022-12-20 11:10:11 -05:00
|
|
|
m_menuButton(nullptr),
|
2022-04-26 13:19:31 -04:00
|
|
|
m_featureAddDialog(this),
|
|
|
|
m_stacking(false),
|
2022-12-20 11:10:11 -05:00
|
|
|
m_autoStack(false),
|
2022-04-26 13:19:31 -04:00
|
|
|
m_userChannelMinWidth(0)
|
2022-04-04 04:23:52 -04:00
|
|
|
{
|
|
|
|
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));
|
2022-04-05 10:26:57 -04:00
|
|
|
setObjectName(tr("W%1").arg(m_index));
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
m_titleBar = new QWidget();
|
|
|
|
m_titleBarLayout = new QHBoxLayout();
|
2022-09-25 14:53:16 -04:00
|
|
|
m_titleBarLayout->setContentsMargins(QMargins());
|
2022-04-04 04:23:52 -04:00
|
|
|
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());
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
#ifdef ANDROID
|
|
|
|
m_menuButton = new QToolButton();
|
|
|
|
QIcon menuIcon(":/listing.png");
|
|
|
|
m_menuButton->setIcon(menuIcon);
|
|
|
|
m_menuButton->setFixedSize(20, 20);
|
|
|
|
m_menuButton->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_configurationPresetsButton = new QPushButton();
|
|
|
|
QIcon configurationPresetsIcon(":/star.png");
|
|
|
|
m_configurationPresetsButton->setIcon(configurationPresetsIcon);
|
|
|
|
m_configurationPresetsButton->setToolTip("Configuration presets");
|
|
|
|
m_configurationPresetsButton->setFixedSize(20, 20);
|
|
|
|
|
|
|
|
m_startStopButton = new ButtonSwitch();
|
|
|
|
m_startStopButton->setCheckable(true);
|
|
|
|
updateStartStopButton(false);
|
|
|
|
m_startStopButton->setFixedSize(20, 20);
|
|
|
|
|
|
|
|
m_vline1 = new QFrame();
|
|
|
|
m_vline1->setFrameShape(QFrame::VLine);
|
|
|
|
m_vline1->setFrameShadow(QFrame::Sunken);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
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);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
m_vline2 = new QFrame();
|
|
|
|
m_vline2->setFrameShape(QFrame::VLine);
|
|
|
|
m_vline2->setFrameShadow(QFrame::Sunken);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
m_addFeatureButton = new QPushButton();
|
2022-04-09 07:38:22 -04:00
|
|
|
QIcon addFeatureIcon(":/tool_add.png");
|
2022-04-04 04:23:52 -04:00
|
|
|
m_addFeatureButton->setIcon(addFeatureIcon);
|
|
|
|
m_addFeatureButton->setToolTip("Add features");
|
|
|
|
m_addFeatureButton->setFixedSize(20, 20);
|
|
|
|
|
|
|
|
m_featurePresetsButton = new QPushButton();
|
2022-04-09 07:38:22 -04:00
|
|
|
QIcon presetsIcon(":/tool_star.png");
|
2022-04-04 04:23:52 -04:00
|
|
|
m_featurePresetsButton->setIcon(presetsIcon);
|
|
|
|
m_featurePresetsButton->setToolTip("Feature presets");
|
|
|
|
m_featurePresetsButton->setFixedSize(20, 20);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
m_vline3 = new QFrame();
|
|
|
|
m_vline3->setFrameShape(QFrame::VLine);
|
|
|
|
m_vline3->setFrameShadow(QFrame::Sunken);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
m_stackVerticalSubWindows = new QPushButton();
|
|
|
|
QIcon stackVerticalSubWindowsIcon(":/stackvertical.png");
|
|
|
|
m_stackVerticalSubWindows->setIcon(stackVerticalSubWindowsIcon);
|
|
|
|
m_stackVerticalSubWindows->setToolTip("Stack sub windows vertically");
|
|
|
|
m_stackVerticalSubWindows->setFixedSize(20, 20);
|
|
|
|
|
|
|
|
m_stackSubWindows = new QPushButton();
|
|
|
|
QIcon stackSubWindowsIcon(":/stackcolumns.png");
|
|
|
|
m_stackSubWindows->setIcon(stackSubWindowsIcon);
|
|
|
|
m_stackSubWindows->setToolTip("Stack sub windows in columns. Right click to stack automatically.");
|
2022-04-26 13:19:31 -04:00
|
|
|
m_stackSubWindows->setFixedSize(20, 20);
|
2022-12-20 11:10:11 -05:00
|
|
|
CRightClickEnabler *stackSubWindowsRightClickEnabler = new CRightClickEnabler(m_stackSubWindows);
|
|
|
|
connect(stackSubWindowsRightClickEnabler, &CRightClickEnabler::rightClick, this, &Workspace::autoStackSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
m_tabSubWindows = new ButtonSwitch();
|
|
|
|
QIcon tabSubWindowsIcon(":/tab.png");
|
|
|
|
m_tabSubWindows->setIcon(tabSubWindowsIcon);
|
|
|
|
m_tabSubWindows->setCheckable(true);
|
|
|
|
m_tabSubWindows->setToolTip("Display sub windows in tabs");
|
|
|
|
m_tabSubWindows->setFixedSize(20, 20);
|
2022-04-26 13:19:31 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
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();
|
2022-04-05 10:26:57 -04:00
|
|
|
QIcon closeIcon(":/hide.png");
|
2022-04-04 04:23:52 -04:00
|
|
|
m_closeButton->setIcon(closeIcon);
|
|
|
|
m_closeButton->setToolTip("Hide workspace");
|
|
|
|
m_closeButton->setFixedSize(20, 20);
|
|
|
|
|
|
|
|
m_titleBarLayout->addWidget(m_titleLabel);
|
2022-12-20 11:10:11 -05:00
|
|
|
if (m_menuButton) {
|
|
|
|
m_titleBarLayout->addWidget(m_menuButton);
|
|
|
|
}
|
|
|
|
m_titleBarLayout->addWidget(m_configurationPresetsButton);
|
|
|
|
m_titleBarLayout->addWidget(m_startStopButton);
|
|
|
|
m_titleBarLayout->addWidget(m_vline1);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addWidget(m_addRxDeviceButton);
|
|
|
|
m_titleBarLayout->addWidget(m_addTxDeviceButton);
|
|
|
|
m_titleBarLayout->addWidget(m_addMIMODeviceButton);
|
2022-12-20 11:10:11 -05:00
|
|
|
m_titleBarLayout->addWidget(m_vline2);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addWidget(m_addFeatureButton);
|
|
|
|
m_titleBarLayout->addWidget(m_featurePresetsButton);
|
2022-12-20 11:10:11 -05:00
|
|
|
m_titleBarLayout->addWidget(m_vline3);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addWidget(m_cascadeSubWindows);
|
|
|
|
m_titleBarLayout->addWidget(m_tileSubWindows);
|
2022-12-20 11:10:11 -05:00
|
|
|
m_titleBarLayout->addWidget(m_stackVerticalSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
m_titleBarLayout->addWidget(m_stackSubWindows);
|
2022-12-20 11:10:11 -05:00
|
|
|
m_titleBarLayout->addWidget(m_tabSubWindows);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addStretch(1);
|
2022-12-20 11:10:11 -05:00
|
|
|
#ifndef ANDROID
|
|
|
|
// Can't undock on Android, as windows don't have title bars to allow them to be moved
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addWidget(m_normalButton);
|
2022-12-20 11:10:11 -05:00
|
|
|
// Don't allow workspaces to be hidden on Android, as if all are hidden, they'll
|
|
|
|
// be no way to redisplay them, as we currently don't have a main menu bar
|
2022-04-04 04:23:52 -04:00
|
|
|
m_titleBarLayout->addWidget(m_closeButton);
|
2022-12-20 11:10:11 -05:00
|
|
|
#else
|
|
|
|
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
#endif
|
2022-04-04 04:23:52 -04:00
|
|
|
setTitleBarWidget(m_titleBar);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_addRxDeviceButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
2022-04-07 10:32:03 -04:00
|
|
|
&Workspace::addRxDeviceClicked
|
2022-04-04 04:23:52 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_addTxDeviceButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
2022-04-07 10:32:03 -04:00
|
|
|
&Workspace::addTxDeviceClicked
|
2022-04-04 04:23:52 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_addMIMODeviceButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
2022-04-07 10:32:03 -04:00
|
|
|
&Workspace::addMIMODeviceClicked
|
2022-04-04 04:23:52 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_addFeatureButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::addFeatureDialog
|
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_featurePresetsButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::featurePresetsDialog
|
|
|
|
);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
QObject::connect(
|
|
|
|
m_configurationPresetsButton,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::configurationPresetsDialog
|
|
|
|
);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_cascadeSubWindows,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::cascadeSubWindows
|
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_tileSubWindows,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::tileSubWindows
|
|
|
|
);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
QObject::connect(
|
|
|
|
m_stackVerticalSubWindows,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::stackVerticalSubWindows
|
|
|
|
);
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_stackSubWindows,
|
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::stackSubWindows
|
|
|
|
);
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_startStopButton,
|
|
|
|
&ButtonSwitch::clicked,
|
|
|
|
this,
|
|
|
|
&Workspace::startStopClicked
|
|
|
|
);
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
QObject::connect(
|
2022-12-20 11:10:11 -05:00
|
|
|
m_tabSubWindows,
|
2022-04-26 13:19:31 -04:00
|
|
|
&QPushButton::clicked,
|
|
|
|
this,
|
2022-12-20 11:10:11 -05:00
|
|
|
&Workspace::tabSubWindows
|
2022-04-26 13:19:31 -04:00
|
|
|
);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
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
|
|
|
|
);
|
2022-04-26 13:19:31 -04:00
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
MainCore::instance(),
|
|
|
|
&MainCore::deviceStateChanged,
|
|
|
|
this,
|
|
|
|
&Workspace::deviceStateChanged
|
|
|
|
);
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
QObject::connect(
|
|
|
|
m_mdi,
|
|
|
|
&QMdiArea::subWindowActivated,
|
|
|
|
this,
|
|
|
|
&Workspace::subWindowActivated
|
|
|
|
);
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
m_tabSubWindows->setChecked(true);
|
|
|
|
tabSubWindows();
|
|
|
|
#endif
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Workspace::~Workspace()
|
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("Workspace::~Workspace");
|
2022-04-04 04:23:52 -04:00
|
|
|
delete m_closeButton;
|
|
|
|
delete m_normalButton;
|
2022-12-20 11:10:11 -05:00
|
|
|
delete m_tabSubWindows;
|
2022-04-26 13:19:31 -04:00
|
|
|
delete m_stackSubWindows;
|
2022-12-20 11:10:11 -05:00
|
|
|
delete m_stackVerticalSubWindows;
|
2022-04-04 04:23:52 -04:00
|
|
|
delete m_tileSubWindows;
|
|
|
|
delete m_cascadeSubWindows;
|
2022-12-20 11:10:11 -05:00
|
|
|
delete m_vline3;
|
2022-04-04 04:23:52 -04:00
|
|
|
delete m_vline2;
|
|
|
|
delete m_vline1;
|
2022-08-27 05:18:17 -04:00
|
|
|
delete m_startStopButton;
|
2022-12-20 11:10:11 -05:00
|
|
|
delete m_configurationPresetsButton;
|
|
|
|
delete m_menuButton;
|
2022-04-04 04:23:52 -04:00
|
|
|
delete m_addRxDeviceButton;
|
|
|
|
delete m_addTxDeviceButton;
|
|
|
|
delete m_addMIMODeviceButton;
|
|
|
|
delete m_addFeatureButton;
|
|
|
|
delete m_featurePresetsButton;
|
|
|
|
delete m_titleLabel;
|
|
|
|
delete m_titleBarLayout;
|
|
|
|
delete m_titleBar;
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("Workspace::~Workspace: about to delete MDI");
|
2022-04-04 04:23:52 -04:00
|
|
|
delete m_mdi;
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("Workspace::~Workspace: end");
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
2022-04-25 17:48:14 -04:00
|
|
|
void Workspace::setIndex(int index)
|
|
|
|
{
|
|
|
|
m_index = index;
|
|
|
|
setWindowTitle(tr("W%1").arg(m_index));
|
|
|
|
setObjectName(tr("W%1").arg(m_index));
|
|
|
|
m_titleLabel->setText(windowTitle());
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QMdiSubWindow *> Workspace::getSubWindowList() const
|
|
|
|
{
|
|
|
|
return m_mdi->subWindowList();
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void Workspace::toggleFloating()
|
|
|
|
{
|
|
|
|
setFloating(!isFloating());
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void Workspace::addRxDeviceClicked()
|
2022-04-04 04:23:52 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
SamplingDeviceDialog dialog(0, this);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
emit addRxDevice(this, dialog.getSelectedDeviceIndex());
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void Workspace::addTxDeviceClicked()
|
2022-04-04 04:23:52 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
SamplingDeviceDialog dialog(1, this);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
emit addTxDevice(this, dialog.getSelectedDeviceIndex());
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void Workspace::addMIMODeviceClicked()
|
2022-04-04 04:23:52 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
SamplingDeviceDialog dialog(2, this);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
emit addMIMODevice(this, dialog.getSelectedDeviceIndex());
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
void Workspace::configurationPresetsDialog()
|
|
|
|
{
|
|
|
|
emit configurationPresetsDialogRequested();
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void Workspace::cascadeSubWindows()
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
setAutoStackOption(false);
|
|
|
|
m_tabSubWindows->setChecked(false);
|
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_mdi->cascadeSubWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::tileSubWindows()
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
setAutoStackOption(false);
|
|
|
|
m_tabSubWindows->setChecked(false);
|
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_mdi->tileSubWindows();
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
void Workspace::stackVerticalSubWindows()
|
|
|
|
{
|
|
|
|
setAutoStackOption(false);
|
|
|
|
unmaximizeSubWindows();
|
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
|
|
|
|
|
|
|
// Spacing between windows
|
|
|
|
const int spacing = 2;
|
|
|
|
|
|
|
|
// Categorise windows according to type and calculate min size needed
|
|
|
|
QList<QMdiSubWindow *> windows = m_mdi->subWindowList(QMdiArea::CreationOrder);
|
|
|
|
QList<DeviceGUI *> devices;
|
|
|
|
QList<MainSpectrumGUI *> spectrums;
|
|
|
|
QList<ChannelGUI *> channels;
|
|
|
|
QList<FeatureGUI *> features;
|
|
|
|
int minHeight = 0;
|
|
|
|
int minWidth = 0;
|
|
|
|
int nonFixedWindows = 0;
|
|
|
|
|
|
|
|
for (auto window : windows)
|
|
|
|
{
|
|
|
|
if (window->isVisible() && !window->isMaximized())
|
|
|
|
{
|
|
|
|
if (window->inherits("DeviceGUI")) {
|
|
|
|
devices.append(qobject_cast<DeviceGUI *>(window));
|
|
|
|
} else if (window->inherits("MainSpectrumGUI")) {
|
|
|
|
spectrums.append(qobject_cast<MainSpectrumGUI *>(window));
|
|
|
|
} else if (window->inherits("ChannelGUI")) {
|
|
|
|
channels.append(qobject_cast<ChannelGUI *>(window));
|
|
|
|
} else if (window->inherits("FeatureGUI")) {
|
|
|
|
features.append(qobject_cast<FeatureGUI *>(window));
|
|
|
|
}
|
|
|
|
minHeight += window->minimumSizeHint().height() + spacing;
|
|
|
|
minWidth = std::max(minWidth, window->minimumSizeHint().width());
|
|
|
|
if (window->sizePolicy().verticalPolicy() != QSizePolicy::Fixed) {
|
|
|
|
nonFixedWindows++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Order windows by device/feature/channel index
|
|
|
|
orderByIndex(devices);
|
|
|
|
orderByIndex(spectrums);
|
|
|
|
orderByIndex(channels);
|
|
|
|
orderByIndex(features);
|
|
|
|
|
|
|
|
// Will we need scroll bars?
|
|
|
|
QSize mdiSize = m_mdi->size();
|
|
|
|
bool requiresHScrollBar = minWidth > mdiSize.width();
|
|
|
|
bool requiresVScrollBar = minHeight > mdiSize.height();
|
|
|
|
|
|
|
|
// Reduce available size if scroll bars needed
|
|
|
|
int sbWidth = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
if (requiresVScrollBar) {
|
|
|
|
mdiSize.setWidth(mdiSize.width() - sbWidth);
|
|
|
|
}
|
|
|
|
if (requiresHScrollBar) {
|
|
|
|
mdiSize.setHeight(mdiSize.height() - sbWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate spare vertical space, to be shared between non-fixed windows
|
|
|
|
int spareSpacePerWindow;
|
2022-12-20 18:17:31 -05:00
|
|
|
if (requiresVScrollBar || (nonFixedWindows == 0)) {
|
2022-12-20 11:10:11 -05:00
|
|
|
spareSpacePerWindow = 0;
|
|
|
|
} else {
|
|
|
|
spareSpacePerWindow = (mdiSize.height() - minHeight) / nonFixedWindows;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now position the windows
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
for (auto window : devices)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
for (auto window : spectrums)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
window->resize(mdiSize.width(), window->minimumSizeHint().height() + spareSpacePerWindow);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
for (auto window : channels)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
int extra = (window->sizePolicy().verticalPolicy() == QSizePolicy::Fixed) ? 0 : spareSpacePerWindow;
|
|
|
|
window->resize(mdiSize.width(), window->minimumSizeHint().height() + extra);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
for (auto window : features)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
int extra = (window->sizePolicy().verticalPolicy() == QSizePolicy::Fixed) ? 0 : spareSpacePerWindow;
|
|
|
|
window->resize(mdiSize.width(), window->minimumSizeHint().height() + extra);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
void Workspace::orderByIndex(QList<ChannelGUI *> &list)
|
|
|
|
{
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
[](const ChannelGUI *a, const ChannelGUI *b) -> bool
|
|
|
|
{
|
|
|
|
if (a->getDeviceSetIndex() == b->getDeviceSetIndex()) {
|
|
|
|
return a->getIndex() < b->getIndex();
|
|
|
|
} else {
|
|
|
|
return a->getDeviceSetIndex() < b->getDeviceSetIndex();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::orderByIndex(QList<FeatureGUI *> &list)
|
|
|
|
{
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
[](const FeatureGUI *a, const FeatureGUI *b) -> bool
|
|
|
|
{
|
|
|
|
return a->getIndex() < b->getIndex();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::orderByIndex(QList<DeviceGUI *> &list)
|
|
|
|
{
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
[](const DeviceGUI *a, const DeviceGUI *b) -> bool
|
|
|
|
{
|
|
|
|
return a->getIndex() < b->getIndex();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::orderByIndex(QList<MainSpectrumGUI *> &list)
|
|
|
|
{
|
|
|
|
std::sort(list.begin(), list.end(),
|
|
|
|
[](const MainSpectrumGUI *a, const MainSpectrumGUI *b) -> bool
|
|
|
|
{
|
|
|
|
return a->getIndex() < b->getIndex();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
void Workspace::unmaximizeSubWindows()
|
|
|
|
{
|
|
|
|
if (m_tabSubWindows->isChecked())
|
|
|
|
{
|
|
|
|
m_tabSubWindows->setChecked(false);
|
|
|
|
// Unmaximize any maximized windows
|
|
|
|
QList<QMdiSubWindow *> windows = m_mdi->subWindowList(QMdiArea::CreationOrder);
|
|
|
|
for (auto window : windows)
|
|
|
|
{
|
|
|
|
if (window->isMaximized()) {
|
|
|
|
window->showNormal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Try to arrange windows somewhat like in earlier versions of SDRangel
|
|
|
|
// Devices and fixed size features stacked on left
|
|
|
|
// Spectrum and expandable features stacked in centre
|
|
|
|
// Channels stacked on right
|
|
|
|
void Workspace::stackSubWindows()
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
unmaximizeSubWindows();
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Set a flag so event handler knows if it's this code or the user that
|
|
|
|
// resizes a window
|
|
|
|
m_stacking = true;
|
|
|
|
|
2022-12-20 11:10:11 -05:00
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Categorise windows according to type
|
|
|
|
QList<QMdiSubWindow *> windows = m_mdi->subWindowList(QMdiArea::CreationOrder);
|
|
|
|
QList<DeviceGUI *> devices;
|
|
|
|
QList<MainSpectrumGUI *> spectrums;
|
|
|
|
QList<ChannelGUI *> channels;
|
|
|
|
QList<FeatureGUI *> fixedFeatures;
|
|
|
|
QList<FeatureGUI *> features;
|
|
|
|
|
|
|
|
for (auto window : windows)
|
|
|
|
{
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
if (window->isVisible() && !window->isMaximized())
|
2022-04-26 13:19:31 -04:00
|
|
|
{
|
|
|
|
if (window->inherits("DeviceGUI")) {
|
|
|
|
devices.append(qobject_cast<DeviceGUI *>(window));
|
|
|
|
} else if (window->inherits("MainSpectrumGUI")) {
|
|
|
|
spectrums.append(qobject_cast<MainSpectrumGUI *>(window));
|
|
|
|
} else if (window->inherits("ChannelGUI")) {
|
|
|
|
channels.append(qobject_cast<ChannelGUI *>(window));
|
|
|
|
} else if (window->inherits("FeatureGUI")) {
|
|
|
|
if (window->sizePolicy().verticalPolicy() == QSizePolicy::Fixed) { // Test vertical, as horizontal can be adjusted a little bit
|
|
|
|
fixedFeatures.append(qobject_cast<FeatureGUI *>(window));
|
|
|
|
} else {
|
|
|
|
features.append(qobject_cast<FeatureGUI *>(window));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Order windows by device/feature/channel index
|
|
|
|
orderByIndex(devices);
|
|
|
|
orderByIndex(spectrums);
|
|
|
|
orderByIndex(channels);
|
|
|
|
orderByIndex(fixedFeatures);
|
|
|
|
orderByIndex(features);
|
|
|
|
|
|
|
|
// Spacing between windows
|
|
|
|
const int spacing = 2;
|
|
|
|
|
2022-11-09 10:53:44 -05:00
|
|
|
// Shrink devices to minimum size, in case they have been maximized
|
|
|
|
for (auto window : devices)
|
|
|
|
{
|
|
|
|
QSize size = window->minimumSizeHint();
|
2022-11-09 11:15:35 -05:00
|
|
|
size = size.expandedTo(window->minimumSize());
|
2022-11-09 10:53:44 -05:00
|
|
|
window->resize(size);
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Calculate width and height needed for devices
|
|
|
|
int deviceMinWidth = 0;
|
|
|
|
int deviceTotalMinHeight = 0;
|
|
|
|
for (auto window : devices)
|
|
|
|
{
|
|
|
|
int winMinWidth = std::max(window->minimumSizeHint().width(), window->minimumWidth());
|
|
|
|
deviceMinWidth = std::max(deviceMinWidth, winMinWidth);
|
|
|
|
deviceTotalMinHeight += window->minimumSizeHint().height() + spacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate width & height needed for spectrums
|
|
|
|
int spectrumMinWidth = 0;
|
|
|
|
int spectrumTotalMinHeight = 0;
|
|
|
|
int expandingSpectrums = 0;
|
|
|
|
for (auto window : spectrums)
|
|
|
|
{
|
|
|
|
int winMinWidth = std::max(window->minimumSizeHint().width(), window->minimumWidth());
|
|
|
|
spectrumMinWidth = std::max(spectrumMinWidth, winMinWidth);
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
int winMinHeight = std::max(window->minimumSizeHint().height(), window->minimumSize().height());
|
|
|
|
spectrumTotalMinHeight += winMinHeight + spacing;
|
2022-04-26 13:19:31 -04:00
|
|
|
expandingSpectrums++;
|
|
|
|
}
|
|
|
|
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
// Restrict user defined channel width, to width of largest channel
|
|
|
|
if (channels.size() == 0)
|
|
|
|
{
|
|
|
|
m_userChannelMinWidth = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int channelMaxWidth = 0;
|
|
|
|
for (auto window : channels) {
|
|
|
|
channelMaxWidth = std::max(channelMaxWidth, window->maximumWidth());
|
|
|
|
}
|
|
|
|
m_userChannelMinWidth = std::min(m_userChannelMinWidth, channelMaxWidth);
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Calculate width & height needed for channels
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
int channelMinWidth = m_userChannelMinWidth; // channels.size() > 0 ? m_userChannelMinWidth : 0;
|
2022-04-26 13:19:31 -04:00
|
|
|
int channelTotalMinHeight = 0;
|
|
|
|
int expandingChannels = 0;
|
|
|
|
for (auto window : channels)
|
|
|
|
{
|
|
|
|
int winMinWidth = std::max(window->minimumSizeHint().width(), window->minimumWidth());
|
|
|
|
channelMinWidth = std::max(channelMinWidth, winMinWidth);
|
|
|
|
channelTotalMinHeight += window->minimumSizeHint().height() + spacing;
|
|
|
|
if (window->sizePolicy().verticalPolicy() == QSizePolicy::Expanding) {
|
|
|
|
expandingChannels++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate width & height needed for features
|
|
|
|
// These are spilt in to two groups - fixed size and expandable
|
|
|
|
int fixedFeaturesWidth = 0;
|
|
|
|
int fixedFeaturesTotalMinHeight = 0;
|
|
|
|
int featuresMinWidth = 0;
|
|
|
|
int featuresTotalMinHeight = 0;
|
|
|
|
int expandingFeatures = 0;
|
|
|
|
for (auto window : fixedFeatures)
|
|
|
|
{
|
|
|
|
int winMinWidth = std::max(window->minimumSizeHint().width(), window->minimumWidth());
|
|
|
|
fixedFeaturesWidth = std::max(fixedFeaturesWidth, winMinWidth);
|
|
|
|
fixedFeaturesTotalMinHeight += window->minimumSizeHint().height() + spacing;
|
|
|
|
}
|
|
|
|
for (auto window : features)
|
|
|
|
{
|
|
|
|
int winMinWidth = std::max(window->minimumSizeHint().width(), window->minimumWidth());
|
|
|
|
featuresMinWidth = std::max(featuresMinWidth, winMinWidth);
|
|
|
|
featuresTotalMinHeight += window->minimumSizeHint().height() + spacing;
|
|
|
|
expandingFeatures++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate width for left hand column
|
|
|
|
int devicesFeaturesWidth = std::max(deviceMinWidth, fixedFeaturesWidth);
|
|
|
|
// Calculate min width for centre column
|
|
|
|
int spectrumFeaturesMinWidth = std::max(spectrumMinWidth, featuresMinWidth);
|
|
|
|
|
|
|
|
// Calculate spacing between columns
|
|
|
|
int spacing1 = devicesFeaturesWidth > 0 ? spacing : 0;
|
|
|
|
int spacing2 = spectrumFeaturesMinWidth > 0 ? spacing : 0;
|
|
|
|
|
|
|
|
// Will we need scroll bars?
|
|
|
|
QSize mdiSize = m_mdi->size();
|
|
|
|
int minWidth = devicesFeaturesWidth + spacing1 + spectrumFeaturesMinWidth + spacing2 + channelMinWidth;
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
int minHeight = std::max(std::max(deviceTotalMinHeight + fixedFeaturesTotalMinHeight, channelTotalMinHeight), spectrumTotalMinHeight + featuresTotalMinHeight);
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
bool requiresHScrollBar = minWidth > mdiSize.width();
|
|
|
|
bool requiresVScrollBar = minHeight > mdiSize.height();
|
|
|
|
|
|
|
|
// Reduce available size if scroll bars needed
|
|
|
|
int sbWidth = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
if (requiresVScrollBar) {
|
|
|
|
mdiSize.setWidth(mdiSize.width() - sbWidth);
|
|
|
|
}
|
|
|
|
if (requiresHScrollBar) {
|
|
|
|
mdiSize.setHeight(mdiSize.height() - sbWidth);
|
|
|
|
}
|
|
|
|
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
// If no spectrum/features, expand channels
|
|
|
|
if ((spectrumFeaturesMinWidth == 0) && expandingChannels > 0) {
|
|
|
|
channelMinWidth = mdiSize.width() - devicesFeaturesWidth - spacing1;
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
// Now position the windows
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
// Put devices down left hand side
|
|
|
|
for (auto window : devices)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put fixed height features underneath devices
|
|
|
|
// Resize them to be same width
|
|
|
|
for (auto window : fixedFeatures)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
window->resize(devicesFeaturesWidth, window->size().height());
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate width needed for spectrum and features in the centre - use all available space
|
|
|
|
int spectrumFeaturesWidth = std::max(mdiSize.width() - channelMinWidth - devicesFeaturesWidth - spacing1 - spacing2, spectrumFeaturesMinWidth);
|
|
|
|
|
|
|
|
// Put channels on right hand side
|
|
|
|
// Try to resize them horizontally so they are the same width
|
|
|
|
// Share any available vertical space between expanding channels
|
|
|
|
|
|
|
|
x = devicesFeaturesWidth + spacing1 + spectrumFeaturesWidth + spacing2;
|
|
|
|
y = 0;
|
|
|
|
int extraSpacePerWindow;
|
|
|
|
int extraSpaceFirstWindow;
|
|
|
|
if ((channelTotalMinHeight < mdiSize.height()) && (expandingChannels > 0))
|
|
|
|
{
|
|
|
|
extraSpacePerWindow = (mdiSize.height() - channelTotalMinHeight) / expandingChannels;
|
|
|
|
extraSpaceFirstWindow = (mdiSize.height() - channelTotalMinHeight) % expandingChannels;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extraSpacePerWindow = 0;
|
|
|
|
extraSpaceFirstWindow = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto window : channels)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
int channelHeight = window->minimumSizeHint().height();
|
|
|
|
if (window->sizePolicy().verticalPolicy() == QSizePolicy::Expanding)
|
|
|
|
{
|
|
|
|
channelHeight += extraSpacePerWindow + extraSpaceFirstWindow;
|
|
|
|
extraSpaceFirstWindow = 0;
|
|
|
|
}
|
|
|
|
window->resize(channelMinWidth, channelHeight);
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Split remaining space in the middle between spectrums and expandable features, with spectrums stacked on top
|
|
|
|
x = devicesFeaturesWidth + spacing1;
|
|
|
|
y = 0;
|
|
|
|
if ((spectrumTotalMinHeight + featuresTotalMinHeight < mdiSize.height()) && (expandingSpectrums + expandingFeatures > 0))
|
|
|
|
{
|
|
|
|
int h = mdiSize.height() - spectrumTotalMinHeight - featuresTotalMinHeight;
|
|
|
|
int f = expandingSpectrums + expandingFeatures;
|
|
|
|
extraSpacePerWindow = h / f;
|
|
|
|
extraSpaceFirstWindow = h % f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
extraSpacePerWindow = 0;
|
|
|
|
extraSpaceFirstWindow = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto window : spectrums)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
int w = spectrumFeaturesWidth;
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
int minHeight = std::max(window->minimumSizeHint().height(), window->minimumSize().height());
|
|
|
|
int h = minHeight + extraSpacePerWindow + extraSpaceFirstWindow;
|
2022-04-26 13:19:31 -04:00
|
|
|
window->resize(w, h);
|
|
|
|
extraSpaceFirstWindow = 0;
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
for (auto window : features)
|
|
|
|
{
|
|
|
|
window->move(x, y);
|
|
|
|
int w = spectrumFeaturesWidth;
|
|
|
|
int h = window->minimumSizeHint().height() + extraSpacePerWindow + extraSpaceFirstWindow;
|
|
|
|
window->resize(w, h);
|
|
|
|
extraSpaceFirstWindow = 0;
|
|
|
|
y += window->size().height() + spacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_stacking = false;
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void Workspace::autoStackSubWindows(const QPoint&)
|
2022-04-26 13:19:31 -04:00
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
setAutoStackOption(!m_autoStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::tabSubWindows()
|
|
|
|
{
|
|
|
|
if (m_tabSubWindows->isChecked())
|
|
|
|
{
|
|
|
|
// Disable autostack
|
|
|
|
setAutoStackOption(false);
|
|
|
|
|
|
|
|
// Move sub windows out of view, so they can't be seen next to a non-expandible window
|
|
|
|
// Perhaps there's a better way to do this - showMinimized didn't work
|
|
|
|
QList<QMdiSubWindow *> windows = m_mdi->subWindowList(QMdiArea::CreationOrder);
|
|
|
|
for (auto window : windows)
|
|
|
|
{
|
|
|
|
if ((window != m_mdi->activeSubWindow()) && ((window->x() != 5000) || (window->y() != 0))) {
|
|
|
|
window->move(5000, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mdi->setViewMode(QMdiArea::TabbedView);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::subWindowActivated(QMdiSubWindow *activatedWindow)
|
|
|
|
{
|
|
|
|
if (activatedWindow && m_tabSubWindows->isChecked())
|
|
|
|
{
|
|
|
|
// Move other windows out of the way
|
|
|
|
QList<QMdiSubWindow *> windows = m_mdi->subWindowList(QMdiArea::CreationOrder);
|
|
|
|
for (auto window : windows)
|
|
|
|
{
|
|
|
|
if ((window != activatedWindow) && ((window->x() != 5000) || (window->y() != 0))) {
|
|
|
|
window->move(5000, 0);
|
|
|
|
} else if ((window == activatedWindow) && ((window->x() != 0) || (window->y() != 0))) {
|
|
|
|
window->move(0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::layoutSubWindows()
|
|
|
|
{
|
|
|
|
if (m_autoStack) {
|
2022-04-26 13:19:31 -04:00
|
|
|
stackSubWindows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
// Start/stop all devices in workspace
|
|
|
|
void Workspace::startStopClicked(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) {
|
|
|
|
emit stopAllDevices(this);
|
|
|
|
} else {
|
|
|
|
emit startAllDevices(this);
|
|
|
|
}
|
|
|
|
updateStartStopButton(checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::updateStartStopButton(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked)
|
|
|
|
{
|
|
|
|
QIcon startIcon(":/play.png");
|
|
|
|
m_startStopButton->setIcon(startIcon);
|
|
|
|
m_startStopButton->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
m_startStopButton->setToolTip("Start all devices in workspace");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QIcon stopIcon(":/stop.png");
|
|
|
|
m_startStopButton->setIcon(stopIcon);
|
|
|
|
m_startStopButton->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
m_startStopButton->setToolTip("Stop all devices in workspace");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void Workspace::deviceStateChanged(int, DeviceAPI *deviceAPI)
|
2022-08-27 05:18:17 -04:00
|
|
|
{
|
|
|
|
if (deviceAPI->getWorkspaceIndex() == m_index)
|
|
|
|
{
|
|
|
|
// Check state of all devices in workspace, to see if any are running or have errors
|
|
|
|
bool running = false;
|
|
|
|
bool error = false;
|
|
|
|
std::vector<DeviceSet*> deviceSets = MainCore::instance()->getDeviceSets();
|
|
|
|
for (auto deviceSet : deviceSets)
|
|
|
|
{
|
|
|
|
DeviceAPI::EngineState state = deviceSet->m_deviceAPI->state();
|
|
|
|
if (state == DeviceAPI::StRunning) {
|
|
|
|
running = true;
|
|
|
|
} else if (state == DeviceAPI::StError) {
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Update start/stop button to reflect current state of devices
|
|
|
|
updateStartStopButton(running);
|
|
|
|
m_startStopButton->setChecked(running);
|
|
|
|
if (error) {
|
|
|
|
m_startStopButton->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:19:31 -04:00
|
|
|
void Workspace::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
QDockWidget::resizeEvent(event);
|
2022-12-20 11:10:11 -05:00
|
|
|
layoutSubWindows();
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void Workspace::addToMdiArea(QMdiSubWindow *sub)
|
|
|
|
{
|
2022-04-26 13:19:31 -04:00
|
|
|
// Add event handler to auto-stack when sub window shown or hidden
|
|
|
|
sub->installEventFilter(this);
|
|
|
|
// Can't use Close event, as it's before window is closed, so
|
|
|
|
// catch sub-window destroyed signal instead
|
2022-12-20 11:10:11 -05:00
|
|
|
connect(sub, &QObject::destroyed, this, &Workspace::layoutSubWindows);
|
2022-04-04 04:23:52 -04:00
|
|
|
m_mdi->addSubWindow(sub);
|
|
|
|
sub->show();
|
2022-12-20 11:10:11 -05:00
|
|
|
// Auto-stack when sub-window's widgets are rolled up
|
2022-04-26 13:19:31 -04:00
|
|
|
ChannelGUI *channel = qobject_cast<ChannelGUI *>(sub);
|
|
|
|
if (channel) {
|
2022-12-20 11:10:11 -05:00
|
|
|
connect(channel->getRollupContents(), &RollupContents::widgetRolled, this, &Workspace::layoutSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
FeatureGUI *feature = qobject_cast<FeatureGUI *>(sub);
|
|
|
|
if (feature) {
|
2022-12-20 11:10:11 -05:00
|
|
|
connect(feature->getRollupContents(), &RollupContents::widgetRolled, this, &Workspace::layoutSubWindows);
|
|
|
|
}
|
|
|
|
if (m_tabSubWindows->isChecked()) {
|
|
|
|
sub->showMaximized();
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::removeFromMdiArea(QMdiSubWindow *sub)
|
|
|
|
{
|
|
|
|
m_mdi->removeSubWindow(sub);
|
2022-04-26 13:19:31 -04:00
|
|
|
sub->removeEventFilter(this);
|
2022-12-20 11:10:11 -05:00
|
|
|
disconnect(sub, &QObject::destroyed, this, &Workspace::layoutSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
ChannelGUI *channel = qobject_cast<ChannelGUI *>(sub);
|
|
|
|
if (channel) {
|
2022-12-20 11:10:11 -05:00
|
|
|
disconnect(channel->getRollupContents(), &RollupContents::widgetRolled, this, &Workspace::layoutSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
FeatureGUI *feature = qobject_cast<FeatureGUI *>(sub);
|
|
|
|
if (feature) {
|
2022-12-20 11:10:11 -05:00
|
|
|
disconnect(feature->getRollupContents(), &RollupContents::widgetRolled, this, &Workspace::layoutSubWindows);
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::Show)
|
|
|
|
{
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
QWidget *widget = qobject_cast<QWidget *>(obj);
|
|
|
|
if (!widget->isMaximized()) {
|
2022-12-20 11:10:11 -05:00
|
|
|
layoutSubWindows();
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
}
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
else if (event->type() == QEvent::Hide)
|
|
|
|
{
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
QWidget *widget = qobject_cast<QWidget *>(obj);
|
|
|
|
if (!widget->isMaximized()) {
|
2022-12-20 11:10:11 -05:00
|
|
|
layoutSubWindows();
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
}
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
else if (event->type() == QEvent::Resize)
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
if (!m_stacking && m_autoStack)
|
2022-04-26 13:19:31 -04:00
|
|
|
{
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
QWidget *widget = qobject_cast<QWidget *>(obj);
|
|
|
|
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
|
2022-04-26 13:19:31 -04:00
|
|
|
ChannelGUI *channel = qobject_cast<ChannelGUI *>(obj);
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
if (channel && !widget->isMaximized())
|
2022-04-26 13:19:31 -04:00
|
|
|
{
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
// When maximizing, we can get resize event where isMaximized is false, even though it should be true,
|
|
|
|
// but we can tell as window size matches mdi size
|
|
|
|
if (m_mdi->size() != resizeEvent->size())
|
|
|
|
{
|
|
|
|
// Allow width of channels column to be set by user when they
|
|
|
|
// resize a channel window
|
|
|
|
m_userChannelMinWidth = resizeEvent->size().width();
|
|
|
|
stackSubWindows();
|
|
|
|
}
|
2022-04-26 13:19:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QDockWidget::eventFilter(obj, event);
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
2022-04-05 10:26:57 -04:00
|
|
|
|
|
|
|
int Workspace::getNumberOfSubWindows() const
|
|
|
|
{
|
|
|
|
return m_mdi->subWindowList().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Workspace::saveMdiGeometry()
|
|
|
|
{
|
|
|
|
return qCompress(m_mdi->saveGeometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::restoreMdiGeometry(const QByteArray& blob)
|
|
|
|
{
|
|
|
|
m_mdi->restoreGeometry(qUncompress(blob));
|
2022-09-25 04:12:12 -04:00
|
|
|
m_mdi->restoreGeometry(qUncompress(blob));
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
2022-04-26 13:44:18 -04:00
|
|
|
|
2022-05-19 09:48:14 -04:00
|
|
|
bool Workspace::getAutoStackOption() const
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
return m_autoStack;
|
2022-05-19 09:48:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setAutoStackOption(bool autoStack)
|
|
|
|
{
|
2022-12-20 11:10:11 -05:00
|
|
|
m_autoStack = autoStack;
|
|
|
|
if (!m_autoStack)
|
|
|
|
{
|
|
|
|
m_stackSubWindows->setStyleSheet(QString("QPushButton{ background-color: %1; }")
|
|
|
|
.arg(palette().button().color().name()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_stackSubWindows->setStyleSheet(QString("QPushButton{ background-color: %1; }")
|
|
|
|
.arg(palette().highlight().color().darker(150).name()));
|
|
|
|
stackSubWindows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::getTabSubWindowsOption() const
|
|
|
|
{
|
|
|
|
return m_tabSubWindows->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setTabSubWindowsOption(bool tab)
|
|
|
|
{
|
|
|
|
m_tabSubWindows->doToggle(tab);
|
|
|
|
if (tab) {
|
|
|
|
tabSubWindows();
|
|
|
|
} else {
|
|
|
|
m_mdi->setViewMode(QMdiArea::SubWindowView);
|
|
|
|
}
|
2022-05-19 09:48:14 -04:00
|
|
|
}
|
|
|
|
|
2022-04-26 13:44:18 -04:00
|
|
|
void Workspace::adjustSubWindowsAfterRestore()
|
|
|
|
{
|
|
|
|
QList<QMdiSubWindow *> subWindowList = m_mdi->subWindowList();
|
|
|
|
|
|
|
|
for (auto& subWindow : subWindowList)
|
|
|
|
{
|
|
|
|
if ((subWindow->y() >= 20) && (subWindow->y() < 40)) {
|
|
|
|
subWindow->move(subWindow->x(), subWindow->y() - 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qobject_cast<ChannelGUI*>(subWindow)) {
|
|
|
|
subWindow->resize(subWindow->width(), subWindow->height() - 22);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qobject_cast<FeatureGUI*>(subWindow)) {
|
|
|
|
subWindow->resize(subWindow->width(), subWindow->height() - 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|