diff options
author | con <qtc-committer@nokia.com> | 2010-02-09 19:05:15 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-02-09 19:07:26 +0100 |
commit | d8def1836287839db812299bbd266020922bed76 (patch) | |
tree | 955879e943616b0aac2f93e89b05bb06ec4a3618 /src/plugins/qt4projectmanager/qt4target.cpp | |
parent | f7207646bdb7d77994a0f300f2023abfe779ab25 (diff) | |
download | qt-creator-d8def1836287839db812299bbd266020922bed76.tar.gz |
Give targets a tool tip property.
Use that for showing details about connected Symbian devices.
Also update the icon with an (not-)connected overlay icon.
Graphics design pending.
Diffstat (limited to 'src/plugins/qt4projectmanager/qt4target.cpp')
-rw-r--r-- | src/plugins/qt4projectmanager/qt4target.cpp | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/src/plugins/qt4projectmanager/qt4target.cpp b/src/plugins/qt4projectmanager/qt4target.cpp index 48eab94ecb..a83d01eadb 100644 --- a/src/plugins/qt4projectmanager/qt4target.cpp +++ b/src/plugins/qt4projectmanager/qt4target.cpp @@ -40,8 +40,12 @@ #include "qt-s60/s60emulatorrunconfiguration.h" #include <projectexplorer/toolchain.h> +#include <coreplugin/coreconstants.h> +#include <symbianutils/symbiandevicemanager.h> #include <QtGui/QApplication> +#include <QtGui/QPixmap> +#include <QtGui/QPainter> using namespace ProjectExplorer; using namespace Qt4ProjectManager; @@ -67,13 +71,13 @@ QIcon iconForId(const QString &id) { if (id == QLatin1String(DESKTOP_TARGET_ID)) return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); if (id == QLatin1String(S60_EMULATOR_TARGET_ID)) - return QIcon(); + return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); if (id == QLatin1String(S60_DEVICE_TARGET_ID)) - return QIcon(); + return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); if (id == QLatin1String(MAEMO_EMULATOR_TARGET_ID)) - return QIcon(); + return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); if (id == QLatin1String(MAEMO_DEVICE_TARGET_ID)) - return QIcon(); + return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); return QIcon(); } @@ -182,9 +186,13 @@ Qt4Target::Qt4Target(Qt4Project *parent, const QString &id) : this, SIGNAL(targetInformationChanged())); connect(this, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SIGNAL(environmentChanged())); + connect(this, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)), + this, SLOT(onAddedRunConfiguration(ProjectExplorer::RunConfiguration*))); + connect(this, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), + this, SLOT(updateToolTipAndIcon())); setDisplayName(displayNameForId(id)); - setIcon(iconForId(id)); + updateToolTipAndIcon(); } Qt4Target::~Qt4Target() @@ -385,18 +393,54 @@ void Qt4Target::updateQtVersion() setEnabled(project()->supportedTargetIds().contains(id())); } -void Qt4Target::onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) +void Qt4Target::onAddedRunConfiguration(ProjectExplorer::RunConfiguration *rc) +{ + Q_ASSERT(rc); + S60DeviceRunConfiguration *deviceRc(qobject_cast<S60DeviceRunConfiguration *>(rc)); + if (!deviceRc) + return; + connect(deviceRc, SIGNAL(serialPortNameChanged()), + this, SLOT(slotUpdateDeviceInformation())); +} + +void Qt4Target::slotUpdateDeviceInformation() { - Q_ASSERT(bc); - Qt4BuildConfiguration *qt4bc(qobject_cast<Qt4BuildConfiguration *>(bc)); - Q_ASSERT(qt4bc); - connect(qt4bc, SIGNAL(targetInformationChanged()), - this, SLOT(changeTargetInformation())); + S60DeviceRunConfiguration *deviceRc(qobject_cast<S60DeviceRunConfiguration *>(sender())); + if (deviceRc && deviceRc == activeRunConfiguration()) { + updateToolTipAndIcon(); + } } -void Qt4Target::changeTargetInformation() +void Qt4Target::updateToolTipAndIcon() { - ProjectExplorer::BuildConfiguration *bc(qobject_cast<ProjectExplorer::BuildConfiguration *>(sender())); - if (bc && bc == activeBuildConfiguration()) - emit targetInformationChanged(); + static const QPixmap connected(":/qt4projectmanager/images/connected.png"); + static const QPixmap notconnected(":/qt4projectmanager/images/notconnected.png"); + S60DeviceRunConfiguration *deviceRc(qobject_cast<S60DeviceRunConfiguration *>(activeRunConfiguration())); + if (!deviceRc) { + setToolTip(QString()); + setIcon(iconForId(id())); + } else { + QString friendlyPortName = SymbianUtils::SymbianDeviceManager::instance()->friendlyNameForPort( + deviceRc->serialPortName()); + QPixmap pixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + const QIcon &icon = iconForId(id()); + QSize actualSize = icon.actualSize(QSize(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE)); + painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE-actualSize.width())/2, + (Core::Constants::TARGET_ICON_SIZE-actualSize.height())/2, + icon.pixmap(Core::Constants::TARGET_ICON_SIZE)); + + if (!friendlyPortName.isEmpty()) { + // device connected + setToolTip(tr("<b>Device:</b> %1").arg(friendlyPortName)); + painter.drawPixmap(Core::Constants::TARGET_ICON_SIZE - connected.width(), + connected.height(), connected); + } else { + setToolTip(tr("<b>Device:</b> Not connected")); + painter.drawPixmap(Core::Constants::TARGET_ICON_SIZE - notconnected.width(), + notconnected.height(), notconnected); + } + setIcon(QIcon(pixmap)); + } } |