diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.ui b/plugins/channelrx/chanalyzer/chanalyzergui.ui index 62ae2a1a2..a8c641eb8 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.ui +++ b/plugins/channelrx/chanalyzer/chanalyzergui.ui @@ -10,6 +10,12 @@ 778 + + + 0 + 0 + + 720 @@ -127,6 +133,15 @@ + + + + 26 + 26 + 26 + + + @@ -147,6 +162,15 @@ + + + + 26 + 26 + 26 + + + @@ -167,6 +191,15 @@ + + + + 26 + 26 + 26 + + + @@ -937,35 +970,12 @@
gui/rollupwidget.h
1 - - GLSpectrum - QWidget -
gui/glspectrum.h
- 1 -
- - GLSpectrumGUI - QWidget -
gui/glspectrumgui.h
- 1 -
ValueDialZ QWidget
gui/valuedialz.h
1
- - ValueDial - QWidget -
gui/valuedial.h
- 1 -
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
GLScope QWidget @@ -978,6 +988,29 @@
gui/glscopegui.h
1
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+ + GLSpectrum + QWidget +
gui/glspectrum.h
+ 1 +
+ + GLSpectrumGUI + QWidget +
gui/glspectrumgui.h
+ 1 +
+ + ValueDial + QWidget +
gui/valuedial.h
+ 1 +
diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.ui b/plugins/channelrx/demodadsb/adsbdemodgui.ui index 3e4bc15e1..092d223c0 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.ui +++ b/plugins/channelrx/demodadsb/adsbdemodgui.ui @@ -699,7 +699,7 @@ - + 0 0 diff --git a/plugins/channelrx/demodais/aisdemodgui.ui b/plugins/channelrx/demodais/aisdemodgui.ui index 26e273a96..c8b87c318 100644 --- a/plugins/channelrx/demodais/aisdemodgui.ui +++ b/plugins/channelrx/demodais/aisdemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -588,7 +588,7 @@ - + 0 0 diff --git a/plugins/channelrx/demodapt/aptdemodgui.ui b/plugins/channelrx/demodapt/aptdemodgui.ui index d7eb1f9fc..87f000937 100644 --- a/plugins/channelrx/demodapt/aptdemodgui.ui +++ b/plugins/channelrx/demodapt/aptdemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -640,7 +640,7 @@ - + 0 0 diff --git a/plugins/channelrx/demoddab/dabdemodgui.ui b/plugins/channelrx/demoddab/dabdemodgui.ui index c59d061bd..929281888 100644 --- a/plugins/channelrx/demoddab/dabdemodgui.ui +++ b/plugins/channelrx/demoddab/dabdemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -622,7 +622,7 @@ - + 0 0 diff --git a/plugins/channelrx/demoddatv/datvdemodgui.ui b/plugins/channelrx/demoddatv/datvdemodgui.ui index b3fe41001..567356794 100644 --- a/plugins/channelrx/demoddatv/datvdemodgui.ui +++ b/plugins/channelrx/demoddatv/datvdemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -204,7 +204,7 @@ QTabWidget::West - 0 + 1 @@ -1073,6 +1073,12 @@ + + + 0 + 0 + + Video @@ -1331,6 +1337,12 @@ + + + 0 + 0 + + 490 @@ -1351,12 +1363,6 @@
gui/rollupwidget.h
1 - - DATVideoRender - QWidget -
datvideorender.h
- 1 -
ValueDialZ QWidget @@ -1364,9 +1370,9 @@ 1 - TVScreen + LevelMeterSignalDB QWidget -
gui/tvscreen.h
+
gui/levelmeter.h
1
@@ -1375,9 +1381,15 @@
gui/buttonswitch.h
- LevelMeterSignalDB + DATVideoRender QWidget -
gui/levelmeter.h
+
datvideorender.h
+ 1 +
+ + TVScreen + QWidget +
gui/tvscreen.h
1
diff --git a/plugins/channelrx/demodpacket/packetdemodgui.ui b/plugins/channelrx/demodpacket/packetdemodgui.ui index adcea90ed..33e849341 100644 --- a/plugins/channelrx/demodpacket/packetdemodgui.ui +++ b/plugins/channelrx/demodpacket/packetdemodgui.ui @@ -11,7 +11,7 @@
- + 0 0 @@ -567,7 +567,7 @@ - + 0 0 diff --git a/plugins/channelrx/demodpager/pagerdemodgui.ui b/plugins/channelrx/demodpager/pagerdemodgui.ui index 51121722f..d9f6b5791 100644 --- a/plugins/channelrx/demodpager/pagerdemodgui.ui +++ b/plugins/channelrx/demodpager/pagerdemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -655,7 +655,7 @@ - + 0 0 diff --git a/plugins/channelrx/demodvor/vordemodgui.ui b/plugins/channelrx/demodvor/vordemodgui.ui index e9b4c4487..e5bd844f3 100644 --- a/plugins/channelrx/demodvor/vordemodgui.ui +++ b/plugins/channelrx/demodvor/vordemodgui.ui @@ -11,7 +11,7 @@ - + 0 0 diff --git a/plugins/channelrx/noisefigure/noisefiguregui.ui b/plugins/channelrx/noisefigure/noisefiguregui.ui index 5500ec0ab..91863bd4f 100644 --- a/plugins/channelrx/noisefigure/noisefiguregui.ui +++ b/plugins/channelrx/noisefigure/noisefiguregui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -687,7 +687,7 @@ - + 0 0 diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.ui b/plugins/channelrx/radioastronomy/radioastronomygui.ui index d065346f4..7723b962a 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.ui +++ b/plugins/channelrx/radioastronomy/radioastronomygui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -4764,7 +4764,7 @@ This should be close to the expected difference in power between hot and cold ca - + 0 0 diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.ui b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.ui index fb03165da..7d1ae478c 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.ui +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_modgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -569,6 +569,12 @@ 141 + + + 0 + 0 + + Transmitted Frames @@ -703,35 +709,12 @@
gui/rollupwidget.h
1 - - GLSpectrum - QWidget -
gui/glspectrum.h
- 1 -
- - GLSpectrumGUI - QWidget -
gui/glspectrumgui.h
- 1 -
ValueDialZ QWidget
gui/valuedialz.h
1
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
- - LevelMeterVU - QWidget -
gui/levelmeter.h
- 1 -
GLScope QWidget @@ -744,6 +727,29 @@
gui/glscopegui.h
1
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+ + GLSpectrum + QWidget +
gui/glspectrum.h
+ 1 +
+ + GLSpectrumGUI + QWidget +
gui/glspectrumgui.h
+ 1 +
+ + LevelMeterVU + QWidget +
gui/levelmeter.h
+ 1 +
deltaFrequency diff --git a/plugins/channeltx/modais/aismodgui.ui b/plugins/channeltx/modais/aismodgui.ui index 7fcb9aa63..870a7a870 100644 --- a/plugins/channeltx/modais/aismodgui.ui +++ b/plugins/channeltx/modais/aismodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -1016,6 +1016,12 @@ 141 + + + 0 + 0 + + Transmitted Messages @@ -1156,6 +1162,23 @@
gui/valuedialz.h
1 + + GLScope + QWidget +
gui/glscope.h
+ 1 +
+ + GLScopeGUI + QWidget +
gui/glscopegui.h
+ 1 +
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
GLSpectrum QWidget @@ -1168,29 +1191,12 @@
gui/glspectrumgui.h
1
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
LevelMeterVU QWidget
gui/levelmeter.h
1
- - GLScope - QWidget -
gui/glscope.h
- 1 -
- - GLScopeGUI - QWidget -
gui/glscopegui.h
- 1 -
deltaFrequency diff --git a/plugins/channeltx/modpacket/packetmodgui.ui b/plugins/channeltx/modpacket/packetmodgui.ui index 10a4da95d..f55faa922 100644 --- a/plugins/channeltx/modpacket/packetmodgui.ui +++ b/plugins/channeltx/modpacket/packetmodgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -788,6 +788,12 @@ APRS examples: 141 + + + 0 + 0 + + Transmitted Packets @@ -873,6 +879,17 @@ APRS examples:
gui/rollupwidget.h
1 + + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
GLSpectrum QWidget @@ -885,17 +902,6 @@ APRS examples:
gui/glspectrumgui.h
1
- - ValueDialZ - QWidget -
gui/valuedialz.h
- 1 -
- - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
LevelMeterVU QWidget diff --git a/plugins/feature/ais/aisgui.ui b/plugins/feature/ais/aisgui.ui index 1c4875bac..b1a5bc871 100644 --- a/plugins/feature/ais/aisgui.ui +++ b/plugins/feature/ais/aisgui.ui @@ -24,8 +24,8 @@ - 2000 - 500 + 16777215 + 16777215 @@ -37,6 +37,9 @@ AIS + + Qt::LeftToRight + diff --git a/plugins/feature/antennatools/antennatoolsgui.ui b/plugins/feature/antennatools/antennatoolsgui.ui index 6699b0767..6e18ad9f7 100644 --- a/plugins/feature/antennatools/antennatoolsgui.ui +++ b/plugins/feature/antennatools/antennatoolsgui.ui @@ -11,7 +11,7 @@ - + 0 0 @@ -47,7 +47,7 @@ - + 0 0 @@ -56,7 +56,7 @@ Calculators - 0 + 1 diff --git a/plugins/feature/satellitetracker/satellitetrackergui.ui b/plugins/feature/satellitetracker/satellitetrackergui.ui index 49411c998..2bb0ef34e 100644 --- a/plugins/feature/satellitetracker/satellitetrackergui.ui +++ b/plugins/feature/satellitetracker/satellitetrackergui.ui @@ -383,7 +383,7 @@ - + 0 0 @@ -527,7 +527,7 @@ - + 0 0 @@ -584,11 +584,17 @@ Next + + Time until next event + Dur + + Duration of next pass + diff --git a/plugins/feature/startracker/startrackergui.ui b/plugins/feature/startracker/startrackergui.ui index e65becc87..11866fb24 100644 --- a/plugins/feature/startracker/startrackergui.ui +++ b/plugins/feature/startracker/startrackergui.ui @@ -11,7 +11,7 @@ - + 0 0 diff --git a/sdrgui/gui/rollupwidget.cpp b/sdrgui/gui/rollupwidget.cpp index 088555737..843ab038f 100644 --- a/sdrgui/gui/rollupwidget.cpp +++ b/sdrgui/gui/rollupwidget.cpp @@ -21,133 +21,133 @@ #include #include #include -#include #include #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(children()[i]); - - if (r) { - count++; - } - } + for (int i = 0; i < children().count(); ++i) + { + QWidget* r = qobject_cast(children()[i]); - stream << VersionMarker; - stream << version; - stream << count; + if (r) { + count++; + } + } - for (int i = 0; i < children().count(); ++i) - { - QWidget* r = qobject_cast(children()[i]); - - if (r) - { - stream << r->objectName(); - - if (r->isHidden()) { - stream << (int) 0; - } else { - stream << (int) 1; - } - } - } + stream << VersionMarker; + stream << version; + stream << count; - return state; + for (int i = 0; i < children().count(); ++i) + { + QWidget* r = qobject_cast(children()[i]); + + if (r) + { + stream << r->objectName(); + + if (r->isHidden()) { + stream << (int) 0; + } else { + stream << (int) 1; + } + } + } + + 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; - - if ((stream.status() != QDataStream::Ok) || (marker != VersionMarker) || (v != version)) { - return false; - } + QByteArray sd = state; + QDataStream stream(&sd, QIODevice::ReadOnly); + int marker, v; + stream >> marker; + stream >> v; - int count; - stream >> count; + if ((stream.status() != QDataStream::Ok) || (marker != VersionMarker) || (v != version)) { + return false; + } - if (stream.status() != QDataStream::Ok) { - return false; - } + int count; + stream >> count; - for (int i = 0; i < count; ++i) - { - QString name; - int visible; + if (stream.status() != QDataStream::Ok) { + return false; + } - stream >> name; - stream >> visible; + for (int i = 0; i < count; ++i) + { + QString name; + int visible; - if (stream.status() != QDataStream::Ok) { - return false; - } + stream >> name; + stream >> visible; - for (int j = 0; j < children().count(); ++j) - { - QWidget* r = qobject_cast(children()[j]); - - if (r) - { - if (r->objectName() == name) - { - if (visible) { - r->show(); - } else { - r->hide(); - } + if (stream.status() != QDataStream::Ok) { + return false; + } - break; - } - } - } - } + for (int j = 0; j < children().count(); ++j) + { + QWidget* r = qobject_cast(children()[j]); - return true; + if (r) + { + if (r->objectName() == name) + { + if (visible) { + r->show(); + } else { + r->hide(); + } + + break; + } + } + } + } + + 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,333 +161,391 @@ 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(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(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(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(*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(*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(*n) != nullptr) { - break; + if (qobject_cast(*n) != nullptr) { + break; } - } + } pos += paintRollup(qobject_cast(*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(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); - } + for (int i = 0; i < children().count(); ++i) + { + QWidget* r = qobject_cast(children()[i]); - arrangeRollups(); - repaint(); - return; - } - else - { - pos += fm.height() + 2; + 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->isHidden()) { - pos += r->height() + 5; - } - } - } - } + arrangeRollups(); + repaint(); + return; + } + else + { + pos += fm.height() + 2; + + 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(object), true); - } - } - else if (event->type() == QEvent::Hide) - { - if (children().contains(object)) - { - arrangeRollups(); - emit widgetRolled(qobject_cast(object), false); - } - } - else if (event->type() == QEvent::WindowTitleChange) - { - if (children().contains(object)) { - repaint(); - } - } - - return QWidget::eventFilter(object, event); + if (event->type() == QEvent::Show) + { + if (children().contains(object)) + { + arrangeRollups(); + emit widgetRolled(qobject_cast(object), true); + } + } + else if (event->type() == QEvent::Hide) + { + if (children().contains(object)) + { + arrangeRollups(); + emit widgetRolled(qobject_cast(object), false); + } + } + else if (event->type() == QEvent::WindowTitleChange) + { + if (children().contains(object)) { + repaint(); + } + } + + return QWidget::eventFilter(object, event); } void RollupWidget::setStreamIndicator(const QString& indicator) { - m_streamIndicator = indicator; - update(); + m_streamIndicator = indicator; + update(); } bool RollupWidget::isRollupChild(QWidget *childWidget) { return (qobject_cast(childWidget) == nullptr); // exclude Dialogs from rollups -} \ No newline at end of file +} diff --git a/sdrgui/gui/rollupwidget.h b/sdrgui/gui/rollupwidget.h index ee30200ac..d5f453556 100644 --- a/sdrgui/gui/rollupwidget.h +++ b/sdrgui/gui/rollupwidget.h @@ -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