1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

Merge pull request #1026 from srcejon/fix_897

Fix #897 - Add support for vertically expanding widgets to RollupWidget
This commit is contained in:
Edouard Griffiths 2021-10-30 18:54:51 +02:00 committed by GitHub
commit f39a966af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 604 additions and 473 deletions

View File

@ -10,6 +10,12 @@
<height>778</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>720</width>
@ -127,6 +133,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Text">
@ -147,6 +162,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Text">
@ -167,6 +191,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
@ -937,35 +970,12 @@
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLScope</class>
<extends>QWidget</extends>
@ -978,6 +988,29 @@
<header>gui/glscopegui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>

View File

@ -699,7 +699,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -588,7 +588,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -640,7 +640,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -622,7 +622,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -204,7 +204,7 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="datvTab">
<attribute name="title">
@ -1073,6 +1073,12 @@
</widget>
</widget>
<widget class="QWidget" name="videoTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Video</string>
</attribute>
@ -1331,6 +1337,12 @@
</property>
<item>
<widget class="DATVideoRender" name="screenTV_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>490</width>
@ -1351,12 +1363,6 @@
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>DATVideoRender</class>
<extends>QWidget</extends>
<header>datvideorender.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
@ -1364,9 +1370,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>TVScreen</class>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/tvscreen.h</header>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
@ -1375,9 +1381,15 @@
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<class>DATVideoRender</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<header>datvideorender.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TVScreen</class>
<extends>QWidget</extends>
<header>gui/tvscreen.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -567,7 +567,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -655,7 +655,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -687,7 +687,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -4764,7 +4764,7 @@ This should be close to the expected difference in power between hot and cold ca
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -569,6 +569,12 @@
<height>141</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Transmitted Frames</string>
</property>
@ -703,35 +709,12 @@
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScope</class>
<extends>QWidget</extends>
@ -744,6 +727,29 @@
<header>gui/glscopegui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>deltaFrequency</tabstop>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -1016,6 +1016,12 @@
<height>141</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Transmitted Messages</string>
</property>
@ -1156,6 +1162,23 @@
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScope</class>
<extends>QWidget</extends>
<header>gui/glscope.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScopeGUI</class>
<extends>QWidget</extends>
<header>gui/glscopegui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
@ -1168,29 +1191,12 @@
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScope</class>
<extends>QWidget</extends>
<header>gui/glscope.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScopeGUI</class>
<extends>QWidget</extends>
<header>gui/glscopegui.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>deltaFrequency</tabstop>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -788,6 +788,12 @@ APRS examples:
<height>141</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Transmitted Packets</string>
</property>
@ -873,6 +879,17 @@ APRS examples:
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
@ -885,17 +902,6 @@ APRS examples:
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterVU</class>
<extends>QWidget</extends>

View File

@ -24,8 +24,8 @@
</property>
<property name="maximumSize">
<size>
<width>2000</width>
<height>500</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
@ -37,6 +37,9 @@
<property name="windowTitle">
<string>AIS</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<widget class="QWidget" name="tableContainer" native="true">
<property name="geometry">
<rect>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -47,7 +47,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -56,7 +56,7 @@
<string>Calculators</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="dipoleTab">
<attribute name="title">

View File

