* when used on instrumentTrack, also show instrument name on trackLabelButton

* removed obsolete support for choosing custom track icons



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1630 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-09-18 21:36:27 +00:00
parent e282227c6a
commit af7e00091e
11 changed files with 129 additions and 191 deletions

View File

@@ -221,8 +221,7 @@ void bbTrackContainer::updateComboBox( void )
for( int i = 0; i < numOfBBs(); ++i )
{
bbTrack * bbt = bbTrack::findBBTrack( i );
m_bbComboBoxModel.addItem( bbt->name(),
new pixmapLoader( bbt->icon() ) );
m_bbComboBoxModel.addItem( bbt->name() );
}
setCurrentBB( cur_bb );
}

View File

@@ -1544,7 +1544,6 @@ track::track( TrackTypes _type, trackContainer * _tc ) :
m_trackContainer( _tc ), /*!< The track container object */
m_type( _type ), /*!< The track type */
m_name(), /*!< The track's name */
m_pixmapLoader( NULL ), /*!< For loading the track's pixmaps */
m_mutedModel( FALSE, this, tr( "Muted" ) ),
/*!< For controlling track muting */
m_soloModel( FALSE, this, tr( "Solo" ) ),

View File

@@ -46,19 +46,17 @@
trackLabelButton::trackLabelButton( trackView * _tv, QWidget * _parent ) :
QToolButton( _parent ),
m_trackView( _tv ),
m_pixmap(),
m_pixmapFile( "" )
m_trackView( _tv )
{
setAcceptDrops( TRUE );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 0, 0 ) );
setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
setFixedSize( 160, 29 );
setIconSize( QSize( 32, 32 ) );
updateName();
setText( " " );
connect( m_trackView->getTrack(), SIGNAL( dataChanged() ),
this, SLOT( updateName() ) );
this, SLOT( update() ) );
}
@@ -71,89 +69,6 @@ trackLabelButton::~trackLabelButton()
void trackLabelButton::setPixmap( const QPixmap & _pixmap )
{
m_pixmap = _pixmap;
setIcon( m_pixmap );
}
void trackLabelButton::setPixmapFile( const QString & _file )
{
QPixmap new_pixmap;
if( QFileInfo( _file ).isRelative() )
{
new_pixmap = QPixmap( configManager::inst()->trackIconsDir() +
_file );
}
else
{
new_pixmap = QPixmap( _file );
}
if( new_pixmap.isNull() )
{
return;
}
setPixmap( new_pixmap );
m_pixmapFile = _file;
emit( pixmapChanged() );
update();
}
void trackLabelButton::selectPixmap( void )
{
QFileDialog ofd( NULL, tr( "Select icon" ) );
QString dir;
if( m_pixmapFile != "" )
{
QString f = m_pixmapFile;
if( QFileInfo( f ).isRelative() )
{
f = configManager::inst()->trackIconsDir() + f;
}
dir = QFileInfo( f ).absolutePath();
}
else
{
dir = configManager::inst()->trackIconsDir();
}
// change dir to position of previously opened file
ofd.setDirectory( dir );
// use default QFileDialog::ExistingFile
// set filters
QStringList types;
types << tr( "All images (*.png *.jpg *.jpeg *.gif *.bmp)" );
ofd.setFilters( types );
if( m_pixmapFile != "" )
{
// select previously opened file
ofd.selectFile( QFileInfo( m_pixmapFile ).fileName() );
}
if ( ofd.exec () == QDialog::Accepted
&& !ofd.selectedFiles().isEmpty()
)
{
QString pf = ofd.selectedFiles()[0];
if( !QFileInfo( pf ).isRelative() )
{
pf = pf.replace( configManager::inst()->trackIconsDir(),
"" );
}
setPixmapFile( pf );
}
}
void trackLabelButton::rename( void )
{
QString txt = m_trackView->getTrack()->name();
@@ -162,56 +77,6 @@ void trackLabelButton::rename( void )
if( txt != text() )
{
m_trackView->getTrack()->setName( txt );
updateName();
}
}
void trackLabelButton::updateName( void )
{
setText( m_trackView->getTrack()->name() );
}
void trackLabelButton::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::RightButton )
{
QSize s( m_pixmap.width(), m_pixmap.height() );
s.scale( width(), height(), Qt::KeepAspectRatio );
if( _me->x() > 4 + s.width() )
{
rename();
}
else
{
selectPixmap();
}
}
else
{
QToolButton::mousePressEvent( _me );
}
}
void trackLabelButton::mouseDoubleClickEvent( QMouseEvent * _me )
{
QSize s( m_pixmap.width(), m_pixmap.height() );
s.scale( width(), height(), Qt::KeepAspectRatio );
if( _me->x() > 4 + s.width() )
{
rename();
}
else
{
selectPixmap();
}
}
@@ -234,6 +99,58 @@ void trackLabelButton::dropEvent( QDropEvent * _de )
void trackLabelButton::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::RightButton )
{
rename();
}
else
{
QToolButton::mousePressEvent( _me );
}
}
void trackLabelButton::mouseDoubleClickEvent( QMouseEvent * _me )
{
rename();
}
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 );
}
}
#include "moc_track_label_button.cxx"

