From 6ca71a2637c46daa8c6551e2cfbbe67437eab2a3 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 14 Dec 2005 10:19:04 +0000 Subject: [PATCH] made LMMS working with Qt4 again git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@33 0778d3d1-df1d-0410-868b-ea421aaaa00d --- Makefile.am | 4 +- configure.in | 5 +- include/gui_templates.h | 3 +- include/midi_alsa_seq.h | 7 +- include/midi_tab_widget.h | 4 + include/pattern.h | 5 +- include/qt3support.h | 24 +- include/qxembed.h | 5 + include/tab_widget.h | 11 +- include/tempo_sync_knob.h | 30 +-- include/tool_button.h | 8 +- .../audio_file_processor.cpp | 5 + plugins/vestige/vestige.cpp | 2 +- plugins/vestige/vestige.h | 2 +- src/audio/audio_alsa.cpp | 4 +- src/audio/audio_oss.cpp | 4 +- src/core/arp_and_chords_tab_widget.cpp | 3 +- src/core/bb_editor.cpp | 20 +- src/core/envelope_and_lfo_widget.cpp | 5 +- src/core/file_browser.cpp | 2 +- src/core/midi_tab_widget.cpp | 211 ++++++++++++++++-- src/core/piano_roll.cpp | 33 ++- src/core/plugin.cpp | 40 +++- src/core/plugin_browser.cpp | 28 ++- src/core/setup_dialog.cpp | 2 +- src/core/song_editor.cpp | 24 +- src/core/timeline.cpp | 3 - src/core/track_container.cpp | 1 + src/lib/ladspa_manager.cpp | 60 +++-- src/lib/string_pair_drag.cpp | 27 ++- src/midi/midi_alsa_raw.cpp | 2 +- src/midi/midi_alsa_seq.cpp | 30 ++- src/midi/midi_oss.cpp | 2 +- src/tracks/pattern.cpp | 54 ++++- src/widgets/cpuload_widget.cpp | 34 ++- src/widgets/knob.cpp | 12 +- src/widgets/nstate_button.cpp | 2 +- src/widgets/project_notes.cpp | 7 + src/widgets/qxembed.cpp | 5 + src/widgets/tab_widget.cpp | 2 - src/widgets/tempo_sync_knob.cpp | 47 +++- src/widgets/tool_button.cpp | 15 +- 42 files changed, 652 insertions(+), 142 deletions(-) diff --git a/Makefile.am b/Makefile.am index a26130e7f..4d565b15f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -273,10 +273,10 @@ lmms_SOURCES = \ $(srcdir)/include/ladspa_manager.h \ $(srcdir)/include/midi_tab_widget.h \ $(srcdir)/include/audio_port.h \ - $(srcdir)/include/qxembed.h \ $(srcdir)/include/tool_button.h \ $(srcdir)/include/cpuload_widget.h \ - $(srcdir)/include/midi_alsa_seq.h + $(srcdir)/include/midi_alsa_seq.h \ + $(srcdir)/include/qxembed.h diff --git a/configure.in b/configure.in index fbdd38840..f0c95e79b 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.1-cvs20051211, tobydox/at/users.sourceforge.net) -AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051211) +AC_INIT(lmms, 0.1.1-cvs20051213, tobydox/at/users.sourceforge.net) +AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051213) AM_CONFIG_HEADER(config.h) @@ -377,7 +377,6 @@ AC_CONFIG_FILES([Makefile midi-maps/Makefile plugins/Makefile plugins/audio_file_processor/Makefile - plugins/midi_out/Makefile plugins/plucked_string_synth/Makefile plugins/triple_oscillator/Makefile plugins/vestige/Makefile diff --git a/include/gui_templates.h b/include/gui_templates.h index 144e988f8..026604f43 100644 --- a/include/gui_templates.h +++ b/include/gui_templates.h @@ -30,7 +30,6 @@ #ifdef QT4 -#include #include #include #include @@ -53,7 +52,7 @@ inline QFont pointSize( QFont _f ) static const int DPI = 96; #ifdef QT4 _f.setPointSizeF( SIZE * DPI / - QPaintDevice( QApplication::desktop() ).logicalDpiY() ); + QApplication::desktop()->logicalDpiY() ); #else _f.setPointSizeFloat( SIZE * DPI / QPaintDeviceMetrics( qApp->desktop() ).logicalDpiY() ); diff --git a/include/midi_alsa_seq.h b/include/midi_alsa_seq.h index a0bdd7db5..a7830d5b7 100644 --- a/include/midi_alsa_seq.h +++ b/include/midi_alsa_seq.h @@ -36,6 +36,8 @@ #define ALSA_SUPPORT #endif +#endif + #include #include "qt3support.h" @@ -147,7 +149,7 @@ private slots: private: virtual void run( void ); - +#ifdef ALSA_SUPPORT snd_seq_t * m_seqHandle; struct ports @@ -161,7 +163,7 @@ private: int m_queueID; volatile bool m_quit; - +#endif QTimer m_portListUpdateTimer; QStringList m_readablePorts; @@ -176,4 +178,3 @@ signals: #endif -#endif diff --git a/include/midi_tab_widget.h b/include/midi_tab_widget.h index 076643b1a..84ae0b6ee 100644 --- a/include/midi_tab_widget.h +++ b/include/midi_tab_widget.h @@ -48,6 +48,7 @@ class QMenu; class QPixmap; +class QAction; class channelTrack; class tabWidget; @@ -80,6 +81,9 @@ protected slots: void midiPortModeToggled( bool ); void readablePortsChanged( void ); void writeablePortsChanged( void ); + void activatedReadablePort( QAction * _item ); + void activatedWriteablePort( QAction * _item ); + // Qt3-version void activatedReadablePort( int _id ); void activatedWriteablePort( int _id ); diff --git a/include/pattern.h b/include/pattern.h index 2dd27eed4..6584d6fb0 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -53,9 +53,10 @@ #include "mixer.h" +class QAction; +class QPixmap; class QProgressBar; class QPushButton; -class QPixmap; class channelTrack; class patternFreezeThread; @@ -167,6 +168,8 @@ protected slots: void unfreeze( void ); void abortFreeze( void ); + void addSteps( QAction * _item ); + void removeSteps( QAction * _item ); void addSteps( int _n ); void removeSteps( int _n ); diff --git a/include/qt3support.h b/include/qt3support.h index f20ea5c5e..58b9e5220 100644 --- a/include/qt3support.h +++ b/include/qt3support.h @@ -71,6 +71,14 @@ inline QString baseName( const QString & _file ) #define QAbstractButton QButton #define QScrollArea QScrollView +#define Q3ListView QListView +#define Q3ListViewItem QListViewItem +#define Q3ScrollView QScrollView + +#define QMatrix QWMatrix +#define QIcon QIconSet + + // QWidget #define setWindowTitle setCaption #define setWindowIcon setIcon @@ -108,6 +116,7 @@ inline QString baseName( const QString & _file ) // QAbstractButton/QButton #define setCheckable setToggleButton +#define setShortcut setAccel // QInputEvent/QKeyEvent @@ -150,6 +159,10 @@ inline QString baseName( const QString & _file ) #define rootPath rootDirPath +// QFileInfo +#define absoluteFilePath absFilePath + + // QToolButton #define setMenu setPopup @@ -158,16 +171,17 @@ inline QString baseName( const QString & _file ) #define transformed xForm -#define Q3ListView QListView -#define Q3ListViewItem QListViewItem -#define Q3ScrollView QScrollView +// QGridLayout +#define setColumnStretch setColStretch +#define columnCount numCols +#define setColumnMinimumWidth setColSpacing -#define QMatrix QWMatrix -#define QIcon QIconSet +// Qt-namespace #define ShiftModifier ShiftButton #define ControlModifier ControlButton + typedef unsigned int csize; // some compat-stuff for older qt-versions... diff --git a/include/qxembed.h b/include/qxembed.h index 79259dc74..e71792f84 100644 --- a/include/qxembed.h +++ b/include/qxembed.h @@ -22,6 +22,10 @@ #ifndef QXEMBED_H #define QXEMBED_H +#include "qt3support.h" + +#ifndef QT4 + #include /*#include */ @@ -232,3 +236,4 @@ private: #endif #endif +#endif diff --git a/include/tab_widget.h b/include/tab_widget.h index a5301476d..101f6613a 100644 --- a/include/tab_widget.h +++ b/include/tab_widget.h @@ -38,16 +38,13 @@ #include #include +#endif + + #include "spc_bg_hndl_widget.h" -#endif - - -class tabWidget : public QWidget -#ifndef QT4 - , public specialBgHandlingWidget -#endif +class tabWidget : public QWidget, public specialBgHandlingWidget { Q_OBJECT public: diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index bc7fd632e..66229ce40 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -28,7 +28,7 @@ #ifdef QT4 -#include +#include #else @@ -39,23 +39,26 @@ #include "knob.h" -enum tempoSyncMode -{ - NO_SYNC, - DOUBLE_WHOLE_NOTE, - WHOLE_NOTE, - HALF_NOTE, - QUARTER_NOTE, - EIGHTH_NOTE, - SIXTEENTH_NOTE, - THIRTYSECOND_NOTE -} ; +class QAction; + - class tempoSyncKnob : public knob { Q_OBJECT public: + enum tempoSyncMode + { + NO_SYNC, + DOUBLE_WHOLE_NOTE, + WHOLE_NOTE, + HALF_NOTE, + QUARTER_NOTE, + EIGHTH_NOTE, + SIXTEENTH_NOTE, + THIRTYSECOND_NOTE + } ; + + tempoSyncKnob( int _knob_num, QWidget * _parent, const QString & _name, float _scale = 1.0f ); virtual ~tempoSyncKnob(); @@ -82,6 +85,7 @@ signals: public slots: void setTempoSync( int _note_type ); + void setTempoSync( QAction * _item ); protected: diff --git a/include/tool_button.h b/include/tool_button.h index 3c99ad6de..8eee8f537 100644 --- a/include/tool_button.h +++ b/include/tool_button.h @@ -66,7 +66,12 @@ public: { m_colorHighlighted = _color; } - +#ifndef QT4 + inline void setIcon( const QPixmap & _icon ) + { + setIconSet( _icon ); + } +#endif protected: virtual void enterEvent( QEvent * _ev ); @@ -83,3 +88,4 @@ private: } ; #endif + diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index 5865cc4dc..d9547b715 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -486,9 +486,14 @@ void audioFileProcessor::paintEvent( QPaintEvent * ) void audioFileProcessor::sampleUpdated( void ) { m_graph = QPixmap( 245, 75 ); +#ifdef QT4 + QPainter p( &m_graph ); + p.drawPixmap( 2, 172, m_graph ); +#else copyBlt( &m_graph, 0, 0, s_artwork, 2, 172, m_graph.width(), m_graph.height() ); QPainter p( &m_graph ); +#endif m_sampleBuffer.drawWaves( p, QRect( 2, 2, m_graph.width() - 4, m_graph.height() - 4 ), m_drawMethod ); diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 29ba0df84..a48084d1a 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -105,7 +105,7 @@ vestigeInstrument::vestigeInstrument( channelTrack * _channel_track ) : m_openPluginButton = new pixmapButton( this ); m_openPluginButton->setCheckable( FALSE ); - m_openPluginButton->setCursor( PointingHandCursor ); + m_openPluginButton->setCursor( Qt::PointingHandCursor ); m_openPluginButton->move( 200, 70 ); m_openPluginButton->setActiveGraphic( embed::getIconPixmap( "project_open_down" ) ); diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index 3c9222091..0574553f0 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -31,7 +31,7 @@ #ifdef QT4 -#include +#include #else diff --git a/src/audio/audio_alsa.cpp b/src/audio/audio_alsa.cpp index 641630f14..2f93d2da8 100644 --- a/src/audio/audio_alsa.cpp +++ b/src/audio/audio_alsa.cpp @@ -179,7 +179,7 @@ int audioALSA::handleError( int _err ) void audioALSA::startProcessing( void ) { - if( !running() ) + if( !isRunning() ) { start(); } @@ -190,7 +190,7 @@ void audioALSA::startProcessing( void ) void audioALSA::stopProcessing( void ) { - if( running() ) + if( isRunning() ) { m_quit = TRUE; wait( 1000 ); diff --git a/src/audio/audio_oss.cpp b/src/audio/audio_oss.cpp index 3686b8c3c..2547458be 100644 --- a/src/audio/audio_oss.cpp +++ b/src/audio/audio_oss.cpp @@ -282,7 +282,7 @@ QString audioOSS::probeDevice( void ) void audioOSS::startProcessing( void ) { - if( !running() ) + if( !isRunning() ) { start(); } @@ -293,7 +293,7 @@ void audioOSS::startProcessing( void ) void audioOSS::stopProcessing( void ) { - if( running() ) + if( isRunning() ) { m_quit = TRUE; wait( 1000 ); diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index e675a8aef..216974d08 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -667,7 +667,8 @@ void arpAndChordsTabWidget::loadSettings( const QDomElement & _this ) m_arpDirection = static_cast( _this.attribute( "arpdir" ).toInt() ); m_arpTimeKnob->setSyncMode( - ( tempoSyncMode ) _this.attribute( "arpsyncmode" ).toInt() ); + ( tempoSyncKnob::tempoSyncMode ) _this.attribute( + "arpsyncmode" ).toInt() ); m_arpGroupBox->setState( m_arpDirection != OFF && !_this.attribute( "arpdisabled" ).toInt() ); diff --git a/src/core/bb_editor.cpp b/src/core/bb_editor.cpp index 3d163edc4..860df70bf 100644 --- a/src/core/bb_editor.cpp +++ b/src/core/bb_editor.cpp @@ -68,8 +68,14 @@ bbEditor::bbEditor() : m_toolBar = new QWidget( this ); m_toolBar->setFixedHeight( 32 ); m_toolBar->move( 0, 0 ); - m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap( - "toolbar_bg" ) ); +#ifdef QT4 + QPalette pal; + pal.setBrush( m_toolBar->backgroundRole(), QBrush( + embed::getIconPixmap( "toolbar_bg" ) ) ); + m_toolBar->setPalette( pal ); +#else + m_toolBar->setErasePixmap( embed::getIconPixmap( "toolbar_bg" ) ); +#endif QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); @@ -320,24 +326,24 @@ void bbEditor::play( void ) { songEditor::inst()->stop(); songEditor::inst()->playBB(); - m_playButton->setPixmap( embed::getIconPixmap( + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { songEditor::inst()->pause(); - m_playButton->setPixmap( embed::getIconPixmap( + m_playButton->setIcon( embed::getIconPixmap( "play" ) ); } } else if( songEditor::inst()->paused() ) { songEditor::inst()->resumeFromPause(); - m_playButton->setPixmap( embed::getIconPixmap( "pause" ) ); + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { - m_playButton->setPixmap( embed::getIconPixmap( "pause" ) ); + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); songEditor::inst()->playBB(); } @@ -349,7 +355,7 @@ void bbEditor::play( void ) void bbEditor::stop( void ) { songEditor::inst()->stop(); - m_playButton->setPixmap( embed::getIconPixmap( "play" ) ); + m_playButton->setIcon( embed::getIconPixmap( "play" ) ); m_playButton->update(); } diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 577c1e850..e6316a470 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -611,8 +611,9 @@ void envelopeAndLFOWidget::loadSettings( const QDomElement & _this ) m_x100Cb->setChecked( _this.attribute( "x100" ).toInt() ); m_controlEnvAmountCb->setChecked( _this.attribute( "ctlenvamt" ).toInt() ); - m_lfoSpeedKnob->setSyncMode( ( tempoSyncMode ) _this.attribute( - "lfosyncmode" ).toInt() ); + m_lfoSpeedKnob->setSyncMode( + ( tempoSyncKnob::tempoSyncMode ) _this.attribute( + "lfosyncmode" ).toInt() ); switch( m_lfoShape ) { diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index cb9d6027a..80baea554 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -595,7 +595,7 @@ void directory::setOpen( bool _o ) if( cur_file[0] != '.' && !QFileInfo( thisDir.absolutePath() + "/" + cur_file ).isDir() && - thisDir.match( m_filter, cur_file.lower() ) + thisDir.match( m_filter, cur_file.toLower() ) /*QDir::match( FILE_FILTER, cur_file )*/ ) #else if( cur_file[0] != '.' && !QFileInfo( diff --git a/src/core/midi_tab_widget.cpp b/src/core/midi_tab_widget.cpp index 6af44b0f7..9dd805437 100644 --- a/src/core/midi_tab_widget.cpp +++ b/src/core/midi_tab_widget.cpp @@ -29,7 +29,6 @@ #ifdef QT4 #include -#include #include #include @@ -40,6 +39,9 @@ #include #include +#define setIcon setPixmap +#define setText setTextLabel + #endif @@ -118,34 +120,52 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track, if( mc->isRaw() == FALSE ) { m_readablePorts = new QMenu( m_setupTabWidget ); +#ifdef QT4 + connect( m_readablePorts, SIGNAL( triggered( QAction * ) ), + this, SLOT( activatedReadablePort( QAction * ) ) ); +#else m_readablePorts->setCheckable( TRUE ); connect( m_readablePorts, SIGNAL( activated( int ) ), this, SLOT( activatedReadablePort( int ) ) ); +#endif m_writeablePorts = new QMenu( m_setupTabWidget ); +#ifdef QT4 + connect( m_writeablePorts, SIGNAL( triggered( QAction * ) ), + this, SLOT( activatedWriteablePort( QAction * ) ) ); +#else m_writeablePorts->setCheckable( TRUE ); connect( m_writeablePorts, SIGNAL( activated( int ) ), this, SLOT( activatedWriteablePort( int ) ) ); +#endif // fill menus readablePortsChanged(); writeablePortsChanged(); QToolButton * rp_btn = new QToolButton( m_setupTabWidget ); - rp_btn->setTextLabel( tr( "MIDI-devices to receive " + rp_btn->setText( tr( "MIDI-devices to receive " "MIDI-events from" ) ); - rp_btn->setIconSet( embed::getIconPixmap( "midi_in" ) ); + rp_btn->setIcon( embed::getIconPixmap( "midi_in" ) ); rp_btn->setGeometry( 186, 34, 40, 40 ); - rp_btn->setPopup( m_readablePorts ); + rp_btn->setMenu( m_readablePorts ); +#ifdef QT4 + rp_btn->setPopupMode( QToolButton::InstantPopup ); +#else rp_btn->setPopupDelay( 1 ); +#endif QToolButton * wp_btn = new QToolButton( m_setupTabWidget ); - wp_btn->setTextLabel( tr( "MIDI-devices to send MIDI-events " + wp_btn->setText( tr( "MIDI-devices to send MIDI-events " "to" ) ); - wp_btn->setPixmap( embed::getIconPixmap( "midi_out" ) ); + wp_btn->setIcon( embed::getIconPixmap( "midi_out" ) ); wp_btn->setGeometry( 186, 94, 40, 40 ); - wp_btn->setPopup( m_writeablePorts ); + wp_btn->setMenu( m_writeablePorts ); +#ifdef QT4 + wp_btn->setPopupMode( QToolButton::InstantPopup ); +#else wp_btn->setPopupDelay( 1 ); +#endif // we want to get informed about port-changes! mc->connectRPChanged( this, SLOT( readablePortsChanged() ) ); @@ -179,6 +199,17 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent ) if( m_readablePorts != NULL && m_receiveCheckBox->isChecked() == TRUE ) { QString rp; +#ifdef QT4 + QList actions = m_readablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() ) + { + rp += ( *it )->text() + ","; + } + } +#else for( csize i = 0; i < m_readablePorts->count(); ++i ) { int id = m_readablePorts->idAt( i ); @@ -187,6 +218,7 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent ) rp += m_readablePorts->text( id ) + ","; } } +#endif // cut off comma if( rp.length() > 0 ) { @@ -198,6 +230,17 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent ) if( m_writeablePorts != NULL && m_sendCheckBox->isChecked() == TRUE ) { QString wp; +#ifdef QT4 + QList actions = m_writeablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() ) + { + wp += ( *it )->text() + ","; + } + } +#else for( csize i = 0; i < m_writeablePorts->count(); ++i ) { int id = m_writeablePorts->idAt( i ); @@ -206,6 +249,7 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent ) wp += m_writeablePorts->text( id ) + ","; } } +#endif // cut off comma if( wp.length() > 0 ) { @@ -231,10 +275,23 @@ void midiTabWidget::loadSettings( const QDomElement & _this ) // restore connections - QStringList rp = QStringList::split( ',', _this.attribute( - "inports" ) ); if( m_readablePorts != NULL && m_receiveCheckBox->isChecked() == TRUE ) { +#ifdef QT4 + QStringList rp = _this.attribute( "inports" ).split( ',' ); + QList actions = m_readablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() != + ( rp.indexOf( ( *it )->text() ) != -1 ) ) + { + activatedReadablePort( *it ); + } + } +#else + QStringList rp = QStringList::split( ',', + _this.attribute( "inports" ) ); for( csize i = 0; i < m_readablePorts->count(); ++i ) { int id = m_readablePorts->idAt( i ); @@ -245,12 +302,26 @@ void midiTabWidget::loadSettings( const QDomElement & _this ) activatedReadablePort( id ); } } +#endif } - QStringList wp = QStringList::split( ',', _this.attribute( - "outports" ) ); if( m_writeablePorts != NULL && m_sendCheckBox->isChecked() == TRUE ) { +#ifdef QT4 + QStringList wp = _this.attribute( "outports" ).split( ',' ); + QList actions = m_writeablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() != + ( wp.indexOf( ( *it )->text() ) != -1 ) ) + { + activatedWriteablePort( *it ); + } + } +#else + QStringList wp = QStringList::split( ',', + _this.attribute( "outports" ) ); for( csize i = 0; i < m_writeablePorts->count(); ++i ) { int id = m_writeablePorts->idAt( i ); @@ -261,6 +332,7 @@ void midiTabWidget::loadSettings( const QDomElement & _this ) activatedWriteablePort( id ); } } +#endif } } @@ -299,25 +371,49 @@ void midiTabWidget::midiPortModeToggled( bool ) // check whether we have to dis-check items in connection-menu if( m_readablePorts != NULL && m_receiveCheckBox->isChecked() == FALSE ) { +#ifdef QT4 + QList actions = m_readablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() == TRUE ) + { + activatedReadablePort( *it ); + } + } +#else for( csize i = 0; i < m_readablePorts->count(); ++i ) { int id = m_readablePorts->idAt( i ); - if( m_readablePorts->isItemChecked( id ) ) + if( m_readablePorts->isItemChecked( id ) == TRUE ) { activatedReadablePort( id ); } } +#endif } if( m_writeablePorts != NULL && m_sendCheckBox->isChecked() == FALSE ) { +#ifdef QT4 + QList actions = m_writeablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() == TRUE ) + { + activatedWriteablePort( *it ); + } + } +#else for( csize i = 0; i < m_writeablePorts->count(); ++i ) { int id = m_writeablePorts->idAt( i ); - if( m_writeablePorts->isItemChecked( id ) ) + if( m_writeablePorts->isItemChecked( id ) == TRUE ) { activatedWriteablePort( id ); } } +#endif } songEditor::inst()->setModified(); } @@ -329,14 +425,26 @@ void midiTabWidget::readablePortsChanged( void ) { // first save all selected ports QStringList selected_ports; +#ifdef QT4 + QList actions = m_readablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() == TRUE ) + { + selected_ports.push_back( ( *it )->text() ); + } + } +#else for( csize i = 0; i < m_readablePorts->count(); ++i ) { int id = m_readablePorts->idAt( i ); - if( m_readablePorts->isItemChecked( id ) ) + if( m_readablePorts->isItemChecked( id ) == TRUE ) { selected_ports.push_back( m_readablePorts->text( id ) ); } } +#endif m_readablePorts->clear(); const QStringList & rp = mixer::inst()->getMIDIClient()-> @@ -344,11 +452,19 @@ void midiTabWidget::readablePortsChanged( void ) // now insert new ports and restore selections for( QStringList::const_iterator it = rp.begin(); it != rp.end(); ++it ) { +#ifdef QT4 + QAction * item = m_readablePorts->addAction( *it ); + if( selected_ports.indexOf( *it ) != -1 ) + { + item->setChecked( TRUE ); + } +#else int id = m_readablePorts->insertItem( *it ); if( selected_ports.find( *it ) != selected_ports.end() ) { m_readablePorts->setItemChecked( id, TRUE ); } +#endif } } @@ -359,15 +475,27 @@ void midiTabWidget::writeablePortsChanged( void ) { // first save all selected ports QStringList selected_ports; +#ifdef QT4 + QList actions = m_writeablePorts->actions(); + for( QList::iterator it = actions.begin(); + it != actions.end(); ++it ) + { + if( ( *it )->isChecked() == TRUE ) + { + selected_ports.push_back( ( *it )->text() ); + } + } +#else for( csize i = 0; i < m_writeablePorts->count(); ++i ) { int id = m_writeablePorts->idAt( i ); - if( m_writeablePorts->isItemChecked( id ) ) + if( m_writeablePorts->isItemChecked( id ) == TRUE ) { selected_ports.push_back( m_writeablePorts->text( id ) ); } } +#endif m_writeablePorts->clear(); const QStringList & wp = mixer::inst()->getMIDIClient()-> @@ -375,17 +503,64 @@ void midiTabWidget::writeablePortsChanged( void ) // now insert new ports and restore selections for( QStringList::const_iterator it = wp.begin(); it != wp.end(); ++it ) { +#ifdef QT4 + QAction * item = m_writeablePorts->addAction( *it ); + if( selected_ports.indexOf( *it ) != -1 ) + { + item->setChecked( TRUE ); + } +#else int id = m_writeablePorts->insertItem( *it ); if( selected_ports.find( *it ) != selected_ports.end() ) { m_writeablePorts->setItemChecked( id, TRUE ); } +#endif } } +#ifdef QT4 +void midiTabWidget::activatedReadablePort( QAction * _item ) +{ + // make sure, MIDI-port is configured for input + if( _item->isChecked() == FALSE && + m_midiPort->mode() != midiPort::INPUT && + m_midiPort->mode() != midiPort::DUPLEX ) + { + m_receiveCheckBox->setChecked( TRUE ); + } + _item->setChecked( !_item->isChecked() ); + mixer::inst()->getMIDIClient()->subscribeReadablePort( m_midiPort, + _item->text(), !_item->isChecked() ); +} + + + + +void midiTabWidget::activatedWriteablePort( QAction * _item ) +{ + // make sure, MIDI-port is configured for output + if( _item->isChecked() == FALSE && + m_midiPort->mode() != midiPort::OUTPUT && + m_midiPort->mode() != midiPort::DUPLEX ) + { + m_sendCheckBox->setChecked( TRUE ); + } + _item->setChecked( !_item->isChecked() ); + mixer::inst()->getMIDIClient()->subscribeWriteablePort( m_midiPort, + _item->text(), !_item->isChecked() ); +} + + +void midiTabWidget::activatedReadablePort( int ) { } +void midiTabWidget::activatedWriteablePort( int ) { } + +#else + + void midiTabWidget::activatedReadablePort( int _id ) { // make sure, MIDI-port is configured for input @@ -422,5 +597,11 @@ void midiTabWidget::activatedWriteablePort( int _id ) } +void midiTabWidget::activatedReadablePort( QAction * ) { } +void midiTabWidget::activatedWriteablePort( QAction * ) { } + +#endif + + #include "midi_tab_widget.moc" diff --git a/src/core/piano_roll.cpp b/src/core/piano_roll.cpp index 2b8be0164..f0d98d44d 100644 --- a/src/core/piano_roll.cpp +++ b/src/core/piano_roll.cpp @@ -204,8 +204,15 @@ pianoRoll::pianoRoll( void ) : m_toolBar = new QWidget( this ); m_toolBar->setFixedHeight( 32 ); m_toolBar->move( 0, 0 ); +#ifdef QT4 + QPalette pal; + pal.setBrush( m_toolBar->backgroundRole(), QBrush( + embed::getIconPixmap( "toolbar_bg" ) ) ); + m_toolBar->setPalette( pal ); +#else m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap( "toolbar_bg" ) ); +#endif QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); @@ -387,11 +394,16 @@ pianoRoll::pianoRoll( void ) : m_zoomingComboBox->setGeometry( 580, 4, 80, 24 ); for( int i = 0; i < 6; ++i ) { - m_zoomingComboBox->insertItem( QString::number( 25 * + m_zoomingComboBox->addItem( QString::number( 25 * static_cast( powf( 2.0f, i ) ) ) + "%" ); } +#ifdef QT4 + m_zoomingComboBox->setCurrentIndex( m_zoomingComboBox->findText( + "100%" ) ); +#else m_zoomingComboBox->setCurrentText( "100%" ); +#endif connect( m_zoomingComboBox, SIGNAL( activated( const QString & ) ), this, SLOT( zoomingChanged( const QString & ) ) ); @@ -1928,10 +1940,18 @@ void pianoRoll::wheelEvent( QWheelEvent * _we ) { m_ppt /= 2; } +#ifdef QT4 + // update combobox with zooming-factor + m_zoomingComboBox->setCurrentIndex( + m_zoomingComboBox->findText( QString::number( + static_cast( m_ppt * 100 / + DEFAULT_PR_PPT ) ) +"%" ) ); +#else // update combobox with zooming-factor m_zoomingComboBox->setCurrentText( QString::number( static_cast( m_ppt * 100 / DEFAULT_PR_PPT ) ) +"%" ); +#endif // update timeline m_timeLine->setPixelsPerTact( m_ppt ); update(); @@ -1964,24 +1984,23 @@ void pianoRoll::play( void ) { songEditor::inst()->stop(); songEditor::inst()->playPattern( m_pattern ); - m_playButton->setPixmap( embed::getIconPixmap( + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { songEditor::inst()->pause(); - m_playButton->setPixmap( embed::getIconPixmap( - "play" ) ); + m_playButton->setIcon( embed::getIconPixmap( "play" ) ); } } else if( songEditor::inst()->paused() ) { songEditor::inst()->resumeFromPause(); - m_playButton->setPixmap( embed::getIconPixmap( "pause" ) ); + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { - m_playButton->setPixmap( embed::getIconPixmap( "pause" ) ); + m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); songEditor::inst()->playPattern( m_pattern ); } } @@ -2010,7 +2029,7 @@ void pianoRoll::record( void ) void pianoRoll::stop( void ) { songEditor::inst()->stop(); - m_playButton->setPixmap( embed::getIconPixmap( "play" ) ); + m_playButton->setIcon( embed::getIconPixmap( "play" ) ); m_playButton->update(); m_recording = FALSE; m_scrollBack = TRUE; diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 45d65de57..4bc6fec44 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -133,15 +133,33 @@ plugin * plugin::instantiate( const QString & _plugin_name, void * _data ) void plugin::getDescriptorsOfAvailPlugins( vvector & _plugin_descs ) { QDir directory( configManager::inst()->pluginDir() ); - const QFileInfoList * list = directory.entryInfoList( "lib*.so" ); - if( list == NULL ) +#ifdef QT4 + QFileInfoList list = directory.entryInfoList( QStringList( + "lib*.so" ) ); +#else + const QFileInfoList * lp = directory.entryInfoList( "lib*.so" ); + // if directory doesn't exist or isn't readable, we get NULL which would + // crash LMMS... + if( lp == NULL ) { return; } - for( QFileInfoList::iterator file = list->begin(); - file != list->end(); ++file ) + QFileInfoList list = *lp; +#endif + for( QFileInfoList::iterator file = list.begin(); + file != list.end(); ++file ) { - void * handle = dlopen( ( *file )->absFilePath().latin1(), +#ifdef QT4 + const QFileInfo & f = *file; +#else + const QFileInfo & f = **file; +#endif + void * handle = dlopen( f.absoluteFilePath(). +#ifdef QT4 + toAscii().constData(), +#else + ascii(), +#endif RTLD_NOW ); char * msg = dlerror(); if( msg != NULL || handle == NULL ) @@ -156,10 +174,16 @@ void plugin::getDescriptorsOfAvailPlugins( vvector & _plugin_descs ) printf( "plugin-loader: %s\n", msg ); continue; } - QString desc_name = ( *file )->fileName().mid( 3 ).section( - '.', 0, 0 ) + "_plugin_descriptor"; + QString desc_name = f.fileName().mid( 3 ).section( '.', 0, 0 ) + + "_plugin_descriptor"; descriptor * plugin_desc = - (descriptor *) dlsym( handle, desc_name.ascii() ); + (descriptor *) dlsym( handle, desc_name. +#ifdef QT4 + toAscii().constData() +#else + ascii() +#endif + ); msg = dlerror(); if( msg != NULL || plugin_desc == NULL ) { diff --git a/src/core/plugin_browser.cpp b/src/core/plugin_browser.cpp index a28f9aa1f..eeac17e6a 100644 --- a/src/core/plugin_browser.cpp +++ b/src/core/plugin_browser.cpp @@ -29,14 +29,13 @@ #include #include -/*#include */ #include +#include #else #include #include -/*#include */ #include #endif @@ -60,7 +59,9 @@ pluginBrowser::pluginBrowser( QWidget * _parent ) : addContentWidget( m_view ); - QVBoxLayout * view_layout = new QVBoxLayout( m_view, 5, 10 ); + QVBoxLayout * view_layout = new QVBoxLayout( m_view ); + view_layout->setMargin( 5 ); + view_layout->setSpacing( 10 ); QLabel * hint = new QLabel( tr( "You can drag an instrument-plugin " @@ -70,7 +71,11 @@ pluginBrowser::pluginBrowser( QWidget * _parent ) : "corresponding channel-button." ), m_view ); hint->setFont( pointSize<8>( hint->font() ) ); - hint->setAlignment( hint->alignment() | WordBreak ); +#ifdef QT4 + hint->setWordWrap( TRUE ); +#else + hint->setAlignment( hint->alignment() | Qt::WordBreak ); +#endif view_layout->addWidget( hint ); plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors ); @@ -113,7 +118,7 @@ pluginDescWidget::pluginDescWidget( const plugin::descriptor & _pd, #ifndef QT4 setBackgroundMode( Qt::NoBackground ); #endif - setCursor( PointingHandCursor ); + setCursor( Qt::PointingHandCursor ); } @@ -156,19 +161,32 @@ void pluginDescWidget::paintEvent( QPaintEvent * ) f.setBold( FALSE ); p.setFont( pointSize<7>( f ) ); +#ifdef QT4 + QStringList words = pluginBrowser::tr( + m_pluginDescriptor.description ).split( ' ' ); +#else QStringList words = QStringList::split( ' ', pluginBrowser::tr( m_pluginDescriptor.description ) ); +#endif for( QStringList::iterator it = words.begin(); it != words.end(); ++it ) { if( ( *it ).contains( '-' ) ) { +#ifdef QT4 + QStringList splitted_word = it->split( '-' ); +#else QStringList splitted_word = QStringList::split( '-', *it ); +#endif QStringList::iterator orig_it = it; for( QStringList::iterator it2 = splitted_word.begin(); it2 != splitted_word.end(); ++it2 ) { +#ifdef QT4 + if( it2 == --splitted_word.end() ) +#else if( it2 == splitted_word.fromLast() ) +#endif { words.insert( it, *it2 ); } diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index 1fd166188..0e03680de 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -361,7 +361,7 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : midi_layout->addStretch(); -#ifndef QT +#ifndef QT4 #define setIcon setPixmap #endif diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 6b6a8e8fc..2a24aaf5e 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -185,7 +185,7 @@ songEditor::songEditor() : toolButton * hq_btn = new toolButton( embed::getIconPixmap( "hq_mode" ), tr( "High quality mode" ), NULL, NULL, tb ); - hq_btn->setToggleButton( TRUE ); + hq_btn->setCheckable( TRUE ); connect( hq_btn, SIGNAL( toggled( bool ) ), mixer::inst(), SLOT( setHighQuality( bool ) ) ); hq_btn->setFixedWidth( 42 ); @@ -276,8 +276,15 @@ songEditor::songEditor() : m_toolBar = new QWidget( cw ); m_toolBar->setFixedHeight( 32 ); m_toolBar->move( 0, 0 ); +#ifdef QT4 + QPalette pal; + pal.setBrush( m_toolBar->backgroundRole(), QBrush( + embed::getIconPixmap( "toolbar_bg" ) ) ); + m_toolBar->setPalette( pal ); +#else m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap( "toolbar_bg" ) ); +#endif QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); @@ -355,11 +362,16 @@ songEditor::songEditor() : m_zoomingComboBox->setGeometry( 580, 4, 80, 24 ); for( int i = 0; i < 7; ++i ) { - m_zoomingComboBox->insertItem( QString::number( 25 * + m_zoomingComboBox->addItem( QString::number( 25 * static_cast( powf( 2.0f, i ) ) ) + "%" ); } +#ifdef QT4 + m_zoomingComboBox->setCurrentIndex( m_zoomingComboBox->findText( + "100%" ) ); +#else m_zoomingComboBox->setCurrentText( "100%" ); +#endif connect( m_zoomingComboBox, SIGNAL( activated( const QString & ) ), this, SLOT( zoomingChanged( const QString & ) ) ); @@ -568,10 +580,18 @@ void songEditor::wheelEvent( QWheelEvent * _we ) { setPixelsPerTact( (int) pixelsPerTact() / 2 ); } +#ifdef QT4 + // update combobox with zooming-factor + m_zoomingComboBox->setCurrentIndex( + m_zoomingComboBox->findText( QString::number( + static_cast( pixelsPerTact() * + 100 / DEFAULT_PIXELS_PER_TACT ) ) +"%" ) ); +#else // update combobox with zooming-factor m_zoomingComboBox->setCurrentText( QString::number( static_cast( pixelsPerTact() * 100 / DEFAULT_PIXELS_PER_TACT ) ) +"%" ); +#endif // update timeline m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact( pixelsPerTact() ); diff --git a/src/core/timeline.cpp b/src/core/timeline.cpp index ce3e089fb..e6c471247 100644 --- a/src/core/timeline.cpp +++ b/src/core/timeline.cpp @@ -131,7 +131,6 @@ timeLine::~timeLine() void timeLine::addToolButtons( QWidget * _tool_bar ) { nStateButton * m_autoScroll = new nStateButton( _tool_bar ); - m_autoScroll->setPaletteBackgroundColor( QColor( 224, 224, 224 ) ); m_autoScroll->setGeneralToolTip( tr( "Enable/disable " "auto-scrolling" ) ); m_autoScroll->addState( embed::getIconPixmap( "autoscroll_on" ) ); @@ -140,7 +139,6 @@ void timeLine::addToolButtons( QWidget * _tool_bar ) SLOT( toggleAutoScroll( int ) ) ); nStateButton * m_loopPoints = new nStateButton( _tool_bar ); - m_loopPoints->setPaletteBackgroundColor( QColor( 224, 224, 224 ) ); m_loopPoints->setGeneralToolTip( tr( "Enable/disable loop-points" ) ); m_loopPoints->addState( embed::getIconPixmap( "loop_points_off" ) ); m_loopPoints->addState( embed::getIconPixmap( "loop_points_on" ) ); @@ -148,7 +146,6 @@ void timeLine::addToolButtons( QWidget * _tool_bar ) SLOT( toggleLoopPoints( int ) ) ); nStateButton * m_behaviourAtStop = new nStateButton( _tool_bar ); - m_behaviourAtStop->setPaletteBackgroundColor( QColor( 224, 224, 224 ) ); m_behaviourAtStop ->addState( embed::getIconPixmap( "back_to_zero" ), tr( "After stopping go back to begin" ) ); diff --git a/src/core/track_container.cpp b/src/core/track_container.cpp index 9f778bd94..c01315733 100644 --- a/src/core/track_container.cpp +++ b/src/core/track_container.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #else diff --git a/src/lib/ladspa_manager.cpp b/src/lib/ladspa_manager.cpp index 21d8543ff..6c1662683 100644 --- a/src/lib/ladspa_manager.cpp +++ b/src/lib/ladspa_manager.cpp @@ -39,6 +39,8 @@ #include #include +#define value data + #endif @@ -59,10 +61,15 @@ ladspaManager::ladspaManager( void ) LADSPA_Descriptor_Function descriptorFunction; void * pluginHandle; - // TODO Need to move the search path definition to the config file to have - // more control over where it tries to find the plugins. + // TODO Need to move the search path definition to the config file to + // have more control over where it tries to find the plugins. +#ifdef QT4 + QStringList ladspaDirectories = QString( getenv( "LADSPA_PATH" ) ). + split( ' ' ); +#else QStringList ladspaDirectories = QStringList::split( ':', QString( getenv( "LADSPA_PATH" ) ) ); +#endif // set default-directory if nothing is specified... if( ladspaDirectories.isEmpty() ) { @@ -73,18 +80,33 @@ ladspaManager::ladspaManager( void ) it != ladspaDirectories.end(); ++it ) { QDir directory( ( *it ) ); - const QFileInfoList * list = directory.entryInfoList(); - // if directory doesn't exist or isn't readable, we get NULL which - // would crash LMMS... - if( list == NULL ) +#ifdef QT4 + QFileInfoList list = directory.entryInfoList(); +#else + const QFileInfoList * lp = directory.entryInfoList(); + // if directory doesn't exist or isn't readable, we get NULL + // which would crash LMMS... + if( lp == NULL ) { continue; } - for( QFileInfoList::iterator file = list->begin(); - file != list->end(); ++file ) + QFileInfoList list = *lp; +#endif + for( QFileInfoList::iterator file = list.begin(); + file != list.end(); ++file ) { - pluginHandle = dlopen( ( *file )->absFilePath().latin1(), - RTLD_LAZY ); +#ifdef QT4 + const QFileInfo & f = *file; +#else + const QFileInfo & f = **file; +#endif + pluginHandle = dlopen( f.absoluteFilePath(). +#ifdef QT4 + toAscii().constData(), +#else + ascii(), +#endif + RTLD_LAZY ); if( pluginHandle ) { dlerror(); @@ -95,14 +117,19 @@ ladspaManager::ladspaManager( void ) if( dlerror() == NULL && descriptorFunction ) { addPlugins( pluginHandle, - descriptorFunction, - ( *file )->fileName() ); + descriptorFunction, + f.fileName() ); } else { dlclose( ( void * ) - ( *file )->absFilePath().latin1() - ); + f.absoluteFilePath(). +#ifdef QT4 + toAscii().constData() +#else + ascii() +#endif + ); } } } @@ -117,7 +144,7 @@ ladspaManager::~ladspaManager() for( ladspaManagerMapType::Iterator it = m_ladspaManagerMap.begin(); it != m_ladspaManagerMap.end(); ++it ) { - dlclose( it.data()->pluginHandle ); + dlclose( it.value()->pluginHandle ); } m_ladspaManagerMap.clear(); } @@ -855,5 +882,8 @@ void FASTCALL ladspaManager::cleanup( const ladspaKey & _plugin, } +#undef value + + #endif diff --git a/src/lib/string_pair_drag.cpp b/src/lib/string_pair_drag.cpp index 63a231f91..94b9ee685 100644 --- a/src/lib/string_pair_drag.cpp +++ b/src/lib/string_pair_drag.cpp @@ -26,6 +26,13 @@ #include "string_pair_drag.h" +#ifdef QT4 + +#include +#include +#include + +#endif stringPairDrag::stringPairDrag( const QString & _key, const QString & _value, @@ -68,21 +75,17 @@ void stringPairDrag::processDragEnterEvent( QDragEnterEvent * _dee, { return; } - QString txt = _dee->mimeData()->data(); -#else - QString txt = _dee->encodedData( "lmms/stringpair" ); -#endif - bool accepted = QStringList::split( ',', _allowed_keys ).contains( - txt.section( ':', 0, 0 ) ); -#ifdef QT4 - if( accepted ) + QString txt = _dee->mimeData()->data( "lmms/stringpair" ); + if( _allowed_keys.split( ',' ).contains( txt.section( ':', 0, 0 ) ) ) { _dee->acceptProposedAction(); } #else + QString txt = _dee->encodedData( "lmms/stringpair" ); + bool accepted = QStringList::split( ',', _allowed_keys ).contains( + txt.section( ':', 0, 0 ) ); _dee->accept( accepted ); #endif - } @@ -91,7 +94,8 @@ void stringPairDrag::processDragEnterEvent( QDragEnterEvent * _dee, QString stringPairDrag::decodeKey( QDropEvent * _de ) { #ifdef QT4 - return( QString( _de->mimeData()->data() ).section( ':', 0, 0 ) ); + return( QString( _de->mimeData()->data( "lmms/stringpair" + ) ).section( ':', 0, 0 ) ); #else return( QString( _de->encodedData( "lmms/stringpair" ) ).section( ':', 0, 0 ) ); @@ -104,7 +108,8 @@ QString stringPairDrag::decodeKey( QDropEvent * _de ) QString stringPairDrag::decodeValue( QDropEvent * _de ) { #ifdef QT4 - return( QString( _de->mimeData()->data() ).section( ':', 1, 1 ) ); + return( QString( _de->mimeData()->data( "lmms/stringpair" + ) ).section( ':', 1, 1 ) ); #else return( QString( _de->encodedData( "lmms/stringpair" ) ).section( ':', 1, 1 ) ); diff --git a/src/midi/midi_alsa_raw.cpp b/src/midi/midi_alsa_raw.cpp index 0831f61e5..b29691b1c 100644 --- a/src/midi/midi_alsa_raw.cpp +++ b/src/midi/midi_alsa_raw.cpp @@ -86,7 +86,7 @@ midiALSARaw::midiALSARaw( void ) : midiALSARaw::~midiALSARaw() { - if( running() ) + if( isRunning() ) { m_quit = TRUE; wait( 1000 ); diff --git a/src/midi/midi_alsa_seq.cpp b/src/midi/midi_alsa_seq.cpp index 6aa489144..c0a942e78 100644 --- a/src/midi/midi_alsa_seq.cpp +++ b/src/midi/midi_alsa_seq.cpp @@ -111,7 +111,7 @@ midiALSASeq::midiALSASeq( void ) : midiALSASeq::~midiALSASeq() { - if( running() ) + if( isRunning() ) { m_quit = TRUE; wait( 1000 ); @@ -251,7 +251,11 @@ void midiALSASeq::applyPortMode( midiPort * _port ) m_portIDs[_port][i] = snd_seq_create_simple_port( m_seqHandle, +#ifdef QT4 + _port->name().toAscii().constData(), +#else _port->name().ascii(), +#endif caps[i], SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION ); @@ -300,7 +304,13 @@ void midiALSASeq::applyPortName( midiPort * _port ) snd_seq_get_port_info( m_seqHandle, m_portIDs[_port][i], port_info ); snd_seq_port_info_set_name( port_info, - _port->name().ascii() ); + _port->name(). +#ifdef QT4 + toAscii().constData() +#else + ascii() +#endif + ); snd_seq_set_port_info( m_seqHandle, m_portIDs[_port][i], port_info ); snd_seq_port_info_free( port_info ); @@ -342,7 +352,13 @@ void midiALSASeq::subscribeReadablePort( midiPort * _port, } snd_seq_addr_t sender; if( snd_seq_parse_address( m_seqHandle, &sender, - _dest.section( ' ', 0, 0 ).ascii() ) ) + _dest.section( ' ', 0, 0 ). +#ifdef QT4 + toAscii().constData() +#else + ascii() +#endif + ) ) { printf( "error parsing sender-address!!\n" ); return; @@ -381,7 +397,13 @@ void midiALSASeq::subscribeWriteablePort( midiPort * _port, } snd_seq_addr_t dest; if( snd_seq_parse_address( m_seqHandle, &dest, - _dest.section( ' ', 0, 0 ).ascii() ) ) + _dest.section( ' ', 0, 0 ). +#ifdef QT4 + toAscii().constData() +#else + ascii() +#endif + ) ) { printf( "error parsing dest-address!!\n" ); return; diff --git a/src/midi/midi_oss.cpp b/src/midi/midi_oss.cpp index 9bff255c4..5dffeba0f 100644 --- a/src/midi/midi_oss.cpp +++ b/src/midi/midi_oss.cpp @@ -81,7 +81,7 @@ midiOSS::midiOSS( void ) : midiOSS::~midiOSS() { - if( running() ) + if( isRunning() ) { m_quit = TRUE; wait( 1000 ); diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 53736b118..80f7b8abc 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -231,27 +231,44 @@ void pattern::constructContextMenu( QMenu * _cm ) _cm->addSeparator(); +#ifdef QT4 + QMenu * add_step_menu = _cm->addMenu( + embed::getIconPixmap( "step_btn_add" ), + tr( "Add steps" ) ); + QMenu * remove_step_menu = _cm->addMenu( + embed::getIconPixmap( "step_btn_remove" ), + tr( "Remove steps" ) ); + connect( add_step_menu, SIGNAL( triggered( QAction * ) ), + this, SLOT( addSteps( QAction * ) ) ); + connect( remove_step_menu, SIGNAL( triggered( QAction * ) ), + this, SLOT( removeSteps( QAction * ) ) ); +#else QMenu * add_step_menu = new QMenu( this ); QMenu * remove_step_menu = new QMenu( this ); +#endif for( int i = 1; i <= 16; i *= 2 ) { const QString label = ( i == 1 ) ? tr( "1 step" ) : tr( "%1 steps" ).arg( i ); - +#ifdef QT4 + add_step_menu->addAction( label ); + remove_step_menu->addAction( label ); +#else int menu_id = add_step_menu->addAction( label, this, SLOT( addSteps( int ) ) ); add_step_menu->setItemParameter( menu_id, i ); menu_id = remove_step_menu->addAction( label, this, SLOT( removeSteps( int ) ) ); remove_step_menu->setItemParameter( menu_id, i ); +#endif } - +#ifndef QT4 _cm->addMenu( embed::getIconPixmap( "step_btn_add" ), tr( "Add steps" ), add_step_menu ); _cm->addMenu( embed::getIconPixmap( "step_btn_remove" ), tr( "Remove steps" ), remove_step_menu ); - +#endif } @@ -638,6 +655,32 @@ void pattern::abortFreeze( void ) +#ifdef QT4 + +void pattern::addSteps( QAction * _item ) +{ + addSteps( _item->text().toInt() ); +} + + + + +void pattern::removeSteps( QAction * _item ) +{ + removeSteps( _item->text().toInt() ); +} + + + +#else + +void pattern::addSteps( QAction * ) { } +void pattern::removeSteps( QAction * ) { } + +#endif + + + void pattern::addSteps( int _n ) { m_steps += _n; @@ -978,8 +1021,11 @@ patternFreezeStatusDialog::patternFreezeStatusDialog( QThread * _thread ) : this, SLOT( updateProgress() ) ); update_timer->start( 100 ); +#ifdef QT4 + setAttribute( Qt::WA_DeleteOnClose, TRUE ); +#else setWFlags( getWFlags() | Qt::WDestructiveClose ); - +#endif connect( this, SIGNAL( aborted() ), this, SLOT( reject() ) ); } diff --git a/src/widgets/cpuload_widget.cpp b/src/widgets/cpuload_widget.cpp index 31c63ebe2..d832290c2 100644 --- a/src/widgets/cpuload_widget.cpp +++ b/src/widgets/cpuload_widget.cpp @@ -24,6 +24,19 @@ */ +#include "qt3support.h" + +#ifdef QT4 + +#include + +#else + +#include + +#endif + + #include "cpuload_widget.h" #include "embed.h" #include "mixer.h" @@ -40,7 +53,7 @@ cpuloadWidget::cpuloadWidget( QWidget * _parent ) : { setFixedSize( m_background.width(), m_background.height() ); - m_temp.resize( width(), height() ); + m_temp = QPixmap( width(), height() ); connect( &m_updateTimer, SIGNAL( timeout() ), this, SLOT( updateCpuLoad() ) ); @@ -63,7 +76,7 @@ cpuloadWidget::~cpuloadWidget() void cpuloadWidget::paintEvent( QPaintEvent * ) { - if( m_changed == TRUE ) +/* if( m_changed == TRUE ) { m_changed = FALSE; @@ -76,7 +89,22 @@ void cpuloadWidget::paintEvent( QPaintEvent * ) ( m_leds.width() * m_currentLoad / 300 ) * 3, m_leds.height(), CopyROP ); } - bitBlt( this, 0, 0, &m_temp, 0, 0, width(), height(), CopyROP ); + bitBlt( this, 0, 0, &m_temp, 0, 0, width(), height(), CopyROP );*/ + if( m_changed == TRUE ) + { + m_changed = FALSE; + + QPainter p( &m_temp ); + // background + p.drawPixmap( 0, 0, m_background ); + + // leds + p.drawPixmap( 23, 3, m_leds, 0, 0, + ( m_leds.width() * m_currentLoad / 300 ) * 3, + m_leds.height() ); + } + QPainter p( this ); + p.drawPixmap( 0, 0, m_temp ); } diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index afadca7ee..68523bb30 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -754,12 +754,20 @@ void knob::pasteValue( void ) void knob::enterValue( void ) { bool ok; - float new_val = QInputDialog::getDouble( accessibleName(), + float new_val = QInputDialog::getDouble( +#ifdef QT4 + this, +#endif + accessibleName(), tr( "Please enter a new value between " "%1 and %2:" ).arg( minValue() ).arg( maxValue() ), value(), minValue(), maxValue(), - 4, &ok, this ); + 4, &ok +#ifndef QT4 + , this +#endif + ); if( ok ) { setValue( new_val ); diff --git a/src/widgets/nstate_button.cpp b/src/widgets/nstate_button.cpp index 6ddd662c3..371c04a58 100644 --- a/src/widgets/nstate_button.cpp +++ b/src/widgets/nstate_button.cpp @@ -88,7 +88,7 @@ void nStateButton::changeState( int _n ) m_generalToolTip; toolTip::add( this, _tooltip ); - setPixmap( *m_states[m_curState].first ); + setIcon( *m_states[m_curState].first ); emit changedState( m_curState ); diff --git a/src/widgets/project_notes.cpp b/src/widgets/project_notes.cpp index f23a60655..e3e69aac2 100644 --- a/src/widgets/project_notes.cpp +++ b/src/widgets/project_notes.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #else @@ -115,9 +116,15 @@ projectNotes::projectNotes() : void projectNotes::clear( void ) { m_edit->setHtml( tr( "Put down your project notes here." ) ); +#ifdef QT4 + m_edit->selectAll(); + m_edit->setTextColor( QColor( 224, 224, 224 ) ); + m_edit->setTextCursor( QTextCursor() ); +#else m_edit->selectAll( TRUE ); m_edit->setTextColor( QColor( 224, 224, 224 ) ); m_edit->selectAll( FALSE ); +#endif } diff --git a/src/widgets/qxembed.cpp b/src/widgets/qxembed.cpp index 542ac50ea..0fd885aa7 100644 --- a/src/widgets/qxembed.cpp +++ b/src/widgets/qxembed.cpp @@ -45,6 +45,10 @@ // // +#include "qt3support.h" + +#ifndef QT4 + #include #include @@ -1356,4 +1360,5 @@ void QXEmbed::reparent( QWidget * parent, WFlags f, const QPoint & p, bool showI // for KDE #include "qxembed.moc" +#endif #endif // Q_WS_X11 diff --git a/src/widgets/tab_widget.cpp b/src/widgets/tab_widget.cpp index d25625c56..ed90166b0 100644 --- a/src/widgets/tab_widget.cpp +++ b/src/widgets/tab_widget.cpp @@ -47,9 +47,7 @@ tabWidget::tabWidget( const QString & _caption, QWidget * _parent ) : QWidget( _parent ), -#ifndef QT4 specialBgHandlingWidget( QColor( 96, 96, 96 ) ), -#endif m_activeTab( 0 ), m_caption( _caption ) { diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index 2bc7fad9a..7609f74e6 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -109,7 +109,35 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) m_hintTextAfterValue ), this, SLOT( pasteValue() ) ); contextMenu.addSeparator(); - +#ifdef QT4 + QMenu * syncMenu = contextMenu.addMenu( m_tempoSyncIcon, + m_tempoSyncDescription ); + connect( syncMenu, SIGNAL( triggered( QAction * ) ), + this, SLOT( setTempoSync( QAction * ) ) ); + syncMenu->addAction( embed::getIconPixmap( "note_none" ), + tr( "No Sync" ) )->setData( (int) NO_SYNC ); + syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), + tr( "Eight beats" ) )->setData( + (int) DOUBLE_WHOLE_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_whole" ), + tr( "Whole note" ) )->setData( + (int) WHOLE_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_half" ), + tr( "Half note" ) )->setData( + (int) HALF_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), + tr( "Quarter note" ) )->setData( + (int) QUARTER_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), + tr( "8th note" ) )->setData( + (int) EIGHTH_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), + tr( "16th note" ) )->setData( + (int) SIXTEENTH_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), + tr( "32nd note" ) )->setData( + (int) THIRTYSECOND_NOTE ); +#else QMenu * syncMenu = new QMenu( this ); int menuId; menuId = syncMenu->addAction( embed::getIconPixmap( "note_none" ), @@ -149,6 +177,8 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription, syncMenu ); +#endif + contextMenu.addSeparator(); contextMenu.addAction( tr( "Connect to MIDI-device" ), this, @@ -183,6 +213,19 @@ void tempoSyncKnob::wheelEvent( QWheelEvent * _we ) +#ifdef QT4 + +void tempoSyncKnob::setTempoSync( QAction * _item ) +{ + setTempoSync( _item->data().toInt() ); +} + +#else + +void tempoSyncKnob::setTempoSync( QAction * ) { } + +#endif + void tempoSyncKnob::setTempoSync( int _note_type ) { @@ -278,7 +321,7 @@ void tempoSyncKnob::calculateTempoSyncTime( int _bpm ) -tempoSyncMode tempoSyncKnob::getSyncMode( void ) +tempoSyncKnob::tempoSyncMode tempoSyncKnob::getSyncMode( void ) { return( m_tempoSyncMode ); } diff --git a/src/widgets/tool_button.cpp b/src/widgets/tool_button.cpp index 1691dad0d..fa34dab78 100644 --- a/src/widgets/tool_button.cpp +++ b/src/widgets/tool_button.cpp @@ -46,7 +46,7 @@ toolButton::toolButton( const QPixmap & _pixmap, const QString & _tooltip, } toolTip::add( this, _tooltip ); setFixedSize( 30, 30 ); - setPixmap( _pixmap ); + setIcon( _pixmap ); leaveEvent( NULL ); } @@ -59,9 +59,16 @@ toolButton::~toolButton() + void toolButton::enterEvent( QEvent * ) { +#ifdef QT4 + QPalette pal; + pal.setColor( backgroundRole(), m_colorHighlighted ); + setPalette( pal ); +#else setPaletteBackgroundColor( m_colorHighlighted ); +#endif } @@ -69,6 +76,12 @@ void toolButton::enterEvent( QEvent * ) void toolButton::leaveEvent( QEvent * ) { +#ifdef QT4 + QPalette pal; + pal.setColor( backgroundRole(), m_colorStandard ); + setPalette( pal ); +#else setPaletteBackgroundColor( m_colorStandard ); +#endif }