mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:37:46 +02:00
Enabled going to the clicked user in the chat.
This commit is contained in:
parent
65f912249d
commit
a48ca65236
4 changed files with 52 additions and 37 deletions
|
@ -45,7 +45,7 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="src/ui/ChatWindow.cpp" line="128"/>
|
<location filename="src/ui/ChatWindow.cpp" line="133"/>
|
||||||
<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="128"/>
|
<location filename="src/ui/ChatWindow.cpp" line="133"/>
|
||||||
<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="128"/>
|
<location filename="src/ui/ChatWindow.cpp" line="133"/>
|
||||||
<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="183"/>
|
<location filename="src/ui/ChatWindow.cpp" line="188"/>
|
||||||
<source>%1 online now:</source>
|
<source>%1 online now:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -923,12 +923,16 @@ void Menu::goTo() {
|
||||||
gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
|
gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
|
||||||
|
|
||||||
int dialogReturn = gotoDialog.exec();
|
int dialogReturn = gotoDialog.exec();
|
||||||
if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
|
goToUser(dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty(),
|
||||||
|
gotoDialog.textValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::goToUser(bool go, const QString& user) {
|
||||||
|
if (go) {
|
||||||
LocationManager* manager = &LocationManager::getInstance();
|
LocationManager* manager = &LocationManager::getInstance();
|
||||||
manager->goTo(gotoDialog.textValue());
|
manager->goTo(user);
|
||||||
connect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision);
|
connect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFakeEnterEvent();
|
sendFakeEnterEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ public slots:
|
||||||
void importSettings();
|
void importSettings();
|
||||||
void exportSettings();
|
void exportSettings();
|
||||||
void goTo();
|
void goTo();
|
||||||
|
void goToUser(bool go, const QString& user);
|
||||||
void pasteToVoxel();
|
void pasteToVoxel();
|
||||||
|
|
||||||
void toggleLoginMenuItem();
|
void toggleLoginMenuItem();
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QTextDocument>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -90,27 +89,33 @@ void ChatWindow::showEvent(QShowEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
|
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
Q_UNUSED(sender);
|
if (sender == ui->messagePlainTextEdit) {
|
||||||
|
if (event->type() != QEvent::KeyPress) {
|
||||||
if (event->type() != QEvent::KeyPress) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
|
||||||
if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) &&
|
|
||||||
(keyEvent->modifiers() & Qt::ShiftModifier) == 0) {
|
|
||||||
QString messageText = ui->messagePlainTextEdit->document()->toPlainText().trimmed();
|
|
||||||
if (!messageText.isEmpty()) {
|
|
||||||
#ifdef HAVE_QXMPP
|
|
||||||
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
|
|
||||||
QXmppMessage message;
|
|
||||||
message.setTo(publicChatRoom->jid());
|
|
||||||
message.setType(QXmppMessage::GroupChat);
|
|
||||||
message.setBody(messageText);
|
|
||||||
XmppClient::getInstance().getXMPPClient().sendPacket(message);
|
|
||||||
#endif
|
|
||||||
ui->messagePlainTextEdit->document()->clear();
|
|
||||||
}
|
}
|
||||||
return true;
|
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) &&
|
||||||
|
(keyEvent->modifiers() & Qt::ShiftModifier) == 0) {
|
||||||
|
QString messageText = ui->messagePlainTextEdit->document()->toPlainText().trimmed();
|
||||||
|
if (!messageText.isEmpty()) {
|
||||||
|
#ifdef HAVE_QXMPP
|
||||||
|
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
|
||||||
|
QXmppMessage message;
|
||||||
|
message.setTo(publicChatRoom->jid());
|
||||||
|
message.setType(QXmppMessage::GroupChat);
|
||||||
|
message.setBody(messageText);
|
||||||
|
XmppClient::getInstance().getXMPPClient().sendPacket(message);
|
||||||
|
#endif
|
||||||
|
ui->messagePlainTextEdit->document()->clear();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (event->type() != QEvent::MouseButtonRelease) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QString user = sender->property("user").toString();
|
||||||
|
Menu::getInstance()->goToUser(true, user);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -187,16 +192,21 @@ void ChatWindow::participantsChanged() {
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
foreach (const QString& participant, participants) {
|
foreach (const QString& participant, participants) {
|
||||||
QLabel* userLabel = new QLabel(getParticipantName(participant));
|
QString participantName = getParticipantName(participant);
|
||||||
|
QLabel* userLabel = new QLabel();
|
||||||
|
userLabel->setText(participantName);
|
||||||
userLabel->setStyleSheet("background-color: palette(light);"
|
userLabel->setStyleSheet("background-color: palette(light);"
|
||||||
"border-radius: 5px;"
|
"border-radius: 5px;"
|
||||||
"color: #267077;"
|
"color: #267077;"
|
||||||
"padding-top: 3px;"
|
"padding-top: 3px;"
|
||||||
"padding-right: 2px;"
|
"padding-right: 2px;"
|
||||||
"padding-bottom: 2px;"
|
"padding-bottom: 2px;"
|
||||||
"padding-left: 2px;"
|
"padding-left: 2px;"
|
||||||
"border: 1px solid palette(shadow);"
|
"border: 1px solid palette(shadow);"
|
||||||
"font-weight: bold");
|
"font-weight: bold");
|
||||||
|
userLabel->setProperty("user", participantName);
|
||||||
|
userLabel->setCursor(Qt::PointingHandCursor);
|
||||||
|
userLabel->installEventFilter(this);
|
||||||
ui->usersWidget->layout()->addWidget(userLabel);
|
ui->usersWidget->layout()->addWidget(userLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue