diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-06-01 08:26:46 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2013-08-01 09:22:45 (GMT) |
commit | db698bbb6d8c7e878e2cb997e18e572f3646e11d (patch) | |
tree | 61aa3ff72c64dd8f309a2fe4b31b5b2d3f22f04b /Swift/QtUI | |
parent | b45602bcd36fb9d2e7a22998434e31014f072d33 (diff) | |
download | swift-contrib-db698bbb6d8c7e878e2cb997e18e572f3646e11d.zip swift-contrib-db698bbb6d8c7e878e2cb997e18e572f3646e11d.tar.bz2 |
Refactor chat messages so parsing of links/emoticons happens in controllers.
Change-Id: I07256f23ffbb6520f5063bdfbed9111946c46746
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/ChatSnippet.cpp | 15 | ||||
-rw-r--r-- | Swift/QtUI/ChatSnippet.h | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.cpp | 12 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 93 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 24 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindowFactory.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindowFactory.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 64 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 2 |
9 files changed, 140 insertions, 84 deletions
diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp index 666dd00..3436531 100644 --- a/Swift/QtUI/ChatSnippet.cpp +++ b/Swift/QtUI/ChatSnippet.cpp @@ -5,7 +5,8 @@ */ +#include <Swift/QtUI/ChatSnippet.h> + #include <QFile> -#include "ChatSnippet.h" #include <Swift/QtUI/QtSwiftUtil.h> @@ -45,4 +46,16 @@ QString ChatSnippet::directionToCSS(Direction direction) { } +ChatSnippet::Direction ChatSnippet::getDirection(const ChatWindow::ChatMessage& message) { + boost::shared_ptr<ChatWindow::ChatTextMessagePart> textPart; + std::string text = ""; + foreach (boost::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) { + if ((textPart = boost::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) { + text = textPart->text; + break; + } + } + return getDirection(text); +} + ChatSnippet::Direction ChatSnippet::getDirection(const std::string& message) { return getDirection(P2QSTRING(message)); diff --git a/Swift/QtUI/ChatSnippet.h b/Swift/QtUI/ChatSnippet.h index d43947f..f60d486 100644 --- a/Swift/QtUI/ChatSnippet.h +++ b/Swift/QtUI/ChatSnippet.h @@ -11,5 +11,9 @@ #include <QString> #include <QDateTime> -#include "QtChatTheme.h" + +#include <Swiften/Base/foreach.h> +#include <Swift/Controllers/UIInterfaces/ChatWindow.h> +#include <Swift/QtUI/QtChatTheme.h> + namespace Swift { @@ -49,4 +53,5 @@ namespace Swift { static Direction getDirection(const std::string& message); + static Direction getDirection(const ChatWindow::ChatMessage& message); static Direction getDirection(const QString& message); diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 18c6e91..2536d39 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -129,5 +129,5 @@ void QtChatView::addMessageTop(boost::shared_ptr<ChatSnippet> snippet) { QString sizeString(QString().setNum(size, 'g', 3) + "em"); const QWebElementCollection spans = firstElement_.findAll("span.swift_resizable"); - foreach (QWebElement span, spans) { + Q_FOREACH (QWebElement span, spans) { span.setStyleProperty("font-size", sizeString); } @@ -162,5 +162,5 @@ void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) { QString sizeString(QString().setNum(size, 'g', 3) + "em"); const QWebElementCollection spans = lastElement_.findAll("span.swift_resizable"); - foreach (QWebElement span, spans) { + Q_FOREACH (QWebElement span, spans) { span.setStyleProperty("font-size", sizeString); } @@ -230,5 +230,5 @@ void QtChatView::showEmoticons(bool show) { { const QWebElementCollection spans = document_.findAll("span.swift_emoticon_image"); - foreach (QWebElement span, spans) { + Q_FOREACH (QWebElement span, spans) { span.setStyleProperty("display", show ? "inline" : "none"); } @@ -236,5 +236,5 @@ void QtChatView::showEmoticons(bool show) { { const QWebElementCollection spans = document_.findAll("span.swift_emoticon_text"); - foreach (QWebElement span, spans) { + Q_FOREACH (QWebElement span, spans) { span.setStyleProperty("display", show ? "none" : "inline"); } @@ -325,5 +325,5 @@ void QtChatView::resizeFont(int fontSizeSteps) { //qDebug() << "Setting to " << sizeString; const QWebElementCollection spans = document_.findAll("span.swift_resizable"); - foreach (QWebElement span, spans) { + Q_FOREACH (QWebElement span, spans) { span.setStyleProperty("font-size", sizeString); } @@ -371,5 +371,5 @@ void QtChatView::resetView() { static QWebElement findElementWithID(QWebElement document, QString elementName, QString id) { QWebElementCollection elements = document.findAll(elementName); - foreach(QWebElement element, elements) { + Q_FOREACH(QWebElement element, elements) { if (element.attribute("id") == id) { return element; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 6dde1cc..d81de61 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -69,5 +69,5 @@ const QString QtChatWindow::ButtonMUCInvite = QString("mucinvite"); -QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings, QMap<QString, QString> emoticons) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageKind_(PreviosuMessageWasNone), eventStream_(eventStream), emoticons_(emoticons), blockingState_(BlockingUnsupported) { +QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageKind_(PreviosuMessageWasNone), eventStream_(eventStream), blockingState_(BlockingUnsupported) { settings_ = settings; unreadCount_ = 0; @@ -223,5 +223,5 @@ bool QtChatWindow::appendToPreviousCheck(QtChatWindow::PreviousMessageKind messa } -ChatSnippet::Direction QtChatWindow::getActualDirection(const std::string& message, Direction direction) { +ChatSnippet::Direction QtChatWindow::getActualDirection(const ChatMessage& message, Direction direction) { if (direction == DefaultDirection) { return QCoreApplication::translate("QApplication", "QT_LAYOUT_DIRECTION") == "RTL" ? ChatSnippet::RTL : ChatSnippet::LTR; @@ -498,5 +498,5 @@ void QtChatWindow::updateTitleWithUnreadCount() { std::string QtChatWindow::addMessage( - const std::string& message, + const ChatMessage& message, const std::string& senderName, bool senderIsSelf, @@ -505,8 +505,42 @@ std::string QtChatWindow::addMessage( const boost::posix_time::ptime& time, const HighlightAction& highlight) { - return addMessage(linkimoticonify(message), senderName, senderIsSelf, label, avatarPath, "", time, highlight, ChatSnippet::getDirection(message)); + return addMessage(chatMessageToHTML(message), senderName, senderIsSelf, label, avatarPath, "", time, highlight, ChatSnippet::getDirection(message)); } -QString QtChatWindow::linkimoticonify(const std::string& message) const { +QString QtChatWindow::chatMessageToHTML(const ChatMessage& message) { + QString result; + foreach (boost::shared_ptr<ChatMessagePart> part, message.getParts()) { + boost::shared_ptr<ChatTextMessagePart> textPart; + boost::shared_ptr<ChatURIMessagePart> uriPart; + boost::shared_ptr<ChatEmoticonMessagePart> emoticonPart; + boost::shared_ptr<ChatHighlightingMessagePart> highlightPart; + + if ((textPart = boost::dynamic_pointer_cast<ChatTextMessagePart>(part))) { + QString text = QtUtilities::htmlEscape(P2QSTRING(textPart->text)); + text.replace("\n","<br/>"); + result += text; + continue; + } + if ((uriPart = boost::dynamic_pointer_cast<ChatURIMessagePart>(part))) { + QString uri = QtUtilities::htmlEscape(P2QSTRING(uriPart->target)); + result += "<a href='" + uri + "' >" + uri + "</a>"; + continue; + } + if ((emoticonPart = boost::dynamic_pointer_cast<ChatEmoticonMessagePart>(part))) { + QString textStyle = showEmoticons_ ? "style='display:none'" : ""; + QString imageStyle = showEmoticons_ ? "" : "style='display:none'"; + result += "<span class='swift_emoticon_image' " + imageStyle + "><img src='" + P2QSTRING(emoticonPart->imagePath) + "'/></span><span class='swift_emoticon_text' " + textStyle + ">" + QtUtilities::htmlEscape(P2QSTRING(emoticonPart->alternativeText)) + "</span>"; + continue; + } + if ((highlightPart = boost::dynamic_pointer_cast<ChatHighlightingMessagePart>(part))) { + //FIXME: Maybe do something here. Anything, really. + continue; + } + + } + return result; +} + +/*QString QtChatWindow::linkimoticonify(const std::string& message) const { return linkimoticonify(P2QSTRING(message)); } @@ -516,10 +550,9 @@ QString QtChatWindow::linkimoticonify(const QString& message) const { messageHTML = QtUtilities::htmlEscape(messageHTML); QMapIterator<QString, QString> it(emoticons_); - QString textStyle = showEmoticons_ ? "style='display:none'" : ""; - QString imageStyle = showEmoticons_ ? "" : "style='display:none'"; + if (messageHTML.length() < 500) { while (it.hasNext()) { it.next(); - messageHTML.replace(it.key(), "<span class='swift_emoticon_image' " + imageStyle + "><img src='" + it.value() + "'/></span><span class='swift_emoticon_text' " + textStyle + ">"+it.key() + "</span>"); + messageHTML.replace(it.key(), ); } messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML))); @@ -527,5 +560,5 @@ QString QtChatWindow::linkimoticonify(const QString& message) const { messageHTML.replace("\n","<br/>"); return messageHTML; -} +}*/ QString QtChatWindow::getHighlightSpanStart(const HighlightAction& highlight) { @@ -563,10 +596,10 @@ std::string QtChatWindow::addMessage( htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(label->getDisplayMarking()))); } - QString messageHTML(message); + QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; QString styleSpanEnd = style == "" ? "" : "</span>"; QString highlightSpanStart = highlight.highlightText() ? getHighlightSpanStart(highlight) : ""; QString highlightSpanEnd = highlight.highlightText() ? "</span>" : ""; - htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + messageHTML + highlightSpanEnd + styleSpanEnd + "</span>" ; + htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + message + highlightSpanEnd + styleSpanEnd + "</span>" ; bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf); @@ -624,6 +657,6 @@ int QtChatWindow::getCount() { } -std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight) { - return addMessage(" *" + linkimoticonify(message) + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time, highlight, ChatSnippet::getDirection(message)); +std::string QtChatWindow::addAction(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight) { + return addMessage(" *" + chatMessageToHTML(message) + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time, highlight, ChatSnippet::getDirection(message)); } @@ -803,11 +836,11 @@ void QtChatWindow::handleHTMLButtonClicked(QString id, QString encodedArgument1, } -void QtChatWindow::addErrorMessage(const std::string& errorMessage) { +void QtChatWindow::addErrorMessage(const ChatMessage& errorMessage) { if (isWidgetSelected()) { onAllMessagesRead(); } - QString errorMessageHTML(linkimoticonify(errorMessage)); - errorMessageHTML.replace("\n","<br/>"); + QString errorMessageHTML(chatMessageToHTML(errorMessage)); + messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>("<span class=\"error\">" + errorMessageHTML + "</span>", QDateTime::currentDateTime(), false, theme_, ChatSnippet::getDirection(errorMessage))); @@ -816,10 +849,10 @@ void QtChatWindow::addErrorMessage(const std::string& errorMessage) { } -void QtChatWindow::addSystemMessage(const std::string& message, Direction direction) { +void QtChatWindow::addSystemMessage(const ChatMessage& message, Direction direction) { if (isWidgetSelected()) { onAllMessagesRead(); } - QString messageHTML = linkimoticonify(message); + QString messageHTML = chatMessageToHTML(message); messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, getActualDirection(message, direction))); @@ -827,10 +860,10 @@ void QtChatWindow::addSystemMessage(const std::string& message, Direction direct } -void QtChatWindow::replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) { - replaceMessage(" *" + linkimoticonify(message) + "*", id, time, "font-style:italic ", highlight); +void QtChatWindow::replaceWithAction(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) { + replaceMessage(" *" + chatMessageToHTML(message) + "*", id, time, "font-style:italic ", highlight); } -void QtChatWindow::replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) { - replaceMessage(linkimoticonify(message), id, time, "", highlight); +void QtChatWindow::replaceMessage(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) { + replaceMessage(chatMessageToHTML(message), id, time, "", highlight); } @@ -856,10 +889,10 @@ void QtChatWindow::replaceMessage(const QString& message, const std::string& id, } -void QtChatWindow::addPresenceMessage(const std::string& message, Direction direction) { +void QtChatWindow::addPresenceMessage(const ChatMessage& message, Direction direction) { if (isWidgetSelected()) { onAllMessagesRead(); } - QString messageHTML = linkimoticonify(message); + QString messageHTML = chatMessageToHTML(message); messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, getActualDirection(message, direction))); @@ -933,11 +966,13 @@ void QtChatWindow::dropEvent(QDropEvent *event) { onSendFileRequest(Q2PSTRING(event->mimeData()->urls().at(0).toLocalFile())); } else { - std::string message(Q2PSTRING(tr("Sending of multiple files at once isn't supported at this time."))); + std::string messageText(Q2PSTRING(tr("Sending of multiple files at once isn't supported at this time."))); + ChatMessage message; + message.append(boost::make_shared<ChatTextMessagePart>(messageText)); addSystemMessage(message, DefaultDirection); } } -void QtChatWindow::replaceLastMessage(const std::string& message) { - messageLog_->replaceLastMessage(linkimoticonify(message)); +void QtChatWindow::replaceLastMessage(const ChatMessage& message) { + messageLog_->replaceLastMessage(chatMessageToHTML(message)); } @@ -1067,10 +1102,10 @@ void QtChatWindow::addMUCInvitation(const std::string& senderName, const JID& ji htmlString += QObject::tr("This person may not have really sent this invitation!") + "\n"; } - htmlString = linkimoticonify(htmlString); + htmlString = chatMessageToHTML(ChatMessage(Q2PSTRING(htmlString))); QString id = QString(ButtonMUCInvite + "%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++))); htmlString += "<div id='" + id + "'>" + - buildChatWindowButton(linkimoticonify(tr("Accept Invite")), ButtonMUCInvite, QtUtilities::htmlEscape(P2QSTRING(jid.toString())), QtUtilities::htmlEscape(P2QSTRING(password)), id) + + buildChatWindowButton(chatMessageToHTML(ChatMessage(Q2PSTRING((tr("Accept Invite"))))), ButtonMUCInvite, QtUtilities::htmlEscape(P2QSTRING(jid.toString())), QtUtilities::htmlEscape(P2QSTRING(password)), id) + "</div>"; diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index a9600d4..a29edad 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -88,15 +88,15 @@ namespace Swift { public: - QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings, QMap<QString, QString> emoticons); + QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings); ~QtChatWindow(); - std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight); - std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight); + std::string addMessage(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight); + std::string addAction(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight); - void addSystemMessage(const std::string& message, Direction direction); - void addPresenceMessage(const std::string& message, Direction direction); - void addErrorMessage(const std::string& errorMessage); + void addSystemMessage(const ChatMessage& message, Direction direction); + void addPresenceMessage(const ChatMessage& message, Direction direction); + void addErrorMessage(const ChatMessage& message); - void replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight); - void replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight); + void replaceMessage(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight); + void replaceWithAction(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight); // File transfer related stuff std::string addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes); @@ -123,5 +123,5 @@ namespace Swift { void setTabComplete(TabComplete* completer); int getCount(); - void replaceLastMessage(const std::string& message); + void replaceLastMessage(const ChatMessage& message); void setAckState(const std::string& id, AckState state); @@ -215,7 +215,6 @@ namespace Swift { void handleOccupantSelectionChanged(RosterItem* item); bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf) const; - static ChatSnippet::Direction getActualDirection(const std::string& message, Direction direction); - QString linkimoticonify(const std::string& message) const; - QString linkimoticonify(const QString& message) const; + static ChatSnippet::Direction getActualDirection(const ChatMessage& message, Direction direction); + QString chatMessageToHTML(const ChatMessage& message); QString getHighlightSpanStart(const HighlightAction& highlight); @@ -257,5 +256,4 @@ namespace Swift { SettingsProvider* settings_; std::vector<ChatWindow::RoomAction> availableRoomActions_; - QMap<QString, QString> emoticons_; bool showEmoticons_; QPalette defaultLabelsPalette_; diff --git a/Swift/QtUI/QtChatWindowFactory.cpp b/Swift/QtUI/QtChatWindowFactory.cpp index bc5d7f4..78c04c9 100644 --- a/Swift/QtUI/QtChatWindowFactory.cpp +++ b/Swift/QtUI/QtChatWindowFactory.cpp @@ -22,5 +22,5 @@ static const QString SPLITTER_STATE = "mucSplitterState"; static const QString CHAT_TABS_GEOMETRY = "chatTabsGeometry"; -QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons) : themePath_(themePath), emoticons_(emoticons) { +QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath) : themePath_(themePath) { qtOnlySettings_ = qtSettings; settings_ = settings; @@ -51,5 +51,5 @@ ChatWindow* QtChatWindowFactory::createChatWindow(const JID &contact,UIEventStre } - QtChatWindow *chatWindow = new QtChatWindow(P2QSTRING(contact.toString()), theme_, eventStream, settings_, emoticons_); + QtChatWindow *chatWindow = new QtChatWindow(P2QSTRING(contact.toString()), theme_, eventStream, settings_); connect(chatWindow, SIGNAL(splitterMoved()), this, SLOT(handleSplitterMoved())); connect(this, SIGNAL(changeSplitterState(QByteArray)), chatWindow, SLOT(handleChangeSplitterState(QByteArray))); diff --git a/Swift/QtUI/QtChatWindowFactory.h b/Swift/QtUI/QtChatWindowFactory.h index 89a322f..63da514 100644 --- a/Swift/QtUI/QtChatWindowFactory.h +++ b/Swift/QtUI/QtChatWindowFactory.h @@ -24,5 +24,5 @@ namespace Swift { Q_OBJECT public: - QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons); + QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath); ~QtChatWindowFactory(); ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream); @@ -38,5 +38,4 @@ namespace Swift { QtChatTabs* tabs_; QtChatTheme* theme_; - QMap<QString, QString> emoticons_; }; } diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index b563c53..4d4cef9 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -5,9 +5,12 @@ */ -#include "QtSwift.h" +#include <Swift/QtUI/QtSwift.h> #include <string> -#include <QFile> +#include <map> + #include <boost/bind.hpp> + +#include <QFile> #include <QMessageBox> #include <QApplication> @@ -15,21 +18,17 @@ #include <qdebug.h> -#include <QtLoginWindow.h> -#include <QtChatTabs.h> -#include <QtSystemTray.h> -#include <QtSoundPlayer.h> -#include <QtSwiftUtil.h> -#include <QtUIFactory.h> -#include <QtChatWindowFactory.h> -#include <QtSingleWindow.h> #include <Swiften/Base/Log.h> #include <Swiften/Base/Path.h> -#include <Swift/Controllers/Storages/CertificateFileStorageFactory.h> -#include <Swift/Controllers/Storages/FileStoragesFactory.h> -#include <SwifTools/Application/PlatformApplicationPathProvider.h> -#include <string> #include <Swiften/Base/Platform.h> #include <Swiften/Elements/Presence.h> #include <Swiften/Client/Client.h> +#include <Swiften/Base/Paths.h> + +#include <SwifTools/Application/PlatformApplicationPathProvider.h> +#include <SwifTools/AutoUpdater/AutoUpdater.h> +#include <SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h> + +#include <Swift/Controllers/Storages/CertificateFileStorageFactory.h> +#include <Swift/Controllers/Storages/FileStoragesFactory.h> #include <Swift/Controllers/Settings/XMLSettingsProvider.h> #include <Swift/Controllers/Settings/SettingsProviderHierachy.h> @@ -37,31 +36,37 @@ #include <Swift/Controllers/ApplicationInfo.h> #include <Swift/Controllers/BuildVersion.h> -#include <SwifTools/AutoUpdater/AutoUpdater.h> -#include <SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h> -#include "Swiften/Base/Paths.h" #include <Swift/Controllers/StatusCache.h> +#include <Swift/QtUI/QtLoginWindow.h> +#include <Swift/QtUI/QtChatTabs.h> +#include <Swift/QtUI/QtSystemTray.h> +#include <Swift/QtUI/QtSoundPlayer.h> +#include <Swift/QtUI/QtSwiftUtil.h> +#include <Swift/QtUI/QtUIFactory.h> +#include <Swift/QtUI/QtChatWindowFactory.h> +#include <Swift/QtUI/QtSingleWindow.h> + #if defined(SWIFTEN_PLATFORM_WINDOWS) -#include "WindowsNotifier.h" +#include <Swift/QtUI/WindowsNotifier.h> #elif defined(HAVE_GROWL) -#include "SwifTools/Notifier/GrowlNotifier.h" +#include <SwifTools/Notifier/GrowlNotifier.h> #elif defined(SWIFTEN_PLATFORM_LINUX) -#include "FreeDesktopNotifier.h" +#include <Swift/QtUI/FreeDesktopNotifier.h> #else -#include "SwifTools/Notifier/NullNotifier.h" +#include <SwifTools/Notifier/NullNotifier.h> #endif #if defined(SWIFTEN_PLATFORM_MACOSX) -#include "SwifTools/Dock/MacOSXDock.h" +#include <SwifTools/Dock/MacOSXDock.h> #else -#include "SwifTools/Dock/NullDock.h" +#include <SwifTools/Dock/NullDock.h> #endif #if defined(SWIFTEN_PLATFORM_MACOSX) -#include "QtURIHandler.h" +#include <Swift/QtUI/QtURIHandler.h> #elif defined(SWIFTEN_PLATFORM_WIN32) #include <SwifTools/URIHandler/NullURIHandler.h> #else -#include "QtDBUSURIHandler.h" +#include <Swift/QtUI/QtDBUSURIHandler.h> #endif @@ -105,5 +110,5 @@ XMLSettingsProvider* QtSwift::loadSettingsFile(const QString& fileName) { } -void QtSwift::loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons) { +void QtSwift::loadEmoticonsFile(const QString& fileName, std::map<std::string, std::string>& emoticons) { QFile file(fileName); if (file.exists() && file.open(QIODevice::ReadOnly)) { @@ -118,5 +123,5 @@ void QtSwift::loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticonFile = "file://" + emoticonFile; } - emoticons[tokens[0]] = emoticonFile; + emoticons[Q2PSTRING(tokens[0])] = Q2PSTRING(emoticonFile); } } @@ -136,5 +141,5 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa settingsHierachy_->addProviderToTopOfStack(qtSettings_); - QMap<QString, QString> emoticons; + std::map<std::string, std::string> emoticons; loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons); loadEmoticonsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "emoticons.txt")), emoticons); @@ -163,5 +168,5 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir(), networkFactories_.getCryptoProvider()); certificateStorageFactory_ = new CertificateFileStorageFactory(applicationPathProvider_->getDataDir(), tlsFactories_.getCertificateFactory(), networkFactories_.getCryptoProvider()); - chatWindowFactory_ = new QtChatWindowFactory(splitter_, settingsHierachy_, qtSettings_, tabs_, "", emoticons); + chatWindowFactory_ = new QtChatWindowFactory(splitter_, settingsHierachy_, qtSettings_, tabs_, ""); soundPlayer_ = new QtSoundPlayer(applicationPathProvider_); @@ -221,4 +226,5 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa uriHandler_, &idleDetector_, + emoticons, options.count("latency-debug") > 0); mainControllers_.push_back(mainController); diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 216527d..1ea8886 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -62,5 +62,5 @@ namespace Swift { private: XMLSettingsProvider* loadSettingsFile(const QString& fileName); - void loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons); + void loadEmoticonsFile(const QString& fileName, std::map<std::string, std::string>& emoticons); private: QtEventLoop clientMainThreadCaller_; |