summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2010-01-22 18:04:24 +0100
committerDaniel Molkentin <daniel.molkentin@nokia.com>2010-01-22 18:04:42 +0100
commitdbc295a07f725928eeab7f9c666049b73d624ac0 (patch)
tree88a960c72ac5fdd771916f54280e0b7c6d4125a5 /src
parentd348e5099b3f64568c7d81c7f5cb5aacad4823be (diff)
downloadqt-creator-dbc295a07f725928eeab7f9c666049b73d624ac0.tar.gz
Fixes for FancyActionBar and TargetSelector.
- Improved icon and text positioning - Improved readability and some gfx glitches on windows and mac - Removed drop down functionality from Run/Debug/Build buttons
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/fancyactionbar.cpp158
-rw-r--r--src/plugins/coreplugin/fancyactionbar.h4
-rw-r--r--src/plugins/coreplugin/modemanager.cpp4
-rw-r--r--src/plugins/coreplugin/modemanager.h2
-rw-r--r--src/plugins/projectexplorer/miniprojecttargetselector.cpp18
-rw-r--r--src/plugins/projectexplorer/miniprojecttargetselector.h1
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp6
7 files changed, 86 insertions, 107 deletions
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp
index 18bca72f99..807ddf2c48 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 ad7807d935..967947c275 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 bede27cb53..408bcb23e0 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 4cf2d8a404..9435d862f2 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 d8de5905b9..9b6c193002 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 14f2dcd4c2..2759f4accd 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 47bead26b4..16e5b53019 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);