diff --git a/Skin.cpp b/Skin.cpp index feb7d10..5e97c93 100644 --- a/Skin.cpp +++ b/Skin.cpp @@ -3,11 +3,12 @@ Skin::Skin (string m_skinname) : m_skinname (m_skinname) { - m_path = QString ("./CleanAMP/"); + m_path = QString ("./Debian/"); m_items = new QHash; m_volume_bar = new QHash; m_balance = new QHash; + m_pledit_txt = new QHash; BuildLetterMap(); BuildButtons(); @@ -15,6 +16,7 @@ Skin::Skin (string m_skinname) : m_skinname (m_skinname) BuildSliders(); BuildOther(); BuildTitleBar(); + ParsePLEdit(); } @@ -22,6 +24,44 @@ Skin::~Skin () { } +void +Skin::ParsePLEdit (void) +{ + QDir dir; + QString path; + + dir.setPath (m_path); + dir.setFilter (QDir::Files); + + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) { + QFileInfo fileInfo = list.at(i); + if (fileInfo.fileName().toLower() == "pledit.txt") { + path += fileInfo.filePath (); + break; + } + } + + if (path.isNull ()) { + qDebug ("trasigt!"); + return; + } + + QFile file (path); + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return; + + while (!file.atEnd ()) { + QByteArray line = file.readLine (); + QList l = line.split ('='); + if (l.count () == 2) { + m_pledit_txt->insert (l[0].toLower (), l[1].trimmed()); + } + } + +} + QPixmap *Skin::GetPixmap (string file) { /* check for files in zip and check if file exists */ diff --git a/Skin.h b/Skin.h index fac864d..f550901 100644 --- a/Skin.h +++ b/Skin.h @@ -17,20 +17,22 @@ class Skin : public QWidget public: Skin(string m_skinname); ~Skin(); + QPixmap *Pixmap (string file); void Parse (string file); - QPixmap *Skin::GetPixmap (string file); void BuildLetterMap (void); void BuildButtons (void); void BuildToggleButtons (void); void BuildTitleBar (void); void BuildSliders (void); void BuildOther (void); + void Skin::ParsePLEdit (void); const QPixmap getItem (uint part) const { return m_items->value(part); } const QPixmap getVol (uint p) const { return m_volume_bar->value(p); } const QPixmap getBal (uint p) const { return m_balance->value(p); } - const QPixmap getLetter (uint c) { return m_letterMap->value(c); } + const QPixmap getLetter (uint c) const { return m_letterMap->value(c); } + const QByteArray getPLeditValue (QByteArray c) const { return m_pledit_txt->value(c); } enum Volume { VOLUMEBAR_POS_MIN, @@ -150,6 +152,7 @@ class Skin : public QWidget TEXTBG }; private: + QPixmap *Skin::GetPixmap (string file); string m_skinname; QString m_path; @@ -194,6 +197,7 @@ class Skin : public QWidget QHash *m_letterMap; QHash *m_volume_bar; QHash *m_balance; + QHash *m_pledit_txt; QList m_buttons; }; diff --git a/TextBar.cpp b/TextBar.cpp index c106f16..99e83f2 100644 --- a/TextBar.cpp +++ b/TextBar.cpp @@ -33,9 +33,9 @@ TextScroller::TextScroller (QWidget *parent, uint w, uint h) : QWidget (parent) setAutoFillBackground (true); - setText (QString::fromUtf8 ("Promoe 0.1")); + //setText (QString::fromUtf8 ("Promoe 0.1")); - //setText (QString::fromUtf8 ("Okerueu etuoduå öästö åntöå dS !! !¤ ¤ % % & & ¤")); + setText (QString::fromUtf8 ("Okerueu etuoduå öästö åntöå dS !! !¤ ¤ % % & & ¤")); } @@ -59,7 +59,7 @@ TextScroller::addOffset () void TextScroller::setText (const QString &text) { - drawBitmapFont (text); + drawQtFont (text); } void @@ -100,6 +100,40 @@ TextScroller::drawBitmapFont (const QString &text) void TextScroller::drawQtFont (const QString &text) { + QFont font(m_skin->getPLeditValue ("font")); + font.setPointSize (6); + + QFontMetrics fM(font); + QRect rect = fM.boundingRect (text); + + QString (temp) = text; + + if (rect.width() > m_w) { + temp += QString::fromAscii (" -- "); + QRect rect = fM.boundingRect (temp); + m_timer->start (40); + m_x2_off = m_w / 2; + + m_pixmap = QPixmap (rect.width(), m_h); + } else { + m_pixmap = QPixmap (m_w, m_h); + } + + QPainter paint; + paint.begin (&m_pixmap); + paint.drawPixmap (m_pixmap.rect (), + m_skin->getItem (Skin::TEXTBG), + m_skin->getItem (Skin::TEXTBG).rect ()); + + paint.setFont (font); + QColor c; + c.setNamedColor (m_skin->getPLeditValue ("normal")); + paint.setPen (c); + paint.drawText (m_pixmap.rect (), + Qt::AlignLeft | Qt::AlignVCenter, + temp); + paint.end (); + } void