mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-28 03:57:02 +02:00
Chat minor improvements
This commit is contained in:
parent
cab2bddf7e
commit
75258baefc
@ -41,10 +41,12 @@ Lobby::Lobby(QWidget *parent) :
|
|||||||
QString hostString("%1:%2");
|
QString hostString("%1:%2");
|
||||||
hostString = hostString.arg(QString::fromStdString(settings["launcher"]["lobbyUrl"].String()));
|
hostString = hostString.arg(QString::fromStdString(settings["launcher"]["lobbyUrl"].String()));
|
||||||
hostString = hostString.arg(settings["launcher"]["lobbyPort"].Integer());
|
hostString = hostString.arg(settings["launcher"]["lobbyPort"].Integer());
|
||||||
|
namesCompleter.setModel(ui->listUsers->model());
|
||||||
|
namesCompleter.setCompletionMode(QCompleter::InlineCompletion);
|
||||||
ui->serverEdit->setText(hostString);
|
ui->serverEdit->setText(hostString);
|
||||||
ui->userEdit->setText(QString::fromStdString(settings["launcher"]["lobbyUsername"].String()));
|
ui->userEdit->setText(QString::fromStdString(settings["launcher"]["lobbyUsername"].String()));
|
||||||
ui->kickButton->setVisible(false);
|
ui->kickButton->setVisible(false);
|
||||||
|
ui->messageEdit->setCompleter(&namesCompleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::changeEvent(QEvent *event)
|
void Lobby::changeEvent(QEvent *event)
|
||||||
@ -151,6 +153,7 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
|||||||
case JOINED:
|
case JOINED:
|
||||||
case KICKED:
|
case KICKED:
|
||||||
protocolAssert(args.size() == 2);
|
protocolAssert(args.size() == 2);
|
||||||
|
session = "";
|
||||||
joinStr = (command.command == JOINED ? "%1 joined to the session %2" : "%1 left session %2");
|
joinStr = (command.command == JOINED ? "%1 joined to the session %2" : "%1 left session %2");
|
||||||
|
|
||||||
if(args[1] == username)
|
if(args[1] == username)
|
||||||
@ -261,7 +264,7 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
|||||||
ui->listUsers->clear();
|
ui->listUsers->clear();
|
||||||
for(int i = 0; i < amount; ++i)
|
for(int i = 0; i < amount; ++i)
|
||||||
{
|
{
|
||||||
ui->listUsers->addItem(new QListWidgetItem(args[i + 1]));
|
ui->listUsers->addItem(new QListWidgetItem("@" + args[i + 1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -322,6 +325,7 @@ catch(const ProtocolError & e)
|
|||||||
void Lobby::onDisconnected()
|
void Lobby::onDisconnected()
|
||||||
{
|
{
|
||||||
authentificationStatus = AuthStatus::AUTH_NONE;
|
authentificationStatus = AuthStatus::AUTH_NONE;
|
||||||
|
session = "";
|
||||||
ui->stackedWidget->setCurrentWidget(ui->sessionsPage);
|
ui->stackedWidget->setCurrentWidget(ui->sessionsPage);
|
||||||
ui->connectButton->setChecked(false);
|
ui->connectButton->setChecked(false);
|
||||||
ui->serverEdit->setEnabled(true);
|
ui->serverEdit->setEnabled(true);
|
||||||
@ -342,7 +346,12 @@ void Lobby::chatMessage(QString title, QString body, bool isSystem)
|
|||||||
curs.movePosition(QTextCursor::End);
|
curs.movePosition(QTextCursor::End);
|
||||||
curs.insertText(title + ": ", fmtTitle);
|
curs.insertText(title + ": ", fmtTitle);
|
||||||
curs.insertText(body + "\n", fmtBody);
|
curs.insertText(body + "\n", fmtBody);
|
||||||
|
|
||||||
|
if(ui->chat->verticalScrollBar()->maximum() - ui->chat->verticalScrollBar()->value() > 32)
|
||||||
|
{
|
||||||
ui->chat->ensureCursorVisible();
|
ui->chat->ensureCursorVisible();
|
||||||
|
ui->chat->verticalScrollBar()->setValue(ui->chat->verticalScrollBar()->maximum());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::sysMessage(QString body)
|
void Lobby::sysMessage(QString body)
|
||||||
@ -564,3 +573,9 @@ void Lobby::on_optLoadGame_toggled(bool checked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Lobby::on_chatSwither_clicked()
|
||||||
|
{
|
||||||
|
isGlobalChat = session.isEmpty() ? true : !isGlobalChat;
|
||||||
|
ui->chatSwither->setText(isGlobalChat ? tr("Global chat") : tr("Room chat"));
|
||||||
|
}
|
||||||
|
@ -64,6 +64,8 @@ private slots:
|
|||||||
|
|
||||||
void on_optLoadGame_toggled(bool checked);
|
void on_optLoadGame_toggled(bool checked);
|
||||||
|
|
||||||
|
void on_chatSwither_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString serverUrl;
|
QString serverUrl;
|
||||||
int serverPort;
|
int serverPort;
|
||||||
@ -76,6 +78,7 @@ private:
|
|||||||
QString username;
|
QString username;
|
||||||
QStringList gameArgs;
|
QStringList gameArgs;
|
||||||
QMap<QString, QString> hostModsMap;
|
QMap<QString, QString> hostModsMap;
|
||||||
|
QCompleter namesCompleter;
|
||||||
|
|
||||||
enum AuthStatus
|
enum AuthStatus
|
||||||
{
|
{
|
||||||
@ -84,6 +87,9 @@ private:
|
|||||||
|
|
||||||
AuthStatus authentificationStatus = AUTH_NONE;
|
AuthStatus authentificationStatus = AUTH_NONE;
|
||||||
|
|
||||||
|
bool isGlobalChat = true;
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> lastTimePointScrollBar;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<QString, QString> buildModsMap() const;
|
QMap<QString, QString> buildModsMap() const;
|
||||||
bool isModAvailable(const QString & modName, const QString & modVersion) const;
|
bool isModAvailable(const QString & modName, const QString & modVersion) const;
|
||||||
|
@ -67,16 +67,30 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Players in lobby</string>
|
<string>Users in chat</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="chatSwither">
|
||||||
|
<property name="text">
|
||||||
|
<string>Global chat</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listUsers">
|
<widget class="QListWidget" name="listUsers">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -109,22 +123,18 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QTextBrowser" name="chat"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="messageEdit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Lobby chat</string>
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>type you message</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPlainTextEdit" name="chat">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="messageEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user