From 0c87f0aabc677e27188c887d229390fdeac65ab5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 19 Jun 2014 19:45:43 -0700 Subject: [PATCH 1/2] Update chat window behavior Lower opacity when inactive Move focus to main window when pressing escape, instead of hiding --- interface/src/Menu.cpp | 1 + interface/src/ui/ChatWindow.cpp | 14 +++++++++++++- interface/src/ui/ChatWindow.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 5c8c2e97aa..334a2e441b 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1293,6 +1293,7 @@ void Menu::showChat() { if (_chatWindow->isHidden()) { _chatWindow->show(); } + _chatWindow->activateWindow(); } else { Application::getInstance()->getTrayIcon()->showMessage("Interface", "You need to login to be able to chat with others on this domain."); } diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index fde77334f4..b101b50b2f 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -30,6 +30,9 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20; +const float OPACITY_ACTIVE = 1.0; +const float OPACITY_INACTIVE = 0.6; + const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)"); const QRegularExpression regexHifiLinks("([#@]\\S+)"); const QString mentionSoundsPath("/mention-sounds/"); @@ -108,7 +111,7 @@ ChatWindow::~ChatWindow() { void ChatWindow::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Escape) { - hide(); + Application::getInstance()->getWindow()->activateWindow(); } else { FramelessDialog::keyPressEvent(event); } @@ -383,3 +386,12 @@ void ChatWindow::scrollToBottom() { QScrollBar* verticalScrollBar = ui->messagesScrollArea->verticalScrollBar(); verticalScrollBar->setValue(verticalScrollBar->maximum()); } + +bool ChatWindow::event(QEvent* event) { + if (event->type() == QEvent::WindowActivate) { + setWindowOpacity(OPACITY_ACTIVE); + } else if (event->type() == QEvent::WindowDeactivate) { + setWindowOpacity(OPACITY_INACTIVE); + } + return FramelessDialog::event(event); +} diff --git a/interface/src/ui/ChatWindow.h b/interface/src/ui/ChatWindow.h index 1e0f533e9e..652dcb5b08 100644 --- a/interface/src/ui/ChatWindow.h +++ b/interface/src/ui/ChatWindow.h @@ -50,6 +50,7 @@ protected: virtual void keyPressEvent(QKeyEvent *event); virtual void showEvent(QShowEvent* event); + virtual bool event(QEvent* event); private: #ifdef HAVE_QXMPP From 0e6abe33597dd0fc39a63d6f044d1374fdb0795d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Jun 2014 16:31:22 -0700 Subject: [PATCH 2/2] Update inactive chat window opacity to 0.8 --- interface/src/ui/ChatWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index b101b50b2f..a7d2c212d2 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -31,7 +31,7 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20; const float OPACITY_ACTIVE = 1.0; -const float OPACITY_INACTIVE = 0.6; +const float OPACITY_INACTIVE = 0.8; const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)"); const QRegularExpression regexHifiLinks("([#@]\\S+)");