@ -383,7 +383,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -527,7 +527,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -584,11 +584,17 @@
<property name="text">
<string>Next</string>
</property>
<property name="toolTip">
<string>Time until next event</string>
</property>
</column>
<column>
<property name="text">
<string>Dur</string>
</property>
<property name="toolTip">
<string>Duration of next pass</string>
</property>
</column>
<column>
<property name="text">

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -21,133 +21,133 @@
#include <QPainter>
#include <QPainterPath>
#include <QMouseEvent>
#include <QDebug>
#include <QDialog>
#include "gui/rollupwidget.h"
#include "ui_glspectrumgui.h"
RollupWidget::RollupWidget(QWidget* parent) :
QWidget(parent),
m_highlighted(false),
QWidget(parent),
m_highlighted(false),
m_contextMenuType(ContextMenuNone),
m_streamIndicator("S"),
m_channelWidget(true)
m_channelWidget(true),
m_newHeight(0)
{
setMinimumSize(250, 150);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setBackgroundRole(QPalette::Window);
setMinimumSize(250, 150);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setBackgroundRole(QPalette::Window);
setAutoFillBackground(false);
setAttribute(Qt::WA_OpaquePaintEvent, true);
setAutoFillBackground(false);
setAttribute(Qt::WA_OpaquePaintEvent, true);
// Vorgaben aus der Palette
m_titleColor = palette().highlight().color();
m_titleTextColor = palette().highlightedText().color();
// Vorgaben aus der Palette
m_titleColor = palette().highlight().color();
m_titleTextColor = palette().highlightedText().color();
}
QByteArray RollupWidget::saveState(int version) const
{
QByteArray state;
QDataStream stream(&state, QIODevice::WriteOnly);
int count = 0;
QByteArray state;
QDataStream stream(&state, QIODevice::WriteOnly);
int count = 0;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if (r) {
count++;
}
}
if (r) {
count++;
}
}
stream << VersionMarker;
stream << version;
stream << count;
stream << VersionMarker;
stream << version;
stream << count;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if (r)
{
stream << r->objectName();
if (r)
{
stream << r->objectName();
if (r->isHidden()) {
stream << (int) 0;
} else {
stream << (int) 1;
}
}
}
if (r->isHidden()) {
stream << (int) 0;
} else {
stream << (int) 1;
}
}
}
return state;
return state;
}
bool RollupWidget::restoreState(const QByteArray& state, int version)
{
if (state.isEmpty()) {
return false;
}
if (state.isEmpty()) {
return false;
}
QByteArray sd = state;
QDataStream stream(&sd, QIODevice::ReadOnly);
int marker, v;
stream >> marker;
stream >> v;
QByteArray sd = state;
QDataStream stream(&sd, QIODevice::ReadOnly);
int marker, v;
stream >> marker;
stream >> v;
if ((stream.status() != QDataStream::Ok) || (marker != VersionMarker) || (v != version)) {
return false;
}
if ((stream.status() != QDataStream::Ok) || (marker != VersionMarker) || (v != version)) {
return false;
}
int count;
stream >> count;
int count;
stream >> count;
if (stream.status() != QDataStream::Ok) {
return false;
}
if (stream.status() != QDataStream::Ok) {
return false;
}
for (int i = 0; i < count; ++i)
{
QString name;
int visible;
for (int i = 0; i < count; ++i)
{
QString name;
int visible;
stream >> name;
stream >> visible;
stream >> name;
stream >> visible;
if (stream.status() != QDataStream::Ok) {
return false;
}
if (stream.status() != QDataStream::Ok) {
return false;
}
for (int j = 0; j < children().count(); ++j)
{
QWidget* r = qobject_cast<QWidget*>(children()[j]);
for (int j = 0; j < children().count(); ++j)
{
QWidget* r = qobject_cast<QWidget*>(children()[j]);
if (r)
{
if (r->objectName() == name)
{
if (visible) {
r->show();
} else {
r->hide();
}
if (r)
{
if (r->objectName() == name)
{
if (visible) {
r->show();
} else {
r->hide();
}
break;
}
}
}
}
break;
}
}
}
}
return true;
return true;
}
void RollupWidget::setTitleColor(const QColor& c)
{
m_titleColor = c;
float l = 0.2126*c.redF() + 0.7152*c.greenF() + 0.0722*c.blueF();
m_titleTextColor = l < 0.5f ? Qt::white : Qt::black;
update();
m_titleColor = c;
float l = 0.2126*c.redF() + 0.7152*c.greenF() + 0.0722*c.blueF();
m_titleTextColor = l < 0.5f ? Qt::white : Qt::black;
update();
}
void RollupWidget::setHighlighted(bool highlighted)
@ -161,330 +161,388 @@ void RollupWidget::setHighlighted(bool highlighted)
int RollupWidget::arrangeRollups()
{
QFontMetrics fm(font());
int pos = fm.height() + 4;
QFontMetrics fm(font());
int pos;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
// First calculate minimum height needed, to determine how much extra space
// we have that can be split between expanding widgets
pos = fm.height() + 4;
int expandingChildren = 0;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if ((r != nullptr) && isRollupChild(r))
{
if ((r != nullptr) && isRollupChild(r))
{
pos += fm.height() + 2;
if (!r->isHidden())
{
if (r->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) {
expandingChildren++;
}
int h = 0;
if (r->hasHeightForWidth()) {
h = r->heightForWidth(width() - 4);
} else {
h = r->minimumSizeHint().height();
}
pos += h + 5;
}
}
}
setMinimumHeight(pos);
// Split extra space equally between widgets
// If there's a remainder, we give it to the first widget
// In the future, we should probably respect 'Vertical Stretch'
int extraSpace;
int firstExtra;
if ((expandingChildren > 0) && (m_newHeight > pos))
{
int totalExtra = m_newHeight - pos;
extraSpace = totalExtra / expandingChildren;
firstExtra = totalExtra - (extraSpace * expandingChildren);
}
else
{
extraSpace = 0;
firstExtra = 0;
}
// Now reposition and resize child widgets
pos = fm.height() + 4;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if ((r != nullptr) && isRollupChild(r))
{
pos += fm.height() + 2;
if (!r->isHidden())
{
r->move(2, pos + 3);
int h = 0;
int h = 0;
if (r->hasHeightForWidth()) {
h = r->heightForWidth(width() - 4);
} else {
h = r->sizeHint().height();
h = r->minimumSizeHint().height();
}
if (r->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag)
{
h += extraSpace;
h += firstExtra;
firstExtra = 0;
}
r->resize(width() - 4, h);
pos += r->height() + 5;
}
}
}
}
}
setMinimumHeight(pos);
setMaximumHeight(pos);
if (expandingChildren == 0) {
setMaximumHeight(pos);
} else {
setMaximumHeight(16777215);
}
return pos;
return pos;
}
void RollupWidget::paintEvent(QPaintEvent*)
{
QPainter p(this);
QColor frame = palette().highlight().color();
QPainter p(this);
QColor frame = palette().highlight().color();
// Eigenbau
QFontMetrics fm(font());
// Eigenbau
QFontMetrics fm(font());
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::Antialiasing, true);
// Ecken
p.setPen(Qt::NoPen);
p.setBrush(palette().base());
p.drawRect(0, 0, 5, 5);
p.drawRect(width() - 5, 0, 5, 5);
p.drawRect(0, height() - 5, 5, 5);
p.drawRect(width() - 5, height() - 5, 5, 5);
// Ecken
p.setPen(Qt::NoPen);
p.setBrush(palette().base());
p.drawRect(0, 0, 5, 5);
p.drawRect(width() - 5, 0, 5, 5);
p.drawRect(0, height() - 5, 5, 5);
p.drawRect(width() - 5, height() - 5, 5, 5);
// Rahmen
p.setPen(m_highlighted ? Qt::white : frame);
p.setBrush(palette().window());
QRectF r(rect());
r.adjust(0.5, 0.5, -0.5, -0.5);
p.drawRoundedRect(r, 3.0, 3.0, Qt::AbsoluteSize);
// Rahmen
p.setPen(m_highlighted ? Qt::white : frame);
p.setBrush(palette().window());
QRectF r(rect());
r.adjust(0.5, 0.5, -0.5, -0.5);
p.drawRoundedRect(r, 3.0, 3.0, Qt::AbsoluteSize);
// Titel-Hintergrund
p.setPen(Qt::NoPen);
p.setBrush(m_titleColor);
QPainterPath path;
path.moveTo(1.5, fm.height() + 2.5);
path.lineTo(width() - 1.5, fm.height() + 2.5);
path.lineTo(width() - 1.5, 3.5);
path.arcTo(QRectF(width() - 3.5, 0, 2.5, 2.5), 270, -90);
path.lineTo(3.5, 1.5);
path.arcTo(QRectF(1.5, 2.5, 2.5, 2.5), 90, 90);
p.drawPath(path);
// Titel-Hintergrund
p.setPen(Qt::NoPen);
p.setBrush(m_titleColor);
QPainterPath path;
path.moveTo(1.5, fm.height() + 2.5);
path.lineTo(width() - 1.5, fm.height() + 2.5);
path.lineTo(width() - 1.5, 3.5);
path.arcTo(QRectF(width() - 3.5, 0, 2.5, 2.5), 270, -90);
path.lineTo(3.5, 1.5);
path.arcTo(QRectF(1.5, 2.5, 2.5, 2.5), 90, 90);
p.drawPath(path);
// Titel-Abschlusslinie
p.setPen(frame);
p.drawLine(QPointF(0.5, 2 + fm.height() + 1.5), QPointF(width() - 1.5, 2 + fm.height() + 1.5));
// Titel-Abschlusslinie
p.setPen(frame);
p.drawLine(QPointF(0.5, 2 + fm.height() + 1.5), QPointF(width() - 1.5, 2 + fm.height() + 1.5));
// Aktiv-Button links
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
p.drawRoundedRect(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()), 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(Qt::white, 1.0));
p.drawText(QRectF(3.5, 2.5, fm.ascent(), fm.ascent()), Qt::AlignCenter, "c");
// Aktiv-Button links
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
p.drawRoundedRect(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()), 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(Qt::white, 1.0));
p.drawText(QRectF(3.5, 2.5, fm.ascent(), fm.ascent()), Qt::AlignCenter, "c");
if (m_channelWidget)
{
// Stromkanal-Button links
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
p.drawRoundedRect(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(Qt::white, 1.0));
p.drawText(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), Qt::AlignCenter, m_streamIndicator);
}
// Schließen-Button rechts
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
r = QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent());
p.drawRoundedRect(r, 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(palette().windowText().color(), 1.5));
p.drawLine(r.topLeft() + QPointF(1, 1), r.bottomRight() + QPointF(-1, -1));
p.drawLine(r.bottomLeft() + QPointF(1, -1), r.topRight() + QPointF(-1, 1));
// Titel
//p.setPen(palette().highlightedText().color());
p.setPen(m_titleTextColor);
p.drawText(QRect(2 + 2*fm.height() + 2, 2, width() - 6 - 3*fm.height(), fm.height()),
fm.elidedText(windowTitle(), Qt::ElideMiddle, width() - 6 - 3*fm.height(), 0));
// Rollups
int pos = fm.height() + 4;
const QObjectList& c = children();
QObjectList::ConstIterator w = c.begin();
QObjectList::ConstIterator n = c.begin();
for (n = c.begin(); n != c.end(); ++n)
if (m_channelWidget)
{
if (qobject_cast<QWidget*>(*n) != nullptr) {
break;
// Stromkanal-Button links
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
p.drawRoundedRect(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(Qt::white, 1.0));
p.drawText(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), Qt::AlignCenter, m_streamIndicator);
}
// Schließen-Button rechts
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(QPen(palette().windowText().color(), 1.0));
p.setBrush(palette().light());
r = QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent());
p.drawRoundedRect(r, 2.0, 2.0, Qt::AbsoluteSize);
p.setPen(QPen(palette().windowText().color(), 1.5));
p.drawLine(r.topLeft() + QPointF(1, 1), r.bottomRight() + QPointF(-1, -1));
p.drawLine(r.bottomLeft() + QPointF(1, -1), r.topRight() + QPointF(-1, 1));
// Titel
//p.setPen(palette().highlightedText().color());
p.setPen(m_titleTextColor);
p.drawText(QRect(2 + 2*fm.height() + 2, 2, width() - 6 - 3*fm.height(), fm.height()),
fm.elidedText(windowTitle(), Qt::ElideMiddle, width() - 6 - 3*fm.height(), 0));
// Rollups
int pos = fm.height() + 4;
const QObjectList& c = children();
QObjectList::ConstIterator w = c.begin();
QObjectList::ConstIterator n = c.begin();
for (n = c.begin(); n != c.end(); ++n)
{
if (qobject_cast<QWidget*>(*n) != nullptr) {
break;
}
}
}
for (w = n; w != c.end(); w = n)
for (w = n; w != c.end(); w = n)
{
if (n != c.end()) {
++n;
if (n != c.end()) {
++n;
}
for (; n != c.end(); ++n)
for (; n != c.end(); ++n)
{
if (qobject_cast<QWidget*>(*n) != nullptr) {
break;
if (qobject_cast<QWidget*>(*n) != nullptr) {
break;
}
}
}
pos += paintRollup(qobject_cast<QWidget*>(*w), pos, &p, n == c.end(), frame);
}
}
}
int RollupWidget::paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame)
{
QFontMetrics fm(font());
int height = 1;
QFontMetrics fm(font());
int height = 1;
// Titel-Abschlusslinie
if (!rollup->isHidden())
{
p->setPen(palette().dark().color());
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
p->setPen(palette().light().color());
p->drawLine(QPointF(1.5, pos + fm.height() + 2.5), QPointF(width() - 1.5, pos + fm.height() + 2.5));
height += 2;
}
else
{
if (!last)
{
p->setPen(frame);
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
height++;
}
}
// Titel-Abschlusslinie
if (!rollup->isHidden())
{
p->setPen(palette().dark().color());
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
p->setPen(palette().light().color());
p->drawLine(QPointF(1.5, pos + fm.height() + 2.5), QPointF(width() - 1.5, pos + fm.height() + 2.5));
height += 2;
}
else
{
if (!last)
{
p->setPen(frame);
p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
height++;
}
}
// Titel
p->setPen(palette().windowText().color());
p->drawText(QRect(2 + fm.height(), pos, width() - 4 - fm.height(), fm.height()),
fm.elidedText(rollup->windowTitle(), Qt::ElideMiddle, width() - 4 - fm.height(), 0));
height += fm.height();
// Titel
p->setPen(palette().windowText().color());
p->drawText(QRect(2 + fm.height(), pos, width() - 4 - fm.height(), fm.height()),
fm.elidedText(rollup->windowTitle(), Qt::ElideMiddle, width() - 4 - fm.height(), 0));
height += fm.height();
// Ausklapp-Icon
p->setPen(palette().windowText().color());
p->setBrush(palette().windowText());
// Ausklapp-Icon
p->setPen(palette().windowText().color());
p->setBrush(palette().windowText());
if (!rollup->isHidden())
{
QPolygonF a;
a.append(QPointF(3.5, pos + 2));
a.append(QPointF(3.5 + fm.ascent(), pos + 2));
a.append(QPointF(3.5 + fm.ascent() / 2.0, pos + fm.height() - 2));
p->drawPolygon(a);
}
else
{
QPolygonF a;
a.append(QPointF(3.5, pos + 2));
a.append(QPointF(3.5, pos + fm.height() - 2));
a.append(QPointF(3.5 + fm.ascent(), pos + fm.height() / 2));
p->drawPolygon(a);
}
if (!rollup->isHidden())
{
QPolygonF a;
a.append(QPointF(3.5, pos + 2));
a.append(QPointF(3.5 + fm.ascent(), pos + 2));
a.append(QPointF(3.5 + fm.ascent() / 2.0, pos + fm.height() - 2));
p->drawPolygon(a);
}
else
{
QPolygonF a;
a.append(QPointF(3.5, pos + 2));
a.append(QPointF(3.5, pos + fm.height() - 2));
a.append(QPointF(3.5 + fm.ascent(), pos + fm.height() / 2));
p->drawPolygon(a);
}
// Inhalt
if (!rollup->isHidden() && (!last))
{
// Rollup-Abschlusslinie
p->setPen(frame);
p->drawLine(QPointF(1.5, pos + fm.height() + rollup->height() + 6.5),
QPointF(width() - 1.5, pos + fm.height() + rollup->height() + 6.5));
height += rollup->height() + 4;
}
// Inhalt
if (!rollup->isHidden() && (!last))
{
// Rollup-Abschlusslinie
p->setPen(frame);
p->drawLine(QPointF(1.5, pos + fm.height() + rollup->height() + 6.5),
QPointF(width() - 1.5, pos + fm.height() + rollup->height() + 6.5));
height += rollup->height() + 4;
}
return height;
return height;
}
void RollupWidget::resizeEvent(QResizeEvent* size)
{
arrangeRollups();
QWidget::resizeEvent(size);
m_newHeight = size->size().height();
arrangeRollups();
QWidget::resizeEvent(size);
}
void RollupWidget::mousePressEvent(QMouseEvent* event)
{
QFontMetrics fm(font());
QFontMetrics fm(font());
// menu box left
if (QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos()))
{
m_contextMenuType = ContextMenuChannelSettings;
emit customContextMenuRequested(event->globalPos());
return;
}
// menu box left
if (QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos()))
{
m_contextMenuType = ContextMenuChannelSettings;
emit customContextMenuRequested(event->globalPos());
return;
}
if (m_channelWidget)
{
// Stream channel menu left
if (QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0).contains(event->pos()))
{
m_contextMenuType = ContextMenuStreamSettings;
emit customContextMenuRequested(event->globalPos());
return;
}
}
if (m_channelWidget)
{
// Stream channel menu left
if (QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0).contains(event->pos()))
{
m_contextMenuType = ContextMenuStreamSettings;
emit customContextMenuRequested(event->globalPos());
return;
}
}
// close button right
if(QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
close();
return;
}
// close button right
if(QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
close();
return;
}
// check if we need to change a rollup widget
int pos = fm.height() + 4;
// check if we need to change a rollup widget
int pos = fm.height() + 4;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if (r)
{
if ((event->y() >= pos) && (event->y() < (pos + fm.height() + 3)))
{
if (r->isHidden())
{
r->show();
//emit widgetRolled(r, true);
}
else
{
r->hide();
//emit widgetRolled(r, false);
}
if (r)
{
if ((event->y() >= pos) && (event->y() < (pos + fm.height() + 3)))
{
if (r->isHidden())
{
r->show();
//emit widgetRolled(r, true);
}
else
{
r->hide();
//emit widgetRolled(r, false);
}
arrangeRollups();
repaint();
return;
}
else
{
pos += fm.height() + 2;
arrangeRollups();
repaint();
return;
}
else
{
pos += fm.height() + 2;
if (!r->isHidden()) {
pos += r->height() + 5;
}
}
}
}
if (!r->isHidden()) {
pos += r->height() + 5;
}
}
}
}
}
bool RollupWidget::event(QEvent* event)
{
if (event->type() == QEvent::ChildAdded)
{
((QChildEvent*)event)->child()->installEventFilter(this);
arrangeRollups();
}
else if (event->type() == QEvent::ChildRemoved)
{
((QChildEvent*)event)->child()->removeEventFilter(this);
arrangeRollups();
}
if (event->type() == QEvent::ChildAdded)
{
((QChildEvent*)event)->child()->installEventFilter(this);
arrangeRollups();
}
else if (event->type() == QEvent::ChildRemoved)
{
((QChildEvent*)event)->child()->removeEventFilter(this);
arrangeRollups();
}
return QWidget::event(event);
return QWidget::event(event);
}
bool RollupWidget::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::Show)
{
if (children().contains(object))
{
arrangeRollups();
emit widgetRolled(qobject_cast<QWidget*>(object), true);
}
}
else if (event->type() == QEvent::Hide)
{
if (children().contains(object))
{
arrangeRollups();
emit widgetRolled(qobject_cast<QWidget*>(object), false);
}
}
else if (event->type() == QEvent::WindowTitleChange)
{
if (children().contains(object)) {
repaint();
}
}
if (event->type() == QEvent::Show)
{
if (children().contains(object))
{
arrangeRollups();
emit widgetRolled(qobject_cast<QWidget*>(object), true);
}
}
else if (event->type() == QEvent::Hide)
{
if (children().contains(object))
{
arrangeRollups();
emit widgetRolled(qobject_cast<QWidget*>(object), false);
}
}
else if (event->type() == QEvent::WindowTitleChange)
{
if (children().contains(object)) {
repaint();
}
}
return QWidget::eventFilter(object, event);
return QWidget::eventFilter(object, event);
}
void RollupWidget::setStreamIndicator(const QString& indicator)
{
m_streamIndicator = indicator;
update();
m_streamIndicator = indicator;
update();
}
bool RollupWidget::isRollupChild(QWidget *childWidget)

