[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-01 4:11:30
Message-ID: 1230783090.379708.846.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 903994 by brandybuck:
fix settings; fix combobox drawing; fix button size
M +6 -8 config/phasestyleconfig.cpp
M +94 -31 phasestyle.cpp
M +6 -0 phasestyle.h
--- trunk/KDE/kdeartwork/styles/phase/config/phasestyleconfig.cpp #903993:903994
@@ -29,12 +29,12 @@
setupUi(this);
- QSettings settings;
+ QSettings settings("phasestyle");
oldgradients =
- settings.value("/phasestyle/Settings/gradients", true).toBool();
+ settings.value("/gradients", true).toBool();
gradients->setChecked(oldgradients);
oldhighlights =
- settings.value("/phasestyle/Settings/highlights", true).toBool();
+ settings.value("/highlights", true).toBool();
highlights->setChecked(oldhighlights);
// connections
@@ -78,11 +78,9 @@
void PhaseStyleConfig::save()
{
- QSettings settings;
- settings.setValue("/phasestyle/Settings/gradients",
- gradients->isChecked());
- settings.setValue("/phasestyle/Settings/highlights",
- highlights->isChecked());
+ QSettings settings("phasestyle");
+ settings.setValue("/gradients", gradients->isChecked());
+ settings.setValue("/highlights", highlights->isChecked());
}
//////////////////////////////////////////////////////////////////////////////
--- trunk/KDE/kdeartwork/styles/phase/phasestyle.cpp #903993:903994
@@ -1,3 +1,4 @@
+// -*- indent-tabs-mode: nil -*-
//////////////////////////////////////////////////////////////////////////////
// phasestyle.cpp
// -------------------
@@ -24,6 +25,7 @@
#include <QBitmap>
#include <QCheckBox>
#include <QComboBox>
+#include <QDialogButtonBox>
#include <QDockWidget>
#include <QKeyEvent>
#include <QLinearGradient>
@@ -62,16 +64,17 @@
PhaseStyle::PhaseStyle()
: QWindowsStyle(), gradients_(QPixmap::defaultDepth() > 8), timerid_(0)
{
- // get config
- QSettings settings;
+ // get phasestyle config
+ QSettings settings("phasestyle");
if (gradients_) { // don't bother setting if already false
- gradients_ =
- settings.value("/phasestyle/Settings/gradients", true).toBool();
- contrast_ = 100 + settings.value("/Qt/KDE/contrast", 5).toInt();
+ gradients_ = settings.value("/gradients", true).toBool();
}
- highlights_ =
- settings.value("/phasestyle/Settings/highlights", true).toBool();
+ highlights_ = settings.value("/highlights", true).toBool();
+ // get contrast from KDE configs
+ QSettings kdesettings("Trolltech");
+ contrast_ = 100 + kdesettings.value("/Qt/KDE/contrast", 5).toInt();
+
// create bitmaps
const QSize arrowsz(6, 6);
const QSize btnsz(10, 10);
@@ -337,12 +340,12 @@
// Draw the basic Phase bevel
void PhaseStyle::drawPhaseBevel(QPainter *painter,
- QRect rect,
- const QPalette &pal,
- const QBrush &fill,
- bool sunken,
- bool horizontal,
- bool reverse) const
+ QRect rect,
+ const QPalette &pal,
+ const QBrush &fill,
+ bool sunken,
+ bool horizontal,
+ bool reverse) const
{
int x, y, w, h;
rect.getRect(&x, &y, &w, &h);
@@ -1831,19 +1834,15 @@
subrect = subControlRect(CC_ComboBox, combo,
SC_ComboBoxArrow, widget);
+
if (combo->editable) {
// draw frame
drawPhasePanel(painter, rect, pal, Qt::NoBrush, true);
// draw arrow box
- drawPhaseButton(painter, subrect, pal, mouseover
- ? pal.button().color().lighter(contrast_)
- : pal.button().color(), sunken);
- // finish off frame (because it overlaps)
- painter->setPen(pal.dark().color());
- painter->drawPoint(subrect.x(), subrect.top()+1);
- painter->drawPoint(subrect.x(), subrect.bottom()-1);
- painter->setPen(pal.light().color());
- painter->drawPoint(subrect.x(), subrect.bottom());
+ drawPhaseBevel(painter, subrect.adjusted(-1, -1, 1, 1),
+ pal, mouseover
+ ? pal.button().color().lighter(contrast_)
+ : pal.button().color(), sunken, false);
} else {
// draw bevel
drawPhaseButton(painter, rect, pal, mouseover
@@ -1851,8 +1850,10 @@
: pal.button().color(), sunken);
}
- if (combo->subControls & SC_ComboBoxArrow) { // draw slot
- int slot = qMax(h/4, 6) + (h%2);
+ if (combo->subControls & SC_ComboBoxArrow) {
+ // draw slot
+ int slot = qMax(h/4, 6);
+ slot = qMin(slot, 12) + (h%2);
subrect.adjust(3, 0, -3, 0);
subrect.setTop(subrect.top() + subrect.height()/2 - slot/2);
subrect.setHeight(slot);
@@ -1864,8 +1865,9 @@
if ((flags & State_HasFocus) && !combo->editable) {
QStyleOptionFocusRect focus;
focus.QStyleOption::operator=(*combo);
- focus.rect = subElementRect(SE_ComboBoxFocusRect,
+ subrect = subElementRect(SE_ComboBoxFocusRect,
combo, widget);
+ focus.rect = visualRect(combo->direction, rect, subrect);
drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
}
break;
@@ -1989,7 +1991,7 @@
// avoid aliasing
QPainter::RenderHints oldhints = painter->renderHints();
- painter->setRenderHint(QPainter::Antialiasing, true);
+ painter->setRenderHint(QPainter::Antialiasing, true);
qreal cx = rect.center().x();
qreal cy = rect.center().y();
@@ -2305,8 +2307,11 @@
int ex = qMax(QApplication::fontMetrics().xHeight(), 17);
switch (metric) {
+ case PM_ButtonMargin:
+ return 6;
+
case PM_ButtonDefaultIndicator: // size of default button frame
- return 3;
+ return 3; // half button margin
case PM_IndicatorWidth:
case PM_IndicatorHeight:
@@ -2372,17 +2377,23 @@
const QWidget *widget) const
{
QRect rect;
+ const int fw = 2;
int x, y, w, h;
option->rect.getRect(&x, &y, &w, &h);
switch (element) {
case SE_PushButtonFocusRect:
- case SE_ComboBoxFocusRect:
// adjust rect in one pixel
rect = QWindowsStyle::subElementRect(element, option, widget);
rect.adjust(1,1,-1,-1);
break;
+ case SE_ComboBoxFocusRect: {
+ int bw = qMin(h, 32); // position between edit and arrow
+ rect.setRect(fw*2, fw*2, w-bw-fw-1, h-(fw*4));
+ break;
+ }
+
case SE_ProgressBarContents:
return option->rect.adjusted(3, 3, -3, -3);
@@ -2463,18 +2474,18 @@
combo = qstyleoption_cast<const QStyleOptionComboBox*>(option);
if (!combo) break;
- int bw = h; // position between edit and arrow
+ int bw = qMin(h, 32); // position between edit and arrow
switch (subcontrol) {
case SC_ComboBoxFrame: // total combobox area
rect = ctlrect;
break;
case SC_ComboBoxArrow: // the right side
- rect.setRect(w-bw, 0, bw, h);
+ rect.setRect(w-bw, fw, bw-fw, h-(fw*2));
break;
case SC_ComboBoxEditField: // the left side
- rect.setRect(fw, fw, w-bw-1, h-(fw*2));
+ rect.setRect(fw, fw, w-bw-fw-1, h-(fw*2));
if (!combo->editable) {
// give extra margin
rect.adjust(pixelMetric(PM_ButtonMargin),
@@ -2738,6 +2749,55 @@
}
//////////////////////////////////////////////////////////////////////////////
+// sizeFromContents()
+// ------------------
+// Return size of the element based on content
+
+QSize PhaseStyle::sizeFromContents(ContentsType contentstype,
+ const QStyleOption *option,
+ const QSize &contentssize,
+ const QWidget *widget) const
+{
+ switch (contentstype) {
+ case CT_PushButton: {
+ const QStyleOptionButton *button;
+ button = qstyleoption_cast<const QStyleOptionButton *>(option);
+ QSize size = contentssize;
+ if (button) {
+ int bm = pixelMetric(PM_ButtonMargin, button, widget);
+ int fw = pixelMetric(PM_DefaultFrameWidth, button, widget) * 2;
+ size.rwidth() += bm + fw;
+ size.rheight() += bm + fw;
+
+ if (button->text.isEmpty()) {
+ size = size.expandedTo(QSize(23, 23));
+ } else {
+ size = size.expandedTo(QSize(75, 23));
+ }
+
+ if (button->features & QStyleOptionButton::AutoDefaultButton) {
+ int dbi = pixelMetric(PM_ButtonDefaultIndicator,
+ button,
+ widget);
+ size.rwidth() += dbi*2;
+ // Note: don't expand height
+ }
+
+ }
+ return size;
+ }
+
+ default:
+ return QWindowsStyle::sizeFromContents(contentstype,
+ option,
+ contentssize,
+ widget);
+ }
+
+ return QSize();
+}
+
+//////////////////////////////////////////////////////////////////////////////
// Miscellaneous stuff //
//////////////////////////////////////////////////////////////////////////////
@@ -2766,6 +2826,9 @@
}
return 0;
+ case SH_DialogButtonLayout:
+ return QDialogButtonBox::KdeLayout;
+
// TODO: investigate other hints, including:
// SH_ItemView_ShowDecorationSelected
// SH_ScrollBar_MiddleClickAbsolutePosition
--- trunk/KDE/kdeartwork/styles/phase/phasestyle.h #903993:903994
@@ -1,3 +1,4 @@
+// -*- indent-tabs-mode: nil -*-
//////////////////////////////////////////////////////////////////////////////
// phasestyle.h
// -------------------
@@ -89,6 +90,11 @@
const QWidget *widget = 0,
QStyleHintReturn *data = 0) const;
+ QSize sizeFromContents(ContentsType contentstype,
+ const QStyleOption *option,
+ const QSize &contentssize,
+ const QWidget *widget) const;
+
private:
enum GradientType {
Horizontal,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic