Changeset 880
- Timestamp:
- 07/06/07 09:29:15 (2 years ago)
- Location:
- trunk/jahwidgets/src/qt3/wrapper
- Files:
-
- 2 modified
-
application.cpp (modified) (3 diffs)
-
property_adapter.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jahwidgets/src/qt3/wrapper/application.cpp
r859 r880 22 22 #include <functional> 23 23 24 // local 25 #include "utils/thread_util.hpp" 26 24 27 namespace jahwidgets { namespace qt3 { 25 28 … … 52 55 }; 53 56 54 // We subclass QApplication only to workaround a bug on windows with key events. 55 // It appears that in-corporating playback into the app's event loop is causing some timing issues with Qt keyboard event handling (note that the problems could also be due to SDL interferring with the event, but this doesn't appear to be the case). The symptons are thus: 56 // * When a clip is not playing most key event text is correct, although occasionaly a lowercase char becomes uppercase 57 // * When playing back most chars are transposed to upper case. 58 // Only the key event's text is incorrect; the key code and modifier appear to always be ok. 57 // We subclass QApplication only to workaround a bug on windows with 58 // key events. It appears that in-corporating playback into the app's 59 // event loop is causing some timing issues with Qt keyboard event 60 // handling (note that the problems could also be due to SDL 61 // interferring with the event, but this doesn't appear to be the 62 // case). The symptons are thus: 63 // * When a clip is not playing most key event text is correct, 64 // although occasionaly a lowercase char becomes uppercase 65 // * When playing back most chars are transposed to upper case. Only 66 // the key event's text is incorrect; the key code and modifier appear 67 // to always be ok. 59 68 class Application : public QApplication 60 69 { … … 111 120 static Application app( dummy_argc, dummy_argv ); 112 121 el.app_ = this; 122 123 initialize_gui_thread(); 113 124 114 125 #if defined( Q_OS_MACX ) && !defined(DEBUG) -
trunk/jahwidgets/src/qt3/wrapper/property_adapter.hpp
r843 r880 15 15 #include "utils/string_utils.hpp" 16 16 #include "utils/image_utils.hpp" 17 #include "utils/thread_util.hpp" 17 18 18 19 // boost … … 67 68 m_slotMemFn( const_cast< NAME##_adapter* >( this ), &internal_adapter::onWidgetChanged ) \ 68 69 { \ 69 owner->installEventFilter( this );\70 \70 owner->installEventFilter( this ); \ 71 \ 71 72 if ( isQtPropertyWritable() ) \ 72 73 { \ 73 m_observer = boost::shared_ptr< pcos::observer >( new MemFnObserver< NAME##_adapter >\74 m_observer = boost::shared_ptr< pcos::observer >( new MemFnObserver< NAME##_adapter > \ 74 75 ( const_cast< NAME##_adapter* >( this ), \ 75 76 &NAME##_adapter::onPropertyChanged ) ); \ 76 77 m_pcosProperty.attach( m_observer ); \ 77 78 } \ 78 \79 QString signature = QString( "%1%2" ).arg( qtprop ).arg( "_changed()" ); \80 if ( !doesSignalExist( signature ) ) { \81 signature = signalSignatureForProp( qtprop ); \82 } \83 \79 \ 80 QString signature = QString( "%1%2" ).arg( qtprop ).arg( "_changed()" ); \ 81 if ( !doesSignalExist( signature ) ) { \ 82 signature = signalSignatureForProp( qtprop ); \ 83 } \ 84 \ 84 85 QString signal = QString( "%1%2" ).arg( QSIGNAL_CODE ).arg( signature ); \ 85 86 if ( doesSignalExist( signature ) ) \ 86 87 { \ 87 if ( !signature.endsWith( "_changed()" ) ) \88 qDebug( "connecting Qt signal %s -> %s", signature.latin1(), qtprop ); \89 \90 m_slotMemFn.connect( m_notifier, signal, SLOT( notify() ) ); \91 } \88 if ( !signature.endsWith( "_changed()" ) ) \ 89 qDebug( "connecting Qt signal %s -> %s", signature.latin1(), qtprop ); \ 90 \ 91 m_slotMemFn.connect( m_notifier, signal, SLOT( notify() ) ); \ 92 } \ 92 93 } \ 93 94 \ … … 98 99 m_pcosProperty.unblock( m_observer ); \ 99 100 } \ 100 \101 protected: \102 bool eventFilter( QObject*, QEvent* e )\103 {\104 if ( (int)e->type() == WH_PROPERTY ) \105 { \106 PropertyEvent* pe = static_cast< PropertyEvent* >( e ); \107 m_owner->setProperty( pe->name_, pe->value_ ); \108 return true; \109 } \110 \111 return false; \112 } \113 \101 \ 102 protected: \ 103 bool eventFilter( QObject*, QEvent* e ) \ 104 { \ 105 if ( (int)e->type() == WH_PROPERTY ) \ 106 { \ 107 PropertyEvent* pe = static_cast< PropertyEvent* >( e ); \ 108 m_owner->setProperty( pe->name_, pe->value_ ); \ 109 return true; \ 110 } \ 111 \ 112 return false; \ 113 } \ 114 \ 114 115 private: \ 115 116 void onPropertyChanged() \ 116 { \ 117 QApplication::postEvent( m_owner, \ 118 new PropertyEvent( m_qtPropertyName, \ 119 CONVERT_FROM( m_pcosProperty.value< TYPE >() ) ) ); \ 120 } \ 117 { \ 118 if ( !is_gui_thread() ) \ 119 QApplication::postEvent( m_owner, \ 120 new PropertyEvent( m_qtPropertyName, \ 121 CONVERT_FROM( m_pcosProperty.value< TYPE >() ) ) ); \ 122 else \ 123 m_owner->setProperty( m_qtPropertyName, CONVERT_FROM( m_pcosProperty.value< TYPE >() ) ); \ 124 } \ 121 125 \ 122 126 boost::shared_ptr< pcos::observer > m_observer; \ … … 124 128 }; 125 129 126 #define DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( name, variantAccessor ) DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( name, name, variantAccessor )127 128 /// \note if any new types are required to be mapped from pcos to python, this129 /// section must be updated accordingly130 131 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( int, toInt )132 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( double, toDouble )133 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( bool, toBool )134 135 #undef CONVERT_TO136 #undef CONVERT_FROM137 #define CONVERT_TO( a ) QStringToWString::convert( a )138 #define CONVERT_FROM( a ) WStringToQString::convert( a )139 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( string, pl::wstring, toString )140 141 #undef CONVERT_TO142 #undef CONVERT_FROM143 #define CONVERT_TO( a ) QStringListToWStringList::convert( a )144 #define CONVERT_FROM( a ) WStringListToQStringList::convert( a )145 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( stringlist, pl::wstring_list, toStringList )146 130 147 131 static pcos::int_list QValueListIntToPcosIntList( const QValueList<QVariant>& value_list ) … … 169 153 } 170 154 155 static il::image_type_ptr qpixmap_to_image_type_ptr( const QPixmap& p ) 156 { 157 return qimage_to_image( p.convertToImage() ); 158 } 159 160 static QPixmap image_type_ptr_to_qpixmap( il::image_type_ptr im ) 161 { 162 QPixmap result; 163 result.convertFromImage( image_to_qimage( im ) ); 164 return result; 165 } 166 167 #define DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( name, variantAccessor ) DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( name, name, variantAccessor ) 168 169 /// \note if any new types are required to be mapped from pcos to python, this 170 /// section must be updated accordingly 171 172 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( int, toInt ) 173 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( double, toDouble ) 174 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION( bool, toBool ) 175 176 #undef CONVERT_TO 177 #undef CONVERT_FROM 178 #define CONVERT_TO( a ) QStringToWString::convert( a ) 179 #define CONVERT_FROM( a ) WStringToQString::convert( a ) 180 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( string, pl::wstring, toString ) 181 182 #undef CONVERT_TO 183 #undef CONVERT_FROM 184 #define CONVERT_TO( a ) QStringListToWStringList::convert( a ) 185 #define CONVERT_FROM( a ) WStringListToQStringList::convert( a ) 186 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( stringlist, pl::wstring_list, toStringList ) 187 171 188 #undef CONVERT_TO 172 189 #undef CONVERT_FROM … … 175 192 DEFINE_INTERNAL_ADAPTER_SPECIALIZATION2( intlist, pcos::int_list, toList ) 176 193 177 static il::image_type_ptr qpixmap_to_image_type_ptr( const QPixmap& p )178 {179 return qimage_to_image( p.convertToImage() );180 }181 182 static QPixmap image_type_ptr_to_qpixmap( il::image_type_ptr im )183 {184 QPixmap result;185 result.convertFromImage( image_to_qimage( im ) );186 return result;187 }188 189 194 #undef CONVERT_TO 190 195 #undef CONVERT_FROM
