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
1818 #include <QTimer>
1919
2020 #include "Application.h"
21+#include "ChatMessageArea.h"
2122 #include "FlowLayout.h"
2223 #include "qtimespan.h"
23−#include "ui_chatWindow.h"
24+#include "UIUtil.h"
2425 #include "XmppClient.h"
25−#include "ChatMessageArea.h"
2626
27+#include "ui_chatWindow.h"
2728 #include "ChatWindow.h"
2829
2930
3031
3132 const int NUM_MESSAGES_TO_TIME_STAMP = 20;
3233
33−const float OPACITY_ACTIVE = 1.0f;
34−const float OPACITY_INACTIVE = 0.8f;
35−
3634 const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)");
3735 const QRegularExpression regexHifiLinks("([#@]\\S+)");
3836 const QString mentionSoundsPath("/mention-sounds/");
3937 const QString mentionRegex("@(\\b%1\\b)");
4038
4139 ChatWindow::ChatWindow(QWidget* parent) :
42− FramelessDialog(parent, 0, POSITION_RIGHT),
40+ QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
41+ Qt::WindowCloseButtonHint),
4342 ui(new Ui::ChatWindow),
4443 numMessagesAfterLastTimeStamp(0),
4544 _mousePressed(false),
@@ -82,7 +81,6 @@ ChatWindow::ChatWindow(QWidget* parent) : · 36 unmodified lines
8281 startTimerForTimeStamps();
8382 } else {
8483 ui->numOnlineLabel->hide();
85− ui->closeButton->hide();
8684 ui->usersArea->hide();
8785 ui->messagesScrollArea->hide();
8886 ui->messagePlainTextEdit->hide();
@@ -112,17 +110,25 @@ ChatWindow::~ChatWindow() { · 23 unmodified lines
112110 void ChatWindow::keyPressEvent(QKeyEvent* event) {
113111 if (event->key() == Qt::Key_Escape) {
114112 Application::getInstance()->getWindow()->activateWindow();
113+ hide();
115114 } else {
116− FramelessDialog::keyPressEvent(event);
115+ QWidget::keyPressEvent(event);
117116 }
118117 }
119118
120119 void ChatWindow::showEvent(QShowEvent* event) {
121− FramelessDialog::showEvent(event);
120+ QWidget::showEvent(event);
122121
123122 if (!event->spontaneous()) {
124123 ui->messagePlainTextEdit->setFocus();
125124 }
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);
126132
127133 Application::processEvents();
128134
@@ -167,7 +173,7 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { · 38 unmodified lines
167173 return true;
168174 }
169175 }
170− return FramelessDialog::eventFilter(sender, event);
176+ return QWidget::eventFilter(sender, event);
171177 }
172178
173179 void ChatWindow::addTimeStamp() {
@@ -214,7 +220,6 @@ void ChatWindow::startTimerForTimeStamps() { · 40 unmodified lines
214220 void ChatWindow::connected() {
215221 ui->connectingToXMPPLabel->hide();
216222 ui->numOnlineLabel->show();
217− ui->closeButton->show();
218223 ui->usersArea->show();
219224 ui->messagesScrollArea->show();
220225 ui->messagePlainTextEdit->show();
@@ -393,9 +398,7 @@ void ChatWindow::scrollToBottom() { · 172 unmodified lines
393398
394399 bool ChatWindow::event(QEvent* event) {
395400 if (event->type() == QEvent::WindowActivate) {
396− setWindowOpacity(OPACITY_ACTIVE);
397− } else if (event->type() == QEvent::WindowDeactivate) {
398− setWindowOpacity(OPACITY_INACTIVE);
401+ ui->messagePlainTextEdit->setFocus();
399402 }
400− return FramelessDialog::event(event);
403+ return QWidget::event(event);
401404 }

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