add a provider for config modules #2

Merged
merged 6 commits into from Dec 12, 2012
View
@@ -13,6 +13,7 @@ providers/Paths.cpp
providers/Shell.cpp
providers/Calculator.cpp
providers/Units.cpp
+providers/ControlModules.cpp
providers/units/units.c
)
qt4_automoc(${Mangonel_SRCS})
View
@@ -5,6 +5,7 @@
Label::Label(QWidget* parent)
{
+ Q_UNUSED(parent);
QFont* font = new QFont();
font->setPointSize(font->pointSize()+6);
this->setFont(*font);
@@ -31,102 +32,102 @@ void Label::appendText(QString text)
QString Label::completion()
{
- return this->completionText;
+ return this->m_completionText;
}
void Label::setCompletion(QString string)
{
- this->completionText = string;
+ this->m_completionText = string;
this->update();
}
QString Label::preEdit()
{
- return this->preEditText;
+ return this->m_preEditText;
}
void Label::setPreEdit(QString preEdit)
{
- this->preEditText = preEdit;
+ this->m_preEditText = preEdit;
this->update();
}
void Label::paintEvent(QPaintEvent*)
{
if (this->text().isEmpty())
return;
- painter = new QPainter(this);
- painter->setFont(this->font());
- Backpen.setBrush(QBrush());
- Frontpen.setBrush(QBrush());
- preEditPen.setBrush(QBrush());
- preEditPen.setColor(Plasma::Theme().color(Plasma::Theme::HighlightColor));
+ m_painter = new QPainter(this);
+ m_painter->setFont(this->font());
+ m_backPen.setBrush(QBrush());
+ m_frontPen.setBrush(QBrush());
+ m_preEditPen.setBrush(QBrush());
+ m_preEditPen.setColor(Plasma::Theme().color(Plasma::Theme::HighlightColor));
QColor color = Plasma::Theme().color(Plasma::Theme::TextColor);
- Frontpen.setColor(color);
+ m_frontPen.setColor(color);
color.setAlpha(100);
- Backpen.setColor(color);
+ m_backPen.setColor(color);
int lFront = this->text().length();
- int lBack = this->completionText.length();
- position = this->contentsRect().width()/2;
+ int lBack = this->m_completionText.length();
+ m_position = this->contentsRect().width()/2;
int length = QFontMetrics(this->font()).width(this->text());
bool drawComletion = false;
- int offset = this->completionText.indexOf(this->text(), 0, Qt::CaseInsensitive);
- position -= length/2;
+ int offset = this->m_completionText.indexOf(this->text(), 0, Qt::CaseInsensitive);
+ m_position -= length/2;
int advance;
if (length >= this->contentsRect().width()-60)
- position = -(length-this->width()+30);
+ m_position = -(length-this->width()+30);
if (offset >= 0)
{
drawComletion = true;
- position -= QFontMetrics(this->font()).width(this->completionText.left(offset));
+ m_position -= QFontMetrics(this->font()).width(this->m_completionText.left(offset));
}
else
{
offset = 0;
}
- Backpen = makeGradient(Backpen);
- Frontpen = makeGradient(Frontpen);
+ m_backPen = makeGradient(m_backPen);
+ m_frontPen = makeGradient(m_frontPen);
for (int index = 0; index < max(lFront, lBack); index++)
{
QChar ch;
if (drawComletion)
{
- ch = this->completionText.at(index);
+ ch = this->m_completionText.at(index);
if (index-offset < 0 or index-offset >= lFront)
- advance = paintText(ch, Backpen);
+ advance = paintText(ch, m_backPen);
else
- advance = paintText(ch, Frontpen);
+ advance = paintText(ch, m_frontPen);
}
else
{
if (index-offset >= lFront)
break;
ch = this->text().at(index);
- advance = paintText(ch, Frontpen);
+ advance = paintText(ch, m_frontPen);
}
- if (!preEditText.isEmpty())
+ if (!m_preEditText.isEmpty())
{
- if (index-lFront > 0 and index-lFront < this->preEditText.length())
+ if (index-lFront > 0 and index-lFront < this->m_preEditText.length())
{
- ch = this->preEditText.at(index-lFront);
- paintText(ch, preEditPen);
+ ch = this->m_preEditText.at(index-lFront);
+ paintText(ch, m_preEditPen);
}
}
- position += advance;
+ m_position += advance;
}
- delete painter;
- painter = 0;
+ delete m_painter;
+ m_painter = 0;
}
int Label::paintText(QChar ch, QPen pen)
{
int width = QFontMetrics(this->font()).width(ch);
- if (position+width >= 0 and position <= this->contentsRect().width())
+ if (m_position+width >= 0 and m_position <= this->contentsRect().width())
{
- painter->setPen(pen);
+ m_painter->setPen(pen);
QRect rect = this->contentsRect();
- rect.setLeft(position);
- painter->drawText(rect, QString(ch));
+ rect.setLeft(m_position);
+ m_painter->drawText(rect, QString(ch));
}
return width;
}
View
@@ -9,7 +9,7 @@
class Label : public QLabel
{
Q_OBJECT
- enum side {left, right, both};
+
public:
Label(QWidget* parent = 0);
~Label();
@@ -20,18 +20,22 @@ class Label : public QLabel
QString preEdit();
void setPreEdit(QString preEdit);
void paintEvent(QPaintEvent*);
+
+signals:
+ void textChanged(QString text);
+
private:
- QString completionText;
- QString preEditText;
- QPen Frontpen;
- QPen Backpen;
- QPen preEditPen;
- int position;
- QPainter* painter;
int paintText(QChar ch, QPen pen);
QPen makeGradient(QPen pen);
-signals:
- void textChanged(QString text);
+
+ QString m_completionText;
+ QString m_preEditText;
+ QPen m_frontPen;
+ QPen m_backPen;
+ QPen m_preEditPen;
+ int m_position;
+ QPainter* m_painter;
+
};
namespace
Oops, something went wrong.