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

Merge branch 'pr419'

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-10-16 14:05:05 +02:00
commit d96ef1a970
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
4 changed files with 93 additions and 5 deletions

View File

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

View File

@ -38,6 +38,7 @@ GeneralForm::GeneralForm() :
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
} }
bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack())); bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack()));
reloadSmiles();
bodyUI->cbUDPDisabled->setChecked(Settings::getInstance().getForceTCP()); bodyUI->cbUDPDisabled->setChecked(Settings::getInstance().getForceTCP());
bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr()); bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr());
@ -89,6 +90,7 @@ void GeneralForm::onSmileyBrowserIndexChanged(int index)
{ {
QString filename = bodyUI->smileyPackBrowser->itemData(index).toString(); QString filename = bodyUI->smileyPackBrowser->itemData(index).toString();
Settings::getInstance().setSmileyPack(filename); Settings::getInstance().setSmileyPack(filename);
reloadSmiles();
} }
void GeneralForm::onUDPUpdated() void GeneralForm::onUDPUpdated()
@ -119,3 +121,26 @@ void GeneralForm::onUseProxyUpdated()
bodyUI->proxyPort->setEnabled(state); bodyUI->proxyPort->setEnabled(state);
Settings::getInstance().setUseProxy(state); Settings::getInstance().setUseProxy(state);
} }
void GeneralForm::reloadSmiles()
{
QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons();
QStringList smiles;
smiles << ":)" << ";)" << ":p" << ":O" << ":["; //just in case...
for(int i = 0; i < emoticons.size(); i++)
smiles.push_front(emoticons.at(i).first());
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

@ -45,6 +45,7 @@ private slots:
private: private:
Ui::GeneralSettings *bodyUI; Ui::GeneralSettings *bodyUI;
void reloadSmiles();
}; };
#endif #endif

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>527</width> <width>527</width>
<height>369</height> <height>421</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -72,6 +72,60 @@
<item> <item>
<widget class="QComboBox" name="smileyPackBrowser"/> <widget class="QComboBox" name="smileyPackBrowser"/>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="smile1">
<property name="toolTip">
<string>:)</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smile2">
<property name="toolTip">
<string>;)</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smile3">
<property name="toolTip">
<string>:p</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smile4">
<property name="toolTip">
<string>:O</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="smile5">
<property name="toolTip">
<string>:'(</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>