mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +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");
|
||||
hostString = hostString.arg(QString::fromStdString(settings["launcher"]["lobbyUrl"].String()));
|
||||
hostString = hostString.arg(settings["launcher"]["lobbyPort"].Integer());
|
||||
|
||||
namesCompleter.setModel(ui->listUsers->model());
|
||||
namesCompleter.setCompletionMode(QCompleter::InlineCompletion);
|
||||
ui->serverEdit->setText(hostString);
|
||||
ui->userEdit->setText(QString::fromStdString(settings["launcher"]["lobbyUsername"].String()));
|
||||
ui->kickButton->setVisible(false);
|
||||
ui->messageEdit->setCompleter(&namesCompleter);
|
||||
}
|
||||
|
||||
void Lobby::changeEvent(QEvent *event)
|
||||
@ -151,6 +153,7 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
case JOINED:
|
||||
case KICKED:
|
||||
protocolAssert(args.size() == 2);
|
||||
session = "";
|
||||
joinStr = (command.command == JOINED ? "%1 joined to the session %2" : "%1 left session %2");
|
||||
|
||||
if(args[1] == username)
|
||||
@ -261,7 +264,7 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
ui->listUsers->clear();
|
||||
for(int i = 0; i < amount; ++i)
|
||||
{
|
||||
ui->listUsers->addItem(new QListWidgetItem(args[i + 1]));
|
||||
ui->listUsers->addItem(new QListWidgetItem("@" + args[i + 1]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -322,6 +325,7 @@ catch(const ProtocolError & e)
|
||||
void Lobby::onDisconnected()
|
||||
{
|
||||
authentificationStatus = AuthStatus::AUTH_NONE;
|
||||
session = "";
|
||||
ui->stackedWidget->setCurrentWidget(ui->sessionsPage);
|
||||
ui->connectButton->setChecked(false);
|
||||
ui->serverEdit->setEnabled(true);
|
||||
@ -342,7 +346,12 @@ void Lobby::chatMessage(QString title, QString body, bool isSystem)
|
||||
curs.movePosition(QTextCursor::End);
|
||||
curs.insertText(title + ": ", fmtTitle);
|
||||
curs.insertText(body + "\n", fmtBody);
|
||||
ui->chat->ensureCursorVisible();
|
||||
|
||||
if(ui->chat->verticalScrollBar()->maximum() - ui->chat->verticalScrollBar()->value() > 32)
|
||||
{
|
||||
ui->chat->ensureCursorVisible();
|
||||
ui->chat->verticalScrollBar()->setValue(ui->chat->verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
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_chatSwither_clicked();
|
||||
|
||||
private:
|
||||
QString serverUrl;
|
||||
int serverPort;
|
||||
@ -76,6 +78,7 @@ private:
|
||||
QString username;
|
||||
QStringList gameArgs;
|
||||
QMap<QString, QString> hostModsMap;
|
||||
QCompleter namesCompleter;
|
||||
|
||||
enum AuthStatus
|
||||
{
|
||||
@ -83,6 +86,9 @@ private:
|
||||
};
|
||||
|
||||
AuthStatus authentificationStatus = AUTH_NONE;
|
||||
|
||||
bool isGlobalChat = true;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> lastTimePointScrollBar;
|
||||
|
||||
private:
|
||||
QMap<QString, QString> buildModsMap() const;
|
||||
|
@ -71,11 +71,25 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Players in lobby</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Users in chat</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="chatSwither">
|
||||
<property name="text">
|
||||
<string>Global chat</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listUsers">
|
||||
@ -109,22 +123,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<widget class="QTextBrowser" name="chat"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="messageEdit">
|
||||
<property name="text">
|
||||
<string>Lobby chat</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>type you message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="chat">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="messageEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user