View File

@ -24,21 +24,21 @@
#include "export.h"
class SDRGUI_API RollupWidget : public QWidget {
Q_OBJECT
Q_OBJECT
public:
RollupWidget(QWidget* parent = nullptr);
void setTitleColor(const QColor& c);
void setHighlighted(bool highlighted);
void setChannelWidget(bool channelWidget) { m_channelWidget = channelWidget; }
RollupWidget(QWidget* parent = nullptr);
void setTitleColor(const QColor& c);
void setHighlighted(bool highlighted);
void setChannelWidget(bool channelWidget) { m_channelWidget = channelWidget; }
signals:
void widgetRolled(QWidget* widget, bool rollDown);
void widgetRolled(QWidget* widget, bool rollDown);
protected:
enum {
VersionMarker = 0xff
};
enum {
VersionMarker = 0xff
};
enum ContextMenuType
{
@ -47,32 +47,33 @@ protected:
ContextMenuStreamSettings
};
QColor m_titleColor;
QColor m_titleTextColor;
bool m_highlighted;
QColor m_titleColor;
QColor m_titleTextColor;
bool m_highlighted;
ContextMenuType m_contextMenuType;
QString m_streamIndicator;
int arrangeRollups();
int arrangeRollups();
QByteArray saveState(int version = 0) const;
QByteArray saveState(int version = 0) const;
bool restoreState(const QByteArray& state, int version = 0);
void paintEvent(QPaintEvent*);
int paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame);
void paintEvent(QPaintEvent*);
int paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame);
void resizeEvent(QResizeEvent* size);
void mousePressEvent(QMouseEvent* event);
void resizeEvent(QResizeEvent* size);
void mousePressEvent(QMouseEvent* event);
bool event(QEvent* event);
bool eventFilter(QObject* object, QEvent* event);
bool event(QEvent* event);
bool eventFilter(QObject* object, QEvent* event);
void resetContextMenuType() { m_contextMenuType = ContextMenuNone; }
void setStreamIndicator(const QString& indicator);
void setStreamIndicator(const QString& indicator);
private:
static bool isRollupChild(QWidget *childWidget); //!< chidl is part of rollups (ex: not a dialog)
bool m_channelWidget;
bool m_channelWidget;
int m_newHeight;
};
#endif // INCLUDE_ROLLUPWIDGET_H