UniversalIndentGUI 1.2.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2006-2012 by Thomas Schweitzer * 00003 * thomas-schweitzer(at)arcor.de * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License version 2.0 as * 00007 * published by the Free Software Foundation. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License * 00015 * along with this program in the file LICENSE.GPL; if not, write to the * 00016 * Free Software Foundation, Inc., * 00017 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00018 ***************************************************************************/ 00019 00020 #include "UiGuiSettings.h" 00021 00022 #include "SettingsPaths.h" 00023 00024 #include <QSettings> 00025 #include <QPoint> 00026 #include <QSize> 00027 #include <QDir> 00028 #include <QDate> 00029 #include <QStringList> 00030 #include <QCoreApplication> 00031 #include <QMetaMethod> 00032 #include <QMetaProperty> 00033 #include <QWidget> 00034 00036 00044 // Inits the single class instance pointer. 00045 QWeakPointer<UiGuiSettings> UiGuiSettings::_instance; 00046 00047 00051 UiGuiSettings::UiGuiSettings() : QObject() { 00052 // Create the main application settings object from the UniversalIndentGUI.ini file. 00053 _qsettings = new QSettings(SettingsPaths::getSettingsPath() + "/UniversalIndentGUI.ini", QSettings::IniFormat, this); 00054 00055 _indenterDirctoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters"; 00056 readAvailableTranslations(); 00057 initSettings(); 00058 } 00059 00060 00064 QSharedPointer<UiGuiSettings> UiGuiSettings::getInstance() { 00065 QSharedPointer<UiGuiSettings> sharedInstance = _instance.toStrongRef(); 00066 if ( sharedInstance.isNull() ) { 00067 // Create the settings object, which loads all UiGui settings from a file. 00068 sharedInstance = QSharedPointer<UiGuiSettings>(new UiGuiSettings()); 00069 _instance = sharedInstance.toWeakRef(); 00070 } 00071 00072 return sharedInstance; 00073 } 00074 00075 00079 UiGuiSettings::~UiGuiSettings() { 00080 // Convert the language setting from an integer index to a string. 00081 int index = _qsettings->value("UniversalIndentGUI/language", 0).toInt(); 00082 if ( index < 0 || index >= _availableTranslations.size() ) 00083 index = 0; 00084 00085 _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.at(index) ); 00086 } 00087 00088 00093 void UiGuiSettings::readAvailableTranslations() { 00094 QString languageShort; 00095 QStringList languageFileList; 00096 00097 // English is the default language. A translation file does not exist but to have a menu entry, added here. 00098 languageFileList << "universalindent_en.qm"; 00099 00100 // Find all translation files in the "translations" directory. 00101 QDir translationDirectory = QDir( SettingsPaths::getGlobalFilesPath() + "/translations" ); 00102 languageFileList << translationDirectory.entryList( QStringList("universalindent_*.qm") ); 00103 00104 // Loop for each found translation file 00105 foreach ( languageShort, languageFileList ) { 00106 // Remove the leading string "universalindent_" from the filename. 00107 languageShort.remove(0,16); 00108 // Remove trailing file extension ".qm". 00109 languageShort.chop(3); 00110 00111 _availableTranslations.append(languageShort); 00112 } 00113 } 00114 00115 00119 QStringList UiGuiSettings::getAvailableTranslations() { 00120 return _availableTranslations; 00121 } 00122 00123 00129 QVariant UiGuiSettings::getValueByName(QString settingName) { 00130 return _qsettings->value("UniversalIndentGUI/" + settingName); 00131 } 00132 00133 00139 bool UiGuiSettings::initSettings() 00140 { 00141 // Read the version string saved in the settings file. 00142 _qsettings->setValue( "UniversalIndentGUI/version", _qsettings->value("UniversalIndentGUI/version", "") ); 00143 00144 // Read windows last size and position from the settings file. 00145 _qsettings->setValue( "UniversalIndentGUI/maximized", _qsettings->value("UniversalIndentGUI/maximized", false) ); 00146 _qsettings->setValue( "UniversalIndentGUI/position", _qsettings->value("UniversalIndentGUI/position", QPoint(50, 50)) ); 00147 _qsettings->setValue( "UniversalIndentGUI/size", _qsettings->value("UniversalIndentGUI/size", QSize(800, 600)) ); 00148 00149 // Read last selected encoding for the opened source code file. 00150 _qsettings->setValue( "UniversalIndentGUI/encoding", _qsettings->value("UniversalIndentGUI/encoding", "UTF-8") ); 00151 00152 // Read maximum length of list for recently opened files. 00153 _qsettings->setValue( "UniversalIndentGUI/recentlyOpenedListSize", _qsettings->value("UniversalIndentGUI/recentlyOpenedListSize", 5) ); 00154 00155 // Read if last opened source code file should be loaded on startup. 00156 _qsettings->setValue( "UniversalIndentGUI/loadLastSourceCodeFileOnStartup", _qsettings->value("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", true) ); 00157 00158 // Read last opened source code file from the settings file. 00159 _qsettings->setValue( "UniversalIndentGUI/lastSourceCodeFile", _qsettings->value("UniversalIndentGUI/lastSourceCodeFile", _indenterDirctoryStr+"/example.cpp") ); 00160 00161 // Read last selected indenter from the settings file. 00162 int selectedIndenter = _qsettings->value("UniversalIndentGUI/selectedIndenter", 0).toInt(); 00163 if ( selectedIndenter < 0 ) { 00164 selectedIndenter = 0; 00165 } 00166 _qsettings->setValue( "UniversalIndentGUI/selectedIndenter", selectedIndenter ); 00167 00168 // Read if syntax highlighting is enabled. 00169 _qsettings->setValue( "UniversalIndentGUI/SyntaxHighlightingEnabled", _qsettings->value("UniversalIndentGUI/SyntaxHighlightingEnabled", true) ); 00170 00171 // Read if white space characters should be displayed. 00172 _qsettings->setValue( "UniversalIndentGUI/whiteSpaceIsVisible", _qsettings->value("UniversalIndentGUI/whiteSpaceIsVisible", false) ); 00173 00174 // Read if indenter parameter tool tips are enabled. 00175 _qsettings->setValue( "UniversalIndentGUI/indenterParameterTooltipsEnabled", _qsettings->value("UniversalIndentGUI/indenterParameterTooltipsEnabled", true) ); 00176 00177 // Read the tab width from the settings file. 00178 _qsettings->setValue( "UniversalIndentGUI/tabWidth", _qsettings->value("UniversalIndentGUI/tabWidth", 4) ); 00179 00180 // Read the last selected language and stores the index it has in the list of available translations. 00181 _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.indexOf( _qsettings->value("UniversalIndentGUI/language", "").toString() ) ); 00182 00183 // Read the update check settings from the settings file. 00184 _qsettings->setValue( "UniversalIndentGUI/CheckForUpdate", _qsettings->value("UniversalIndentGUI/CheckForUpdate", true) ); 00185 _qsettings->setValue( "UniversalIndentGUI/LastUpdateCheck", _qsettings->value("UniversalIndentGUI/LastUpdateCheck", QDate(1900,1,1)) ); 00186 00187 // Read the main window state. 00188 _qsettings->setValue( "UniversalIndentGUI/MainWindowState", _qsettings->value("UniversalIndentGUI/MainWindowState", QByteArray()) ); 00189 00190 return true; 00191 } 00192 00193 00200 bool UiGuiSettings::registerObjectProperty( QObject *obj, const QString &propertyName, const QString &settingName ) 00201 { 00202 const QMetaObject *metaObject = obj->metaObject(); 00203 bool connectSuccess = false; 00204 00205 // Connect to the objects destroyed signal, so that it will be correctly unregistered. 00206 connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); 00207 00208 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00209 if ( connectSuccess && indexOfProp > -1 ) { 00210 QMetaProperty mProp = metaObject->property(indexOfProp); 00211 00212 // Connect to the property's value changed signal. 00213 if ( mProp.hasNotifySignal() ) { 00214 QMetaMethod signal = mProp.notifySignal(); 00215 //QString teststr = qPrintable(SIGNAL() + QString(signal.signature())); 00216 // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL. 00217 connectSuccess = connect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange())); 00218 } 00219 00220 if ( connectSuccess ) { 00221 _registeredObjectProperties[obj] = QStringList() << propertyName << settingName; 00222 } 00223 else { 00224 //TODO: Write a debug warning to the log. 00225 disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); 00226 return false; 00227 } 00228 00229 // If setting already exists, set the objects property to the setting value. 00230 if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) { 00231 mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); 00232 } 00233 // Otherwise add the setting and set it to the value of the objects property. 00234 else { 00235 _qsettings->setValue("UniversalIndentGUI/" + settingName, mProp.read(obj)); 00236 } 00237 } 00238 else { 00239 //TODO: Write a debug warning to the log. 00240 disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); 00241 return false; 00242 } 00243 00244 return true; 00245 } 00246 00247 00260 bool UiGuiSettings::registerObjectPropertyRecursive(QObject *obj) { 00261 return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::registerObjectProperty); 00262 } 00263 00264 00271 bool UiGuiSettings::setObjectPropertyToSettingValue( QObject *obj, const QString &propertyName, const QString &settingName ) 00272 { 00273 const QMetaObject *metaObject = obj->metaObject(); 00274 00275 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00276 if ( indexOfProp > -1 ) { 00277 QMetaProperty mProp = metaObject->property(indexOfProp); 00278 00279 // If setting already exists, set the objects property to the setting value. 00280 if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) { 00281 mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); 00282 } 00283 // The setting didn't exist so return that setting the objects property failed. 00284 else { 00285 //TODO: Write a debug warning to the log. 00286 return false; 00287 } 00288 } 00289 else { 00290 //TODO: Write a debug warning to the log. 00291 return false; 00292 } 00293 00294 return true; 00295 } 00296 00297 00309 bool UiGuiSettings::setObjectPropertyToSettingValueRecursive(QObject *obj) { 00310 return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setObjectPropertyToSettingValue); 00311 } 00312 00313 00322 bool UiGuiSettings::setSettingToObjectPropertyValue( QObject *obj, const QString &propertyName, const QString &settingName ) 00323 { 00324 const QMetaObject *metaObject = obj->metaObject(); 00325 00326 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00327 if ( indexOfProp > -1 ) { 00328 QMetaProperty mProp = metaObject->property(indexOfProp); 00329 00330 setValueByName(settingName, mProp.read(obj)); 00331 } 00332 else { 00333 //TODO: Write a debug warning to the log. 00334 return false; 00335 } 00336 00337 return true; 00338 } 00339 00340 00353 bool UiGuiSettings::setSettingToObjectPropertyValueRecursive(QObject *obj) { 00354 return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setSettingToObjectPropertyValue); 00355 } 00356 00357 00363 bool UiGuiSettings::checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName)) { 00364 bool success = true; 00365 00366 // Find all widgets that have PropertyName and SettingName defined in their style sheet. 00367 QList<QObject *> allObjects = obj->findChildren<QObject *>(); 00368 foreach (QObject *object, allObjects) { 00369 QString propertyName = object->property("connectedPropertyName").toString(); 00370 QString settingName = object->property("connectedSettingName").toString(); 00371 00372 // If property and setting name were found, register that widget with the settings. 00373 if ( !propertyName.isEmpty() && !settingName.isEmpty() ) { 00374 success &= (this->*callBackFunc)( object, propertyName, settingName ); 00375 } 00376 } 00377 00378 return success; 00379 } 00380 00381 00385 void UiGuiSettings::unregisterObjectProperty(QObject *obj) { 00386 if ( _registeredObjectProperties.contains(obj) ) { 00387 const QMetaObject *metaObject = obj->metaObject(); 00388 QString propertyName = _registeredObjectProperties[obj].first(); 00389 QString settingName = _registeredObjectProperties[obj].last(); 00390 00391 bool connectSuccess = false; 00392 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00393 if ( indexOfProp > -1 ) { 00394 QMetaProperty mProp = metaObject->property(indexOfProp); 00395 00396 // Disconnect to the property's value changed signal. 00397 if ( mProp.hasNotifySignal() ) { 00398 QMetaMethod signal = mProp.notifySignal(); 00399 // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL. 00400 connectSuccess = disconnect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange())); 00401 } 00402 } 00403 _registeredObjectProperties.remove(obj); 00404 } 00405 } 00406 00407 00416 bool UiGuiSettings::registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) { 00417 00418 const QMetaObject *metaObject = obj->metaObject(); 00419 00420 bool connectSuccess = false; 00421 // Connect to the objects destroyed signal, so that it will be correctly unregistered. 00422 connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); 00423 00424 QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) ); 00425 int indexOfMethod = metaObject->indexOfMethod( qPrintable(normalizedSlotName) ); 00426 if ( connectSuccess && indexOfMethod > -1 ) { 00427 QMetaMethod mMethod = metaObject->method(indexOfMethod); 00428 //QMetaMethod::Access access = mMethod.access(); 00429 //QMetaMethod::MethodType methType = mMethod.methodType(); 00430 00431 // Since the method can at maximum be invoked with the setting value as argument, 00432 // only methods taking max one argument are allowed. 00433 if ( mMethod.parameterTypes().size() <= 1 ) { 00434 _registeredObjectSlots.insert(obj, QStringList() << normalizedSlotName << settingName); 00435 } 00436 else { 00437 //TODO: Write a debug warning to the log. 00438 disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); 00439 return false; 00440 } 00441 } 00442 else { 00443 //TODO: Write a debug warning to the log. 00444 disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); 00445 return false; 00446 } 00447 00448 return true; 00449 } 00450 00451 00456 void UiGuiSettings::unregisterObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) { 00457 //const QMetaObject *metaObject = obj->metaObject(); 00458 QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) ); 00459 QMutableMapIterator<QObject*, QStringList> it(_registeredObjectSlots); 00460 while (it.hasNext()) { 00461 it.next(); 00462 if (it.key() == obj && slotName.isEmpty() && settingName.isEmpty()) 00463 it.remove(); 00464 else if (it.key() == obj && it.value().first() == slotName && it.value().last() == settingName) 00465 it.remove(); 00466 } 00467 } 00468 00469 00474 void UiGuiSettings::handleObjectPropertyChange() { 00475 QObject *obj = QObject::sender(); 00476 QString className = obj->metaObject()->className(); 00477 const QMetaObject *metaObject = obj->metaObject(); 00478 QString propertyName = _registeredObjectProperties[obj].first(); 00479 QString settingName = _registeredObjectProperties[obj].last(); 00480 00481 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00482 if ( indexOfProp > -1 ) { 00483 QMetaProperty mProp = metaObject->property(indexOfProp); 00484 setValueByName(settingName, mProp.read(obj)); 00485 } 00486 } 00487 00488 00496 void UiGuiSettings::setValueByName(const QString &settingName, const QVariant &value) { 00497 // Do the updating only, if the setting was really changed. 00498 if ( _qsettings->value("UniversalIndentGUI/" + settingName) != value ) { 00499 _qsettings->setValue("UniversalIndentGUI/" + settingName, value); 00500 00501 // Set the new value for all registered object properties for settingName. 00502 for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectProperties.begin(); it != _registeredObjectProperties.end(); ++it ) { 00503 if ( it.value().last() == settingName ) { 00504 QObject *obj = it.key(); 00505 const QMetaObject *metaObject = obj->metaObject(); 00506 QString propertyName = it.value().first(); 00507 00508 int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); 00509 if ( indexOfProp > -1 ) { 00510 QMetaProperty mProp = metaObject->property(indexOfProp); 00511 mProp.write(obj, value); 00512 } 00513 } 00514 } 00515 00516 // Invoke all registered object methods for settingName. 00517 for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectSlots.begin(); it != _registeredObjectSlots.end(); ++it ) { 00518 if ( it.value().last() == settingName ) { 00519 QObject *obj = it.key(); 00520 const QMetaObject *metaObject = obj->metaObject(); 00521 QString slotName = it.value().first(); 00522 00523 int indexOfMethod = metaObject->indexOfMethod( qPrintable(slotName) ); 00524 if ( indexOfMethod > -1 ) { 00525 QMetaMethod mMethod = metaObject->method(indexOfMethod); 00526 //QMetaMethod::Access access = mMethod.access(); 00527 //QMetaMethod::MethodType methType = mMethod.methodType(); 00528 00529 bool success = false; 00530 00531 // Handle registered slots taking one parameter. 00532 if ( mMethod.parameterTypes().size() == 1 ) { 00533 if ( mMethod.parameterTypes().first() == value.typeName() ) { 00534 success = invokeMethodWithValue(obj, mMethod, value); 00535 } 00536 } 00537 // Handle registered slots taking zero parameters. 00538 else { 00539 success = mMethod.invoke( obj, Qt::DirectConnection ); 00540 } 00541 00542 if ( success == false ) { 00543 // TODO: Write a warning to the log if no success. 00544 } 00545 } 00546 } 00547 } 00548 } 00549 } 00550 00551 00552 #include <QBitArray> 00553 #include <QBitmap> 00554 #include <QBrush> 00555 #include <QCursor> 00556 #include <QDateTime> 00557 #include <QFont> 00558 #include <QIcon> 00559 #include <QKeySequence> 00560 #include <QLocale> 00561 #include <QPalette> 00562 #include <QPen> 00563 #include <QSizePolicy> 00564 #include <QTextFormat> 00565 #include <QTextLength> 00566 #include <QUrl> 00567 #if QT_VERSION >= 0x040600 00568 #include <QMatrix4x4> 00569 #include <QVector2D> 00570 #endif 00571 00572 bool UiGuiSettings::invokeMethodWithValue( QObject *obj, QMetaMethod mMethod, QVariant value ) 00573 { 00574 switch (value.type()) { 00575 case QVariant::BitArray : 00576 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitArray, value.toBitArray()) ); 00577 case QVariant::Bitmap : 00578 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitmap, value.value<QBitmap>()) ); 00579 case QVariant::Bool : 00580 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(bool, value.toBool()) ); 00581 case QVariant::Brush : 00582 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBrush, value.value<QBrush>()) ); 00583 case QVariant::ByteArray : 00584 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QByteArray, value.toByteArray()) ); 00585 case QVariant::Char : 00586 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QChar, value.toChar()) ); 00587 case QVariant::Color : 00588 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QColor, value.value<QColor>()) ); 00589 case QVariant::Cursor : 00590 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QCursor, value.value<QCursor>()) ); 00591 case QVariant::Date : 00592 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDate, value.toDate()) ); 00593 case QVariant::DateTime : 00594 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDateTime, value.toDateTime()) ); 00595 case QVariant::Double : 00596 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(double, value.toDouble()) ); 00597 case QVariant::Font : 00598 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QFont, value.value<QFont>()) ); 00599 case QVariant::Hash : 00600 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantHash, value.toHash()) ); 00601 case QVariant::Icon : 00602 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QIcon, value.value<QIcon>()) ); 00603 case QVariant::Image : 00604 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QImage, value.value<QImage>()) ); 00605 case QVariant::Int : 00606 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(int, value.toInt()) ); 00607 case QVariant::KeySequence : 00608 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QKeySequence, value.value<QKeySequence>()) ); 00609 case QVariant::Line : 00610 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLine, value.toLine()) ); 00611 case QVariant::LineF : 00612 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLineF, value.toLineF()) ); 00613 case QVariant::List : 00614 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantList, value.toList()) ); 00615 case QVariant::Locale : 00616 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLocale, value.toLocale()) ); 00617 case QVariant::LongLong : 00618 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qlonglong, value.toLongLong()) ); 00619 case QVariant::Map : 00620 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantMap, value.toMap()) ); 00621 case QVariant::Matrix : 00622 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix, value.value<QMatrix>()) ); 00623 case QVariant::Transform : 00624 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTransform, value.value<QTransform>()) ); 00625 #if QT_VERSION >= 0x040600 00626 case QVariant::Matrix4x4 : 00627 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix4x4, value.value<QMatrix4x4>()) ); 00628 #endif 00629 case QVariant::Palette : 00630 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPalette, value.value<QPalette>()) ); 00631 case QVariant::Pen : 00632 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPen, value.value<QPen>()) ); 00633 case QVariant::Pixmap : 00634 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPixmap, value.value<QPixmap>()) ); 00635 case QVariant::Point : 00636 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPoint, value.toPoint()) ); 00637 // case QVariant::PointArray : 00638 // return Q_ARG(QPointArray, value.value<QPointArray>()) ); 00639 case QVariant::PointF : 00640 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPointF, value.toPointF()) ); 00641 case QVariant::Polygon : 00642 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPolygon, value.value<QPolygon>()) ); 00643 #if QT_VERSION >= 0x040600 00644 case QVariant::Quaternion : 00645 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QQuaternion, value.value<QQuaternion>()) ); 00646 #endif 00647 case QVariant::Rect : 00648 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRect, value.toRect()) ); 00649 case QVariant::RectF : 00650 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRectF, value.toRectF()) ); 00651 case QVariant::RegExp : 00652 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegExp, value.toRegExp()) ); 00653 case QVariant::Region : 00654 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegion, value.value<QRegion>()) ); 00655 case QVariant::Size : 00656 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSize, value.toSize()) ); 00657 case QVariant::SizeF : 00658 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizeF, value.toSizeF()) ); 00659 case QVariant::SizePolicy : 00660 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizePolicy, value.value<QSizePolicy>()) ); 00661 case QVariant::String : 00662 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QString, value.toString()) ); 00663 case QVariant::StringList : 00664 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QStringList, value.toStringList()) ); 00665 case QVariant::TextFormat : 00666 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextFormat, value.value<QTextFormat>()) ); 00667 case QVariant::TextLength : 00668 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextLength, value.value<QTextLength>()) ); 00669 case QVariant::Time : 00670 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTime, value.toTime()) ); 00671 case QVariant::UInt : 00672 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(uint, value.toUInt()) ); 00673 case QVariant::ULongLong : 00674 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qulonglong, value.toULongLong()) ); 00675 case QVariant::Url : 00676 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QUrl, value.toUrl()) ); 00677 #if QT_VERSION >= 0x040600 00678 case QVariant::Vector2D : 00679 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector2D, value.value<QVector2D>()) ); 00680 case QVariant::Vector3D : 00681 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector3D, value.value<QVector3D>()) ); 00682 case QVariant::Vector4D : 00683 return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector4D, value.value<QVector4D>()) ); 00684 #endif 00685 default: 00686 return false; 00687 } 00688 }