~ubuntu-sdk-team/ubuntu-ui-toolkit/bottomKeyboard

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/plugin/uclabel.cpp

  • Committer: Tarmac
  • Author(s): Zsombor Egri
  • Date: 2016-01-27 17:49:36 UTC
  • mfrom: (1814.2.23 paleette2)
  • Revision ID: tarmac-20160127174936-3bcz1l7w5wlibq05
Palette fix. Update components to use the palette. Fixes: https://bugs.launchpad.net/bugs/1495477.

Approved by ubuntu-sdk-build-bot, Tim Peeters, Christian Dywan, Zoltan Balogh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
UCLabel::UCLabel(QQuickItem* parent)
80
80
    : QQuickText(parent)
81
81
    , UCThemingExtension(this)
82
 
    , m_textSize(Medium)
83
 
    , m_flags(0)
84
 
{
 
82
    , m_defaultColor(getDefaultColor)
 
83
    , m_textSize(Medium)
 
84
    , m_flags(0)
 
85
{
 
86
}
 
87
 
 
88
UCLabel::UCLabel(std::function<QColor (QQuickItem*, UCTheme*)> defaultColor, QQuickItem *parent)
 
89
    : QQuickText(parent)
 
90
    , UCThemingExtension(this)
 
91
    , m_defaultColor(defaultColor)
 
92
    , m_textSize(Medium)
 
93
    , m_flags(0)
 
94
{
 
95
}
 
96
 
 
97
QColor UCLabel::getDefaultColor(QQuickItem *item, UCTheme *theme)
 
98
{
 
99
    // FIXME: replace the code below with automatic color
 
100
    // change detection based on teh item's state
 
101
    const char *valueSet = item->isEnabled() ? "normal" : "disabled";
 
102
    return theme ? theme->getPaletteColor(valueSet, "backgroundText") : QColor();
85
103
}
86
104
 
87
105
void UCLabel::classBegin()
101
119
 
102
120
    connect(this, &UCLabel::fontChanged, this, &UCLabel::_q_updateFontFlag, Qt::DirectConnection);
103
121
    connect(this, &UCLabel::colorChanged, this, &UCLabel::_q_customColor, Qt::DirectConnection);
 
122
    connect(this, &UCLabel::enabledChanged, this, &UCLabel::postThemeChanged, Qt::DirectConnection);
104
123
}
105
124
 
106
125
void UCLabel::postThemeChanged()
110
129
    }
111
130
    UCTheme *theme = getTheme();
112
131
    if (theme) {
113
 
        setColor(theme->getPaletteColor("normal", "baseText"));
 
132
        setColor(m_defaultColor(this, theme));
114
133
        m_flags &= ~ColorSet;
115
134
    }
116
135
}