diff --git a/src/app/app.pro b/src/app/app.pro index 69f5aa6fdceeeed3e045d58f8f5ca4532cfee55c..b1830edff2f7f9800b4a368463fae639f1085b76 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -17,7 +17,7 @@ win32 { } else:macx { CONFIG(debug, debug|release):LIBS *= -lExtensionSystem_debug -lAggregation_debug else:LIBS *= -lExtensionSystem -lAggregation - + LIBS += -framework CoreFoundation ICON = qtcreator.icns QMAKE_INFO_PLIST = Info.plist FILETYPES.files = profile.icns prifile.icns diff --git a/src/app/main.cpp b/src/app/main.cpp index 599459eb05cfa54fc9a19d68a7640dfc1b0dcdf8..f6a0dc45b3c9f37253850a6458401644500b8be8 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -48,6 +48,20 @@ #ifdef Q_OS_MAC # include <sys/resource.h> +# include <CoreFoundation/CoreFoundation.h> + +// Helper function CoreFoundation -> Qt +static QString stringFromCFString(CFStringRef value) { + QString retVal; + CFIndex maxLength = 2 * CFStringGetLength(value) + 1/*zero term*/; // max UTF8 + char *cstring = new char[maxLength]; + if (CFStringGetCString(CFStringRef(value), cstring, maxLength, kCFStringEncodingUTF8)) { + retVal = QString::fromUtf8(cstring); + } + delete cstring; + return retVal; +} + #endif enum { OptionIndent = 4, DescriptionIndent = 24 }; @@ -216,7 +230,29 @@ int main(int argc, char **argv) QTranslator translator; QTranslator qtTranslator; - const QString &locale = QLocale::system().name(); + QString locale = QLocale::system().name(); +#ifdef Q_OS_MAC + // because QLocale's system locale is basically useless on the Mac. + // Try to get the real system setting via core foundation + CFLocaleRef maclocale = CFLocaleCopyCurrent(); + CFTypeRef value = CFLocaleGetValue(maclocale, kCFLocaleLanguageCode); + QString preferredLanguage = stringFromCFString(CFStringRef(value)); + if (!preferredLanguage.isEmpty()) + locale = preferredLanguage; + CFRelease(maclocale); + CFArrayRef languages = (CFArrayRef)CFPreferencesCopyValue( + CFSTR("AppleLanguages"), + kCFPreferencesAnyApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); +// CFShow(languages); + if (CFArrayGetCount(languages) > 0) { + QString preferredLanguage = stringFromCFString(CFStringRef(CFArrayGetValueAtIndex(languages, 0))); + if (!preferredLanguage.isEmpty()) + locale = preferredLanguage; + } + CFRelease(languages); +#endif const QString &creatorTrPath = QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH "/translations"); if (translator.load(QLatin1String("qtcreator_") + locale, creatorTrPath)) { diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index e42d5c03423252e07f7be764ee7672afb7766b73..af8576b8ac4fa63d112c7212d1e6c129c52b0547 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -160,7 +160,7 @@ MainWindow::MainWindow() : QCoreApplication::setOrganizationName(QLatin1String("Nokia")); QSettings::setDefaultFormat(QSettings::IniFormat); QString baseName = qApp->style()->objectName(); -#ifdef Q_WS_X11 +#ifdef Q_WS_X11 if (baseName == QLatin1String("windows")) { // Sometimes we get the standard windows 95 style as a fallback // e.g. if we are running on a KDE4 desktop @@ -325,7 +325,7 @@ bool MainWindow::init(QString *errorMessage) void MainWindow::modeChanged(Core::IMode *mode) { - if (mode == m_outputMode) { + if (mode == m_outputMode) { int idx = OutputPaneManager::instance()->m_widgetComboBox->itemData(OutputPaneManager::instance()->m_widgetComboBox->currentIndex()).toInt(); IOutputPane *out = OutputPaneManager::instance()->m_pageMap.value(idx); if (out && out->canFocus()) @@ -678,6 +678,7 @@ void MainWindow::registerDefaultActions() cmd = am->registerAction(m_optionsAction, Constants::OPTIONS, m_globalContext); #ifdef Q_WS_MAC cmd->setDefaultKeySequence(QKeySequence("Ctrl+,")); + cmd->action()->setMenuRole(QAction::PreferencesRole); #endif mtools->addAction(cmd, Constants::G_DEFAULT_THREE); connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); @@ -735,7 +736,11 @@ void MainWindow::registerDefaultActions() cmd = am->registerAction(tmpaction, Constants::ABOUT_QTCREATOR, m_globalContext); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); +#ifdef Q_WS_MAC + cmd->action()->setMenuRole(QAction::ApplicationSpecificRole); +#endif connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutQtCreator())); + //About Plugins Action tmpaction = new QAction(tr("About &Plugins..."), this); cmd = am->registerAction(tmpaction, Constants::ABOUT_PLUGINS, m_globalContext);