summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-07-27 11:47:17 (GMT)
committerEike Ziller <eike.ziller@nokia.com>2011-07-27 12:28:44 (GMT)
commit80c5ea1a99e0c7794245e53175c949597315c96f (patch)
tree5c9beeb4c5ab4256aec8efa19ed10a3b4fbedf1a /tools/linguist
parent4bda273330f6705b79cf18c3ea8ef294f58a5239 (diff)
downloadQt-80c5ea1a99e0c7794245e53175c949597315c96f.zip
Qt-80c5ea1a99e0c7794245e53175c949597315c96f.tar.gz
Qt-80c5ea1a99e0c7794245e53175c949597315c96f.tar.bz2
Document support for Linguist on Mac.
Fixes dragging documents on Linguist dock icon, double clicking document in Finder, and the "open" terminal command. Task-number: QTBUG-20194 Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/linguist/Info_mac.plist60
-rw-r--r--tools/linguist/linguist/main.cpp58
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