From 5672a225d346454d8386bcc7e50f75d5e1fcdbda Mon Sep 17 00:00:00 2001 From: con <qtc-committer@nokia.com> Date: Tue, 24 Nov 2009 18:20:06 +0100 Subject: [PATCH] Mac OS X: Show build error count in Dock icon. Mac OS X >= Leopard only. Task-number: QTCREATORBUG-356 --- src/plugins/projectexplorer/buildprogress.cpp | 11 +++++ .../projectexplorer/buildprogress_mac.h | 41 ++++++++++++++++ .../projectexplorer/buildprogress_mac.mm | 47 +++++++++++++++++++ .../projectexplorer/projectexplorer.pro | 9 +++- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 src/plugins/projectexplorer/buildprogress_mac.h create mode 100644 src/plugins/projectexplorer/buildprogress_mac.mm diff --git a/src/plugins/projectexplorer/buildprogress.cpp b/src/plugins/projectexplorer/buildprogress.cpp index c97ce2c87ae..906a366634e 100644 --- a/src/plugins/projectexplorer/buildprogress.cpp +++ b/src/plugins/projectexplorer/buildprogress.cpp @@ -35,6 +35,11 @@ #include <QtGui/QHBoxLayout> #include <QtGui/QFont> #include <QtGui/QPixmap> +#include <QtDebug> + +#ifdef Q_OS_MAC +#include "buildprogress_mac.h" +#endif using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; @@ -93,4 +98,10 @@ void BuildProgress::updateState() m_warningIcon->setEnabled(haveWarnings); m_warningLabel->setEnabled(haveWarnings); m_warningLabel->setText(QString("%1").arg(warnings)); +#ifdef Q_OS_MAC + if (haveErrors) + qtcShowDockTileBadgeLabel(QString("%1").arg(errors)); + else + qtcShowDockTileBadgeLabel(""); +#endif } diff --git a/src/plugins/projectexplorer/buildprogress_mac.h b/src/plugins/projectexplorer/buildprogress_mac.h new file mode 100644 index 00000000000..fa51dfa6480 --- /dev/null +++ b/src/plugins/projectexplorer/buildprogress_mac.h @@ -0,0 +1,41 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BUILDPROGRESS_MAC_H +#define BUILDPROGRESS_MAC_H + +#include <QtCore/QString> + +namespace ProjectExplorer { + namespace Internal { + void qtcShowDockTileBadgeLabel(const QString &text); + } +} + +#endif diff --git a/src/plugins/projectexplorer/buildprogress_mac.mm b/src/plugins/projectexplorer/buildprogress_mac.mm new file mode 100644 index 00000000000..049c06bcdef --- /dev/null +++ b/src/plugins/projectexplorer/buildprogress_mac.mm @@ -0,0 +1,47 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "buildprogress_mac.h" + +#include <AppKit/NSDockTile.h> +#include <AppKit/NSApplication.h> +#include <Foundation/NSString.h> + + +void ProjectExplorer::Internal::qtcShowDockTileBadgeLabel(const QString &text) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + const char *utf8String = text.toUtf8().constData(); + NSString *cocoaString = [[NSString alloc] initWithUTF8String:utf8String]; + [[NSApp dockTile] setBadgeLabel:cocoaString]; + [cocoaString release]; +#else + Q_UNUSED(text) +#endif +} diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 54a631e837d..fbc3219b14f 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -135,9 +135,14 @@ win32 { HEADERS += winguiprocess.h } else:unix:SOURCES += applicationlauncher_x11.cpp + +macx { + HEADERS += buildprogress_mac.h + OBJECTIVE_SOURCES += buildprogress_mac.mm + LIBS += -framework Carbon -framework AppKit +} + RESOURCES += projectexplorer.qrc DEFINES += PROJECTEXPLORER_LIBRARY OTHER_FILES += ProjectExplorer.pluginspec -mac:LIBS += -framework Carbon - -- GitLab