summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorSami Merila <sami.merila@nokia.com>2010-03-05 09:48:35 (GMT)
committerSami Merila <sami.merila@nokia.com>2010-03-05 09:48:35 (GMT)
commitd80b0e347bb01d039c0104e857674bb2cf0adc0f (patch)
tree7f8cde7eec68c811e19a3627654d894eff3b93c1 /src/gui/styles
parent5dba125fb953718d8282ff317a6ff34b612bcf45 (diff)
downloadQt-d80b0e347bb01d039c0104e857674bb2cf0adc0f.zip
Qt-d80b0e347bb01d039c0104e857674bb2cf0adc0f.tar.gz
Qt-d80b0e347bb01d039c0104e857674bb2cf0adc0f.tar.bz2
QS60Style ignores widget palette when drawing highlighted widget text
Currently: QS60Style does not polish widgets with highlight colors. Instead it fetches color information from native theme side and uses that color for drawing the text. http://bugreports.qt.nokia.com/browse/QTBUG-8704 Fix: All widgets with highlighted text (lists, tables, headers, tabs, radiobuttons and checkboxes) polish their palette. This palette value is then used in the drawing code. Earlier it was not possible for developers to define their own highlight text color, now it is possible. Task-number: QTBUG-8704 Reviewed-by: Janne Anttila
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 565cc2c..bf5a62e 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -759,13 +759,29 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
QApplication::setPalette(widgetPalette, "QMenuBar");
widgetPalette = *palette;
+ widgetPalette.setColor(QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
+ QApplication::setPalette(widgetPalette, "QMenu");
+ widgetPalette = *palette;
+
widgetPalette.setColor(QPalette::WindowText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0));
QApplication::setPalette(widgetPalette, "QTabBar");
widgetPalette = *palette;
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ QApplication::setPalette(widgetPalette, "QListView");
+ widgetPalette = *palette;
+
widgetPalette.setColor(QPalette::Text,
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
QApplication::setPalette(widgetPalette, "QTableView");
widgetPalette = *palette;
@@ -789,6 +805,8 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
widgetPalette = *palette;
widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
QApplication::setPalette(widgetPalette, "QRadioButton");
QApplication::setPalette(widgetPalette, "QCheckBox");
widgetPalette = *palette;
@@ -1241,6 +1259,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_RadioButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
bool isRadio = (element == CE_RadioButton);
+ QStyleOptionButton subopt = *btn;
+
// Highlight needs to be drawn first, as it goes "underneath" the text and indicator.
if (btn->state & State_HasFocus) {
QStyleOptionFocusRect fropt;
@@ -1248,8 +1268,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
: SE_CheckBoxFocusRect, btn, widget);
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
+
+ subopt.palette.setColor(QPalette::Active, QPalette::WindowText,
+ subopt.palette.highlightedText().color());
}
- QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
: SE_CheckBoxIndicator, btn, widget);
@@ -1408,7 +1430,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
} else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);}
// draw the focus rect
- if (isSelected | hasFocus) {
+ if (isSelected || hasFocus ) {
QRect highlightRect = option->rect.adjusted(1,1,-1,-1);
QAbstractItemView::SelectionBehavior selectionBehavior =
itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems;
@@ -1480,15 +1502,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
// draw the text
if (!voptAdj.text.isEmpty()) {
- if (isSelected) {
- if (qobject_cast<const QTableView *>(widget))
- voptAdj.palette.setColor(
- QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
- else
- voptAdj.palette.setColor(
- QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
- }
- painter->setPen(voptAdj.palette.text().color());
+ if (isSelected || hasFocus )
+ painter->setPen(voptAdj.palette.highlightedText().color());
+ else
+ painter->setPen(voptAdj.palette.text().color());
d->viewItemDrawText(painter, &voptAdj, textRect);
}
painter->restore();
@@ -1590,7 +1607,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const bool selected = optionTab.state & State_Selected;
if (selected)
optionTab.palette.setColor(QPalette::Active, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option));
+ optionTab.palette.highlightedText().color());
const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
|| optionTab.shape == QTabBar::RoundedWest
@@ -1723,7 +1740,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
text_flags |= Qt::TextHideMnemonic;
- if ((option->state & State_Selected) && (option->state & State_Enabled))
+ const bool selected = (option->state & State_Selected) && (option->state & State_Enabled);
+ if (selected)
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
@@ -1793,6 +1811,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
painter->setOpacity(0.5);
}
+ if (selected)
+ optionMenuItem.palette.setColor(
+ QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color());
+
QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
optionMenuItem.text, QPalette::Text);