From 3f094407491897f1e79f99bdd5211179b675967f Mon Sep 17 00:00:00 2001 From: Cyrille Bollu Date: Thu, 25 Feb 2016 16:45:28 +0100 Subject: [PATCH] 1) Tabs in TabWidget class have now a "tooltip" attribute. So that they can now show more meaningfull information then simply the tab's name. 2) Fixed the compilation problem with QT5 --- include/TabWidget.h | 3 ++- src/gui/widgets/TabWidget.cpp | 11 +++++++---- src/tracks/InstrumentTrack.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/TabWidget.h b/include/TabWidget.h index 231afc0f1..dc1796744 100644 --- a/include/TabWidget.h +++ b/include/TabWidget.h @@ -38,7 +38,7 @@ public: TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false ); virtual ~TabWidget(); - void addTab( QWidget *_w, const QString &_name, const char *activePixmap = NULL, const char *inactivePixmap = NULL, int _idx = -1 ); + void addTab( QWidget *_w, const QString &_name, const QString &_tooltip = NULL, const char *activePixmap = NULL, const char *inactivePixmap = NULL, int _idx = -1 ); void setActiveTab( int _idx ); @@ -65,6 +65,7 @@ private: const char *activePixmap; // artwork for the widget const char *inactivePixmap; // artwork for the widget QString name; // name for widget + QString tooltip; // name for widget int nwidth; // width of name when painting (only valid for text tab) } ; typedef QMap widgetStack; diff --git a/src/gui/widgets/TabWidget.cpp b/src/gui/widgets/TabWidget.cpp index a3a52a8c7..fa032935b 100644 --- a/src/gui/widgets/TabWidget.cpp +++ b/src/gui/widgets/TabWidget.cpp @@ -65,7 +65,7 @@ TabWidget::~TabWidget() -void TabWidget::addTab( QWidget * _w, const QString & _name, const char *activePixmap, const char *inactivePixmap, int _idx ) +void TabWidget::addTab( QWidget * _w, const QString & _name, const QString & _tooltip, const char *activePixmap, const char *inactivePixmap, int _idx ) { setFont( pointSize<8>( font() ) ); @@ -81,7 +81,7 @@ void TabWidget::addTab( QWidget * _w, const QString & _name, const char *active int w = fontMetrics().width( _name ) + 10; // Register new tab - widgetDesc d = { _w, activePixmap, inactivePixmap, _name, w } ; + widgetDesc d = { _w, activePixmap, inactivePixmap, _name, _tooltip, w } ; m_widgets[_idx] = d; // Position tab's window @@ -154,7 +154,7 @@ bool TabWidget::event(QEvent *event) if ( idx != -1 ) { // Display tab's tooltip - QToolTip::showText( helpEvent->globalPos(), m_widgets[idx].name ); + QToolTip::showText( helpEvent->globalPos(), m_widgets[idx].tooltip ); } else { // The tooltip event doesn't relate to any tab, let's ignore it @@ -174,8 +174,11 @@ bool TabWidget::event(QEvent *event) void TabWidget::mousePressEvent( QMouseEvent * _me ) { - int idx = findTabAtPos( & _me->pos() ); + // Find index of tab that has been clicked + QPoint pos = _me->pos(); + int idx = findTabAtPos( &pos ); + // When found, activate tab that has been clicked if ( idx != -1 ) { setActiveTab( idx ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 6a08d6671..d053e4910 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1434,11 +1434,11 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : m_miscView = new InstrumentMiscView( m_track, m_tabWidget ); - m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), "env_lfo_active", "env_lfo_inactive", 1 ); - m_tabWidget->addTab( instrumentFunctions, tr( "FUNC" ), "functions_active", "functions_inactive", 2 ); - m_tabWidget->addTab( m_effectView, tr( "FX" ), "fx_active", "fx_inactive", 3 ); - m_tabWidget->addTab( m_midiView, tr( "MIDI" ), "midi_active", "midi_inactive", 4 ); - m_tabWidget->addTab( m_miscView, tr( "MISC" ), "misc_active", "misc_inactive", 5 ); + m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), tr( "ENV/LFO" ), "env_lfo_active", "env_lfo_inactive", 1 ); + m_tabWidget->addTab( instrumentFunctions, tr( "FUNC" ), tr( "FUNC" ), "functions_active", "functions_inactive", 2 ); + m_tabWidget->addTab( m_effectView, tr( "FX" ), tr( "FX" ), "fx_active", "fx_inactive", 3 ); + m_tabWidget->addTab( m_midiView, tr( "MIDI" ), tr( "MIDI" ), "midi_active", "midi_inactive", 4 ); + m_tabWidget->addTab( m_miscView, tr( "MISC" ), tr( "MISC" ), "misc_active", "misc_inactive", 5 ); // setup piano-widget m_pianoView = new PianoView( this ); @@ -1611,7 +1611,7 @@ void InstrumentTrackWindow::updateInstrumentView() if( m_track->m_instrument != NULL ) { m_instrumentView = m_track->m_instrument->createView( m_tabWidget ); - m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), "plugin_active", "plugin_inactive", 0 ); + m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), tr( "PLUGIN" ), "plugin_active", "plugin_inactive", 0 ); m_tabWidget->setActiveTab( 0 ); m_ssView->setFunctionsHidden( m_track->m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) );