From ca3182e281ac1ad6d7f3811c9a6b79dbf637b28e Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 11 Oct 2014 16:53:20 +0100 Subject: [PATCH] error handling for missing graphical icons preview of emoticons based on dynamic list of emoticons, not hardcoded anymore --- misc/smileypack.cpp | 16 ++++++++++++---- widget/form/settings/generalform.cpp | 20 +++++++++++++++++++- widget/form/settings/generalsettings.ui | 12 ++++++------ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/misc/smileypack.cpp b/misc/smileypack.cpp index 57a754c76..f3230c3ea 100644 --- a/misc/smileypack.cpp +++ b/misc/smileypack.cpp @@ -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); } diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index 5644f3eaf..d471e9614 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -124,11 +124,29 @@ void GeneralForm::onUseProxyUpdated() void GeneralForm::reloadSmiles() { - QString smiles[] = {":)", ";)", ":p", ":O", ":'("}; + QList 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]); } diff --git a/widget/form/settings/generalsettings.ui b/widget/form/settings/generalsettings.ui index 23515cf2e..7086f3afc 100644 --- a/widget/form/settings/generalsettings.ui +++ b/widget/form/settings/generalsettings.ui @@ -7,7 +7,7 @@ 0 0 527 - 397 + 421 @@ -80,7 +80,7 @@ :) - :) + @@ -90,7 +90,7 @@ ;) - ;) + @@ -100,7 +100,7 @@ :p - :p + @@ -110,7 +110,7 @@ :O - :O + @@ -120,7 +120,7 @@ :'( - :'( +