1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Massive UI revamping (v7): Feature and channels: set the border on the outer side of the window. Part of #1213

This commit is contained in:
f4exb 2022-04-24 01:22:39 +02:00
parent f7bfd10bd7
commit f762863a23
7 changed files with 24 additions and 26 deletions

View File

@ -44,6 +44,10 @@ ChannelGUI::ChannelGUI(QWidget *parent) :
{
qDebug("ChannelGUI::ChannelGUI");
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setObjectName("ChannelGUI");
setStyleSheet(QString(tr("#ChannelGUI { border: 1px solid %1; background-color: %2; }")
.arg(palette().highlight().color().darker(115).name()))
.arg(palette().dark().color().darker(115).name()));
m_indexLabel = new QLabel();
m_indexLabel->setFixedSize(50, 16);
@ -124,8 +128,8 @@ ChannelGUI::ChannelGUI(QWidget *parent) :
m_statusLabel->setToolTip("Channel status");
m_layouts = new QVBoxLayout();
m_layouts->setContentsMargins(m_resizer.m_gripSize, 4, m_resizer.m_gripSize, 4);
m_layouts->setSpacing(2);
m_layouts->setContentsMargins(m_resizer.m_gripSize, m_resizer.m_gripSize, m_resizer.m_gripSize, m_resizer.m_gripSize);
m_layouts->setSpacing(0);
m_topLayout = new QHBoxLayout();
m_topLayout->setContentsMargins(0, 0, 0, 0);
@ -152,6 +156,7 @@ ChannelGUI::ChannelGUI(QWidget *parent) :
m_bottomLayout->addWidget(m_statusLabel);
m_sizeGripBottomRight = new QSizeGrip(this);
m_sizeGripBottomRight->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_sizeGripBottomRight->setFixedHeight(20);
// m_bottomLayout->addStretch(1);
m_bottomLayout->addWidget(m_sizeGripBottomRight, 0, Qt::AlignBottom | Qt::AlignRight);
@ -318,6 +323,7 @@ void ChannelGUI::shrinkWindow()
{
qDebug("ChannelGUI::shrinkWindow");
adjustSize();
resize(width(), m_rollupContents->height() + getAdditionalHeight());
}
void ChannelGUI::setTitle(const QString& title)

View File

@ -95,7 +95,7 @@ protected:
void mouseMoveEvent(QMouseEvent* event) override;
void resetContextMenuType() { m_contextMenuType = ContextMenuNone; }
void updateIndexLabel();
int getAdditionalHeight() const { return 29 + 26; }
int getAdditionalHeight() const { return 25 + 22; }
DeviceType m_deviceType;
int m_deviceSetIndex;

View File

@ -39,6 +39,10 @@ FeatureGUI::FeatureGUI(QWidget *parent) :
{
qDebug("FeatureGUI::FeatureGUI");
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setObjectName("FeatureGUI");
setStyleSheet(QString(tr("#FeatureGUI { border: 1px solid %1; background-color: %2; }")
.arg(palette().highlight().color().darker(115).name()))
.arg(palette().dark().color().darker(115).name()));
m_indexLabel = new QLabel();
m_indexLabel->setFixedSize(40, 16);
@ -90,8 +94,8 @@ FeatureGUI::FeatureGUI(QWidget *parent) :
m_statusLabel->setToolTip("Feature status");
m_layouts = new QVBoxLayout();
m_layouts->setContentsMargins(m_resizer.m_gripSize, 4, m_resizer.m_gripSize, 4);
m_layouts->setSpacing(2);
m_layouts->setContentsMargins(m_resizer.m_gripSize, m_resizer.m_gripSize, m_resizer.m_gripSize, m_resizer.m_gripSize);
m_layouts->setSpacing(0);
m_topLayout = new QHBoxLayout();
m_topLayout->setContentsMargins(0, 0, 0, 0);
@ -112,6 +116,7 @@ FeatureGUI::FeatureGUI(QWidget *parent) :
m_bottomLayout->addWidget(m_statusLabel);
m_sizeGripBottomRight = new QSizeGrip(this);
m_sizeGripBottomRight->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_sizeGripBottomRight->setFixedHeight(20);
// m_bottomLayout->addStretch(1);
m_bottomLayout->addWidget(m_sizeGripBottomRight, 0, Qt::AlignBottom | Qt::AlignRight);
@ -256,6 +261,7 @@ void FeatureGUI::shrinkWindow()
{
qDebug("FeatureGUI::shrinkWindow");
adjustSize();
resize(width(), m_rollupContents.height() + getAdditionalHeight());
}
void FeatureGUI::setTitle(const QString& title)

View File

@ -72,6 +72,7 @@ protected:
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void resetContextMenuType() { m_contextMenuType = ContextMenuNone; }
int getAdditionalHeight() const { return 25 + 22; }
int m_featureIndex;
QString m_helpURL;

View File

@ -54,7 +54,7 @@ public:
void mouseMoveEvent(QMouseEvent* event);
void leaveEvent(QEvent* event);
const int m_gripSize = 3; // Size in pixels of the border of the window that can be clicked in to resize it
const int m_gripSize = 2; // Size in pixels of the border of the window that can be clicked in to resize it
protected:
bool mouseOnTopBorder(QPoint pos) const;

View File

@ -92,22 +92,6 @@ void RollupContents::setHighlighted(bool highlighted)
}
}
int RollupContents::getAdditionalHeiht()
{
int pos = 0;
for (int i = 0; i < children().count(); ++i)
{
QWidget* r = qobject_cast<QWidget*>(children()[i]);
if (r && isRollupChild(r) && !r->isHidden()) {
pos += 5;
}
}
return pos;
}
bool RollupContents::hasExpandableWidgets()
{
for (int i = 0; i < children().count(); ++i)
@ -218,7 +202,8 @@ int RollupContents::arrangeRollups()
void RollupContents::paintEvent(QPaintEvent*)
{
QPainter p(this);
QColor frameColor = palette().highlight().color().darker(115);
QColor frameColor = palette().highlight().color().darker(125);
// QColor frameColor = Qt::black;
// Eigenbau
QFontMetrics fm(font());
@ -237,9 +222,10 @@ void RollupContents::paintEvent(QPaintEvent*)
p.setPen(m_highlighted ? Qt::white : frameColor);
p.setBrush(palette().window());
QRectF r(rect());
r.adjust(0.5, 0.5, -0.5, -0.5);
// r.adjust(0.5, 0.5, -0.5, -0.5);
// p.drawRoundedRect(r, 3.0, 3.0, Qt::AbsoluteSize);
p.drawRect(r);
// p.drawRect(r);
p.fillRect(r, palette().window());
// Rollups
int pos = 2; // fm.height() + 4;

View File

@ -34,7 +34,6 @@ public:
void saveState(RollupState& state) const;
void restoreState(const RollupState& state);
int arrangeRollups();
int getAdditionalHeiht();
bool hasExpandableWidgets();
signals: