mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:50:37 +02:00
Merge pull request #2303 from ddobrev/xmppchat
Moved the chat from a window to a built-in panel
This commit is contained in:
commit
c9c76ca30f
6 changed files with 69 additions and 38 deletions
|
@ -4,22 +4,22 @@
|
||||||
<context>
|
<context>
|
||||||
<name>Application</name>
|
<name>Application</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="1353"/>
|
<location filename="src/Application.cpp" line="1362"/>
|
||||||
<source>Export Voxels</source>
|
<source>Export Voxels</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="1354"/>
|
<location filename="src/Application.cpp" line="1363"/>
|
||||||
<source>Sparse Voxel Octree Files (*.svo)</source>
|
<source>Sparse Voxel Octree Files (*.svo)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="3557"/>
|
<location filename="src/Application.cpp" line="3569"/>
|
||||||
<source>Open Script</source>
|
<source>Open Script</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Application.cpp" line="3558"/>
|
<location filename="src/Application.cpp" line="3570"/>
|
||||||
<source>JavaScript Files (*.js)</source>
|
<source>JavaScript Files (*.js)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -27,25 +27,25 @@
|
||||||
<context>
|
<context>
|
||||||
<name>ChatWindow</name>
|
<name>ChatWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="ui/chatWindow.ui" line="14"/>
|
<location filename="ui/chatWindow.ui" line="20"/>
|
||||||
<location filename="../build/interface/ui_chatWindow.h" line="141"/>
|
<location filename="../build/interface/ui_chatWindow.h" line="143"/>
|
||||||
<source>Chat</source>
|
<source>Chat</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="ui/chatWindow.ui" line="41"/>
|
<location filename="ui/chatWindow.ui" line="50"/>
|
||||||
<location filename="../build/interface/ui_chatWindow.h" line="142"/>
|
<location filename="../build/interface/ui_chatWindow.h" line="144"/>
|
||||||
<source>Connecting to XMPP...</source>
|
<source>Connecting to XMPP...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="ui/chatWindow.ui" line="62"/>
|
<location filename="ui/chatWindow.ui" line="71"/>
|
||||||
<location filename="../build/interface/ui_chatWindow.h" line="143"/>
|
<location filename="../build/interface/ui_chatWindow.h" line="145"/>
|
||||||
<source> online now:</source>
|
<source> online now:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="src/ui/ChatWindow.cpp" line="115"/>
|
<location filename="src/ui/ChatWindow.cpp" line="124"/>
|
||||||
<source>day</source>
|
<source>day</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>%n day</numerusform>
|
<numerusform>%n day</numerusform>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="src/ui/ChatWindow.cpp" line="115"/>
|
<location filename="src/ui/ChatWindow.cpp" line="124"/>
|
||||||
<source>hour</source>
|
<source>hour</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>%n hour</numerusform>
|
<numerusform>%n hour</numerusform>
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="src/ui/ChatWindow.cpp" line="115"/>
|
<location filename="src/ui/ChatWindow.cpp" line="124"/>
|
||||||
<source>minute</source>
|
<source>minute</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>%n minute</numerusform>
|
<numerusform>%n minute</numerusform>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/ui/ChatWindow.cpp" line="170"/>
|
<location filename="src/ui/ChatWindow.cpp" line="179"/>
|
||||||
<source>%1 online now:</source>
|
<source>%1 online now:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -113,18 +113,18 @@
|
||||||
<context>
|
<context>
|
||||||
<name>Menu</name>
|
<name>Menu</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Menu.cpp" line="422"/>
|
<location filename="src/Menu.cpp" line="424"/>
|
||||||
<source>Open .ini config file</source>
|
<source>Open .ini config file</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Menu.cpp" line="424"/>
|
<location filename="src/Menu.cpp" line="426"/>
|
||||||
<location filename="src/Menu.cpp" line="436"/>
|
<location filename="src/Menu.cpp" line="438"/>
|
||||||
<source>Text files (*.ini)</source>
|
<source>Text files (*.ini)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="src/Menu.cpp" line="434"/>
|
<location filename="src/Menu.cpp" line="436"/>
|
||||||
<source>Save .ini config file</source>
|
<source>Save .ini config file</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
@ -291,7 +292,14 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
ResourceCache::setNetworkAccessManager(_networkAccessManager);
|
ResourceCache::setNetworkAccessManager(_networkAccessManager);
|
||||||
ResourceCache::setRequestLimit(3);
|
ResourceCache::setRequestLimit(3);
|
||||||
|
|
||||||
_window->setCentralWidget(_glWidget);
|
QWidget* centralWidget = new QWidget();
|
||||||
|
QHBoxLayout* mainLayout = new QHBoxLayout();
|
||||||
|
mainLayout->setSpacing(0);
|
||||||
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
centralWidget->setLayout(mainLayout);
|
||||||
|
_glWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
centralWidget->layout()->addWidget(_glWidget);
|
||||||
|
_window->setCentralWidget(centralWidget);
|
||||||
|
|
||||||
restoreSizeAndPosition();
|
restoreSizeAndPosition();
|
||||||
|
|
||||||
|
|
|
@ -1041,22 +1041,20 @@ void Menu::showChat() {
|
||||||
if (!_chatWindow) {
|
if (!_chatWindow) {
|
||||||
_chatWindow = new ChatWindow();
|
_chatWindow = new ChatWindow();
|
||||||
QMainWindow* mainWindow = Application::getInstance()->getWindow();
|
QMainWindow* mainWindow = Application::getInstance()->getWindow();
|
||||||
_chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(),
|
QBoxLayout* boxLayout = static_cast<QBoxLayout*>(mainWindow->centralWidget()->layout());
|
||||||
mainWindow->geometry().y(),
|
boxLayout->addWidget(_chatWindow, 0, Qt::AlignRight);
|
||||||
_chatWindow->width(),
|
} else {
|
||||||
mainWindow->height());
|
|
||||||
}
|
|
||||||
if (!_chatWindow->isVisible()) {
|
if (!_chatWindow->isVisible()) {
|
||||||
_chatWindow->show();
|
_chatWindow->show();
|
||||||
}
|
}
|
||||||
_chatWindow->raise();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::toggleChat() {
|
void Menu::toggleChat() {
|
||||||
#ifdef HAVE_QXMPP
|
#ifdef HAVE_QXMPP
|
||||||
_chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected());
|
_chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected());
|
||||||
if (!_chatAction->isEnabled() && _chatWindow) {
|
if (!_chatAction->isEnabled() && _chatWindow) {
|
||||||
_chatWindow->close();
|
_chatWindow->hide();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20;
|
||||||
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
|
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
|
||||||
|
|
||||||
ChatWindow::ChatWindow() :
|
ChatWindow::ChatWindow() :
|
||||||
QDialog(Application::getInstance()->getGLWidget(), Qt::CustomizeWindowHint),
|
QWidget(),
|
||||||
ui(new Ui::ChatWindow),
|
ui(new Ui::ChatWindow),
|
||||||
numMessagesAfterLastTimeStamp(0)
|
numMessagesAfterLastTimeStamp(0)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,6 @@ ChatWindow::ChatWindow() :
|
||||||
|
|
||||||
ui->messagePlainTextEdit->installEventFilter(this);
|
ui->messagePlainTextEdit->installEventFilter(this);
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
#ifdef HAVE_QXMPP
|
#ifdef HAVE_QXMPP
|
||||||
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
|
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
|
||||||
if (xmppClient.isConnected()) {
|
if (xmppClient.isConnected()) {
|
||||||
|
@ -72,9 +71,19 @@ ChatWindow::~ChatWindow() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWindow::reject() {
|
void ChatWindow::keyPressEvent(QKeyEvent* event) {
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
if (event->key() == Qt::Key_Escape) {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatWindow::showEvent(QShowEvent* event) {
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
if (!event->spontaneous()) {
|
||||||
|
ui->messagePlainTextEdit->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
|
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
Q_UNUSED(sender);
|
Q_UNUSED(sender);
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#ifndef __interface__ChatWindow__
|
#ifndef __interface__ChatWindow__
|
||||||
#define __interface__ChatWindow__
|
#define __interface__ChatWindow__
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
@ -26,14 +26,15 @@ namespace Ui {
|
||||||
class ChatWindow;
|
class ChatWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatWindow : public QDialog {
|
class ChatWindow : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatWindow();
|
ChatWindow();
|
||||||
~ChatWindow();
|
~ChatWindow();
|
||||||
|
|
||||||
virtual void reject();
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
|
virtual void showEvent(QShowEvent* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject* sender, QEvent* event);
|
bool eventFilter(QObject* sender, QEvent* event);
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -10,9 +10,18 @@
|
||||||
<height>608</height>
|
<height>608</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Chat</string>
|
<string>Chat</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font-family: Helvetica, Arial, sans-serif;</string>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -100,7 +109,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="messagesScrollArea">
|
<widget class="QScrollArea" name="messagesScrollArea">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">margin-top: 12px; font-family: Helvetica, Arial, sans-serif;</string>
|
<string notr="true">margin-top: 12px;</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
@ -114,7 +123,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>358</width>
|
<width>358</width>
|
||||||
<height>452</height>
|
<height>464</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
@ -154,6 +163,12 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;</string>
|
<string notr="true">border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in a new issue