in instrument tracks draw icon of instrument rather than displaying the full name of the instrument on track label button

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1766 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-10-18 10:22:43 +00:00
parent 88f6f1d080
commit 58c2980507
6 changed files with 62 additions and 47 deletions

View File

@@ -1,3 +1,21 @@
2008-10-18 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/embed.h:
* include/instrument_track.h:
* include/plugin.h:
* include/track_label_button.h:
* src/gui/widgets/track_label_button.cpp:
in instrument tracks draw icon of instrument rather than displaying the
full name of the instrument on track label button
* src/tracks/instrument_track.cpp:
do not call trackView::dragEnterEvent() if instrument track window
already accepted drag event - fixes dragging of presets and
instruments onto track label button
* src/core/piano.cpp:
do not reclaim keyboard focus if new focus widget is a QLineEdit
2008-10-17 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/remote_plugin.h:

View File

@@ -93,6 +93,11 @@ public:
{
}
virtual QString pixmapName( void ) const
{
return m_name;
}
protected:
QString m_name;
} ;
@@ -116,6 +121,13 @@ public:
}
return( QPixmap() );
}
virtual QString pixmapName( void ) const
{
return QString( STRINGIFY_PLUGIN_NAME(PLUGIN_NAME) ) +
"::" + m_name;
}
} ;
#endif

View File

@@ -101,11 +101,6 @@ public:
// name-stuff
virtual void setName( const QString & _new_name );
inline virtual QString displayName( void ) const
{
return instrumentName() + ":" + track::displayName();
}
// translate given key of a note-event to absolute key (i.e.
// add global master-pitch and base-note of this instrument track)
int masterKey( int _midi_key ) const;

View File

@@ -76,9 +76,9 @@ public:
const char * supportedFileTypes;
inline bool supportsFileType( const QString & _ext ) const
{
return( QString( supportedFileTypes ).
return QString( supportedFileTypes ).
split( QChar( ',' ) ).
contains( _ext ) );
contains( _ext );
}
class EXPORT subPluginFeatures
{
@@ -105,8 +105,8 @@ public:
inline bool isValid( void ) const
{
return( desc != NULL &&
name != QString::null );
return desc != NULL &&
name != QString::null;
}
plugin::descriptor * desc;
@@ -152,21 +152,21 @@ public:
// returns display-name out of descriptor
virtual QString displayName( void ) const
{
return( model::displayName().isNull() ?
m_descriptor->displayName :
model::displayName() );
return model::displayName().isNull() ?
m_descriptor->displayName :
model::displayName();
}
// return plugin-type
inline PluginTypes type( void ) const
{
return( m_descriptor->type );
return m_descriptor->type;
}
// return plugin-descriptor for further information
inline const descriptor * getDescriptor( void ) const
{
return( m_descriptor );
return m_descriptor;
}
// can be called if a file matching supportedFileTypes should be

View File

@@ -54,6 +54,7 @@ protected:
private:
trackView * m_trackView;
QString m_iconName;
} ;

View File

@@ -1,5 +1,3 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* track_label_button.cpp - implementation of class trackLabelButton, a label
* which is renamable by double-clicking it
@@ -26,19 +24,15 @@
*/
#include <QtGui/QFileDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QApplication>
#include <QtGui/QMouseEvent>
#include <QtGui/QPainter>
#include <QtGui/QToolButton>
#include "track_label_button.h"
#include "embed.h"
#include "rename_dialog.h"
#include "bb_track_container.h"
#include "bb_track.h"
#include "gui_templates.h"
#include "instrument_track.h"
#include "instrument.h"
#include "config_mgr.h"
#include "engine.h"
@@ -46,9 +40,10 @@
trackLabelButton::trackLabelButton( trackView * _tv, QWidget * _parent ) :
QToolButton( _parent ),
m_trackView( _tv )
m_trackView( _tv ),
m_iconName()
{
setAcceptDrops( TRUE );
setAcceptDrops( true );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 0, 0 ) );
setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
setFixedSize( 160, 29 );
@@ -94,7 +89,7 @@ void trackLabelButton::dragEnterEvent( QDragEnterEvent * _dee )
void trackLabelButton::dropEvent( QDropEvent * _de )
{
m_trackView->dropEvent( _de );
setChecked( TRUE );
setChecked( true );
}
@@ -127,31 +122,25 @@ void trackLabelButton::paintEvent( QPaintEvent * _pe )
{
if( m_trackView->getTrack()->type() == track::InstrumentTrack )
{
QToolButton::paintEvent( _pe );
QPainter p( this );
const QString dn = m_trackView->getTrack()->displayName();
const QString in = dn.split( ':' )[0];
const QString tn = dn.split( ':' )[1];
const int extra = ( isDown() || isChecked() ) ? -2 : -3;
const int is = 40;
p.setPen( QApplication::palette().buttonText().color().
darker( 130 ) );
p.drawText( is + extra, height() / 2 + extra, in );
p.setPen( QApplication::palette().buttonText().color() );
p.drawText( is + extra, height() / 2 +
QFontMetrics( p.font() ).height() + extra - 2,
tn );
}
else
{
setText( m_trackView->getTrack()->displayName() );
QToolButton::paintEvent( _pe );
instrumentTrack * it =
dynamic_cast<instrumentTrack *>(
m_trackView->getTrack() );
const pixmapLoader * pl;
if( it && ( pl = it->getInstrument()->getDescriptor()->logo ) )
{
if( pl->pixmapName() != m_iconName )
{
m_iconName = pl->pixmapName();
setIcon( pl->pixmap() );
}
}
}
setText( m_trackView->getTrack()->displayName() );
QToolButton::paintEvent( _pe );
}
#include "moc_track_label_button.cxx"
#endif