[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeartwork/styles/phase
From:       David Johnson <david () usermode ! org>
Date:       2009-01-05 0:32:05
Message-ID: 1231115525.672325.12018.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 905764 by brandybuck:

improve mdi window titlebar


 M  +106 -87   phasestyle.cpp  


--- trunk/KDE/kdeartwork/styles/phase/phasestyle.cpp #905763:905764
@@ -1465,6 +1465,14 @@
               break;
           }
 
+          // set pen for text and icons
+          if (enabled) {
+              painter->setPen(active ? pal.highlightedText().color() :
+                              pal.windowText().color());
+          } else {
+              painter->setPen(pal.mid().color());
+          }
+
           // draw icon
           if (!mi->icon.isNull() && !checked) {
               QIcon::Mode mode;
@@ -1502,13 +1510,6 @@
           QRect trect(xp, y+ITEMVMARGIN, tw, h - 2 * ITEMVMARGIN);
           vrect = visualRect(option->direction, rect, trect);
 
-          if (enabled) {
-              painter->setPen(active ? pal.highlightedText().color() :
-                              pal.windowText().color());
-          } else {
-              painter->setPen(pal.mid().color());
-          }
-
           if (!text.isEmpty()) { // draw label
               painter->save();
 
@@ -2134,33 +2135,39 @@
           title = qstyleoption_cast<const QStyleOptionTitleBar*>(option);
           if (!title) break;
 
-          // draw titlebar frame
-          drawPhaseGradient(painter, rect, pal.highlight().color(),
-                            false, rect.size(), false);
+          bool shaded = (title->titleBarState & Qt::WindowMinimized);
 
           int x2 = rect.right();
           int y2 = rect.bottom();
 
+          // draw titlebar frame
+          drawPhaseGradient(painter, rect.adjusted(0,0,0,-3),
+                            pal.highlight().color(),
+                            false, rect.size(), false);
+
           painter->setPen(pal.shadow().color());
           painter->drawLine(x, y, x, y2);
           painter->drawLine(x, y, x2, y);
           painter->drawLine(x2, y, x2, y2);
-
-          if (!(title->titleBarState & Qt::WindowMinimized))
-              painter->setPen(pal.dark().color());
-          painter->drawLine(x+1, y2, x2-1, y2);
-
-          painter->setPen(pal.highlight().color().lighter(110));
+          painter->setPen(pal.midlight().color());
           painter->drawLine(x+1, y+1, x2-2, y+1);
-          painter->drawLine(x+1, y+2, x+1, y2-2);
-
-          painter->setPen(pal.highlight().color().darker(120));
-          painter->drawLine(x+2, y2-1, x2-1, y2-1);
-          painter->drawLine(x2-1, y+2, x2-1, y2-2);
-
-          painter->setPen(pal.highlight().color());
-          painter->drawPoint(x+1, y2-1);
+          painter->drawLine(x+1, y+2, x+1, y2);
+          painter->setPen(pal.mid().color());
+          painter->drawLine(x2-1, y+2, x2-1, y2);
+          painter->setPen(pal.window().color());
+          painter->drawLine(x+2, y+2, x2-2, y+2);
+          painter->drawLine(x+2, y+2, x+2, y2);
+          painter->drawLine(x2-2, y+2, x2-2, y2);
           painter->drawPoint(x2-1, y+1);
+          if (shaded) {
+              painter->setPen(pal.shadow().color());
+              painter->drawLine(x, y2, x2, y2);
+              painter->setPen(pal.mid().color());
+              painter->drawLine(x+2, y2-1, x2-1, y2-1);
+              painter->setPen(pal.window().color());
+              painter->drawLine(x+2, y2-2, x2-2, y2-2);
+              painter->drawPoint(x+1, y2-1);
+          }
 
           // draw label
           if (title->subControls & SC_TitleBarLabel) {
@@ -2170,13 +2177,13 @@
               QFont font = painter->font();
               font.setBold(true);
               painter->setFont(font);
-              painter->setPen(pal.text().color());
-              painter->drawText(subrect.adjusted(1, 1, 1, 1),
-                                Qt::AlignCenter | Qt::TextSingleLine,
-                                title->text);
-              painter->setPen(pal.highlightedText().color());
-              painter->drawText(subrect,  Qt::AlignCenter | Qt::TextSingleLine,
-                                title->text);
+
+              drawItemText(painter, subrect,
+                           Qt::AlignCenter |
+                           Qt::TextShowMnemonic |
+                           Qt::TextSingleLine,
+                           pal, enabled, title->text,
+                           QPalette::HighlightedText);
           }
 
           // draw buttons
@@ -2184,11 +2191,11 @@
           bool down;
           QStyleOption tool(*title);
 
-          painter->save();
-          painter->setPen(pal.text().color());
+          painter->setPen(pal.windowText().color());
 
+          // menu/icon button
           if ((title->subControls & SC_TitleBarSysMenu) &&
-              (title->titleBarFlags & Qt::WindowSystemMenuHint)){
+              (title->titleBarFlags & Qt::WindowSystemMenuHint)) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarSysMenu, widget);
                 if (!title->icon.isNull()) {
@@ -2203,56 +2210,60 @@
 
                     if (down) painter->translate(1, 1);
                     drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                    if (down) painter->translate(-1, -1);
                 }
           }
 
           if (title->subControls & SC_TitleBarCloseButton) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarCloseButton, widget);
-
-              down = ((title->activeSubControls & SC_TitleBarCloseButton)
-                      && (flags & State_Sunken));
-              if ((title->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool
-                  || qobject_cast<const QDockWidget *>(widget))
-                  pix = standardPixmap(SP_DockWidgetCloseButton, &tool, widget);
-              else
+              if (!subrect.isNull()) {
+                  down = ((title->activeSubControls & SC_TitleBarCloseButton)
+                          && (flags & State_Sunken));
                   pix = standardPixmap(SP_TitleBarCloseButton, &tool, widget);
-              tool.rect = subrect;
-              tool.state = down ? State_Sunken : State_Raised;
-              drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
+                  tool.rect = subrect;
+                  tool.state = down ? State_Sunken : State_Raised;
+                  drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
-              if (down) painter->translate(1, 1);
-              drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(1, 1);
+                  drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(-1, -1);
+              }
           }
 
           if (title->subControls & SC_TitleBarMinButton) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarMinButton, widget);
-              down = ((title->activeSubControls & SC_TitleBarMinButton)
-                      && (flags & State_Sunken));
-              pix = standardPixmap(SP_TitleBarMinButton, &tool, widget);
-              tool.rect = subrect;
-              tool.state = down ? State_Sunken : State_Raised;
-              drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
+              if (!subrect.isNull()) {
+                  down = ((title->activeSubControls & SC_TitleBarMinButton)
+                          && (flags & State_Sunken));
+                  pix = standardPixmap(SP_TitleBarMinButton, &tool, widget);
+                  tool.rect = subrect;
+                  tool.state = down ? State_Sunken : State_Raised;
+                  drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
-              if (down) painter->translate(1, 1);
-              drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(1, 1);
+                  drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(-1, -1);
+              }
           }
 
           if ((title->subControls & SC_TitleBarMaxButton) &&
               (title->titleBarFlags & Qt::WindowMaximizeButtonHint)) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarMaxButton, widget);
+              if (!subrect.isNull()) {
+                  down = ((title->activeSubControls & SC_TitleBarMaxButton) &&
+                          (flags & State_Sunken));
+                  pix = standardPixmap(SP_TitleBarMaxButton, &tool, widget);
+                  tool.rect = subrect;
+                  tool.state = down ? State_Sunken : State_Raised;
+                  drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
-              down = ((title->activeSubControls & SC_TitleBarMaxButton) &&
-                      (flags & State_Sunken));
-              pix = standardPixmap(SP_TitleBarMaxButton, &tool, widget);
-              tool.rect = subrect;
-              tool.state = down ? State_Sunken : State_Raised;
-              drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
-
-              if (down) painter->translate(1, 1);
-              drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(1, 1);
+                  drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(-1, -1);
+              }
           }
 
           if ((title->subControls & SC_TitleBarNormalButton) &&
@@ -2262,31 +2273,37 @@
                 (title->titleBarState & Qt::WindowMaximized)))) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarNormalButton, widget);
-              down = ((title->activeSubControls & SC_TitleBarNormalButton) &&
-                      (flags & State_Sunken));
-              pix = standardPixmap(SP_TitleBarNormalButton, &tool, widget);
-              tool.rect = subrect;
-              tool.state = down ? State_Sunken : State_Raised;
-              drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
+              if (!subrect.isNull()) {
+                  down = ((title->activeSubControls & SC_TitleBarNormalButton)
+                          && (flags & State_Sunken));
+                  pix = standardPixmap(SP_TitleBarNormalButton, &tool, widget);
+                  tool.rect = subrect;
+                  tool.state = down ? State_Sunken : State_Raised;
+                  drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
-              if (down) painter->translate(1, 1);
-              drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(1, 1);
+                  drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+              }
           }
 
-          if (title->subControls & SC_TitleBarContextHelpButton) {
+          if ((title->subControls & SC_TitleBarContextHelpButton) &&
+              (title->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
               subrect = subControlRect(CC_TitleBar, title,
                                        SC_TitleBarContextHelpButton, widget);
-              down = ((title->activeSubControls & SC_TitleBarContextHelpButton) &&
-                      (flags & State_Sunken));
-              pix = standardPixmap(SP_TitleBarContextHelpButton, &tool, widget);
-              tool.rect = subrect;
-              tool.state = down ? State_Sunken : State_Raised;
-              drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
+              if (!subrect.isNull()) {
+                  down = ((title->activeSubControls & SC_TitleBarContextHelpButton)
+                          && (flags & State_Sunken));
+                  pix = standardPixmap(SP_TitleBarContextHelpButton,
+                                       &tool, widget);
+                  tool.rect = subrect;
+                  tool.state = down ? State_Sunken : State_Raised;
+                  drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
 
-              if (down) painter->translate(1, 1);
-              drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(1, 1);
+                  drawItemPixmap(painter, subrect, Qt::AlignCenter, pix);
+                  if (down) painter->translate(-1, -1);
+              }
           }
-          painter->restore();
 
           break;
       }
@@ -2404,9 +2421,10 @@
           int breadth = qMax(option->rect.width(), option->rect.height());
           return qMax(breadth / 10, 10);
       }
+
       case PM_TitleBarHeight:
           return qMax(widget ? widget->fontMetrics().lineSpacing() :
-                      (option ? option->fontMetrics.lineSpacing() : 0), 20);
+                      (option ? option->fontMetrics.lineSpacing() : 0), 22);
 
       default:
           return QWindowsStyle::pixelMetric(metric, option, widget);
@@ -2676,7 +2694,8 @@
           title = qstyleoption_cast<const QStyleOptionTitleBar*>(option);
           if (!title) break;
 
-          const int button = h - 2*fw;
+          const int wfw = 3; // window frame width
+          const int button = h - 2*wfw;
           const int delta = button + fw;
           int offset = 0;
 
@@ -2689,14 +2708,14 @@
                 if (title->titleBarFlags
                     & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
                     if (title->titleBarFlags & Qt::WindowSystemMenuHint)
-                        rect.adjust(delta, 0, -delta, 0);
+                        rect.adjust(delta, 0, 0, 0);
                     if (title->titleBarFlags & Qt::WindowMinimizeButtonHint)
                         rect.adjust(0, 0, -delta, 0);
                     if (title->titleBarFlags & Qt::WindowMaximizeButtonHint)
                         rect.adjust(0, 0, -delta, 0);
                     if (title->titleBarFlags & Qt::WindowContextHelpButtonHint)
                       rect.adjust(0, 0, -delta, 0);
-                    rect.adjust(fw, fw, -fw, -fw);
+                    rect.adjust(wfw, wfw, -wfw, -wfw);
                 }
                 break;
 
@@ -2734,13 +2753,13 @@
                     offset += delta;
                 else if (subcontrol == SC_TitleBarCloseButton)
                     break;
-                rect.setRect(x2 - offset + 1, y + fw,  button, button);
+                rect.setRect(x2 - offset, y + wfw, button, button);
                 break;
 
             // left side buttons
             case SC_TitleBarSysMenu:
                 if (title->titleBarFlags & Qt::WindowSystemMenuHint) {
-                    rect.setRect(x + fw, y + fw, button, button);
+                    rect.setRect(x + wfw, y + wfw, button, button);
                 }
                 break;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic