summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.project2
-rw-r--r--Swift/QtUI/QtChatTabs.cpp5
-rw-r--r--Swift/QtUI/QtChatTabs.h3
-rw-r--r--Swift/QtUI/QtChatWindow.cpp4
-rw-r--r--Swift/QtUI/QtChatWindow.h1
-rw-r--r--Swift/QtUI/QtTabWidget.cpp17
-rw-r--r--Swift/QtUI/QtTabWidget.h12
-rw-r--r--Swift/QtUI/QtTabbable.h1
-rw-r--r--Swift/QtUI/SConscript1
9 files changed, 43 insertions, 3 deletions
diff --git a/.project b/.project
index 04db171..e6f13ff 100644
--- a/.project
+++ b/.project
@@ -1,74 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Swift</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
- <value>-j 2 check=1</value>
+ <value>-j 2</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>scons</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${ProjDirPath}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>-c</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>false</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index f9a42a4..6e5c55d 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -1,118 +1,121 @@
#include "QtChatTabs.h"
#include <algorithm>
#include <QCloseEvent>
#include <QDesktopWidget>
#include <QtGlobal>
#include <QTabWidget>
#include <QLayout>
+#include <QTabBar>
namespace Swift {
QtChatTabs::QtChatTabs() : QWidget() {
- tabs_ = new QTabWidget(this);
+ tabs_ = new QtTabWidget(this);
#if QT_VERSION >= 0x040500
/*For Macs, change the tab rendering.*/
tabs_->setDocumentMode(true);
/*Closable tabs are only in Qt4.5 and later*/
tabs_->setTabsClosable(true);
connect(tabs_, SIGNAL(tabCloseRequested(int)), this, SLOT(handleTabCloseRequested(int)));
#endif
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setContentsMargins(0, 3, 0, 0);
layout->addWidget(tabs_);
setLayout(layout);
//resize(400, 300);
}
void QtChatTabs::closeEvent(QCloseEvent* event) {
//Hide first to prevent flickering as each tab is removed.
hide();
for (int i = tabs_->count() - 1; i >= 0; i--) {
tabs_->removeTab(i);
}
event->accept();
}
void QtChatTabs::addTab(QtTabbable* tab) {
tabs_->addTab(tab, tab->windowTitle());
connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated()));
connect(tab, SIGNAL(windowClosing()), this, SLOT(handleTabClosing()));
connect(tab, SIGNAL(windowOpening()), this, SLOT(handleWidgetShown()));
connect(tab, SIGNAL(wantsToActivate()), this, SLOT(handleWantsToActivate()));
}
void QtChatTabs::handleWidgetShown() {
QtTabbable* widget = qobject_cast<QtTabbable*>(sender());
if (!widget) {
return;
}
if (tabs_->indexOf(widget) >= 0) {
return;
}
addTab(widget);
show();
}
void QtChatTabs::handleWantsToActivate() {
QtTabbable* widget = qobject_cast<QtTabbable*>(sender());
Q_ASSERT(widget);
Q_ASSERT(tabs_->indexOf(widget) >= 0);
//Un-minimize and bring to front.
setWindowState(windowState() & ~Qt::WindowMinimized);
setWindowState(windowState() | Qt::WindowActive);
tabs_->setCurrentWidget(widget);
widget->setFocus();
activateWindow();
}
void QtChatTabs::handleTabClosing() {
QWidget* widget = qobject_cast<QWidget*>(sender());
if (!widget) {
return;
}
int index = tabs_->indexOf(widget);
if (index < 0) {
return;
}
tabs_->removeTab(index);
if (tabs_->count() == 0) {
hide();
}
handleTabTitleUpdated(tabs_->currentWidget());
}
void QtChatTabs::handleTabCloseRequested(int index) {
QWidget* widget = tabs_->widget(index);
widget->close();
}
void QtChatTabs::handleTabTitleUpdated() {
QWidget* widget = qobject_cast<QWidget*>(sender());
handleTabTitleUpdated(widget);
}
void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
if (!widget) {
return;
}
+ QtTabbable* tabbable = qobject_cast<QtTabbable*>(widget);
int index = tabs_->indexOf(widget);
if (index < 0) {
return;
}
tabs_->setTabText(index, widget->windowTitle());
+ tabs_->tabBar()->setTabTextColor(index, tabbable->isWidgetAlerting() ? QColor(255,0,0) : QColor(-1,-1,-1)); //invalid resets to default
if (widget == tabs_->currentWidget()) {
setWindowTitle(widget->windowTitle());
}
}
void QtChatTabs::resizeEvent(QResizeEvent*) {
emit geometryChanged();
}
void QtChatTabs::moveEvent(QMoveEvent*) {
emit geometryChanged();
}
}
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index c51b88d..12ab3b8 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -1,35 +1,36 @@
#pragma once
#include "QtTabbable.h"
+#include "QtTabWidget.h"
#include <QWidget>
#include <QRect>
class QTabWidget;
namespace Swift {
class QtChatTabs : public QWidget {
Q_OBJECT
public:
QtChatTabs();
void addTab(QtTabbable* tab);
void minimise();
signals:
void geometryChanged();
protected slots:
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent* event);
void moveEvent(QMoveEvent* event);
private slots:
void handleTabClosing();
void handleTabTitleUpdated();
void handleTabTitleUpdated(QWidget* widget);
void handleTabCloseRequested(int index);
void handleWidgetShown();
void handleWantsToActivate();
private:
- QTabWidget* tabs_;
+ QtTabWidget* tabs_;
};
}
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index bebebe8..831dbfd 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -89,96 +89,100 @@ void QtChatWindow::setSecurityLabelsError() {
void QtChatWindow::setSecurityLabelsEnabled(bool enabled) {
if (enabled) {
labelsWidget_->setEnabled(true);
labelsWidget_->show();
} else {
labelsWidget_->hide();
}
}
SecurityLabel QtChatWindow::getSelectedSecurityLabel() {
assert(labelsWidget_->isEnabled());
return availableLabels_[labelsWidget_->currentIndex()];
}
void QtChatWindow::closeEvent(QCloseEvent* event) {
onClosed();
emit windowClosing();
event->accept();
}
void QtChatWindow::convertToMUC() {
treeWidget_->show();
}
void QtChatWindow::qAppFocusChanged(QWidget *old, QWidget *now) {
Q_UNUSED(old);
Q_UNUSED(now);
if (isWidgetSelected()) {
onAllMessagesRead();
}
}
void QtChatWindow::setInputEnabled(bool enabled) {
input_->setEnabled(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::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) {
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 9c41ddc..b743aaf 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -1,63 +1,64 @@
#ifndef SWIFT_QtChatWindow_H
#define SWIFT_QtChatWindow_H
#include "Swift/Controllers/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 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/QtTabWidget.cpp b/Swift/QtUI/QtTabWidget.cpp
new file mode 100644
index 0000000..64399c5
--- /dev/null
+++ b/Swift/QtUI/QtTabWidget.cpp
@@ -0,0 +1,17 @@
+#include "QtTabWidget.h"
+
+namespace Swift {
+
+QtTabWidget::QtTabWidget(QWidget* parent) : QTabWidget(parent) {
+
+}
+
+QtTabWidget::~QtTabWidget() {
+
+}
+
+QTabBar* QtTabWidget::tabBar() {
+ return QTabWidget::tabBar();
+}
+
+}
diff --git a/Swift/QtUI/QtTabWidget.h b/Swift/QtUI/QtTabWidget.h
new file mode 100644
index 0000000..a7721bf
--- /dev/null
+++ b/Swift/QtUI/QtTabWidget.h
@@ -0,0 +1,12 @@
+#pragma once
+#include <QTabWidget>
+
+namespace Swift {
+ class QtTabWidget : public QTabWidget {
+ Q_OBJECT
+ public:
+ QtTabWidget(QWidget* parent);
+ ~QtTabWidget();
+ QTabBar* tabBar();
+ };
+}
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index e3dd47b..c28e301 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -1,20 +1,21 @@
#pragma once
#include <QWidget>
namespace Swift {
class QtTabbable : public QWidget {
Q_OBJECT
public:
bool isWidgetSelected();
+ virtual bool isWidgetAlerting() {return false;};
protected:
QtTabbable() : QWidget() {};
signals:
void titleUpdated();
void windowClosing();
void windowOpening();
void wantsToActivate();
};
}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 77bc8f8..d6bc47a 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -23,96 +23,97 @@ myenv = env.Clone()
myenv.MergeFlags(env["SWIFT_CONTROLLERS_FLAGS"])
myenv.MergeFlags(env["SWIFTOOLS_FLAGS"])
if myenv["HAVE_XSS"] :
myenv.MergeFlags(env["XSS_FLAGS"])
if myenv["HAVE_SPARKLE"] :
myenv.MergeFlags(env["SPARKLE_FLAGS"])
myenv.MergeFlags(env["SWIFTEN_FLAGS"])
myenv.MergeFlags(env["CPPUNIT_FLAGS"])
myenv.MergeFlags(env["LIBIDN_FLAGS"])
myenv.MergeFlags(env["BOOST_FLAGS"])
myenv.MergeFlags(env["SQLITE_FLAGS"])
myenv.MergeFlags(env["ZLIB_FLAGS"])
myenv.MergeFlags(env["OPENSSL_FLAGS"])
myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"])
myenv.Tool("nsis", toolpath = ["#/BuildTools/SCons/Tools"])
myenv.EnableQt4Modules(['QtCore', 'QtGui', 'QtWebKit'], debug = False)
myenv.Append(CPPPATH = ["."])
if env["PLATFORM"] == "win32" :
#myenv["LINKFLAGS"] = ["/SUBSYSTEM:CONSOLE"]
myenv.Append(LINKFLAGS = ["/SUBSYSTEM:WINDOWS"])
myenv.Append(LIBS = "qtmain")
myenv.Command("DefaultTheme.qrc", "../resources/themes/Default", Action(generateDefaultTheme, cmdstr = "$GENCOMSTR"))
sources = [
"main.cpp",
"QtAboutWidget.cpp",
"QtAddContactDialog.cpp",
"QtChatWindow.cpp",
"QtChatWindowFactory.cpp",
"QtJoinMUCDialog.cpp",
"QtLoginWindow.cpp",
"QtLoginWindowFactory.cpp",
"QtMainWindow.cpp",
"QtMainWindowFactory.cpp",
"QtSettingsProvider.cpp",
"QtStatusWidget.cpp",
"QtSwift.cpp",
"QtChatView.cpp",
"QtChatTabs.cpp",
"QtSoundPlayer.cpp",
"QtSystemTray.cpp",
"QtTabbable.cpp",
+ "QtTabWidget.cpp",
"QtTextEdit.cpp",
"QtXMLConsoleWidgetFactory.cpp",
"QtXMLConsoleWidget.cpp",
"ChatSnippet.cpp",
"MessageSnippet.cpp",
"SystemMessageSnippet.cpp",
"Roster/RosterModel.cpp",
"Roster/QtTreeWidget.cpp",
"Roster/QtTreeWidgetItem.cpp",
"Roster/RosterDelegate.cpp",
"EventViewer/EventView.cpp",
"EventViewer/EventModel.cpp",
"EventViewer/EventDelegate.cpp",
"QtRosterHeader.cpp",
"qrc_DefaultTheme.cc",
"qrc_Swift.cc",
]
myenv.BuildVersion("BuildVersion.h", version = env["SWIFT_VERSION"])
if env["PLATFORM"] == "win32" :
myenv.RES("../resources/Windows/Swift.rc")
sources += ["../resources/Windows/Swift.res"]
if env["PLATFORM"] == "darwin" or env["PLATFORM"] == "win32" :
swiftProgram = myenv.Program("Swift", sources)
else :
swiftProgram = myenv.Program("swift", sources)
myenv.Uic4("QtJoinMUCDialog.ui")
myenv.Uic4("QtAddContactDialog.ui")
myenv.Qrc("DefaultTheme.qrc")
myenv.Qrc("Swift.qrc")
if env["PLATFORM"] == "darwin" :
frameworks = []
if env["HAVE_SPARKLE"] :
frameworks.append(env["SPARKLE_FRAMEWORK"])
app = myenv.AppBundle("Swift", version = env["SWIFT_VERSION"], resources = ["../resources/MacOSX/Swift.icns"], frameworks = frameworks)
if "dist" in COMMAND_LINE_TARGETS :
myenv.Command(["Swift-${SWIFT_VERSION}.dmg"], [app], [
"$QTDIR/bin/macdeployqt $SOURCE -dmg",
Move("$TARGET", "$SOURCE.dir/Swift.dmg")
])
if env.get("SWIFT_INSTALLDIR", "") :
env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "bin"), swiftProgram)