Update chat window behavior

Lower opacity when inactive
Move focus to main window when pressing escape, instead of hiding
This commit is contained in:
Ryan Huffman 2014-06-19 19:45:43 -07:00
parent d7782a2365
commit 0c87f0aabc
3 changed files with 15 additions and 1 deletions

View file

@ -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.");
}

View file

@ -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);
}

View file

@ -50,6 +50,7 @@ protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void showEvent(QShowEvent* event);
virtual bool event(QEvent* event);
private:
#ifdef HAVE_QXMPP