diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-01-17 00:17:11 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-01-17 00:20:41 (GMT) |
commit | ed8990c5ee4f54d63e88b6bad28356d0c032a8c3 (patch) | |
tree | ac0ca6f18e4b01c76471d0f4660f8e111bc4fdac /Swift/QtUI | |
parent | 9ece5e827fa308b36f18884487d34e0073870496 (diff) | |
download | swift-ed8990c5ee4f54d63e88b6bad28356d0c032a8c3.zip swift-ed8990c5ee4f54d63e88b6bad28356d0c032a8c3.tar.bz2 |
Preparation. for /me.
QtUI's implementation isn't done yet.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindowFactory.h | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 831dbfd..e982b21 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -127,90 +127,94 @@ void QtChatWindow::setInputEnabled(bool enabled) { void QtChatWindow::showEvent(QShowEvent* event) { emit windowOpening(); QWidget::showEvent(event); } void QtChatWindow::setUnreadMessageCount(int count) { unreadCount_ = count; updateTitleWithUnreadCount(); } bool QtChatWindow::isWidgetAlerting() { return unreadCount_ > 0; } void QtChatWindow::setName(const String& name) { contact_ = P2QSTRING(name); updateTitleWithUnreadCount(); } void QtChatWindow::updateTitleWithUnreadCount() { setWindowTitle(unreadCount_ > 0 ? QString("(%1) %2").arg(unreadCount_).arg(contact_) : contact_); emit titleUpdated(); } void QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) { if (isWidgetSelected()) { onAllMessagesRead(); } QString htmlString; if (label) { htmlString = QString("<span style=\"border: thin dashed grey; padding-left: .5em; padding-right: .5em; color: %1; background-color: %2; font-size: 90%; margin-right: .5em; \">").arg(Qt::escape(P2QSTRING(label->getForegroundColor()))).arg(Qt::escape(P2QSTRING(label->getBackgroundColor()))); htmlString += QString("%3</span> ").arg(Qt::escape(P2QSTRING(label->getDisplayMarking()))); } QString messageHTML(Qt::escape(P2QSTRING(message))); messageHTML.replace("\n","<br/>"); messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML))); htmlString += messageHTML; bool appendToPrevious = !previousMessageWasSystem_ && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_ && previousSenderName_ == P2QSTRING(senderName))); QString qAvatarPath = avatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); messageLog_->addMessage(MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), QDateTime::currentDateTime(), qAvatarPath, senderIsSelf, appendToPrevious)); previousMessageWasSelf_ = senderIsSelf; previousSenderName_ = P2QSTRING(senderName); previousMessageWasSystem_ = false; } +void QtChatWindow::addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) { + addMessage(message, senderName, senderIsSelf, label, avatarPath); +} + void QtChatWindow::addErrorMessage(const String& errorMessage) { if (isWidgetSelected()) { onAllMessagesRead(); } QString errorMessageHTML(Qt::escape(P2QSTRING(errorMessage))); errorMessageHTML.replace("\n","<br/>"); messageLog_->addMessage(SystemMessageSnippet(QString("<span class=\"error\">%1</span>").arg(errorMessageHTML), QDateTime::currentDateTime(),previousMessageWasSystem_)); previousMessageWasSelf_ = false; previousMessageWasSystem_ = true; } void QtChatWindow::addSystemMessage(const String& message) { if (isWidgetSelected()) { onAllMessagesRead(); } QString messageHTML(Qt::escape(P2QSTRING(message))); messageHTML.replace("\n","<br/>"); messageLog_->addMessage(SystemMessageSnippet(messageHTML, QDateTime::currentDateTime(),previousMessageWasSystem_)); previousMessageWasSelf_ = false; previousMessageWasSystem_ = true; } void QtChatWindow::returnPressed() { onSendMessageRequest(Q2PSTRING(input_->toPlainText())); messageLog_->scrollToBottom(); input_->clear(); } void QtChatWindow::show() { QWidget::show(); emit windowOpening(); } void QtChatWindow::activate() { emit wantsToActivate(); } } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index b743aaf..e147fb8 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -1,64 +1,65 @@ #ifndef SWIFT_QtChatWindow_H #define SWIFT_QtChatWindow_H -#include "Swift/Controllers/ChatWindow.h" +#include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "QtTabbable.h" class QTextEdit; class QLineEdit; class QComboBox; namespace Swift { class QtChatView; class QtTreeWidget; class QtTreeWidgetFactory; class TreeWidget; class QtTextEdit; class QtChatWindow : public QtTabbable, public ChatWindow { Q_OBJECT public: QtChatWindow(const QString &contact, QtTreeWidgetFactory* treeWidgetFactory); ~QtChatWindow(); void addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath); + void addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath); void addSystemMessage(const String& message); void addErrorMessage(const String& errorMessage); void show(); void activate(); void setUnreadMessageCount(int count); void convertToMUC(); TreeWidget *getTreeWidget(); void setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels); void setSecurityLabelsEnabled(bool enabled); void setSecurityLabelsError(); SecurityLabel getSelectedSecurityLabel(); void setName(const String& name); void setInputEnabled(bool enabled); virtual bool isWidgetAlerting(); protected slots: void qAppFocusChanged(QWidget* old, QWidget* now); void closeEvent(QCloseEvent* event); protected: void showEvent(QShowEvent* event); private slots: void returnPressed(); private: void updateTitleWithUnreadCount(); int unreadCount_; QString contact_; QtChatView *messageLog_; QtTextEdit* input_; QComboBox *labelsWidget_; QtTreeWidget *treeWidget_; std::vector<SecurityLabel> availableLabels_; bool previousMessageWasSelf_; bool previousMessageWasSystem_; QString previousSenderName_; }; } #endif diff --git a/Swift/QtUI/QtChatWindowFactory.h b/Swift/QtUI/QtChatWindowFactory.h index 0c8a092..51db3db 100644 --- a/Swift/QtUI/QtChatWindowFactory.h +++ b/Swift/QtUI/QtChatWindowFactory.h @@ -1,27 +1,27 @@ #ifndef SWIFT_QtChatWindowFactory_H #define SWIFT_QtChatWindowFactory_H -#include "Swift/Controllers/ChatWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" #include "Swiften/JID/JID.h" #include "QtSettingsProvider.h" #include <QObject> #include <QSplitter> namespace Swift { class QtTreeWidgetFactory; class QtChatTabs; class QtChatWindowFactory : public QObject, public ChatWindowFactory { Q_OBJECT public: QtChatWindowFactory(QtTreeWidgetFactory *treeWidgetFactory, QSplitter* splitter, QtSettingsProvider* settings, QtChatTabs* tabs); ChatWindow* createChatWindow(const JID &contact); private slots: void handleWindowGeometryChanged(); private: QtTreeWidgetFactory* treeWidgetFactory_; QtSettingsProvider* settings_; QtChatTabs* tabs_; }; } #endif |