summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtChatTabs.cpp')
-rw-r--r--Swift/QtUI/QtChatTabs.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index d3a5676..de1ee7c 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -22,8 +22,8 @@
#include <qdebug.h>
namespace Swift {
-QtChatTabs::QtChatTabs() : QWidget() {
-#ifndef Q_WS_MAC
+QtChatTabs::QtChatTabs(bool singleWindow) : QWidget(), singleWindow_(singleWindow) {
+#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-chat-16.png"));
#else
setAttribute(Qt::WA_ShowWithoutActivating);
@@ -46,7 +46,6 @@ QtChatTabs::QtChatTabs() : QWidget() {
layout->setContentsMargins(0, 3, 0, 0);
layout->addWidget(tabs_);
setLayout(layout);
- //resize(400, 300);
}
void QtChatTabs::closeEvent(QCloseEvent* event) {
@@ -114,7 +113,13 @@ void QtChatTabs::handleTabClosing() {
if (widget && ((index = tabs_->indexOf(widget)) >= 0)) {
tabs_->removeTab(index);
if (tabs_->count() == 0) {
- hide();
+ if (!singleWindow_) {
+ hide();
+ }
+ else {
+ setWindowTitle("");
+ onTitleChanged("");
+ }
}
else {
handleTabTitleUpdated(tabs_->currentWidget());
@@ -176,10 +181,9 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
}
QString tabText = tabbable->windowTitle().simplified();
-
// look for spectrum-generated and other long JID localparts, and
// try to abbreviate the resulting long tab texts
- QRegExp hasTrailingGarbage("^(.[-\\w\\s&]+)([^\\s\\w].*)$");
+ QRegExp hasTrailingGarbage("^(.[-\\w\\s,&]+)([^\\s\\,w].*)$");
if (hasTrailingGarbage.exactMatch(tabText) &&
hasTrailingGarbage.cap(1).simplified().length() >= 2 &&
hasTrailingGarbage.cap(2).length() >= 7) {
@@ -188,10 +192,8 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
// least a couple of characters.
tabText = hasTrailingGarbage.cap(1).simplified();
}
-
// QTabBar interprets &, so escape that
tabText.replace("&", "&&");
-
// see which alt[a-z] keys other tabs use
bool accelsTaken[26];
int i = 0;
@@ -237,7 +239,7 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
switch (tabbable->getWidgetAlertState()) {
case QtTabbable::WaitingActivity : tabTextColor = QColor(217, 20, 43); break;
case QtTabbable::ImpendingActivity : tabTextColor = QColor(27, 171, 32); break;
- default : tabTextColor = QColor();
+ case QtTabbable::NoActivity : tabTextColor = QColor(); break;
}
tabs_->tabBar()->setTabTextColor(index, tabTextColor);
@@ -251,7 +253,9 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
std::string current(Q2PSTRING(qobject_cast<QtTabbable*>(tabs_->currentWidget())->windowTitle()));
ChatMessageSummarizer summary;
- setWindowTitle(summary.getSummary(current, unreads).c_str());
+ QString title = summary.getSummary(current, unreads).c_str();
+ setWindowTitle(title);
+ emit onTitleChanged(title);
}
void QtChatTabs::flash() {
@@ -270,7 +274,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