Skip to content
Merged
Prev Previous commit
Next Next commit
Show plugin details in tooltips instead of the browser header.
  • Loading branch information
irrenhaus3 committed Aug 24, 2017
commit 84e053a0b95e85aeaef59171f949afaa4aa081a6
26 changes: 0 additions & 26 deletions include/PluginBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

#include <QtCore/QTimer>
#include <QPixmap>
#include <QLabel>

#include <memory>

#include "SideBarWidget.h"
#include "Plugin.h"
Expand All @@ -42,16 +39,8 @@ class PluginBrowser : public SideBarWidget
PluginBrowser( QWidget * _parent );
virtual ~PluginBrowser() = default;

private slots:
void highlightPlugin(Plugin::Descriptor const& pd);
void highlightNone();


private:
QWidget * m_view;

std::unique_ptr<QLabel> m_hint;

};


Expand All @@ -62,14 +51,6 @@ class PluginDescList : public QWidget
Q_OBJECT
public:
PluginDescList(QWidget* parent);

signals:
void highlight(Plugin::Descriptor const&);
void unhighlight();

private slots:
void receiveHighlight(Plugin::Descriptor const&);
void receiveUnhighlight();
};


Expand All @@ -88,16 +69,9 @@ class PluginDescWidget : public QWidget
void mousePressEvent( QMouseEvent * _me ) override;
void paintEvent( QPaintEvent * _pe ) override;

signals:
void highlight(Plugin::Descriptor const& pd);
void unhighlight();


private:
constexpr static int DEFAULT_HEIGHT{24};

QTimer m_updateTimer;

const Plugin::Descriptor & m_pluginDescriptor;
QPixmap m_logo;

Expand Down
11 changes: 0 additions & 11 deletions include/SideBarWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ class SideBarWidget : public QWidget
m_layout->addLayout( _l );
}

void changeIcon(QPixmap const& icon)
{
m_icon=icon;
}

void changeTitle(QString const& title)
{
m_title=title;
}


private:
QWidget * m_contents;
QVBoxLayout * m_layout;
Expand Down
70 changes: 5 additions & 65 deletions src/gui/PluginBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,61 +54,23 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) :
view_layout->setSpacing( 5 );


m_hint.reset(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." ),
m_view )
);
m_hint->setWordWrap( true );
// TODO fixed height causes some descriptions to be cropped;
// variable height causes layout resizing.
// Maybe pre-set to a height where resizing is never needed.
m_hint->setFixedHeight( m_hint->sizeHint().height() );
m_view );
hint->setWordWrap( true );

QScrollArea* scrollarea = new QScrollArea( m_view );
PluginDescList* descList = new PluginDescList( m_view );
QObject::connect(
descList,SIGNAL(highlight(Plugin::Descriptor const&)),
this,SLOT(highlightPlugin(Plugin::Descriptor const&))
);
QObject::connect(
descList,SIGNAL(unhighlight()),
this,SLOT(highlightNone())
);

scrollarea->setWidget(descList);
scrollarea->setWidgetResizable(true);

view_layout->addWidget(m_hint.get());
view_layout->addWidget(hint);
view_layout->addWidget(scrollarea);
}


void PluginBrowser::highlightNone(){
m_hint->setText(
tr( "Drag an instrument "
"into either the Song-Editor, the "
"Beat+Bassline Editor or into an "
"existing instrument track."
)
);
changeTitle("Instrument Plugins");
changeIcon(embed::getIconPixmap( "plugins" ).transformed( QTransform().rotate( 90 ) ));
update();
}

void PluginBrowser::highlightPlugin(Plugin::Descriptor const& pd)
{
m_hint->setText(
tr(pd.description)
);
changeTitle(pd.displayName);
changeIcon(pd.logo->pixmap().transformed(QTransform().rotate(90)));
update();
}




PluginDescList::PluginDescList(QWidget *parent) :
Expand All @@ -128,15 +90,6 @@ PluginDescList::PluginDescList(QWidget *parent) :
for (const Plugin::Descriptor* desc : descs)
{
PluginDescWidget* p = new PluginDescWidget( *desc, this );
QObject::connect(
p,SIGNAL(highlight(Plugin::Descriptor const&)),
this,SLOT(receiveHighlight(Plugin::Descriptor const&))
);

QObject::connect(
p,SIGNAL(unhighlight()),
this,SLOT(receiveUnhighlight())
);
p->show();
layout->addWidget(p);
}
Expand All @@ -145,29 +98,20 @@ PluginDescList::PluginDescList(QWidget *parent) :
layout->addStretch();
}

void PluginDescList::receiveHighlight(Plugin::Descriptor const& pd){
emit highlight(pd);
}

void PluginDescList::receiveUnhighlight()
{
emit unhighlight();
}




PluginDescWidget::PluginDescWidget( const Plugin::Descriptor & _pd,
QWidget * _parent ) :
QWidget( _parent ),
m_updateTimer( this ),
m_pluginDescriptor( _pd ),
m_logo( _pd.logo->pixmap() ),
m_mouseOver( false )
{
setFixedHeight( DEFAULT_HEIGHT );
setMouseTracking( true );
setCursor( Qt::PointingHandCursor );
setToolTip(_pd.description);
}


Expand Down Expand Up @@ -209,8 +153,6 @@ void PluginDescWidget::enterEvent( QEvent * _e )
{
m_mouseOver = true;

emit highlight(m_pluginDescriptor);

QWidget::enterEvent( _e );
}

Expand All @@ -221,8 +163,6 @@ void PluginDescWidget::leaveEvent( QEvent * _e )
{
m_mouseOver = false;

emit unhighlight();

QWidget::leaveEvent( _e );
}

Expand Down