|
32 | 32 | #include <QStyle>
|
33 | 33 | #include <QPlastiqueStyle>
|
34 | 34 | #include <QTranslator>
|
| 35 | +#include <QImageReader> |
35 | 36 |
|
36 | 37 | #include <iostream>
|
37 | 38 | #include <cstdio>
|
@@ -501,6 +502,50 @@ int main(int argc, char *argv[])
|
501 | 502 | mypSplash->show();
|
502 | 503 | }
|
503 | 504 |
|
| 505 | + // For non static builds on mac and win (static builds are not supported) |
| 506 | + // we need to be sure we can find the qt image |
| 507 | + // plugins. In mac be sure to look in the |
| 508 | + // application bundle... |
| 509 | +#ifdef Q_WS_WIN |
| 510 | + QCoreApplication::addLibraryPath( QApplication::applicationDirPath() |
| 511 | + + QDir::separator() + "plugins" ); |
| 512 | +#endif |
| 513 | +#ifdef Q_OS_MACX |
| 514 | + //qDebug("Adding qt image plugins to plugin search path..."); |
| 515 | + CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
| 516 | + CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle); |
| 517 | + const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding()); |
| 518 | + CFRelease(myBundleRef); |
| 519 | + CFRelease(myMacPath); |
| 520 | + QString myPath(mypPathPtr); |
| 521 | + // if we are not in a bundle assume that the app is built |
| 522 | + // as a non bundle app and that image plugins will be |
| 523 | + // in system Qt frameworks. If the app is a bundle |
| 524 | + // lets try to set the qt plugin search path... |
| 525 | + QFileInfo myInfo(myPath); |
| 526 | + if (myInfo.isBundle()) |
| 527 | + { |
| 528 | + // First clear the plugin search paths so we can be sure |
| 529 | + // only plugins from the bundle are being used |
| 530 | + QStringList myPathList; |
| 531 | + QCoreApplication::setLibraryPaths(myPathList); |
| 532 | + // Now set the paths inside the bundle |
| 533 | + myPath += "/Contents/plugins"; |
| 534 | + QCoreApplication::addLibraryPath( myPath ); |
| 535 | + //next two lines should not be needed, testing only |
| 536 | + //QCoreApplication::addLibraryPath( myPath + "/imageformats" ); |
| 537 | + //QCoreApplication::addLibraryPath( myPath + "/sqldrivers" ); |
| 538 | + //foreach (myPath, a.libraryPaths()) |
| 539 | + //{ |
| 540 | + //qDebug("Path:" + myPath.toLocal8Bit()); |
| 541 | + //} |
| 542 | + //qDebug( "Added %s to plugin search path", qPrintable( myPath ) ); |
| 543 | + //QList<QByteArray> myFormats = QImageReader::supportedImageFormats(); |
| 544 | + //for ( int x = 0; x < myFormats.count(); ++x ) { |
| 545 | + // qDebug("Format: " + myFormats[x]); |
| 546 | + //} |
| 547 | + } |
| 548 | +#endif |
504 | 549 |
|
505 | 550 |
|
506 | 551 |
|
|
0 commit comments