1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

error handling for missing graphical icons

preview of emoticons based on dynamic list of emoticons, not hardcoded anymore
This commit is contained in:
agilob 2014-10-11 16:53:20 +01:00
parent fc0ed91c74
commit ca3182e281
No known key found for this signature in database
GPG Key ID: 2CACF3EEF598C663
3 changed files with 37 additions and 11 deletions

View File

@ -127,12 +127,21 @@ bool SmileyPack::load(const QString& filename)
{
QString emoticon = stringElement.text();
filenameTable.insert(emoticon, file);
emoticonSet.push_back(emoticon);
cacheSmiley(file); // preload all smileys
QPixmap pm;
pm.loadFromData(getCachedSmiley(emoticon), "PNG");
if(pm.size().width() > 0)
emoticonSet.push_back(emoticon);
stringElement = stringElement.nextSibling().toElement();
}
emoticons.push_back(emoticonSet);
if(emoticonSet.size() > 0)
emoticons.push_back(emoticonSet);
}
// success!
@ -176,7 +185,6 @@ QIcon SmileyPack::getAsIcon(const QString &key)
{
QPixmap pm;
pm.loadFromData(getCachedSmiley(key), "PNG");
return QIcon(pm);
}

View File

@ -124,11 +124,29 @@ void GeneralForm::onUseProxyUpdated()
void GeneralForm::reloadSmiles()
{
QString smiles[] = {":)", ";)", ":p", ":O", ":'("};
QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons();
QStringList smiles;
smiles << ":)" << ";)" << ":p" << ":O" << ":'("; //just in case...
for(int i = 0; i < emoticons.size(); i++)
{
foreach (QString icon, emoticons.at(i)) {
{
smiles.push_front(icon);
}
}
}
int pixSize = 30;
bodyUI->smile1->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[0]).pixmap(pixSize, pixSize));
bodyUI->smile2->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[1]).pixmap(pixSize, pixSize));
bodyUI->smile3->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[2]).pixmap(pixSize, pixSize));
bodyUI->smile4->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[3]).pixmap(pixSize, pixSize));
bodyUI->smile5->setPixmap(SmileyPack::getInstance().getAsIcon(smiles[4]).pixmap(pixSize, pixSize));
bodyUI->smile1->setToolTip(smiles[0]);
bodyUI->smile2->setToolTip(smiles[1]);
bodyUI->smile3->setToolTip(smiles[2]);
bodyUI->smile4->setToolTip(smiles[3]);
bodyUI->smile5->setToolTip(smiles[4]);
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>527</width>
<height>397</height>
<height>421</height>
</rect>
</property>
<property name="windowTitle">
@ -80,7 +80,7 @@
<string>:)</string>
</property>
<property name="text">
<string>:)</string>
<string/>
</property>
</widget>
</item>
@ -90,7 +90,7 @@
<string>;)</string>
</property>
<property name="text">
<string>;)</string>
<string/>
</property>
</widget>
</item>
@ -100,7 +100,7 @@
<string>:p</string>
</property>
<property name="text">
<string>:p</string>
<string/>
</property>
</widget>
</item>
@ -110,7 +110,7 @@
<string>:O</string>
</property>
<property name="text">
<string>:O</string>
<string/>
</property>
</widget>
</item>
@ -120,7 +120,7 @@
<string>:'(</string>
</property>
<property name="text">
<string>:'(</string>
<string/>
</property>
</widget>
</item>