diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 18bca72f99c8cf73cb00ff480e5434955222e543..807ddf2c48e0e721645703a64ecb54c659ad4023 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -56,98 +56,98 @@ FancyToolButton::FancyToolButton(QWidget *parent) void FancyToolButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - QPainter p(this); + QPainter painter(this); + // draw borders QLayout *parentLayout = qobject_cast<FancyActionBar*>(parentWidget())->actionsLayout(); - int lineHeight = fontMetrics().height(); bool isTitledAction = defaultAction()->property("titledAction").toBool(); #ifndef Q_WS_MAC // Mac UIs usually don't hover if (underMouse() && isEnabled() && !isDown()) { QColor whiteOverlay(Qt::white); whiteOverlay.setAlpha(20); - p.fillRect(rect().adjusted(1, 1, -1, -1), whiteOverlay); + painter.fillRect(rect().adjusted(1, 1, -1, -1), whiteOverlay); } #endif if (isDown()) { QColor whiteOverlay(Qt::black); whiteOverlay.setAlpha(20); - p.fillRect(rect().adjusted(1, 1, -1, -1), whiteOverlay); + painter.fillRect(rect().adjusted(1, 1, -1, -1), whiteOverlay); } - QPixmap borderPixmap; - QMargins margins; - if (parentLayout && parentLayout->count() > 0 && - parentLayout->itemAt(parentLayout->count()-1)->widget() == this) { - margins = QMargins(3, 3, 2, 0); - borderPixmap = QPixmap( - QLatin1String(":/fancyactionbar/images/fancytoolbutton_bottom_outline.png")); - } else if (parentLayout && parentLayout->count() > 0 && - parentLayout->itemAt(0)->widget() == this) { - margins = QMargins(3, 3, 2, 3); - borderPixmap = QPixmap( - QLatin1String(":/fancyactionbar/images/fancytoolbutton_top_outline.png")); - } else { - margins = QMargins(3, 3, 2, 0); - borderPixmap = QPixmap( - QLatin1String(":/fancyactionbar/images/fancytoolbutton_normal_outline.png")); - } - - QRect drawRect = rect(); - qDrawBorderPixmap(&p, drawRect, margins, borderPixmap); + QPixmap borderPixmap; + QMargins margins; + if (parentLayout && parentLayout->count() > 0 && + parentLayout->itemAt(parentLayout->count()-1)->widget() == this) { + margins = QMargins(3, 3, 2, 0); + borderPixmap = QPixmap( + QLatin1String(":/fancyactionbar/images/fancytoolbutton_bottom_outline.png")); + } else if (parentLayout && parentLayout->count() > 0 && + parentLayout->itemAt(0)->widget() == this) { + margins = QMargins(3, 3, 2, 3); + borderPixmap = QPixmap( + QLatin1String(":/fancyactionbar/images/fancytoolbutton_top_outline.png")); + } else { + margins = QMargins(3, 3, 2, 0); + borderPixmap = QPixmap( + QLatin1String(":/fancyactionbar/images/fancytoolbutton_normal_outline.png")); + } - QPixmap pix = icon().pixmap(size() - QSize(15, 15), isEnabled() ? QIcon::Normal : QIcon::Disabled); - QPoint center = rect().center(); - QSize halfPixSize = pix.size()/2; + // draw pixmap + QRect drawRect = rect(); + qDrawBorderPixmap(&painter, drawRect, margins, borderPixmap); - p.drawPixmap(center-QPoint(halfPixSize.width()-1, halfPixSize.height()-1), pix); + QPixmap pix = icon().pixmap(32, 32, isEnabled() ? QIcon::Normal : QIcon::Disabled); + QPoint center = rect().center(); + QSizeF halfPixSize = pix.size()/2.0; - if (popupMode() == QToolButton::DelayedPopup && !isTitledAction) { - QPoint arrowOffset = center + QPoint(pix.rect().width()/2, pix.rect().height()/2); - QStyleOption opt; - if (isEnabled()) - opt.state &= QStyle::State_Enabled; - else - opt.state |= QStyle::State_Enabled; - opt.rect = QRect(arrowOffset.x(), arrowOffset.y(), 6, 6); - style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, - &opt, &p, this); - } + painter.drawPixmap(center-QPointF(halfPixSize.width()-1, halfPixSize.height()-1), pix); + // draw popup texts if (isTitledAction) { - QRect r(0, lineHeight/2, rect().width(), lineHeight); + QFont normalFont(painter.font()); + normalFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); + QFont boldFont(normalFont); + boldFont.setBold(true); + QFontMetrics fm(normalFont); + QFontMetrics boldFm(boldFont); + int lineHeight = boldFm.height(); + + int textFlags = Qt::AlignVCenter|Qt::AlignHCenter; + + painter.setFont(normalFont); + + QPoint textOffset = center - QPoint(pix.rect().width()/2, pix.rect().height()/2); + textOffset = textOffset - QPoint(0, lineHeight+5); + QRectF r(0, textOffset.y(), rect().width(), lineHeight); QColor penColor; if (isEnabled()) penColor = Qt::white; else penColor = Qt::gray; - p.setPen(penColor); + painter.setPen(penColor); const QString projectName = defaultAction()->property("heading").toString(); - QFont f = font(); - f.setPointSize(f.pointSize()-1); - p.setFont(f); - QFontMetrics fm(f); QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, r.width()); if (isEnabled()) { - const QRect shadowR = r.translated(0, 1); - p.setPen(Qt::black); - p.drawText(shadowR, Qt::AlignVCenter|Qt::AlignHCenter, ellidedProjectName); - p.setPen(penColor); + const QRectF shadowR = r.translated(0, 1); + painter.setPen(QColor(30, 30, 30, 80)); + painter.drawText(shadowR, textFlags, ellidedProjectName); + painter.setPen(penColor); } - p.drawText(r, Qt::AlignVCenter|Qt::AlignHCenter, ellidedProjectName); - r = QRect(0, rect().bottom()-lineHeight*1.5, rect().width(), lineHeight); + painter.drawText(r, textFlags, ellidedProjectName); + textOffset = center + QPoint(pix.rect().width()/2, pix.rect().height()/2); + r = QRectF(0, textOffset.y()+5, rect().width(), lineHeight); const QString buildConfiguration = defaultAction()->property("subtitle").toString(); - f.setBold(true); - p.setFont(f); - QString ellidedBuildConfiguration = fm.elidedText(buildConfiguration, Qt::ElideMiddle, r.width()); + painter.setFont(boldFont); + QString ellidedBuildConfiguration = boldFm.elidedText(buildConfiguration, Qt::ElideMiddle, r.width()); if (isEnabled()) { - const QRect shadowR = r.translated(0, 1); - p.setPen(Qt::black); - p.drawText(shadowR, Qt::AlignVCenter|Qt::AlignHCenter, ellidedBuildConfiguration); - p.setPen(penColor); + const QRectF shadowR = r.translated(0, 1); + painter.setPen(QColor(30, 30, 30, 80)); + painter.drawText(shadowR, textFlags, ellidedBuildConfiguration); + painter.setPen(penColor); } - p.drawText(r, Qt::AlignVCenter|Qt::AlignHCenter, ellidedBuildConfiguration); + painter.drawText(r, textFlags, ellidedBuildConfiguration); } } @@ -156,15 +156,19 @@ void FancyActionBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) } - QSize FancyToolButton::sizeHint() const { - QSize buttonSize = iconSize().expandedTo(QSize(64, 40)); + QSizeF buttonSize = iconSize().expandedTo(QSize(64, 40)); if (defaultAction()->property("titledAction").toBool()) { - int lineHeight = fontMetrics().height(); - buttonSize += QSize(0, lineHeight*4); + QFont boldFont(font()); + boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); + boldFont.setBold(true); + QFontMetrics fm(boldFont); + qreal lineHeight = fm.height(); + buttonSize += QSizeF(0, (lineHeight*3.5)); + } - return buttonSize; + return buttonSize.toSize(); } QSize FancyToolButton::minimumSizeHint() const @@ -209,38 +213,14 @@ void FancyActionBar::addProjectSelector(QAction *action) m_actionsLayout->insertWidget(0, toolButton); } -void FancyActionBar::insertAction(int index, QAction *action, QMenu *menu) +void FancyActionBar::insertAction(int index, QAction *action) { FancyToolButton *toolButton = new FancyToolButton(this); toolButton->setDefaultAction(action); connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged())); - - if (menu) { - toolButton->setMenu(menu); - toolButton->setPopupMode(QToolButton::DelayedPopup); - - // execute action also if a context menu item is select - connect(toolButton, SIGNAL(triggered(QAction*)), - this, SLOT(toolButtonContextMenuActionTriggered(QAction*)), - Qt::QueuedConnection); - } m_actionsLayout->insertWidget(index, toolButton); } -/* - This slot is invoked when a context menu action of a tool button is triggered. - In this case we also want to trigger the default action of the button. - - This allows the user e.g. to select and run a specific run configuration with one click. - */ -void FancyActionBar::toolButtonContextMenuActionTriggered(QAction* action) -{ - if (QToolButton *button = qobject_cast<QToolButton*>(sender())) { - if (action != button->defaultAction()) - button->defaultAction()->trigger(); - } -} - QLayout *FancyActionBar::actionsLayout() const { return m_actionsLayout; diff --git a/src/plugins/coreplugin/fancyactionbar.h b/src/plugins/coreplugin/fancyactionbar.h index ad7807d9357f9242e451afedf16530ef3c23b88c..967947c275fcc6f72a5f530cd4849344e80e13fb 100644 --- a/src/plugins/coreplugin/fancyactionbar.h +++ b/src/plugins/coreplugin/fancyactionbar.h @@ -64,12 +64,10 @@ public: FancyActionBar(QWidget *parent = 0); void paintEvent(QPaintEvent *event); - void insertAction(int index, QAction *action, QMenu *menu = 0); + void insertAction(int index, QAction *action); void addProjectSelector(QAction *action); QLayout *actionsLayout() const; -private slots: - void toolButtonContextMenuActionTriggered(QAction*); private: QVBoxLayout *m_actionsLayout; }; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index bede27cb535a9189bdc25d7a06555dbbe86ceabf..408bcb23e0f9703f9ec0a3b1702985e021ac6341 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -191,7 +191,7 @@ void ModeManager::aboutToRemoveObject(QObject *obj) m_mainWindow->removeContextObject(mode); } -void ModeManager::addAction(Command *command, int priority, QMenu *menu) +void ModeManager::addAction(Command *command, int priority) { m_actions.insert(command, priority); @@ -202,7 +202,7 @@ void ModeManager::addAction(Command *command, int priority, QMenu *menu) ++index; } - m_actionBar->insertAction(index, command->action(), menu); + m_actionBar->insertAction(index, command->action()); } void ModeManager::addProjectSelector(QAction *action) diff --git a/src/plugins/coreplugin/modemanager.h b/src/plugins/coreplugin/modemanager.h index 4cf2d8a404312e3d3561ac039f712381e9d37852..9435d862f20e2605e928818619d0f3cd054d5ab0 100644 --- a/src/plugins/coreplugin/modemanager.h +++ b/src/plugins/coreplugin/modemanager.h @@ -68,7 +68,7 @@ public: IMode* currentMode() const; IMode* mode(const QString &id) const; - void addAction(Command *command, int priority, QMenu *menu = 0); + void addAction(Command *command, int priority); void addProjectSelector(QAction *action); void addWidget(QWidget *widget); diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index d8de5905b92f57ee0efb030e078685b16a76a6ed..9b6c193002e788210bcfd6414bdf12c79ced201b 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -35,13 +35,13 @@ MiniTargetWidget::MiniTargetWidget(Project *project, QWidget *parent) : m_runComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); int fontSize = font().pointSize(); - setStyleSheet(QString("QWidget { font-size: %1pt; color: white; } " - "QLabel#targetName { font-size: %2pt; font-weight: bold; } " - "QComboBox { background-color: transparent; margin: 0; border: none; } " - "QComboBox QWidget { background-color: %3 } " - "QComboBox::drop-down { border: none; }" - "QComboBox::down-arrow { image: url(:/welcome/images/combobox_arrow.png); } " - ).arg(fontSize-1).arg(fontSize).arg(Utils::StyleHelper::baseColor().name())); + setStyleSheet(QString::fromLatin1("QWidget { font-size: %1pt; color: white; } " + "QLabel#targetName { font-size: %2pt; font-weight: bold; } " + "QComboBox { background-color: transparent; margin: 0; border: none; } " + "QComboBox QWidget { background-color: %3; border: 1px solid lightgrey; } " + "QComboBox::drop-down { border: none; }" + "QComboBox::down-arrow { image: url(:/welcome/images/combobox_arrow.png); } " + ).arg(fontSize-1).arg(fontSize).arg(Utils::StyleHelper::baseColor().name())); QGridLayout *gridLayout = new QGridLayout(this); @@ -217,8 +217,8 @@ void MiniProjectTargetSelector::addProject(ProjectExplorer::Project* project) { QTC_ASSERT(project, return); ProjectListWidget *targetList = new ProjectListWidget(project); - targetList->setStyleSheet(QString("QListWidget { background: %1; border: none; }") - .arg(Utils::StyleHelper::baseColor().name())); + targetList->setStyleSheet(QString::fromLatin1("QListWidget { background: %1; border: none; }") + .arg(Utils::StyleHelper::baseColor().name())); int pos = m_widgetStack->addWidget(targetList); m_projectsBox->addItem(project->displayName(), QVariant::fromValue(project)); diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.h b/src/plugins/projectexplorer/miniprojecttargetselector.h index 14f2dcd4c2bc4da5bd39bf586256df248c328e8d..2759f4accd5193b1768305c3dafc11e2c7ee50d7 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.h +++ b/src/plugins/projectexplorer/miniprojecttargetselector.h @@ -31,6 +31,7 @@ public: { setFocusPolicy(Qt::NoFocus); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlternatingRowColors(false); } ProjectExplorer::Project *project() const diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 47bead26b44fde5c13341056421046f60c2eb426..16e5b53019514d2f268a27836766b0fe65d5142f 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -566,7 +566,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mbuild->addAction(cmd, Constants::G_BUILD_SESSION); msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); // Add to mode bar - modeManager->addAction(cmd, Constants::P_ACTION_BUILDSESSION, d->m_buildConfigurationMenu); + modeManager->addAction(cmd, Constants::P_ACTION_BUILDSESSION); // rebuild session action QIcon rebuildIcon(Constants::ICON_REBUILD); @@ -647,7 +647,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(mbuild->menu(), SIGNAL(aboutToShow()), this, SLOT(populateRunConfigurationMenu())); connect(d->m_runConfigurationMenu, SIGNAL(triggered(QAction *)), this, SLOT(runConfigurationMenuTriggered(QAction *))); - modeManager->addAction(cmd, Constants::P_ACTION_RUN, d->m_runConfigurationMenu); + modeManager->addAction(cmd, Constants::P_ACTION_RUN); d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this); cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, globalcontext); @@ -668,7 +668,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd->setDefaultText(tr("Start Debugging")); cmd->setDefaultKeySequence(QKeySequence(tr("F5"))); mstartdebugging->addAction(cmd, Core::Constants::G_DEFAULT_ONE); - modeManager->addAction(cmd, Constants::P_ACTION_DEBUG, d->m_runConfigurationMenu); + modeManager->addAction(cmd, Constants::P_ACTION_DEBUG); // add new file action d->m_addNewFileAction = new QAction(tr("Add New..."), this);