diff --git a/src/plugins/projectexplorer/images/targetbuildselected.png b/src/plugins/projectexplorer/images/targetbuildselected.png index f1cf44c08b97cd29655a9af67f07e772a195060a..a62e4956768cc080e403da343a243ad032866bce 100644 Binary files a/src/plugins/projectexplorer/images/targetbuildselected.png and b/src/plugins/projectexplorer/images/targetbuildselected.png differ diff --git a/src/plugins/projectexplorer/images/targetrunselected.png b/src/plugins/projectexplorer/images/targetrunselected.png index 228287b3e102ade477734619d48d60bb15fe0427..7fc5f92f56d5d17887cc3a2e2111fc05a01700ed 100644 Binary files a/src/plugins/projectexplorer/images/targetrunselected.png and b/src/plugins/projectexplorer/images/targetrunselected.png differ diff --git a/src/plugins/projectexplorer/images/targetunselected.png b/src/plugins/projectexplorer/images/targetunselected.png index 2df56444182b87e036c7c3343e73e183663d4bf7..6470b267048ef762bc5634cbc771f7677f1d859d 100644 Binary files a/src/plugins/projectexplorer/images/targetunselected.png and b/src/plugins/projectexplorer/images/targetunselected.png differ diff --git a/src/plugins/projectexplorer/targetselector.cpp b/src/plugins/projectexplorer/targetselector.cpp index a0936ebc07feb2fadf98b54799b209b99f835613..72ee9ea5a42d130c4f640baf7c1028787c3730c7 100644 --- a/src/plugins/projectexplorer/targetselector.cpp +++ b/src/plugins/projectexplorer/targetselector.cpp @@ -1,12 +1,12 @@ #include "targetselector.h" #include <utils/qtcassert.h> +#include <utils/stylehelper.h> #include <QtGui/QPainter> #include <QtGui/QMouseEvent> #include <QtGui/QFontMetrics> -static const int TARGET_WIDTH = 109; static const int TARGET_HEIGHT = 43; static const int ADDBUTTON_WIDTH = 27; @@ -124,9 +124,20 @@ bool TargetSelector::isRemoveButtonEnabled() const return m_removeButtonEnabled; } +int TargetSelector::targetWidth() const +{ + static int width = -1; + if (width < 0) { + QFontMetrics fm = fontMetrics(); + width = qMax(fm.width(runButtonString()), fm.width(buildButtonString())); + width = qMax(129, width * 2 + 31); + } + return width; +} + QSize TargetSelector::minimumSizeHint() const { - return QSize((TARGET_WIDTH + 1) * m_targets.size() + (ADDBUTTON_WIDTH + 1) * 2 + 1, TARGET_HEIGHT + 2); + return QSize((targetWidth() + 1) * m_targets.size() + (ADDBUTTON_WIDTH + 1) * 2 + 1, TARGET_HEIGHT + 2); } void TargetSelector::mousePressEvent(QMouseEvent *event) @@ -135,7 +146,7 @@ void TargetSelector::mousePressEvent(QMouseEvent *event) event->accept(); if (m_removeButtonEnabled) emit removeButtonClicked(); - } else if (event->x() > ADDBUTTON_WIDTH + (TARGET_WIDTH + 1) * m_targets.size()) { + } else if (event->x() > ADDBUTTON_WIDTH + (targetWidth() + 1) * m_targets.size()) { // check for add button event->accept(); if (m_addButtonEnabled) @@ -148,14 +159,14 @@ void TargetSelector::mousePressEvent(QMouseEvent *event) if (event->x() <= x) { break; } - x += TARGET_WIDTH + 1; + x += targetWidth() + 1; } --index; if (index >= 0 && index < m_targets.size()) { // handle clicked target // check if user clicked on Build or Run if (event->y() > TARGET_HEIGHT * 3/5) { - if ((event->x() - (ADDBUTTON_WIDTH + (TARGET_WIDTH + 1) * index)) - 2 > TARGET_WIDTH / 2) { + if ((event->x() - (ADDBUTTON_WIDTH + (targetWidth() + 1) * index)) - 2 > targetWidth() / 2) { m_targets[index].currentSubIndex = 1; } else { m_targets[index].currentSubIndex = 0; @@ -195,22 +206,49 @@ void TargetSelector::paintEvent(QPaintEvent *event) p.setPen(QColor(0, 0, 0)); p.drawLine(x, 1, x, TARGET_HEIGHT); x += 1; + + const QString runString = runButtonString(); + const QString buildString = buildButtonString(); foreach (const Target &target, m_targets) { - const QPixmap *pixmap = &m_unselected; + QImage image = m_unselected; + bool buildSelected = target.currentSubIndex == 0; if (index == m_currentTargetIndex) { p.setPen(QColor(255, 255, 255)); - if (target.currentSubIndex == 0) { - pixmap = &m_buildselected; + if (buildSelected) { + image = m_buildselected; } else { - pixmap = &m_runselected; + image= m_runselected; } - } else { - p.setPen(QColor(0, 0, 0)); } - p.drawPixmap(x, 1, *pixmap); - p.drawText(x + (TARGET_WIDTH - fm.width(target.name))/2 + 1, 7 + fm.ascent(), + + QRect buttonRect(x, 1, targetWidth() , image.height()); + Utils::StyleHelper::drawCornerImage(image, &p, buttonRect, 16, 0, 16, 0); + p.drawText(x + (targetWidth()- fm.width(target.name))/2 + 1, 7 + fm.ascent(), target.name); - x += TARGET_WIDTH; + + // Build + int margin = 2; // position centered within the rounded buttons + QFontMetrics fm = fontMetrics(); + QRect textRect(x + margin, size.height() - fm.height() - 5, targetWidth()/2, fm.height()); + p.setPen(buildSelected ? Qt::black : Qt::white); + if (index!=m_currentTargetIndex) + p.setPen(QColor(0x555555)); + else + p.setPen(buildSelected ? Qt::black : Qt::white); + + p.drawText(textRect, Qt::AlignHCenter, runString); + + // Run + textRect.moveLeft(x + targetWidth()/2 - 2 * margin); + if (index!=m_currentTargetIndex) + p.setPen(QColor(0x555555)); + else + p.setPen(buildSelected ? Qt::white: Qt::black); + p.drawText(textRect, Qt::AlignHCenter, buildString); + + x += targetWidth(); + + p.setPen(index == m_currentTargetIndex ? QColor(0x222222) : QColor(0xcccccc)); p.drawLine(x, 1, x, TARGET_HEIGHT); ++x; ++index; diff --git a/src/plugins/projectexplorer/targetselector.h b/src/plugins/projectexplorer/targetselector.h index 41cb0e681a64dd6facb2783859e7c707e9df233d..b6c2037e4e15ccd28ea10b247ff5e479014ac67c 100644 --- a/src/plugins/projectexplorer/targetselector.h +++ b/src/plugins/projectexplorer/targetselector.h @@ -20,6 +20,10 @@ public: QSize minimumSizeHint() const; + int targetWidth() const; + QString runButtonString() const { return tr("Run"); } + QString buildButtonString() const { return tr("Build"); } + Target targetAt(int index) const; int targetCount() const { return m_targets.size(); } int currentIndex() const { return m_currentTargetIndex; } @@ -49,9 +53,9 @@ protected: void mousePressEvent(QMouseEvent *event); private: - const QPixmap m_unselected; - const QPixmap m_runselected; - const QPixmap m_buildselected; + const QImage m_unselected; + const QImage m_runselected; + const QImage m_buildselected; const QPixmap m_targetaddbutton; const QPixmap m_targetaddbuttondisabled; const QPixmap m_targetremovebutton;