From afeea76b4c979e3ff46b8f0464b9e9e040f774cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 17 Jul 2009 09:58:06 +0000 Subject: [PATCH] Support for optional custom button width for each button type in Aurorae. svn path=/trunk/KDE/kdebase/workspace/; revision=998257 --- clients/aurorae/src/aurorae.cpp | 21 +++++++++++++++- clients/aurorae/src/config/config.cpp | 33 ++++++++++++++++++------ clients/aurorae/src/themeconfig.cpp | 9 +++++++ clients/aurorae/src/themeconfig.h | 36 +++++++++++++++++++++++++++ clients/aurorae/theme-description | 9 +++++++ 5 files changed, 99 insertions(+), 9 deletions(-) diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index b8d7bc4ba3..6af9533bc1 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -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: diff --git a/clients/aurorae/src/config/config.cpp b/clients/aurorae/src/config/config.cpp index b13733dee3..0101edc7ed 100644 --- a/clients/aurorae/src/config/config.cpp +++ b/clients/aurorae/src/config/config.cpp @@ -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(); } diff --git a/clients/aurorae/src/themeconfig.cpp b/clients/aurorae/src/themeconfig.cpp index 75b693fc28..cc5b0f8135 100644 --- a/clients/aurorae/src/themeconfig.cpp +++ b/clients/aurorae/src/themeconfig.cpp @@ -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); diff --git a/clients/aurorae/src/themeconfig.h b/clients/aurorae/src/themeconfig.h index d6e8f1e4a2..73e52f8130 100644 --- a/clients/aurorae/src/themeconfig.h +++ b/clients/aurorae/src/themeconfig.h @@ -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; diff --git a/clients/aurorae/theme-description b/clients/aurorae/theme-description index 54693be016..709882ac49 100644 --- a/clients/aurorae/theme-description +++ b/clients/aurorae/theme-description @@ -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