From 4e491ae4417f0062440d283b308483415e7f36f3 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sat, 13 Apr 2024 15:06:08 -0700 Subject: [PATCH] Attach and detach now resize the main window. Still some work to be done on selecting good sizes for the scopes themselves. --- spectrumscope.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spectrumscope.cpp b/spectrumscope.cpp index 9e62f89..f684bfd 100644 --- a/spectrumscope.cpp +++ b/spectrumscope.cpp @@ -19,6 +19,7 @@ spectrumScope::spectrumScope(uchar receiver, uchar vfo, QWidget *parent) splitter = new QSplitter(this); layout->addWidget(splitter); splitter->setOrientation(Qt::Vertical); + originalParent = parent; displayLayout = new QHBoxLayout(); @@ -1787,13 +1788,29 @@ void spectrumScope::detachScope(bool state) detachButton->setText("Attach"); qInfo(logGui()) << "Detaching scope" << (receiver?"Sub":"Main"); this->parentWidget()->layout()->replaceWidget(this,windowLabel); + + QTimer::singleShot(1, [&](){ + if(originalParent) { + this->originalParent->resize(1,1); + } + }); + + this->parentWidget()->resize(1,1); this->setParent(NULL); + this-> setWindowFlags(Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); this->move(screen()->geometry().center() - frameGeometry().center()); } else { detachButton->setText("Detach"); qInfo(logGui()) << "Attaching scope" << (receiver?"Sub":"Main"); windowLabel->parentWidget()->layout()->replaceWidget(windowLabel,this); + + QTimer::singleShot(1, [&](){ + if(originalParent) { + this->originalParent->resize(1,1); + } + }); + windowLabel->setParent(NULL); delete windowLabel; }