Support for optional custom button width for each button type in Aurorae.

svn path=/trunk/KDE/kdebase/workspace/; revision=998257
icc-effect-5.14.5
Martin Gräßlin 2009-07-17 09:58:06 +00:00
parent fb96229d06
commit afeea76b4c
5 changed files with 99 additions and 9 deletions

View File

@ -549,7 +549,26 @@ int AuroraeClient::layoutMetric(LayoutMetric lm, bool respectWindowState,
return conf.titleHeight();
case LM_ButtonWidth:
return conf.buttonWidth();
switch (button->type()) {
case MinButton:
return conf.buttonWidthMinimize();
case MaxButton:
return conf.buttonWidthMaximizeRestore();
case CloseButton:
return conf.buttonWidthClose();
case OnAllDesktopsButton:
return conf.buttonWidthAllDesktops();
case AboveButton:
return conf.buttonWidthKeepAbove();
case BelowButton:
return conf.buttonWidthKeepBelow();
case ShadeButton:
return conf.buttonWidthShade();
case MenuButton:
return conf.buttonWidthMenu();
default:
return conf.buttonWidth();
}
case LM_ButtonHeight:
return conf.buttonHeight();
case LM_ButtonSpacing:

View File

@ -294,6 +294,7 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
int buttonHeight = themeConfig->buttonHeight();
foreach (const QChar &character, themeConfig->defaultButtonsLeft()) {
QString buttonName;
int width = buttonWidth;
if (character == '_'){
x += themeConfig->explicitButtonSpacer() + themeConfig->buttonSpacing();
continue;
@ -302,34 +303,42 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
KIcon icon = KIcon( "xorg" );
QSize buttonSize(buttonWidth,buttonHeight);
painter->drawPixmap(QPoint(x,y), icon.pixmap(buttonSize));
x += buttonWidth;
x += themeConfig->buttonWidthMenu();
}
else if (character == 'S') {
buttonName = "alldesktops";
width = themeConfig->buttonWidthAllDesktops();
}
else if (character == 'H') {
buttonName = "help";
width = themeConfig->buttonWidthHelp();
}
else if (character == 'I') {
buttonName = "minimize";
width = themeConfig->buttonWidthMinimize();
}
else if (character == 'A') {
buttonName = "restore";
if (!buttons->contains(buttonName)) {
buttonName = "maximize";
}
width = themeConfig->buttonWidthMaximizeRestore();
}
else if (character == 'X') {
buttonName = "close";
width = themeConfig->buttonWidthClose();
}
else if (character == 'F') {
buttonName = "keepabove";
width = themeConfig->buttonWidthKeepAbove();
}
else if (character == 'B') {
buttonName = "keepbelow";
width = themeConfig->buttonWidthKeepBelow();
}
else if (character == 'L') {
buttonName = "shade";
width = themeConfig->buttonWidthShade();
}
if (!buttonName.isEmpty() && buttons->contains(buttonName)) {
Plasma::FrameSvg *frame = buttons->value(buttonName);
@ -337,9 +346,9 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
if (!active && frame->hasElementPrefix("inactive")) {
frame->setElementPrefix("inactive");
}
frame->resizeFrame(QSize(buttonWidth,buttonHeight));
frame->resizeFrame(QSize(width,buttonHeight));
frame->paintFrame(painter, QPoint(x, y));
x += buttonWidth;
x += width;
}
x += themeConfig->buttonSpacing();
}
@ -348,13 +357,14 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
}
int titleLeft = x;
x = option.rect.right() - rightMargin - themeConfig->paddingRight() - themeConfig->titleEdgeRight() - buttonWidth;
x = option.rect.right() - rightMargin - themeConfig->paddingRight() - themeConfig->titleEdgeRight();
QString rightButtons;
foreach (const QChar &character, themeConfig->defaultButtonsRight()) {
rightButtons.prepend(character);
}
foreach (const QChar &character, rightButtons) {
QString buttonName;
int width = buttonWidth;
if (character == '_'){
x -= themeConfig->explicitButtonSpacer() + themeConfig->buttonSpacing();
continue;
@ -362,35 +372,43 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
else if (character == 'M') {
KIcon icon = KIcon( "xorg" );
QSize buttonSize(buttonWidth,buttonHeight);
x -= themeConfig->buttonWidthMenu();
painter->drawPixmap(QPoint(x,y), icon.pixmap(buttonSize));
x -= buttonWidth;
}
else if (character == 'S') {
buttonName = "alldesktops";
width = themeConfig->buttonWidthAllDesktops();
}
else if (character == 'H') {
buttonName = "help";
width = themeConfig->buttonWidthHelp();
}
else if (character == 'I') {
buttonName = "minimize";
width = themeConfig->buttonWidthMinimize();
}
else if (character == 'A') {
buttonName = "restore";
if (!buttons->contains(buttonName)) {
buttonName = "maximize";
}
width = themeConfig->buttonWidthMaximizeRestore();
}
else if (character == 'X') {
buttonName = "close";
width = themeConfig->buttonWidthClose();
}
else if (character == 'F') {
buttonName = "keepabove";
width = themeConfig->buttonWidthKeepAbove();
}
else if (character == 'B') {
buttonName = "keepbelow";
width = themeConfig->buttonWidthKeepBelow();
}
else if (character == 'L') {
buttonName = "shade";
width = themeConfig->buttonWidthShade();
}
if (!buttonName.isEmpty() && buttons->contains(buttonName)) {
Plasma::FrameSvg *frame = buttons->value(buttonName);
@ -398,13 +416,12 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption
if (!active && frame->hasElementPrefix("inactive")) {
frame->setElementPrefix("inactive");
}
frame->resizeFrame(QSize(buttonWidth,buttonHeight));
frame->resizeFrame(QSize(width,buttonHeight));
x -= width;
frame->paintFrame(painter, QPoint(x, y));
x -= buttonWidth;
}
x -= themeConfig->buttonSpacing();
}
x += buttonWidth;
if (!rightButtons.isEmpty()){
x += themeConfig->buttonSpacing();
}

View File

@ -71,6 +71,15 @@ void ThemeConfig::load(KConfig *conf)
m_titleHeight = border.readEntry("TitleHeight", 20);
m_buttonWidth = border.readEntry("ButtonWidth", 20);
m_buttonWidthMinimize = border.readEntry("ButtonWidthMinimize", m_buttonWidth);
m_buttonWidthMaximizeRestore = border.readEntry("ButtonWidthMaximizeRestore", m_buttonWidth);
m_buttonWidthClose = border.readEntry("ButtonWidthClose", m_buttonWidth);
m_buttonWidthAllDesktops = border.readEntry("ButtonWidthAlldesktops", m_buttonWidth);
m_buttonWidthKeepAbove = border.readEntry("ButtonWidthKeepabove", m_buttonWidth);
m_buttonWidthKeepBelow = border.readEntry("ButtonWidthKeepbelow", m_buttonWidth);
m_buttonWidthShade = border.readEntry("ButtonWidthShade", m_buttonWidth);
m_buttonWidthHelp = border.readEntry("ButtonWidthHelp", m_buttonWidth);
m_buttonWidthMenu = border.readEntry("ButtonWidthMenu", m_buttonWidth);
m_buttonHeight = border.readEntry("ButtonHeight", 20);
m_buttonSpacing = border.readEntry("ButtonSpacing", 5);
m_buttonMarginTop = border.readEntry("ButtonMarginTop", 0);

View File

@ -86,6 +86,33 @@ public:
int buttonWidth() const {
return m_buttonWidth;
}
int buttonWidthMinimize() const {
return m_buttonWidthMinimize;
}
int buttonWidthMaximizeRestore() const {
return m_buttonWidthMaximizeRestore;
}
int buttonWidthClose() const {
return m_buttonWidthClose;
}
int buttonWidthAllDesktops() const {
return m_buttonWidthAllDesktops;
}
int buttonWidthKeepAbove() const {
return m_buttonWidthKeepAbove;
}
int buttonWidthKeepBelow() const {
return m_buttonWidthKeepBelow;
}
int buttonWidthShade() const {
return m_buttonWidthShade;
}
int buttonWidthHelp() const {
return m_buttonWidthHelp;
}
int buttonWidthMenu() const {
return m_buttonWidthMenu;
}
int buttonHeight() const {
return m_buttonHeight;
}
@ -143,6 +170,15 @@ private:
// buttons
int m_buttonWidth;
int m_buttonWidthMinimize;
int m_buttonWidthMaximizeRestore;
int m_buttonWidthClose;
int m_buttonWidthAllDesktops;
int m_buttonWidthKeepAbove;
int m_buttonWidthKeepBelow;
int m_buttonWidthShade;
int m_buttonWidthHelp;
int m_buttonWidthMenu;
int m_buttonHeight;
int m_buttonSpacing;
int m_buttonMarginTop;

View File

@ -105,6 +105,15 @@ TitleBorderLeft=5
TitleBorderRight=5
TitleHeight=20
ButtonWidth=20
ButtonWidthMinimize=? # optional - default depends on ButtonWidth
ButtonWidthMaximizeRestore=? # optional - default depends on ButtonWidth
ButtonWidthClose=? # optional - default depends on ButtonWidth
ButtonWidthAlldesktops=? # optional - default depends on ButtonWidth
ButtonWidthKeepabove=? # optional - default depends on ButtonWidth
ButtonWidthKeepbelow=? # optional - default depends on ButtonWidth
ButtonWidthShade=? # optional - default depends on ButtonWidth
ButtonWidthHelp=? # optional - default depends on ButtonWidth
ButtonWidthMenu=? # optional - default depends on ButtonWidth
ButtonHeight=20
ButtonSpacing=5
ButtonMarginTop=0