From 918f449eb39b371942e3abe176cf719a5fc35a71 Mon Sep 17 00:00:00 2001 From: Levin Oehlmann Date: Wed, 15 Nov 2017 06:08:48 +0100 Subject: [PATCH] UI: New behavior for the Plugin Browser (#3773) Remove widget resizing altogether, display plugin info in tooltip instead --- data/themes/default/style.css | 2 +- include/PluginBrowser.h | 21 +++------ include/SideBarWidget.h | 1 - src/gui/PluginBrowser.cpp | 86 ++++++----------------------------- 4 files changed, 21 insertions(+), 89 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 695e9b6fd..2a2dbec6f 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -531,7 +531,7 @@ PluginDescWidget { } PluginDescWidget:hover { - background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #2E343B, stop:1 #1E2326); + background: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #7C8799, stop:1 #343840); color: #d1d8e4; } diff --git a/include/PluginBrowser.h b/include/PluginBrowser.h index bd86705a1..75c7cd291 100644 --- a/include/PluginBrowser.h +++ b/include/PluginBrowser.h @@ -37,8 +37,7 @@ class PluginBrowser : public SideBarWidget Q_OBJECT public: PluginBrowser( QWidget * _parent ); - virtual ~PluginBrowser(); - + virtual ~PluginBrowser() = default; private: QWidget * m_view; @@ -62,29 +61,21 @@ class PluginDescWidget : public QWidget Q_OBJECT public: PluginDescWidget( const Plugin::Descriptor & _pd, QWidget * _parent ); - virtual ~PluginDescWidget(); protected: - virtual void enterEvent( QEvent * _e ); - virtual void leaveEvent( QEvent * _e ); - virtual void mousePressEvent( QMouseEvent * _me ); - virtual void paintEvent( QPaintEvent * _pe ); - - -private slots: - void updateHeight(); - + void enterEvent( QEvent * _e ) override; + void leaveEvent( QEvent * _e ) override; + void mousePressEvent( QMouseEvent * _me ) override; + void paintEvent( QPaintEvent * _pe ) override; private: - QTimer m_updateTimer; + constexpr static int DEFAULT_HEIGHT{24}; const Plugin::Descriptor & m_pluginDescriptor; QPixmap m_logo; bool m_mouseOver; - int m_targetHeight; - }; diff --git a/include/SideBarWidget.h b/include/SideBarWidget.h index 613c89c4a..229f07df0 100644 --- a/include/SideBarWidget.h +++ b/include/SideBarWidget.h @@ -70,7 +70,6 @@ protected: m_layout->addLayout( _l ); } - private: QWidget * m_contents; QVBoxLayout * m_layout; diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 61fb965ef..dc0fc35e0 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -37,14 +37,6 @@ #include "PluginFactory.h" -static bool pluginBefore( const Plugin::Descriptor* d1, const Plugin::Descriptor* d2 ) -{ - return qstricmp( d1->displayName, d2->displayName ) < 0 ? true : false; -} - - - - PluginBrowser::PluginBrowser( QWidget * _parent ) : SideBarWidget( tr( "Instrument Plugins" ), embed::getIconPixmap( "plugins" ).transformed( QTransform().rotate( 90 ) ), _parent ) @@ -60,7 +52,7 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : view_layout->setSpacing( 5 ); - QLabel * hint = new QLabel( tr( "Drag an instrument " + auto hint = new QLabel( tr( "Drag an instrument " "into either the Song-Editor, the " "Beat+Bassline Editor or into an " "existing instrument track." ), @@ -79,20 +71,20 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : -PluginBrowser::~PluginBrowser() -{ -} - - - - PluginDescList::PluginDescList(QWidget *parent) : QWidget(parent) { QVBoxLayout* layout = new QVBoxLayout(this); QList descs = pluginFactory->descriptors(Plugin::Instrument); - std::sort(descs.begin(), descs.end(), pluginBefore); + std::sort( + descs.begin(), + descs.end(), + []( const Plugin::Descriptor* d1, const Plugin::Descriptor* d2 ) -> bool + { + return qstricmp( d1->displayName, d2->displayName ) < 0 ? true : false; + } + ); for (const Plugin::Descriptor* desc : descs) { PluginDescWidget* p = new PluginDescWidget( *desc, this ); @@ -110,23 +102,14 @@ PluginDescList::PluginDescList(QWidget *parent) : PluginDescWidget::PluginDescWidget( const Plugin::Descriptor & _pd, QWidget * _parent ) : QWidget( _parent ), - m_updateTimer( this ), m_pluginDescriptor( _pd ), m_logo( _pd.logo->pixmap() ), - m_mouseOver( false ), - m_targetHeight( 24 ) + m_mouseOver( false ) { - connect( &m_updateTimer, SIGNAL( timeout() ), SLOT( updateHeight() ) ); - setFixedHeight( m_targetHeight ); + setFixedHeight( DEFAULT_HEIGHT ); setMouseTracking( true ); setCursor( Qt::PointingHandCursor ); -} - - - - -PluginDescWidget::~PluginDescWidget() -{ + setToolTip(_pd.description); } @@ -159,21 +142,6 @@ void PluginDescWidget::paintEvent( QPaintEvent * e ) p.setFont( f ); p.drawText( 10 + logo_size.width(), 15, m_pluginDescriptor.displayName ); - - if( height() > 24 || m_mouseOver ) - { - f.setBold( false ); - p.setFont( f ); - QRect br; - p.drawText( 10 + logo_size.width(), 20, width() - 58 - 5, 999, - Qt::TextWordWrap, - qApp->translate( "pluginBrowser", m_pluginDescriptor.description ), - &br ); - if( m_mouseOver ) - { - m_targetHeight = qMax( 60, 25 + br.height() ); - } - } } @@ -182,8 +150,7 @@ void PluginDescWidget::paintEvent( QPaintEvent * e ) void PluginDescWidget::enterEvent( QEvent * _e ) { m_mouseOver = true; - m_targetHeight = height() + 1; - updateHeight(); + QWidget::enterEvent( _e ); } @@ -193,8 +160,7 @@ void PluginDescWidget::enterEvent( QEvent * _e ) void PluginDescWidget::leaveEvent( QEvent * _e ) { m_mouseOver = false; - m_targetHeight = 24; - updateHeight(); + QWidget::leaveEvent( _e ); } @@ -214,30 +180,6 @@ void PluginDescWidget::mousePressEvent( QMouseEvent * _me ) -void PluginDescWidget::updateHeight() -{ - if( m_targetHeight > height() ) - { - setFixedHeight( height() + 1 ); - } - else if( m_targetHeight < height() ) - { - setFixedHeight( height() - 1 ); - } - else - { - m_updateTimer.stop(); - return; - } - - if( !m_updateTimer.isActive() ) - { - m_updateTimer.start( 10 ); - } -} - - -