diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-27 12:35:36 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-27 12:35:36 (GMT) |
commit | 8b0e86ee25265a14669b4a4eedbfd7d7caa7b00f (patch) | |
tree | 5c9beeb4c5ab4256aec8efa19ed10a3b4fbedf1a | |
parent | a9c13698cc5f3e8fbbfe79c8ad3aff13b2ed5960 (diff) | |
parent | 80c5ea1a99e0c7794245e53175c949597315c96f (diff) | |
download | Qt-8b0e86ee25265a14669b4a4eedbfd7d7caa7b00f.zip Qt-8b0e86ee25265a14669b4a4eedbfd7d7caa7b00f.tar.gz Qt-8b0e86ee25265a14669b4a4eedbfd7d7caa7b00f.tar.bz2 |
Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qt-fire-team
* 'master' of git://scm.dev.nokia.troll.no/qt/qt-fire-team:
Document support for Linguist on Mac.
-rw-r--r-- | tools/linguist/linguist/Info_mac.plist | 60 | ||||
-rw-r--r-- | tools/linguist/linguist/main.cpp | 58 |
2 files changed, 118 insertions, 0 deletions
diff --git a/tools/linguist/linguist/Info_mac.plist b/tools/linguist/linguist/Info_mac.plist index b11f493..b37a43b 100644 --- a/tools/linguist/linguist/Info_mac.plist +++ b/tools/linguist/linguist/Info_mac.plist @@ -14,5 +14,65 @@ <string>????</string> <key>CFBundleExecutable</key> <string>Linguist</string> + + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>CFBundleTypeIconFile</key> + <string>linguist.icns</string> + <key>CFBundleTypeExtensions</key> + <array> + <string>qph</string> + </array> + <key>CFBundleTypeName</key> + <string>Qt Linguist 'Phrase Book'</string> + <key>LSHandlerRank</key> + <string>Default</string> + </dict> + <dict> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>CFBundleTypeIconFile</key> + <string>linguist.icns</string> + <key>CFBundleTypeExtensions</key> + <array> + <string>ts</string> + </array> + <key>CFBundleTypeName</key> + <string>Qt Translation Source</string> + <key>LSHandlerRank</key> + <string>Default</string> + </dict> + <dict> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>CFBundleTypeIconFile</key> + <string>linguist.icns</string> + <key>CFBundleTypeExtensions</key> + <array> + <string>po</string> + </array> + <key>CFBundleTypeName</key> + <string>GNU Gettext Localization File</string> + <key>LSHandlerRank</key> + <string>Default</string> + </dict> + <dict> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>CFBundleTypeIconFile</key> + <string>linguist.icns</string> + <key>CFBundleTypeExtensions</key> + <array> + <string>xlf</string> + </array> + <key>CFBundleTypeName</key> + <string>XLIFF Localization File</string> + <key>LSHandlerRank</key> + <string>Default</string> + </dict> + </array> </dict> </plist> diff --git a/tools/linguist/linguist/main.cpp b/tools/linguist/linguist/main.cpp index a137f36..ba45613 100644 --- a/tools/linguist/linguist/main.cpp +++ b/tools/linguist/linguist/main.cpp @@ -54,8 +54,54 @@ #include <QtGui/QPixmap> #include <QtGui/QSplashScreen> +#ifdef Q_WS_MAC +#include <QtCore/QUrl> +#include <QtGui/QFileOpenEvent> +#endif // Q_WS_MAC + QT_USE_NAMESPACE +#ifdef Q_WS_MAC +class ApplicationEventFilter : public QObject +{ + Q_OBJECT + +public: + ApplicationEventFilter() + : m_mainWindow(0) + { + } + + void setMainWindow(MainWindow *mw) + { + m_mainWindow = mw; + if (!m_filesToOpen.isEmpty() && m_mainWindow) { + m_mainWindow->openFiles(m_filesToOpen); + m_filesToOpen.clear(); + } + } + +protected: + bool eventFilter(QObject *object, QEvent *event) + { + if (object == qApp && event->type() == QEvent::FileOpen) { + QFileOpenEvent *e = static_cast<QFileOpenEvent*>(event); + QString file = e->url().toLocalFile(); + if (!m_mainWindow) + m_filesToOpen << file; + else + m_mainWindow->openFiles(QStringList() << file); + return true; + } + return QObject::eventFilter(object, event); + } + +private: + MainWindow *m_mainWindow; + QStringList m_filesToOpen; +}; +#endif // Q_WS_MAC + int main(int argc, char **argv) { Q_INIT_RESOURCE(linguist); @@ -63,6 +109,11 @@ int main(int argc, char **argv) QApplication app(argc, argv); QApplication::setOverrideCursor(Qt::WaitCursor); +#ifdef Q_WS_MAC + ApplicationEventFilter eventFilter; + app.installEventFilter(&eventFilter); +#endif // Q_WS_MAC + QStringList files; QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); QStringList args = app.arguments(); @@ -111,6 +162,9 @@ int main(int argc, char **argv) splash->show(); MainWindow mw; +#ifdef Q_WS_MAC + eventFilter.setMainWindow(&mw); +#endif // Q_WS_MAC mw.show(); splash->finish(&mw); QApplication::restoreOverrideCursor(); @@ -119,3 +173,7 @@ int main(int argc, char **argv) return app.exec(); } + +#ifdef Q_WS_MAC +#include "main.moc" +#endif // Q_WS_MAC |