Skip to content

Commit 94b6745

Browse files
ten9876claude
andcommitted
AppletPanel: drop hover-reveal, dim handle at rest with 500ms hold
Maintainer feedback: the hover-reveal felt too abrupt and the transparent track left a visible gap on the right edge of the panel when the slider faded out. Changes from the original PR: - Track always visible at #0a0a14 (matches the rest of the app and fills the gap consistently — no transparent strip). - Handle dim (#2a3a4a) at rest, bright (#4a6880) on hover or drag. - 500ms delay before dimming back so quick scroll gestures don't flicker; re-entering during the hold cancels the timer. - Implemented via dynamic property `active` plus an event filter on the QScrollBar (QSS doesn't support animated transitions). `min-height: 20px` and the bright color are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 292f3cc commit 94b6745

2 files changed

Lines changed: 54 additions & 4 deletions

File tree

src/gui/AppletPanel.cpp

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include "core/AppSettings.h"
4040
#include <QPushButton>
4141
#include <QScrollArea>
42+
#include <QScrollBar>
43+
#include <QStyle>
44+
#include <QTimer>
4245
#include <QVBoxLayout>
4346
#include <QHBoxLayout>
4447
#include <QLabel>
@@ -368,13 +371,24 @@ AppletPanel::AppletPanel(QWidget* parent) : QWidget(parent)
368371
m_scrollArea->setFrameShape(QFrame::NoFrame);
369372
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
370373
m_scrollArea->setWidgetResizable(true);
374+
// Handle dims to #2a3a4a at rest, brightens to #4a6880 on hover/drag.
375+
// 500 ms delay before dimming back so quick drags don't flicker.
371376
m_scrollArea->setStyleSheet(
372-
"QScrollBar:vertical { background: transparent; width: 12px; }"
373-
"QScrollBar:vertical:hover { background: #0a0a14; }"
374-
"QScrollBar::handle:vertical { background: transparent; border-radius: 4px; min-height: 20px; }"
375-
"QScrollBar::handle:vertical:hover, QScrollBar::handle:vertical:pressed { background: #4a6880; }"
377+
"QScrollBar:vertical { background: #0a0a14; width: 12px; }"
378+
"QScrollBar::handle:vertical { background: #2a3a4a; border-radius: 4px; min-height: 20px; }"
379+
"QScrollBar::handle:vertical[active=\"true\"] { background: #4a6880; }"
376380
"QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { height: 0; }");
377381

382+
if (auto* sb = m_scrollArea->verticalScrollBar()) {
383+
sb->setProperty("active", false);
384+
sb->installEventFilter(this);
385+
}
386+
m_scrollDimTimer = new QTimer(this);
387+
m_scrollDimTimer->setSingleShot(true);
388+
m_scrollDimTimer->setInterval(500);
389+
connect(m_scrollDimTimer, &QTimer::timeout, this,
390+
[this]() { setScrollHandleActive(false); });
391+
378392
auto* container = new QWidget;
379393
m_stack = new QVBoxLayout(container);
380394
m_stack->setContentsMargins(0, 0, 0, 0);
@@ -1104,5 +1118,35 @@ void AppletPanel::setTxDspChainOrder(
11041118
}
11051119
}
11061120

1121+
bool AppletPanel::eventFilter(QObject* obj, QEvent* ev)
1122+
{
1123+
if (m_scrollArea && obj == m_scrollArea->verticalScrollBar()) {
1124+
switch (ev->type()) {
1125+
case QEvent::Enter:
1126+
case QEvent::MouseButtonPress:
1127+
if (m_scrollDimTimer) m_scrollDimTimer->stop();
1128+
setScrollHandleActive(true);
1129+
break;
1130+
case QEvent::Leave:
1131+
case QEvent::MouseButtonRelease:
1132+
if (m_scrollDimTimer) m_scrollDimTimer->start();
1133+
break;
1134+
default:
1135+
break;
1136+
}
1137+
}
1138+
return QWidget::eventFilter(obj, ev);
1139+
}
1140+
1141+
void AppletPanel::setScrollHandleActive(bool active)
1142+
{
1143+
if (!m_scrollArea) return;
1144+
auto* sb = m_scrollArea->verticalScrollBar();
1145+
if (!sb) return;
1146+
if (sb->property("active").toBool() == active) return;
1147+
sb->setProperty("active", active);
1148+
sb->style()->unpolish(sb);
1149+
sb->style()->polish(sb);
1150+
}
11071151

11081152
} // namespace AetherSDR

src/gui/AppletPanel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class QComboBox;
1111
class QPushButton;
1212
class QScrollArea;
13+
class QTimer;
1314
class QVBoxLayout;
1415

1516
namespace AetherSDR {
@@ -175,10 +176,14 @@ class AppletPanel : public QWidget {
175176

176177
friend class AppletDropArea;
177178

179+
protected:
180+
bool eventFilter(QObject* obj, QEvent* ev) override;
181+
178182
private:
179183
void rebuildStackOrder();
180184
void saveOrder();
181185
int dropIndexFromY(int localY) const;
186+
void setScrollHandleActive(bool active);
182187

183188
ContainerManager* m_containerMgr{nullptr};
184189
ContainerWidget* m_rootSidebar{nullptr};
@@ -228,6 +233,7 @@ class AppletPanel : public QWidget {
228233
QPushButton* m_ssBtn{nullptr};
229234
QVBoxLayout* m_stack{nullptr};
230235
QScrollArea* m_scrollArea{nullptr};
236+
QTimer* m_scrollDimTimer{nullptr};
231237
QWidget* m_dropIndicator{nullptr};
232238
QPushButton* m_lockBtn{nullptr}; // controls-lock toggle (#745)
233239

0 commit comments

Comments
 (0)