History

Merge pull request #3357 from huffman/19968

Code Review for Job #19968

Brad Hefta-Gaub committed 12 years ago

Commit d342f922 parents 2f22292 2b5759b4 files · +27 −75Browse files

Showing the changes to interface/src/ui/ChatWindow.cpp (1 of 4 files). Show all

Unified · Split

interface/src/ui/ChatWindow.cpp+18−15
@@ -18,28 +18,27 @@ · 17 unmodified lines
18#include <QTimer>18#include <QTimer>
19 19
20#include "Application.h"20#include "Application.h"
21#include "ChatMessageArea.h"
21#include "FlowLayout.h"22#include "FlowLayout.h"
22#include "qtimespan.h"23#include "qtimespan.h"
23#include "ui_chatWindow.h"24#include "UIUtil.h"
24#include "XmppClient.h"25#include "XmppClient.h"
25#include "ChatMessageArea.h"
26 26
27#include "ui_chatWindow.h"
27#include "ChatWindow.h"28#include "ChatWindow.h"
28 29
29 30
30 31
31const int NUM_MESSAGES_TO_TIME_STAMP = 20;32const int NUM_MESSAGES_TO_TIME_STAMP = 20;
32 33
33const float OPACITY_ACTIVE = 1.0f;
34const float OPACITY_INACTIVE = 0.8f;
35
36const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)");34const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)");
37const QRegularExpression regexHifiLinks("([#@]\\S+)");35const QRegularExpression regexHifiLinks("([#@]\\S+)");
38const QString mentionSoundsPath("/mention-sounds/");36const QString mentionSoundsPath("/mention-sounds/");
39const QString mentionRegex("@(\\b%1\\b)");37const QString mentionRegex("@(\\b%1\\b)");
40 38
41ChatWindow::ChatWindow(QWidget* parent) :39ChatWindow::ChatWindow(QWidget* parent) :
42 FramelessDialog(parent, 0, POSITION_RIGHT),40 QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
41 Qt::WindowCloseButtonHint),
43 ui(new Ui::ChatWindow),42 ui(new Ui::ChatWindow),
44 numMessagesAfterLastTimeStamp(0),43 numMessagesAfterLastTimeStamp(0),
45 _mousePressed(false),44 _mousePressed(false),
@@ -82,7 +81,6 @@ ChatWindow::ChatWindow(QWidget* parent) : · 36 unmodified lines
82 startTimerForTimeStamps();81 startTimerForTimeStamps();
83 } else {82 } else {
84 ui->numOnlineLabel->hide();83 ui->numOnlineLabel->hide();
85 ui->closeButton->hide();
86 ui->usersArea->hide();84 ui->usersArea->hide();
87 ui->messagesScrollArea->hide();85 ui->messagesScrollArea->hide();
88 ui->messagePlainTextEdit->hide();86 ui->messagePlainTextEdit->hide();
@@ -112,17 +110,25 @@ ChatWindow::~ChatWindow() { · 23 unmodified lines
112void ChatWindow::keyPressEvent(QKeyEvent* event) {110void ChatWindow::keyPressEvent(QKeyEvent* event) {
113 if (event->key() == Qt::Key_Escape) {111 if (event->key() == Qt::Key_Escape) {
114 Application::getInstance()->getWindow()->activateWindow();112 Application::getInstance()->getWindow()->activateWindow();
113 hide();
115 } else {114 } else {
116 FramelessDialog::keyPressEvent(event);115 QWidget::keyPressEvent(event);
117 }116 }
118}117}
119 118
120void ChatWindow::showEvent(QShowEvent* event) {119void ChatWindow::showEvent(QShowEvent* event) {
121 FramelessDialog::showEvent(event);120 QWidget::showEvent(event);
122 121
123 if (!event->spontaneous()) {122 if (!event->spontaneous()) {
124 ui->messagePlainTextEdit->setFocus();123 ui->messagePlainTextEdit->setFocus();
125 }124 }
125 const QRect parentGeometry = parentWidget()->geometry();
126 int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
127 int menuBarHeight = Menu::getInstance()->geometry().height();
128 int topMargin = titleBarHeight + menuBarHeight;
129
130 setGeometry(parentGeometry.topRight().x() - size().width() + 1, parentGeometry.topRight().y() + topMargin,
131 size().width(), parentWidget()->height() - topMargin);
126 132
127 Application::processEvents();133 Application::processEvents();
128 134
@@ -167,7 +173,7 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { · 38 unmodified lines
167 return true;173 return true;
168 }174 }
169 }175 }
170 return FramelessDialog::eventFilter(sender, event);176 return QWidget::eventFilter(sender, event);
171}177}
172 178
173void ChatWindow::addTimeStamp() {179void ChatWindow::addTimeStamp() {
@@ -214,7 +220,6 @@ void ChatWindow::startTimerForTimeStamps() { · 40 unmodified lines
214void ChatWindow::connected() {220void ChatWindow::connected() {
215 ui->connectingToXMPPLabel->hide();221 ui->connectingToXMPPLabel->hide();
216 ui->numOnlineLabel->show();222 ui->numOnlineLabel->show();
217 ui->closeButton->show();
218 ui->usersArea->show();223 ui->usersArea->show();
219 ui->messagesScrollArea->show();224 ui->messagesScrollArea->show();
220 ui->messagePlainTextEdit->show();225 ui->messagePlainTextEdit->show();
@@ -393,9 +398,7 @@ void ChatWindow::scrollToBottom() { · 172 unmodified lines
393 398
394bool ChatWindow::event(QEvent* event) {399bool ChatWindow::event(QEvent* event) {
395 if (event->type() == QEvent::WindowActivate) {400 if (event->type() == QEvent::WindowActivate) {
396 setWindowOpacity(OPACITY_ACTIVE);401 ui->messagePlainTextEdit->setFocus();
397 } else if (event->type() == QEvent::WindowDeactivate) {
398 setWindowOpacity(OPACITY_INACTIVE);
399 }402 }
400 return FramelessDialog::event(event);403 return QWidget::event(event);
401}404}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t