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(); return conf.titleHeight();
case LM_ButtonWidth: 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: case LM_ButtonHeight:
return conf.buttonHeight(); return conf.buttonHeight();
case LM_ButtonSpacing: case LM_ButtonSpacing:

View File

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

View File

@ -71,6 +71,15 @@ void ThemeConfig::load(KConfig *conf)
m_titleHeight = border.readEntry("TitleHeight", 20); m_titleHeight = border.readEntry("TitleHeight", 20);
m_buttonWidth = border.readEntry("ButtonWidth", 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_buttonHeight = border.readEntry("ButtonHeight", 20);
m_buttonSpacing = border.readEntry("ButtonSpacing", 5); m_buttonSpacing = border.readEntry("ButtonSpacing", 5);
m_buttonMarginTop = border.readEntry("ButtonMarginTop", 0); m_buttonMarginTop = border.readEntry("ButtonMarginTop", 0);

View File

@ -86,6 +86,33 @@ public:
int buttonWidth() const { int buttonWidth() const {
return m_buttonWidth; 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 { int buttonHeight() const {
return m_buttonHeight; return m_buttonHeight;
} }
@ -143,6 +170,15 @@ private:
// buttons // buttons
int m_buttonWidth; 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_buttonHeight;
int m_buttonSpacing; int m_buttonSpacing;
int m_buttonMarginTop; int m_buttonMarginTop;

View File

@ -105,6 +105,15 @@ TitleBorderLeft=5
TitleBorderRight=5 TitleBorderRight=5
TitleHeight=20 TitleHeight=20
ButtonWidth=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 ButtonHeight=20
ButtonSpacing=5 ButtonSpacing=5
ButtonMarginTop=0 ButtonMarginTop=0