mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:33:27 +02:00
commit
d342f9281f
4 changed files with 27 additions and 75 deletions
|
@ -1468,7 +1468,9 @@ void Menu::showChat() {
|
||||||
if (_chatWindow->isHidden()) {
|
if (_chatWindow->isHidden()) {
|
||||||
_chatWindow->show();
|
_chatWindow->show();
|
||||||
}
|
}
|
||||||
|
_chatWindow->raise();
|
||||||
_chatWindow->activateWindow();
|
_chatWindow->activateWindow();
|
||||||
|
_chatWindow->setFocus();
|
||||||
} else {
|
} else {
|
||||||
Application::getInstance()->getTrayIcon()->showMessage("Interface", "You need to login to be able to chat with others on this domain.");
|
Application::getInstance()->getTrayIcon()->showMessage("Interface", "You need to login to be able to chat with others on this domain.");
|
||||||
}
|
}
|
||||||
|
@ -1480,6 +1482,9 @@ void Menu::toggleChat() {
|
||||||
if (!_chatAction->isEnabled() && _chatWindow && AccountManager::getInstance().isLoggedIn()) {
|
if (!_chatAction->isEnabled() && _chatWindow && AccountManager::getInstance().isLoggedIn()) {
|
||||||
if (_chatWindow->isHidden()) {
|
if (_chatWindow->isHidden()) {
|
||||||
_chatWindow->show();
|
_chatWindow->show();
|
||||||
|
_chatWindow->raise();
|
||||||
|
_chatWindow->activateWindow();
|
||||||
|
_chatWindow->setFocus();
|
||||||
} else {
|
} else {
|
||||||
_chatWindow->hide();
|
_chatWindow->hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,28 +18,27 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "ChatMessageArea.h"
|
||||||
#include "FlowLayout.h"
|
#include "FlowLayout.h"
|
||||||
#include "qtimespan.h"
|
#include "qtimespan.h"
|
||||||
#include "ui_chatWindow.h"
|
#include "UIUtil.h"
|
||||||
#include "XmppClient.h"
|
#include "XmppClient.h"
|
||||||
#include "ChatMessageArea.h"
|
|
||||||
|
|
||||||
|
#include "ui_chatWindow.h"
|
||||||
#include "ChatWindow.h"
|
#include "ChatWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int NUM_MESSAGES_TO_TIME_STAMP = 20;
|
const int NUM_MESSAGES_TO_TIME_STAMP = 20;
|
||||||
|
|
||||||
const float OPACITY_ACTIVE = 1.0f;
|
|
||||||
const float OPACITY_INACTIVE = 0.8f;
|
|
||||||
|
|
||||||
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)");
|
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?)|(?:hifi))://\\S+)");
|
||||||
const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
||||||
const QString mentionSoundsPath("/mention-sounds/");
|
const QString mentionSoundsPath("/mention-sounds/");
|
||||||
const QString mentionRegex("@(\\b%1\\b)");
|
const QString mentionRegex("@(\\b%1\\b)");
|
||||||
|
|
||||||
ChatWindow::ChatWindow(QWidget* parent) :
|
ChatWindow::ChatWindow(QWidget* parent) :
|
||||||
FramelessDialog(parent, 0, POSITION_RIGHT),
|
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||||
|
Qt::WindowCloseButtonHint),
|
||||||
ui(new Ui::ChatWindow),
|
ui(new Ui::ChatWindow),
|
||||||
numMessagesAfterLastTimeStamp(0),
|
numMessagesAfterLastTimeStamp(0),
|
||||||
_mousePressed(false),
|
_mousePressed(false),
|
||||||
|
@ -82,7 +81,6 @@ ChatWindow::ChatWindow(QWidget* parent) :
|
||||||
startTimerForTimeStamps();
|
startTimerForTimeStamps();
|
||||||
} else {
|
} else {
|
||||||
ui->numOnlineLabel->hide();
|
ui->numOnlineLabel->hide();
|
||||||
ui->closeButton->hide();
|
|
||||||
ui->usersArea->hide();
|
ui->usersArea->hide();
|
||||||
ui->messagesScrollArea->hide();
|
ui->messagesScrollArea->hide();
|
||||||
ui->messagePlainTextEdit->hide();
|
ui->messagePlainTextEdit->hide();
|
||||||
|
@ -112,17 +110,25 @@ ChatWindow::~ChatWindow() {
|
||||||
void ChatWindow::keyPressEvent(QKeyEvent* event) {
|
void ChatWindow::keyPressEvent(QKeyEvent* event) {
|
||||||
if (event->key() == Qt::Key_Escape) {
|
if (event->key() == Qt::Key_Escape) {
|
||||||
Application::getInstance()->getWindow()->activateWindow();
|
Application::getInstance()->getWindow()->activateWindow();
|
||||||
|
hide();
|
||||||
} else {
|
} else {
|
||||||
FramelessDialog::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWindow::showEvent(QShowEvent* event) {
|
void ChatWindow::showEvent(QShowEvent* event) {
|
||||||
FramelessDialog::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
|
|
||||||
if (!event->spontaneous()) {
|
if (!event->spontaneous()) {
|
||||||
ui->messagePlainTextEdit->setFocus();
|
ui->messagePlainTextEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
const QRect parentGeometry = parentWidget()->geometry();
|
||||||
|
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
||||||
|
int menuBarHeight = Menu::getInstance()->geometry().height();
|
||||||
|
int topMargin = titleBarHeight + menuBarHeight;
|
||||||
|
|
||||||
|
setGeometry(parentGeometry.topRight().x() - size().width() + 1, parentGeometry.topRight().y() + topMargin,
|
||||||
|
size().width(), parentWidget()->height() - topMargin);
|
||||||
|
|
||||||
Application::processEvents();
|
Application::processEvents();
|
||||||
|
|
||||||
|
@ -167,7 +173,7 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FramelessDialog::eventFilter(sender, event);
|
return QWidget::eventFilter(sender, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWindow::addTimeStamp() {
|
void ChatWindow::addTimeStamp() {
|
||||||
|
@ -214,7 +220,6 @@ void ChatWindow::startTimerForTimeStamps() {
|
||||||
void ChatWindow::connected() {
|
void ChatWindow::connected() {
|
||||||
ui->connectingToXMPPLabel->hide();
|
ui->connectingToXMPPLabel->hide();
|
||||||
ui->numOnlineLabel->show();
|
ui->numOnlineLabel->show();
|
||||||
ui->closeButton->show();
|
|
||||||
ui->usersArea->show();
|
ui->usersArea->show();
|
||||||
ui->messagesScrollArea->show();
|
ui->messagesScrollArea->show();
|
||||||
ui->messagePlainTextEdit->show();
|
ui->messagePlainTextEdit->show();
|
||||||
|
@ -393,9 +398,7 @@ void ChatWindow::scrollToBottom() {
|
||||||
|
|
||||||
bool ChatWindow::event(QEvent* event) {
|
bool ChatWindow::event(QEvent* event) {
|
||||||
if (event->type() == QEvent::WindowActivate) {
|
if (event->type() == QEvent::WindowActivate) {
|
||||||
setWindowOpacity(OPACITY_ACTIVE);
|
ui->messagePlainTextEdit->setFocus();
|
||||||
} else if (event->type() == QEvent::WindowDeactivate) {
|
|
||||||
setWindowOpacity(OPACITY_INACTIVE);
|
|
||||||
}
|
}
|
||||||
return FramelessDialog::event(event);
|
return QWidget::event(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ const int AUTO_SCROLL_THRESHOLD = 20;
|
||||||
class ChatWindow;
|
class ChatWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatWindow : public FramelessDialog {
|
class ChatWindow : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ChatWindow</class>
|
<class>ChatWindow</class>
|
||||||
<widget class="QDialog" name="ChatWindow">
|
<widget class="QWidget" name="ChatWindow">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -86,45 +86,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="closeButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QPushButton {
|
|
||||||
background-color: rgba( 0, 0, 0, 0% );
|
|
||||||
border: none;
|
|
||||||
image: url(../resources/images/close.svg)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPushButton:pressed {
|
|
||||||
background-color: rgba( 0, 0, 0, 0% );
|
|
||||||
border: none;
|
|
||||||
image: url(../resources/images/close_down.svg)
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -283,7 +244,7 @@ border-color: palette(dark); border-style: solid; border-left-width: 1px; borde
|
||||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="tabChangesFocus">
|
<property name="tabChangesFocus">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptRichText">
|
<property name="acceptRichText">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -308,22 +269,5 @@ border-color: palette(dark); border-style: solid; border-left-width: 1px; borde
|
||||||
<tabstop>messagesScrollArea</tabstop>
|
<tabstop>messagesScrollArea</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>closeButton</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>ChatWindow</receiver>
|
|
||||||
<slot>hide()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>390</x>
|
|
||||||
<y>42</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>550</x>
|
|
||||||
<y>42</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue