6969
7070namespace {
7171
72+ QEasingCurve responsiveEaseOut () {
73+ QEasingCurve curve (QEasingCurve::BezierSpline);
74+ curve.addCubicBezierSegment (QPointF (0.23 , 1.0 ), QPointF (0.32 , 1.0 ), QPointF (1.0 , 1.0 ));
75+ return curve;
76+ }
77+
7278void setButtonSymbolSmooth (QToolButton *button, const QString &symbol, double pointSize, const QColor &color) {
7379 if (!button) return ;
7480 const QString previousSymbol = button->property (" sfSymbolName" ).toString ();
@@ -90,17 +96,17 @@ void setButtonSymbolSmooth(QToolButton *button, const QString &symbol, double po
9096 button->setGraphicsEffect (effect);
9197 }
9298 auto *out = new QPropertyAnimation (effect, " opacity" , button);
93- out->setDuration (45 );
99+ out->setDuration (55 );
94100 out->setStartValue (effect->opacity ());
95101 out->setEndValue (0.35 );
96- out->setEasingCurve (QEasingCurve::OutCubic );
102+ out->setEasingCurve (responsiveEaseOut () );
97103 QObject::connect (out, &QPropertyAnimation::finished, button, [button, effect, applyIcon] {
98104 applyIcon ();
99105 auto *in = new QPropertyAnimation (effect, " opacity" , button);
100- in->setDuration (45 );
106+ in->setDuration (70 );
101107 in->setStartValue (effect->opacity ());
102108 in->setEndValue (1.0 );
103- in->setEasingCurve (QEasingCurve::OutCubic );
109+ in->setEasingCurve (responsiveEaseOut () );
104110 QObject::connect (in, &QPropertyAnimation::finished, in, &QObject::deleteLater);
105111 in->start ();
106112 });
@@ -527,7 +533,11 @@ void BrowserWindow::splitTabs(WebView *first, WebView *second, const QPoint &glo
527533 };
528534 syncPaneNav ();
529535 connect (view, &WebView::navigationStateChanged, toolbar.bar , syncPaneNav);
530- connect (toolbar.sidebar , &QToolButton::clicked, this , [this ] { if (m_sidebar && m_sidebarWidget) m_sidebar->setHidden (m_sidebarWidget->isVisible ()); });
536+ connect (toolbar.sidebar , &QToolButton::clicked, this , [this ] {
537+ if (!m_sidebar || !m_sidebarWidget) return ;
538+ if (m_sidebarWidget->isVisible ()) m_sidebar->setHidden (true );
539+ else m_sidebar->expandAnimated ();
540+ });
531541 connect (toolbar.back , &QToolButton::clicked, view, [viewGuard] { if (viewGuard) viewGuard->back (); });
532542 connect (toolbar.forward , &QToolButton::clicked, view, [viewGuard] { if (viewGuard) viewGuard->forward (); });
533543 connect (toolbar.reload , &QToolButton::clicked, view, [viewGuard] { if (viewGuard) { if (viewGuard->isLoading ()) viewGuard->stop (); else viewGuard->reload (); } });
@@ -865,7 +875,11 @@ QWidget *BrowserWindow::buildTopbar(QWidget *parent) {
865875 if (auto *v = currentView ()) v->setFocus ();
866876 });
867877
868- connect (m_sidebarBtn, &QToolButton::clicked, this , [this ] { if (m_sidebar && m_sidebarWidget) m_sidebar->setHidden (m_sidebarWidget->isVisible ()); });
878+ connect (m_sidebarBtn, &QToolButton::clicked, this , [this ] {
879+ if (!m_sidebar || !m_sidebarWidget) return ;
880+ if (m_sidebarWidget->isVisible ()) m_sidebar->setHidden (true );
881+ else m_sidebar->expandAnimated ();
882+ });
869883 connect (m_backBtn, &QToolButton::clicked, this , [this ] { if (auto *v = currentView ()) v->back (); });
870884 connect (m_fwdBtn, &QToolButton::clicked, this , [this ] { if (auto *v = currentView ()) v->forward (); });
871885 connect (m_reloadBtn, &QToolButton::clicked, this , [this ] { if (auto *v = currentView ()) { if (v->isLoading ()) v->stop (); else v->reload (); } });
@@ -1022,8 +1036,8 @@ void BrowserWindow::settleSidebarSwipe(bool commit) {
10221036 m_sidebarSwipeAnim = driver;
10231037 driver->setStartValue (startOffset);
10241038 driver->setEndValue (commit ? (direction > 0 ? -width : width) : 0 );
1025- driver->setDuration (commit ? 160 : 120 );
1026- driver->setEasingCurve (QEasingCurve::OutCubic );
1039+ driver->setDuration (commit ? 150 : 105 );
1040+ driver->setEasingCurve (responsiveEaseOut () );
10271041 m_sidebarSwipeSettling = true ;
10281042 connect (driver, &QVariantAnimation::valueChanged, this , [this ](const QVariant &value) {
10291043 setSidebarSwipeOffset (value.toInt ());
@@ -1056,10 +1070,10 @@ void BrowserWindow::animateProfileSwitcher(int direction) {
10561070 QRect start = end.translated (direction > 0 ? 18 : -18 , 0 );
10571071 m_profileBtn->setGeometry (start);
10581072 m_profileAnim = new QPropertyAnimation (m_profileBtn, " geometry" , this );
1059- m_profileAnim->setDuration (180 );
1073+ m_profileAnim->setDuration (155 );
10601074 m_profileAnim->setStartValue (start);
10611075 m_profileAnim->setEndValue (end);
1062- m_profileAnim->setEasingCurve (QEasingCurve::OutCubic );
1076+ m_profileAnim->setEasingCurve (responsiveEaseOut () );
10631077 QPropertyAnimation *anim = m_profileAnim;
10641078 connect (anim, &QPropertyAnimation::finished, anim, &QObject::deleteLater);
10651079 connect (anim, &QObject::destroyed, this , [this , anim] { if (m_profileAnim == anim) m_profileAnim = nullptr ; });
@@ -1580,14 +1594,10 @@ void BrowserWindow::setupActions() {
15801594 auto *side = m_splitter->widget (0 );
15811595 if (!side) return ;
15821596 const bool nowVisible = !side->isVisible ();
1583- m_sidebar->setHidden (!nowVisible);
15841597 if (nowVisible) {
1585- QTimer::singleShot (0 , this , [this , side] {
1586- const int saved = QSettings ().value (" ui/sidebarWidth" , ui::metrics::SidebarDefaultWidth).toInt ();
1587- const int target = qBound (side->minimumWidth (), saved, side->maximumWidth ());
1588- const int total = m_splitter->size ().width ();
1589- m_splitter->setSizes ({target, qMax (0 , total - target - m_splitter->handleWidth ())});
1590- });
1598+ m_sidebar->expandAnimated ();
1599+ } else {
1600+ m_sidebar->setHidden (true );
15911601 }
15921602 };
15931603
0 commit comments