From ec0865b409da8320cbfea2e35dc7ad4dad4c2e0c Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 9 May 2019 20:53:18 +0200 Subject: [PATCH] New stream setting display and change dialog placeholder in channel rollup widget --- sdrgui/gui/rollupwidget.cpp | 30 ++++++++++++++++++++++++++---- sdrgui/gui/rollupwidget.h | 11 +++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/sdrgui/gui/rollupwidget.cpp b/sdrgui/gui/rollupwidget.cpp index 782ba0927..db65407fe 100644 --- a/sdrgui/gui/rollupwidget.cpp +++ b/sdrgui/gui/rollupwidget.cpp @@ -6,7 +6,9 @@ RollupWidget::RollupWidget(QWidget* parent) : QWidget(parent), - m_highlighted(false) + m_highlighted(false), + m_contextMenuType(ContextMenuNone), + m_streamIndicator("S") { setMinimumSize(250, 150); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -189,6 +191,15 @@ void RollupWidget::paintEvent(QPaintEvent*) 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"); + + // 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); @@ -203,8 +214,8 @@ void RollupWidget::paintEvent(QPaintEvent*) // Titel //p.setPen(palette().highlightedText().color()); p.setPen(m_titleTextColor); - p.drawText(QRect(2 + fm.height(), 2, width() - 4 - 2 * fm.height(), fm.height()), - fm.elidedText(windowTitle(), Qt::ElideMiddle, width() - 4 - 2 * fm.height(), 0)); + 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; @@ -296,11 +307,22 @@ void RollupWidget::mousePressEvent(QMouseEvent* event) QFontMetrics fm(font()); // menu box left - if(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) { + if (QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) + { + m_contextMenuType = ContextMenuChannelSettings; emit customContextMenuRequested(event->globalPos()); return; } + // 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(); diff --git a/sdrgui/gui/rollupwidget.h b/sdrgui/gui/rollupwidget.h index 377a32058..01d1def56 100644 --- a/sdrgui/gui/rollupwidget.h +++ b/sdrgui/gui/rollupwidget.h @@ -20,9 +20,18 @@ protected: VersionMarker = 0xff }; + enum ContextMenuType + { + ContextMenuNone, + ContextMenuChannelSettings, + ContextMenuStreamSettings + }; + QColor m_titleColor; QColor m_titleTextColor; bool m_highlighted; + ContextMenuType m_contextMenuType; + QString m_streamIndicator; int arrangeRollups(); @@ -37,6 +46,8 @@ protected: bool event(QEvent* event); bool eventFilter(QObject* object, QEvent* event); + + void resetContextMenuType() { m_contextMenuType = ContextMenuNone; } }; #endif // INCLUDE_ROLLUPWIDGET_H