Fixes: Polish toolbar buttons, fix invisible extension

Details:
I used vector graphics for icons, to give them a smoother
appearance and added an improved extension button that is
visible on a dark background. Down arrows are now
painted with AA enabled.
This commit is contained in:
Jens Bache-Wiig
2009-01-26 15:46:11 +01:00
parent c85ba53365
commit 9c897b4411
7 changed files with 113 additions and 25 deletions

View File

@@ -67,5 +67,6 @@
<file>images/undo.png</file> <file>images/undo.png</file>
<file>images/unknownfile.png</file> <file>images/unknownfile.png</file>
<file>images/unlocked.png</file> <file>images/unlocked.png</file>
<file>images/extension.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 435 B

View File

@@ -152,6 +152,24 @@ MainWindow::MainWindow() :
setWindowTitle(tr("Qt Creator")); setWindowTitle(tr("Qt Creator"));
qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png")); qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::IDE_VERSION_LONG));
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
QSettings::setDefaultFormat(QSettings::IniFormat);
QString baseName = qApp->style()->objectName();
#ifdef Q_WS_X11
if (baseName == "windows") {
// Sometimes we get the standard windows 95 style as a fallback
// e.g. if we are running on a KDE4 desktop
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
if (desktopEnvironment == "kde")
baseName = "plastique";
else
baseName = "cleanlooks";
}
#endif
qApp->setStyle(new ManhattanStyle(baseName));
setDockNestingEnabled(true); setDockNestingEnabled(true);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@@ -183,23 +201,6 @@ MainWindow::MainWindow() :
//signal(SIGINT, handleSigInt); //signal(SIGINT, handleSigInt);
#endif #endif
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::IDE_VERSION_LONG));
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
QSettings::setDefaultFormat(QSettings::IniFormat);
QString baseName = qApp->style()->objectName();
#ifdef Q_WS_X11
if (baseName == "windows") {
// Sometimes we get the standard windows 95 style as a fallback
// e.g. if we are running on a KDE4 desktop
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
if (desktopEnvironment == "kde")
baseName = "plastique";
else
baseName = "cleanlooks";
}
#endif
qApp->setStyle(new ManhattanStyle(baseName));
statusBar()->setProperty("p_styled", true); statusBar()->setProperty("p_styled", true);
} }

View File

@@ -345,12 +345,11 @@ void ManhattanStyle::polish(QPalette &pal)
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
const QWidget *widget) const const QWidget *widget) const
{ {
static const QIcon closeButton(":/core/images/closebutton.png");
QIcon icon; QIcon icon;
switch (standardIcon) { switch (standardIcon) {
case QStyle::SP_TitleBarCloseButton: case QStyle::SP_TitleBarCloseButton:
icon = closeButton; case QStyle::SP_ToolBarHorizontalExtensionButton:
break; return QIcon(standardPixmap(standardIcon, option, widget));
default: default:
icon = d->style->standardIcon(standardIcon, option, widget); icon = d->style->standardIcon(standardIcon, option, widget);
} }
@@ -360,11 +359,20 @@ QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, co
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const const QWidget *widget) const
{ {
static const QPixmap closeButton(":/core/images/closebutton.png"); if (widget && !panelWidget(widget))
return d->style->standardPixmap(standardPixmap, opt, widget);
QPixmap pixmap; QPixmap pixmap;
switch (standardPixmap) { switch (standardPixmap) {
case QStyle::SP_TitleBarCloseButton: case QStyle::SP_ToolBarHorizontalExtensionButton: {
pixmap = closeButton; static const QPixmap extButton(":/core/images/extension.png");
pixmap = extButton;
}
break;
case QStyle::SP_TitleBarCloseButton: {
static const QPixmap closeButton(":/core/images/closebutton.png");
pixmap = closeButton;
}
break; break;
default: default:
pixmap = d->style->standardPixmap(standardPixmap, opt, widget); pixmap = d->style->standardPixmap(standardPixmap, opt, widget);
@@ -593,6 +601,84 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->restore(); painter->restore();
} }
break; break;
case PE_IndicatorArrowUp:
case PE_IndicatorArrowDown:
case PE_IndicatorArrowRight:
case PE_IndicatorArrowLeft:
{
// From windowsstyle but modified to enable AA
if (option->rect.width() <= 1 || option->rect.height() <= 1)
break;
QRect r = option->rect;
int size = qMin(r.height(), r.width());
QPixmap pixmap;
QString pixmapName;
pixmapName.sprintf("%s-%s-%d-%d-%d-%lld",
"$qt_ia", metaObject()->className(),
uint(option->state), element,
size, option->palette.cacheKey());
if (!QPixmapCache::find(pixmapName, pixmap)) {
int border = size/5;
int sqsize = 2*(size/2);
QImage image(sqsize, sqsize, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter imagePainter(&image);
imagePainter.setRenderHint(QPainter::Antialiasing, true);
imagePainter.translate(0.5, 0.5);
QPolygon a;
switch (element) {
case PE_IndicatorArrowUp:
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
break;
case PE_IndicatorArrowDown:
a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
break;
case PE_IndicatorArrowRight:
a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
break;
case PE_IndicatorArrowLeft:
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
break;
default:
break;
}
int bsx = 0;
int bsy = 0;
if (option->state & State_Sunken) {
bsx = pixelMetric(PM_ButtonShiftHorizontal);
bsy = pixelMetric(PM_ButtonShiftVertical);
}
QRect bounds = a.boundingRect();
int sx = sqsize / 2 - bounds.center().x() - 1;
int sy = sqsize / 2 - bounds.center().y() - 1;
imagePainter.translate(sx + bsx, sy + bsy);
imagePainter.setPen(option->palette.buttonText().color());
imagePainter.setBrush(option->palette.buttonText());
if (!(option->state & State_Enabled)) {
imagePainter.translate(1, 1);
imagePainter.setBrush(option->palette.light().color());
imagePainter.setPen(option->palette.light().color());
imagePainter.drawPolygon(a);
imagePainter.translate(-1, -1);
imagePainter.setBrush(option->palette.mid().color());
imagePainter.setPen(option->palette.mid().color());
}
imagePainter.drawPolygon(a);
imagePainter.end();
pixmap = QPixmap::fromImage(image);
QPixmapCache::insert(pixmapName, pixmap);
}
int xOffset = r.x() + (r.width() - size)/2;
int yOffset = r.y() + (r.height() - size)/2;
painter->drawPixmap(xOffset, yOffset, pixmap);
}
break;
default: default:
d->style->drawPrimitive(element, option, painter, widget); d->style->drawPrimitive(element, option, painter, widget);
@@ -902,7 +988,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
newBtn.palette = panelPalette(option->palette); newBtn.palette = panelPalette(option->palette);
newBtn.rect = QRect(ir.right() - arrowSize - 1, newBtn.rect = QRect(ir.right() - arrowSize - 1,
ir.height() - arrowSize - 2, arrowSize, arrowSize); ir.height() - arrowSize - 2, arrowSize, arrowSize);
QWindowsStyle::drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
} }
} }
break; break;
@@ -929,7 +1015,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
pal.setBrush(QPalette::All, QPalette::ButtonText, StyleHelper::panelTextColor()); pal.setBrush(QPalette::All, QPalette::ButtonText, StyleHelper::panelTextColor());
arrowOpt.palette = pal; arrowOpt.palette = pal;
QWindowsStyle::drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
painter->restore(); painter->restore();
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 494 B