From 58c29805078295027c1b3d6081439333ab9dd637 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 18 Oct 2008 10:22:43 +0000 Subject: [PATCH] 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 --- ChangeLog | 18 +++++++++ include/embed.h | 12 ++++++ include/instrument_track.h | 5 --- include/plugin.h | 18 ++++----- include/track_label_button.h | 1 + src/gui/widgets/track_label_button.cpp | 55 +++++++++++--------------- 6 files changed, 62 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77cd40820..c7ce26356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-10-18 Tobias Doerffel + + * 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 * include/remote_plugin.h: diff --git a/include/embed.h b/include/embed.h index acd67057a..2dad5ce4c 100644 --- a/include/embed.h +++ b/include/embed.h @@ -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 diff --git a/include/instrument_track.h b/include/instrument_track.h index ef1f96fc5..6b4ddd114 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -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; diff --git a/include/plugin.h b/include/plugin.h index 83af04cd7..d7f847ff7 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -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 diff --git a/include/track_label_button.h b/include/track_label_button.h index bc6e7a9cc..d9d90ae3e 100644 --- a/include/track_label_button.h +++ b/include/track_label_button.h @@ -54,6 +54,7 @@ protected: private: trackView * m_trackView; + QString m_iconName; } ; diff --git a/src/gui/widgets/track_label_button.cpp b/src/gui/widgets/track_label_button.cpp index f88391c58..dda74b8b3 100644 --- a/src/gui/widgets/track_label_button.cpp +++ b/src/gui/widgets/track_label_button.cpp @@ -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 -#include +#include #include -#include -#include #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( + 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