summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Roster/ContactRosterItem.h2
-rw-r--r--Swift/QtUI/ChatSnippet.cpp2
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.cpp5
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp2
-rw-r--r--Swift/QtUI/QtAboutWidget.cpp2
-rw-r--r--Swift/QtUI/QtChatTabs.cpp4
-rw-r--r--Swift/QtUI/QtChatView.cpp2
-rw-r--r--Swift/QtUI/QtChatWindow.cpp28
-rw-r--r--Swift/QtUI/QtFileTransferListItemModel.cpp2
-rw-r--r--Swift/QtUI/QtFileTransferListItemModel.h2
-rw-r--r--Swift/QtUI/QtHighlightRulesItemModel.cpp4
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp7
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp2
-rw-r--r--Swift/QtUI/QtNameWidget.h2
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp3
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp2
-rw-r--r--Swift/QtUI/QtSystemTray.cpp4
-rw-r--r--Swift/QtUI/QtTextEdit.cpp2
-rw-r--r--Swift/QtUI/QtTranslator.h4
-rw-r--r--Swift/QtUI/QtUIFactory.cpp2
-rw-r--r--Swift/QtUI/QtUtilities.cpp15
-rw-r--r--Swift/QtUI/QtUtilities.h5
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp2
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.cpp3
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardJIDField.cpp3
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp6
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardURLField.cpp4
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp1
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp17
-rw-r--r--Swift/QtUI/SConscript11
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp6
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp2
-rw-r--r--Swift/QtUI/main.cpp4
33 files changed, 103 insertions, 59 deletions
diff --git a/Swift/Controllers/Roster/ContactRosterItem.h b/Swift/Controllers/Roster/ContactRosterItem.h
index 7a2100e..247c606 100644
--- a/Swift/Controllers/Roster/ContactRosterItem.h
+++ b/Swift/Controllers/Roster/ContactRosterItem.h
@@ -26,7 +26,7 @@ class ContactRosterItem : public RosterItem {
public:
enum Feature {
FileTransferFeature,
- WhiteboardFeature,
+ WhiteboardFeature
};
public:
diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp
index ab31d29..4a0560b 100644
--- a/Swift/QtUI/ChatSnippet.cpp
+++ b/Swift/QtUI/ChatSnippet.cpp
@@ -39,4 +39,4 @@ QString ChatSnippet::wrapResizable(const QString& text) {
return "<span class='swift_resizable'>" + text + "</span>";
}
-};
+}
diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp
index 3c6f16c..c3ff944 100644
--- a/Swift/QtUI/EventViewer/QtEvent.cpp
+++ b/Swift/QtUI/EventViewer/QtEvent.cpp
@@ -7,6 +7,7 @@
#include "Swift/QtUI/EventViewer/QtEvent.h"
#include <QDateTime>
+#include <QColor>
#include "Swift/Controllers/XMPPEvents/MessageEvent.h"
#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
@@ -25,8 +26,8 @@ QVariant QtEvent::data(int role) {
switch (role) {
case Qt::ToolTipRole: return QVariant(text()).toString() + "\n" + B2QDATE(event_->getTime()).toString();
case Qt::DisplayRole: return QVariant(text());
- case Qt::TextColorRole: return active_ ? Qt::black : Qt::darkGray;
- case Qt::BackgroundColorRole: return active_ ? Qt::white : Qt::lightGray;
+ case Qt::TextColorRole: return QColor(active_ ? Qt::black : Qt::darkGray);
+ case Qt::BackgroundColorRole: return QColor(active_ ? Qt::white : Qt::lightGray);
case SenderRole: return QVariant(sender());
/*case StatusTextRole: return statusText_;
case AvatarRole: return avatar_;
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
index 2fa24c2..7bd16e3 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -23,7 +23,7 @@ namespace Swift {
QtMUCSearchWindow::QtMUCSearchWindow() {
ui_.setupUi(this);
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
setModal(true);
diff --git a/Swift/QtUI/QtAboutWidget.cpp b/Swift/QtUI/QtAboutWidget.cpp
index acdc61e..c00acf7 100644
--- a/Swift/QtUI/QtAboutWidget.cpp
+++ b/Swift/QtUI/QtAboutWidget.cpp
@@ -19,7 +19,7 @@
namespace Swift {
QtAboutWidget::QtAboutWidget() : QDialog() {
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowTitle(QString(tr("About %1")).arg("Swift"));
#endif
setWindowIcon(QIcon(":/logo-icon-16.png"));
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 7d8f16e..e37803e 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -23,7 +23,7 @@
namespace Swift {
QtChatTabs::QtChatTabs() : QWidget() {
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-chat-16.png"));
#else
setAttribute(Qt::WA_ShowWithoutActivating);
@@ -270,7 +270,7 @@ void QtChatTabs::moveEvent(QMoveEvent*) {
void QtChatTabs::checkForFirstShow() {
if (!isVisible()) {
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
showMinimized();
#else
/* https://bugreports.qt-project.org/browse/QTBUG-19194
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 967ebec..ad3ba2a 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -41,7 +41,7 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScro
connect(webView_, SIGNAL(clearRequested()), SLOT(handleClearRequested()));
connect(webView_, SIGNAL(fontGrowRequested()), SLOT(increaseFontSize()));
connect(webView_, SIGNAL(fontShrinkRequested()), SLOT(decreaseFontSize()));
-#ifdef Q_WS_X11
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
/* To give a border on Linux, where it looks bad without */
QStackedWidget* stack = new QStackedWidget(this);
stack->addWidget(webView_);
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index a53ca5d..7f27cb6 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -25,6 +25,7 @@
#include <Swift/Controllers/UIEvents/SendFileUIEvent.h>
#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
#include "QtChatWindowJSBridge.h"
+#include "QtUtilities.h"
#include <boost/cstdint.hpp>
#include <boost/format.hpp>
@@ -33,6 +34,7 @@
#include <QLabel>
#include <qdebug.h>
#include <QMessageBox>
+#include <QMimeData>
#include <QInputDialog>
#include <QApplication>
#include <QBoxLayout>
@@ -487,7 +489,7 @@ std::string QtChatWindow::addMessage(const std::string &message, const std::stri
QString QtChatWindow::linkimoticonify(const QString& message) const {
QString messageHTML(message);
- messageHTML = Qt::escape(messageHTML);
+ messageHTML = QtUtilities::htmlEscape(messageHTML);
QMapIterator<QString, QString> it(emoticons_);
QString textStyle = showEmoticons_ ? "style='display:none'" : "";
QString imageStyle = showEmoticons_ ? "" : "style='display:none'";
@@ -504,8 +506,8 @@ QString QtChatWindow::linkimoticonify(const QString& message) const {
QString QtChatWindow::getHighlightSpanStart(const HighlightAction& highlight)
{
- QString color = Qt::escape(P2QSTRING(highlight.getTextColor()));
- QString background = Qt::escape(P2QSTRING(highlight.getTextBackground()));
+ QString color = QtUtilities::htmlEscape(P2QSTRING(highlight.getTextColor()));
+ QString background = QtUtilities::htmlEscape(P2QSTRING(highlight.getTextBackground()));
if (color.isEmpty()) {
color = "black";
}
@@ -524,8 +526,8 @@ std::string QtChatWindow::addMessage(const QString &message, const std::string &
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; \" class='swift_label'>").arg(Qt::escape(P2QSTRING(label->getForegroundColor()))).arg(Qt::escape(P2QSTRING(label->getBackgroundColor())));
- htmlString += QString("%1</span> ").arg(Qt::escape(P2QSTRING(label->getDisplayMarking())));
+ 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; \" class='swift_label'>").arg(QtUtilities::htmlEscape(P2QSTRING(label->getForegroundColor()))).arg(QtUtilities::htmlEscape(P2QSTRING(label->getBackgroundColor())));
+ htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(label->getDisplayMarking())));
}
QString messageHTML(message);
QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">";
@@ -543,7 +545,7 @@ std::string QtChatWindow::addMessage(const QString &message, const std::string &
}
QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded();
std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++);
- messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, QtUtilities::htmlEscape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
previousMessageWasSelf_ = senderIsSelf;
previousSenderName_ = P2QSTRING(senderName);
@@ -605,7 +607,7 @@ std::string formatSize(const boost::uintmax_t bytes) {
}
static QString encodeButtonArgument(const QString& str) {
- return Qt::escape(P2QSTRING(Base64::encode(createByteArray(Q2PSTRING(str)))));
+ return QtUtilities::htmlEscape(P2QSTRING(Base64::encode(createByteArray(Q2PSTRING(str)))));
}
static QString decodeButtonArgument(const QString& str) {
@@ -653,7 +655,7 @@ std::string QtChatWindow::addFileTransfer(const std::string& senderName, bool se
}
QString qAvatarPath = "qrc:/icons/avatar.png";
std::string id = "ftmessage" + boost::lexical_cast<std::string>(idCounter_++);
- messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, QtUtilities::htmlEscape(P2QSTRING(senderName)), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
previousMessageWasSelf_ = senderIsSelf;
previousSenderName_ = P2QSTRING(senderName);
@@ -677,7 +679,7 @@ std::string QtChatWindow::addWhiteboardRequest(bool senderIsSelf) {
buildChatWindowButton(tr("Cancel"), ButtonWhiteboardSessionCancel, wb_id) +
"</div>";
} else {
- htmlString = "<div id='" + wb_id + "'>" + tr("%1 would like to start a whiteboard chat").arg(Qt::escape(contact_)) + ": <br/>" +
+ htmlString = "<div id='" + wb_id + "'>" + tr("%1 would like to start a whiteboard chat").arg(QtUtilities::htmlEscape(contact_)) + ": <br/>" +
buildChatWindowButton(tr("Cancel"), ButtonWhiteboardSessionCancel, wb_id) +
buildChatWindowButton(tr("Accept"), ButtonWhiteboardSessionAcceptRequest, wb_id) +
"</div>";
@@ -691,7 +693,7 @@ std::string QtChatWindow::addWhiteboardRequest(bool senderIsSelf) {
}
QString qAvatarPath = "qrc:/icons/avatar.png";
std::string id = "wbmessage" + boost::lexical_cast<std::string>(idCounter_++);
- messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, Qt::escape(contact_), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, false, false, theme_, P2QSTRING(id))));
+ messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, QtUtilities::htmlEscape(contact_), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, false, false, theme_, P2QSTRING(id))));
previousMessageWasSelf_ = false;
previousSenderName_ = contact_;
@@ -766,7 +768,7 @@ void QtChatWindow::addErrorMessage(const std::string& errorMessage) {
onAllMessagesRead();
}
- QString errorMessageHTML(Qt::escape(P2QSTRING(errorMessage)));
+ QString errorMessageHTML(QtUtilities::htmlEscape(P2QSTRING(errorMessage)));
errorMessageHTML.replace("\n","<br/>");
messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new SystemMessageSnippet("<span class=\"error\">" + errorMessageHTML + "</span>", QDateTime::currentDateTime(), false, theme_)));
@@ -1009,7 +1011,7 @@ void QtChatWindow::addMUCInvitation(const std::string& senderName, const JID& ji
QString id = QString(ButtonMUCInvite + "%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++)));
htmlString += "<div id='" + id + "'>" +
- buildChatWindowButton(tr("Accept Invite"), ButtonMUCInvite, Qt::escape(P2QSTRING(jid.toString())), Qt::escape(P2QSTRING(password)), id) +
+ buildChatWindowButton(tr("Accept Invite"), ButtonMUCInvite, QtUtilities::htmlEscape(P2QSTRING(jid.toString())), QtUtilities::htmlEscape(P2QSTRING(password)), id) +
"</div>";
bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMUCInvite, senderName, false);
@@ -1021,7 +1023,7 @@ void QtChatWindow::addMUCInvitation(const std::string& senderName, const JID& ji
}
QString qAvatarPath = "qrc:/icons/avatar.png";
- messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, false, appendToPrevious, theme_, id)));
+ messageLog_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, QtUtilities::htmlEscape(P2QSTRING(senderName)), B2QDATE(boost::posix_time::second_clock::local_time()), qAvatarPath, false, appendToPrevious, theme_, id)));
previousMessageWasSelf_ = false;
previousSenderName_ = P2QSTRING(senderName);
previousMessageKind_ = PreviousMessageWasMUCInvite;
diff --git a/Swift/QtUI/QtFileTransferListItemModel.cpp b/Swift/QtUI/QtFileTransferListItemModel.cpp
index 71961c2..fac0761 100644
--- a/Swift/QtUI/QtFileTransferListItemModel.cpp
+++ b/Swift/QtUI/QtFileTransferListItemModel.cpp
@@ -105,7 +105,7 @@ int QtFileTransferListItemModel::rowCount(const QModelIndex& /* parent */) const
}
QModelIndex QtFileTransferListItemModel::index(int row, int column, const QModelIndex& /* parent */) const {
- return createIndex(row, column, 0);
+ return createIndex(row, column, (void*) 0);
}
}
diff --git a/Swift/QtUI/QtFileTransferListItemModel.h b/Swift/QtUI/QtFileTransferListItemModel.h
index 1d892a5..28f13f8 100644
--- a/Swift/QtUI/QtFileTransferListItemModel.h
+++ b/Swift/QtUI/QtFileTransferListItemModel.h
@@ -34,7 +34,7 @@ private:
State,
Progress,
OverallSize,
- NoOfColumns,
+ NoOfColumns
};
private:
diff --git a/Swift/QtUI/QtHighlightRulesItemModel.cpp b/Swift/QtUI/QtHighlightRulesItemModel.cpp
index ff2f639..4efa712 100644
--- a/Swift/QtUI/QtHighlightRulesItemModel.cpp
+++ b/Swift/QtUI/QtHighlightRulesItemModel.cpp
@@ -206,7 +206,7 @@ bool QtHighlightRulesItemModel::setData(const QModelIndex &index, const QVariant
highlightManager_->setRule(index.row(), r);
emit dataChanged(index, index);
foreach (int column, changedColumns) {
- QModelIndex i = createIndex(index.row(), column, 0);
+ QModelIndex i = createIndex(index.row(), column, (void*) 0);
emit dataChanged(i, i);
}
}
@@ -227,7 +227,7 @@ int QtHighlightRulesItemModel::rowCount(const QModelIndex& /* parent */) const
QModelIndex QtHighlightRulesItemModel::index(int row, int column, const QModelIndex& /* parent */) const
{
- return createIndex(row, column, 0);
+ return createIndex(row, column, (void*) 0);
}
bool QtHighlightRulesItemModel::insertRows(int row, int count, const QModelIndex& /* parent */)
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index 875235d..23621c6 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -21,6 +21,7 @@
#include <QDateTime>
#include <Swift/QtUI/QtScaledAvatarCache.h>
#include <QLineEdit>
+#include "QtUtilities.h"
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -108,7 +109,7 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str());
QString messageHTML(P2QSTRING(message));
- messageHTML = Qt::escape(messageHTML);
+ messageHTML = QtUtilities::htmlEscape(messageHTML);
QString searchTerm = ui_.searchBox_->lineEdit()->text();
if (searchTerm.length()) {
messageHTML.replace(searchTerm, "<span style='background-color: yellow'>" + searchTerm + "</span>");
@@ -125,14 +126,14 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
if (addAtTheTop) {
bool appendToPrevious = ((senderIsSelf && previousTopMessageWasSelf_) || (!senderIsSelf && !previousTopMessageWasSelf_&& previousTopSenderName_ == P2QSTRING(senderName)));
- conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, QtUtilities::htmlEscape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
previousTopMessageWasSelf_ = senderIsSelf;
previousTopSenderName_ = P2QSTRING(senderName);
}
else {
bool appendToPrevious = ((senderIsSelf && previousBottomMessageWasSelf_) || (!senderIsSelf && !previousBottomMessageWasSelf_&& previousBottomSenderName_ == P2QSTRING(senderName)));
- conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, QtUtilities::htmlEscape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
previousBottomMessageWasSelf_ = senderIsSelf;
previousBottomSenderName_ = P2QSTRING(senderName);
}
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index cf22ad0..188e55f 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -55,7 +55,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, SettingsProvider* set
uiEventStream_ = uiEventStream;
setWindowTitle("Swift");
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
QtUtilities::setX11Resource(this, "Main");
diff --git a/Swift/QtUI/QtNameWidget.h b/Swift/QtUI/QtNameWidget.h
index 0f00c41..3225879 100644
--- a/Swift/QtUI/QtNameWidget.h
+++ b/Swift/QtUI/QtNameWidget.h
@@ -31,7 +31,7 @@ namespace Swift {
private:
enum Mode {
ShowNick,
- ShowJID,
+ ShowJID
};
SettingsProvider* settings;
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
index 26b160a..b1cdd19 100644
--- a/Swift/QtUI/QtProfileWindow.cpp
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -19,6 +19,7 @@
#include <QTextDocument>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
@@ -75,7 +76,7 @@ void QtProfileWindow::setProcessing(bool processing) {
void QtProfileWindow::setError(const std::string& error) {
if (!error.empty()) {
- ui->errorLabel->setText("<font color='red'>" + Qt::escape(P2QSTRING(error)) + "</font>");
+ ui->errorLabel->setText("<font color='red'>" + QtUtilities::htmlEscape(P2QSTRING(error)) + "</font>");
}
else {
ui->errorLabel->setText("");
diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp
index 64e88d4..a98cdf3 100644
--- a/Swift/QtUI/QtSettingsProvider.cpp
+++ b/Swift/QtUI/QtSettingsProvider.cpp
@@ -108,7 +108,7 @@ QSettings* QtSettingsProvider::getQSettings() {
}
void QtSettingsProvider::updatePermissions() {
-#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
QFile file(settings_.fileName());
if (file.exists()) {
file.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp
index 2f45709..456a56f 100644
--- a/Swift/QtUI/QtSystemTray.cpp
+++ b/Swift/QtUI/QtSystemTray.cpp
@@ -9,7 +9,7 @@
#include "Swift/QtUI/QtSystemTray.h"
#include <QtDebug>
-#ifdef Q_WS_X11
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
#include <QDBusInterface>
#endif
#include <QIcon>
@@ -24,7 +24,7 @@ QtSystemTray::QtSystemTray() : QObject(), trayMenu_(0), onlineIcon_(":icons/onli
trayIcon_->setToolTip("Swift");
connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason)));
connect(&throbberMovie_, SIGNAL(frameChanged(int)), this, SLOT(handleThrobberFrameChanged(int)));
-#ifdef Q_WS_X11
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
bool isUnity = QDBusInterface("com.canonical.Unity.Launcher", "/com/canonical/Unity/Launcher").isValid();
if (isUnity) {
// Add an activation menu, because this is the only way to get the application to the
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 3a62325..0497d01 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -14,7 +14,7 @@ namespace Swift {
QtTextEdit::QtTextEdit(QWidget* parent) : QTextEdit(parent){
connect(this, SIGNAL(textChanged()), this, SLOT(handleTextChanged()));
handleTextChanged();
-};
+}
void QtTextEdit::keyPressEvent(QKeyEvent* event) {
int key = event->key();
diff --git a/Swift/QtUI/QtTranslator.h b/Swift/QtUI/QtTranslator.h
index fdafaf0..a2129f0 100644
--- a/Swift/QtUI/QtTranslator.h
+++ b/Swift/QtUI/QtTranslator.h
@@ -16,6 +16,10 @@ class QtTranslator : public Swift::Translator {
}
virtual std::string translate(const std::string& text, const std::string& context) {
+#if QT_VERSION >= 0x050000
+ return std::string(QCoreApplication::translate(context.c_str(), text.c_str(), 0).toUtf8());
+#else
return std::string(QCoreApplication::translate(context.c_str(), text.c_str(), 0, QCoreApplication::UnicodeUTF8).toUtf8());
+#endif
}
};
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 2ec2818..7ec25df 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -145,7 +145,7 @@ void QtUIFactory::handleChatWindowFontResized(int size) {
UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups) {
return new QtUserSearchWindow(eventStream, type, groups);
-};
+}
JoinMUCWindow* QtUIFactory::createJoinMUCWindow(UIEventStream* uiEventStream) {
return new QtJoinMUCWindow(uiEventStream);
diff --git a/Swift/QtUI/QtUtilities.cpp b/Swift/QtUI/QtUtilities.cpp
index be9d179..e9aa4a4 100644
--- a/Swift/QtUI/QtUtilities.cpp
+++ b/Swift/QtUI/QtUtilities.cpp
@@ -1,13 +1,14 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include "QtUtilities.h"
+#include <QTextDocument>
#include <QWidget>
-#ifdef Q_WS_X11
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
#include <QX11Info>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -18,7 +19,7 @@
namespace QtUtilities {
void setX11Resource(QWidget* widget, const QString& c) {
-#ifdef Q_WS_X11
+#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
char res_class[] = SWIFT_APPLICATION_NAME;
XClassHint hint;
hint.res_name = (QString(SWIFT_APPLICATION_NAME) + "-" + c).toUtf8().data();
@@ -30,4 +31,12 @@ void setX11Resource(QWidget* widget, const QString& c) {
#endif
}
+QString htmlEscape(const QString& s) {
+#if QT_VERSION >= 0x050000
+ return s.toHtmlEscaped();
+#else
+ return Qt::escape(s);
+#endif
+}
+
}
diff --git a/Swift/QtUI/QtUtilities.h b/Swift/QtUI/QtUtilities.h
index 6e64d6e..40c16bc 100644
--- a/Swift/QtUI/QtUtilities.h
+++ b/Swift/QtUI/QtUtilities.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -11,4 +11,5 @@ class QString;
namespace QtUtilities {
void setX11Resource(QWidget* widget, const QString& c);
-};
+ QString htmlEscape(const QString& s);
+}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
index 4d34e53..d9bb4fe 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp
@@ -156,7 +156,7 @@ void QtVCardAddressField::handleEditibleChanged(bool isEditable) {
foreach (QWidget* widget, textFields) {
QtResizableLineEdit* lineEdit;
if ((lineEdit = dynamic_cast<QtResizableLineEdit*>(widget))) {
- lineEdit->setShown(isEditable ? true : !lineEdit->text().isEmpty());
+ lineEdit->setVisible(isEditable ? true : !lineEdit->text().isEmpty());
lineEdit->setStyleSheet(isEditable ? "" : "QLineEdit { border: none; background: transparent; }");
}
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.cpp
index 46f253f..b946fc4 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.cpp
@@ -12,6 +12,7 @@
#include <Swiften/Base/Log.h>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
@@ -71,7 +72,7 @@ void QtVCardInternetEMailField::handleEditibleChanged(bool isEditable) {
} else {
if (emailLineEdit) emailLineEdit->hide();
if (emailLabel) {
- emailLabel->setText(QString("<a href=\"mailto:%1\">%1</a>").arg(Qt::escape(emailLineEdit->text())));
+ emailLabel->setText(QString("<a href=\"mailto:%1\">%1</a>").arg(QtUtilities::htmlEscape(emailLineEdit->text())));
emailLabel->show();
}
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardJIDField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardJIDField.cpp
index dbb4b7c..ecb5533 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardJIDField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardJIDField.cpp
@@ -11,6 +11,7 @@
#include <boost/algorithm/string.hpp>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
@@ -62,7 +63,7 @@ void QtVCardJIDField::handleEditibleChanged(bool isEditable) {
} else {
if (jidLineEdit) jidLineEdit->hide();
if (jidLabel) {
- jidLabel->setText(QString("<a href=\"xmpp:%1\">%1</a>").arg(Qt::escape(jidLineEdit->text())));
+ jidLabel->setText(QString("<a href=\"xmpp:%1\">%1</a>").arg(QtUtilities::htmlEscape(jidLineEdit->text())));
jidLabel->show();
}
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
index 5f231dc..e399885 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
@@ -41,7 +41,13 @@ void QtVCardOrganizationField::setupContentWidgets() {
unitsTreeWidget->header()->setStretchLastSection(false);
int closeIconWidth = unitsTreeWidget->fontMetrics().height();
unitsTreeWidget->header()->resizeSection(1, closeIconWidth);
+
+#if QT_VERSION >= 0x050000
+ unitsTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
+#else
unitsTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
+#endif
+
unitsTreeWidget->setHeaderHidden(true);
unitsTreeWidget->setRootIsDecorated(false);
unitsTreeWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardURLField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardURLField.cpp
index 0b6f0c1..35cc4ce 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardURLField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardURLField.cpp
@@ -12,6 +12,8 @@
#include <boost/algorithm/string.hpp>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUtilities.h>
+
namespace Swift {
@@ -59,7 +61,7 @@ void QtVCardURLField::handleEditibleChanged(bool isEditable) {
} else {
if (urlLineEdit) urlLineEdit->hide();
if (urlLabel) {
- urlLabel->setText(QString("<a href=\"%1\">%1</a>").arg(Qt::escape(urlLineEdit->text())));
+ urlLabel->setText(QString("<a href=\"%1\">%1</a>").arg(QtUtilities::htmlEscape(urlLineEdit->text())));
urlLabel->show();
}
}
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 5fdf138..64d0fcf 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -10,6 +10,7 @@
#include <boost/bind.hpp>
#include <QUrl>
+#include <QMimeData>
#include <Swiften/Base/Platform.h>
#include <Swift/Controllers/Roster/ContactRosterItem.h>
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index 885d04c..2909c05 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -40,7 +40,8 @@ void RosterModel::setRoster(Roster* roster) {
void RosterModel::reLayout() {
//emit layoutChanged();
- reset();
+ beginResetModel();
+ endResetModel(); // TODO: Not sure if this isn't too early?
if (!roster_) {
return;
}
@@ -53,7 +54,7 @@ void RosterModel::reLayout() {
void RosterModel::handleChildrenChanged(GroupRosterItem* /*group*/) {
reLayout();
-}
+}
void RosterModel::handleDataChanged(RosterItem* item) {
Q_ASSERT(item);
@@ -163,12 +164,12 @@ QIcon RosterModel::getPresenceIcon(RosterItem* item) const {
if (!contact) return QIcon();
QString iconString;
switch (contact->getStatusShow()) {
- case StatusShow::Online: iconString = "online";break;
- case StatusShow::Away: iconString = "away";break;
- case StatusShow::XA: iconString = "away";break;
- case StatusShow::FFC: iconString = "online";break;
- case StatusShow::DND: iconString = "dnd";break;
- case StatusShow::None: iconString = "offline";break;
+ case StatusShow::Online: iconString = "online";break;
+ case StatusShow::Away: iconString = "away";break;
+ case StatusShow::XA: iconString = "away";break;
+ case StatusShow::FFC: iconString = "online";break;
+ case StatusShow::DND: iconString = "dnd";break;
+ case StatusShow::None: iconString = "offline";break;
}
return QIcon(":/icons/" + iconString + ".png");
}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 4ab6792..13d36fa 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -24,7 +24,7 @@ myenv = env.Clone()
# Disable warnings that affect Qt
myenv["CXXFLAGS"] = filter(lambda x : x != "-Wfloat-equal", myenv["CXXFLAGS"])
if "clang" in env["CC"] :
- myenv.Append(CXXFLAGS = ["-Wno-float-equal", "-Wno-shorten-64-to-32", "-Wno-missing-prototypes", "-Wno-unreachable-code", "-Wno-disabled-macro-expansion", "-Wno-unused-private-field", "-Wno-extra-semi", "-Wno-duplicate-enum", "-Wno-missing-variable-declarations", "-Wno-conversion"])
+ myenv.Append(CXXFLAGS = ["-Wno-float-equal", "-Wno-shorten-64-to-32", "-Wno-missing-prototypes", "-Wno-unreachable-code", "-Wno-disabled-macro-expansion", "-Wno-unused-private-field", "-Wno-extra-semi", "-Wno-duplicate-enum", "-Wno-missing-variable-declarations", "-Wno-conversion", "-Wno-undefined-reinterpret-cast"])
myenv.UseFlags(env["SWIFT_CONTROLLERS_FLAGS"])
myenv.UseFlags(env["SWIFTOOLS_FLAGS"])
@@ -53,13 +53,18 @@ myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
myenv.Tool("nsis", toolpath = ["#/BuildTools/SCons/Tools"])
myenv.Tool("wix", toolpath = ["#/BuildTools/SCons/Tools"])
myenv.Tool("textfile", toolpath = ["#/BuildTools/SCons/Tools"])
-qt4modules = ['QtCore', 'QtGui', 'QtWebKit']
+qt4modules = ['QtCore', 'QtWebKit', 'QtGui']
+if myenv["qt5"] :
+ qt_version = '5'
+ qt4modules += ['QtWidgets', 'QtWebKitWidgets', 'QtMultimedia']
+else :
+ qt_version = '4'
if env["PLATFORM"] == "posix" :
qt4modules += ["QtDBus"]
if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" :
qt4modules += ["QtNetwork"]
-myenv.EnableQt4Modules(qt4modules, debug = False)
+myenv.EnableQt4Modules(qt4modules, debug = False, version = qt_version)
myenv.Append(CPPPATH = ["."])
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index d69c626..02b238e 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -29,7 +29,7 @@ namespace Swift {
QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWindow::Type type, const std::set<std::string>& groups) : eventStream_(eventStream), type_(type), model_(NULL) {
setupUi(this);
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
QString title(type == UserSearchWindow::AddContact ? tr("Add Contact") : tr("Chat to User"));
@@ -264,7 +264,11 @@ void QtUserSearchWindow::setResultsForm(Form::ref results) {
resultsPage_->results_->setModel(newModel);
resultsPage_->results_->setItemDelegate(new QItemDelegate());
resultsPage_->results_->setHeaderHidden(false);
+#if QT_VERSION >= 0x050000
+ resultsPage_->results_->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+#else
resultsPage_->results_->header()->setResizeMode(QHeaderView::ResizeToContents);
+#endif
delete model_;
model_ = newModel;
resultsPage_->setNoResults(model_->rowCount() == 0);
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 414e590..89de95e 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -26,7 +26,7 @@
namespace Swift {
QtWhiteboardWindow::QtWhiteboardWindow(WhiteboardSession::ref whiteboardSession) : QWidget() {
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
layout = new QVBoxLayout(this);
diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp
index d02cce6..70947f5 100644
--- a/Swift/QtUI/main.cpp
+++ b/Swift/QtUI/main.cpp
@@ -33,7 +33,9 @@ int main(int argc, char* argv[]) {
Swift::CrashReporter crashReporter(applicationPathProvider.getDataDir() / "crashes");
+#if QT_VERSION < 0x050000
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+#endif
// Parse program options
boost::program_options::options_description desc = Swift::QtSwift::getOptionsDescription();
@@ -62,7 +64,9 @@ int main(int argc, char* argv[]) {
}
// Translation
+#if QT_VERSION < 0x050000
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+#endif
boost::filesystem::path someTranslationPath = applicationPathProvider.getResourcePath("/translations/swift_en.qm");
QTranslator qtTranslator;