View File

@@ -137,7 +137,7 @@ automationTrackView::automationTrackView( automationTrack * _at,
setFixedHeight( 32 );
trackLabelButton * tlb = new trackLabelButton( this,
getTrackSettingsWidget() );
tlb->setPixmap( embed::getIconPixmap( "automation_track" ) );
tlb->setIcon( embed::getIconPixmap( "automation_track" ) );
tlb->move( 3, 1 );
tlb->show();
setModel( _at );

View File

@@ -549,13 +549,11 @@ bbTrackView::bbTrackView( bbTrack * _bbt, trackContainerView * _tcv ) :
setAcceptDrops( FALSE );
m_trackLabel = new trackLabelButton( this, getTrackSettingsWidget() );
m_trackLabel->setPixmap( embed::getIconPixmap( "bb_track" ) );
m_trackLabel->setIcon( embed::getIconPixmap( "bb_track" ) );
m_trackLabel->move( 3, 1 );
m_trackLabel->show();
connect( m_trackLabel, SIGNAL( clicked( bool ) ),
this, SLOT( clickedTrackLabel() ) );
connect( m_trackLabel, SIGNAL( pixmapChanged() ),
engine::getBBTrackContainer(), SLOT( updateComboBox() ) );
setModel( _bbt );
}

View File

@@ -501,14 +501,6 @@ int instrumentTrack::masterKey( int _midi_key ) const
QString instrumentTrack::displayName( void ) const
{
return instrumentName() + ":" + name();
}
void instrumentTrack::removeMidiPortNode( multimediaProject & _mmp )
{
QDomNodeList n = _mmp.elementsByTagName( "midiport" );
@@ -845,7 +837,7 @@ instrumentTrackView::instrumentTrackView( instrumentTrack * _it,
m_tlb = new trackLabelButton( this, getTrackSettingsWidget() );
m_tlb->setCheckable( TRUE );
m_tlb->setPixmap( embed::getIconPixmap( "instrument_track" ) );
m_tlb->setIcon( embed::getIconPixmap( "instrument_track" ) );
m_tlb->move( 3, 1 );
m_tlb->show();
@@ -853,7 +845,7 @@ instrumentTrackView::instrumentTrackView( instrumentTrack * _it,
this, SLOT( toggleInstrumentWindow( bool ) ) );
connect( _it, SIGNAL( nameChanged() ),
m_tlb, SLOT( updateName() ) );
m_tlb, SLOT( update() ) );
// creation of widgets for track-settings-widget
m_volumeKnob = new knob( knobSmall_17, getTrackSettingsWidget(),

View File

@@ -497,12 +497,6 @@ void sampleTrack::loadTrackSpecificSettings( const QDomElement & _this )
}
node = node.nextSibling();
}
#if 0
if( _this.attribute( "icon" ) != "" )
{
tlb->setPixmapFile( _this.attribute( "icon" ) );
}
#endif
m_volumeModel.loadSettings( _this, "vol" );
}
@@ -520,7 +514,7 @@ sampleTrackView::sampleTrackView( sampleTrack * _t, trackContainerView * _tcv )
getTrackSettingsWidget() );
connect( tlb, SIGNAL( clicked( bool ) ),
this, SLOT( showEffects() ) );
tlb->setPixmap( embed::getIconPixmap( "sample_track" ) );
tlb->setIcon( embed::getIconPixmap( "sample_track" ) );
tlb->move( 3, 1 );
tlb->show();