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