TrueType redering
This commit is contained in:
parent
862bc20776
commit
e66a3f1fa6
3 changed files with 84 additions and 6 deletions
42
Skin.cpp
42
Skin.cpp
|
@ -3,11 +3,12 @@
|
||||||
|
|
||||||
Skin::Skin (string m_skinname) : m_skinname (m_skinname)
|
Skin::Skin (string m_skinname) : m_skinname (m_skinname)
|
||||||
{
|
{
|
||||||
m_path = QString ("./CleanAMP/");
|
m_path = QString ("./Debian/");
|
||||||
|
|
||||||
m_items = new QHash<uint, QPixmap>;
|
m_items = new QHash<uint, QPixmap>;
|
||||||
m_volume_bar = new QHash<uint, QPixmap>;
|
m_volume_bar = new QHash<uint, QPixmap>;
|
||||||
m_balance = new QHash<uint, QPixmap>;
|
m_balance = new QHash<uint, QPixmap>;
|
||||||
|
m_pledit_txt = new QHash<QByteArray, QByteArray>;
|
||||||
|
|
||||||
BuildLetterMap();
|
BuildLetterMap();
|
||||||
BuildButtons();
|
BuildButtons();
|
||||||
|
@ -15,6 +16,7 @@ Skin::Skin (string m_skinname) : m_skinname (m_skinname)
|
||||||
BuildSliders();
|
BuildSliders();
|
||||||
BuildOther();
|
BuildOther();
|
||||||
BuildTitleBar();
|
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<QByteArray> l = line.split ('=');
|
||||||
|
if (l.count () == 2) {
|
||||||
|
m_pledit_txt->insert (l[0].toLower (), l[1].trimmed());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap *Skin::GetPixmap (string file)
|
QPixmap *Skin::GetPixmap (string file)
|
||||||
{
|
{
|
||||||
/* check for files in zip and check if file exists */
|
/* check for files in zip and check if file exists */
|
||||||
|
|
8
Skin.h
8
Skin.h
|
@ -17,20 +17,22 @@ class Skin : public QWidget
|
||||||
public:
|
public:
|
||||||
Skin(string m_skinname);
|
Skin(string m_skinname);
|
||||||
~Skin();
|
~Skin();
|
||||||
|
|
||||||
QPixmap *Pixmap (string file);
|
QPixmap *Pixmap (string file);
|
||||||
void Parse (string file);
|
void Parse (string file);
|
||||||
QPixmap *Skin::GetPixmap (string file);
|
|
||||||
void BuildLetterMap (void);
|
void BuildLetterMap (void);
|
||||||
void BuildButtons (void);
|
void BuildButtons (void);
|
||||||
void BuildToggleButtons (void);
|
void BuildToggleButtons (void);
|
||||||
void BuildTitleBar (void);
|
void BuildTitleBar (void);
|
||||||
void BuildSliders (void);
|
void BuildSliders (void);
|
||||||
void BuildOther (void);
|
void BuildOther (void);
|
||||||
|
void Skin::ParsePLEdit (void);
|
||||||
|
|
||||||
const QPixmap getItem (uint part) const { return m_items->value(part); }
|
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 getVol (uint p) const { return m_volume_bar->value(p); }
|
||||||
const QPixmap getBal (uint p) const { return m_balance->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 {
|
enum Volume {
|
||||||
VOLUMEBAR_POS_MIN,
|
VOLUMEBAR_POS_MIN,
|
||||||
|
@ -150,6 +152,7 @@ class Skin : public QWidget
|
||||||
TEXTBG
|
TEXTBG
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
|
QPixmap *Skin::GetPixmap (string file);
|
||||||
string m_skinname;
|
string m_skinname;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
|
||||||
|
@ -194,6 +197,7 @@ class Skin : public QWidget
|
||||||
QHash<uint, QPixmap> *m_letterMap;
|
QHash<uint, QPixmap> *m_letterMap;
|
||||||
QHash<uint, QPixmap> *m_volume_bar;
|
QHash<uint, QPixmap> *m_volume_bar;
|
||||||
QHash<uint, QPixmap> *m_balance;
|
QHash<uint, QPixmap> *m_balance;
|
||||||
|
QHash<QByteArray, QByteArray> *m_pledit_txt;
|
||||||
QList<QPixmap *> m_buttons;
|
QList<QPixmap *> m_buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
40
TextBar.cpp
40
TextBar.cpp
|
@ -33,9 +33,9 @@ TextScroller::TextScroller (QWidget *parent, uint w, uint h) : QWidget (parent)
|
||||||
|
|
||||||
setAutoFillBackground (true);
|
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
|
void
|
||||||
TextScroller::setText (const QString &text)
|
TextScroller::setText (const QString &text)
|
||||||
{
|
{
|
||||||
drawBitmapFont (text);
|
drawQtFont (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -100,6 +100,40 @@ TextScroller::drawBitmapFont (const QString &text)
|
||||||
void
|
void
|
||||||
TextScroller::drawQtFont (const QString &text)
|
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
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue