diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-11-10 10:34:02 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-12-23 11:46:08 (GMT) |
commit | fd69376ab41d443d854fe26367dc027dd490d96b (patch) | |
tree | 8c786e791f61bb949f546243ef5c419a0f241a5a /Swift/QtUI | |
parent | eac8b0d41d9ba7609a22f0d84fabc488872cc547 (diff) | |
download | swift-fd69376ab41d443d854fe26367dc027dd490d96b.zip swift-fd69376ab41d443d854fe26367dc027dd490d96b.tar.bz2 |
Bundle a bare set of emoticons with Swift.
Change-Id: I6b5bc58558a94b5d3939171ebf5d318a067c8b3d
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 20 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/Swift.qrc | 9 |
3 files changed, 23 insertions, 8 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 57386d4..944656d 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -103,10 +103,11 @@ XMLSettingsProvider* QtSwift::loadSettingsFile(const QString& fileName) { return new XMLSettingsProvider(""); } -QMap<QString, QString> QtSwift::loadEmoticonsFile(const QString& fileName) { - QMap<QString, QString> emoticons; +void QtSwift::loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons) { + qDebug() << "Trying to load " << fileName; QFile file(fileName); if (file.exists() && file.open(QIODevice::ReadOnly)) { + qDebug() << "Success"; while (!file.atEnd()) { QString line = file.readLine(); line.replace("\n", ""); @@ -114,13 +115,16 @@ QMap<QString, QString> QtSwift::loadEmoticonsFile(const QString& fileName) { qDebug() << "Parsing line : " << line; QStringList tokens = line.split(" "); if (tokens.size() == 2) { - emoticons[tokens[0]] = "file://" + tokens[1]; - qDebug() << "Adding mapping from " << tokens[0] << " to " << tokens[1]; + QString emoticonFile = tokens[1]; + if (!emoticonFile.startsWith(":/") && !emoticonFile.startsWith("qrc:/")) { + emoticonFile = "file://" + emoticonFile; + } + emoticons[tokens[0]] = emoticonFile; + qDebug() << "Adding mapping from " << tokens[0] << " to " << emoticonFile; } } } - - return emoticons; + qDebug() << "Done"; } QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL), idleDetector_(&idleQuerier_, networkFactories_.getTimerFactory(), 1000) { @@ -135,7 +139,9 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa settingsHierachy_->addProviderToTopOfStack(xmlSettings_); settingsHierachy_->addProviderToTopOfStack(qtSettings_); - QMap<QString, QString> emoticons = loadEmoticonsFile(P2QSTRING((Paths::getExecutablePath() / "emoticons.txt").string())); + QMap<QString, QString> emoticons; + loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons); + loadEmoticonsFile(P2QSTRING((Paths::getExecutablePath() / "emoticons.txt").string()), emoticons); if (options.count("netbook-mode")) { splitter_ = new QtSingleWindow(qtSettings_); diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 94b0648..216527d 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -61,7 +61,7 @@ namespace Swift { ~QtSwift(); private: XMLSettingsProvider* loadSettingsFile(const QString& fileName); - QMap<QString, QString> loadEmoticonsFile(const QString& fileName); + void loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons); private: QtEventLoop clientMainThreadCaller_; PlatformTLSFactories tlsFactories_; diff --git a/Swift/QtUI/Swift.qrc b/Swift/QtUI/Swift.qrc index eb4f7ee..39201da 100644 --- a/Swift/QtUI/Swift.qrc +++ b/Swift/QtUI/Swift.qrc @@ -29,5 +29,14 @@ <file alias="icons/polygon.png">../resources/icons/polygon.png</file> <file alias="icons/cursor.png">../resources/icons/cursor.png</file> <file alias="icons/eraser.png">../resources/icons/eraser.png</file> + <file alias="emoticons/emoticons.txt">../resources/emoticons/emoticons.txt</file> + <file alias="emoticons/evilgrin.png">../resources/emoticons/evilgrin.png</file> + <file alias="emoticons/grin.png">../resources/emoticons/grin.png</file> + <file alias="emoticons/happy.png">../resources/emoticons/happy.png</file> + <file alias="emoticons/smile.png">../resources/emoticons/smile.png</file> + <file alias="emoticons/surprised.png">../resources/emoticons/surprised.png</file> + <file alias="emoticons/tongue.png">../resources/emoticons/tongue.png</file> + <file alias="emoticons/unhappy.png">../resources/emoticons/unhappy.png</file> + <file alias="emoticons/wink.png">../resources/emoticons/wink.png</file> </qresource> </RCC> |