Merge pull request #4749 from zhaowenlan1779/webfix
web_service: Misc fixes
This commit is contained in:
@@ -10,10 +10,11 @@
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure.h"
|
||||
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry)
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, bool enable_web_config)
|
||||
: QDialog(parent), registry(registry), ui(new Ui::ConfigureDialog) {
|
||||
ui->setupUi(this);
|
||||
ui->hotkeysTab->Populate(registry);
|
||||
ui->webTab->SetWebServiceConfigEnabled(enable_web_config);
|
||||
|
||||
this->PopulateSelectionList();
|
||||
connect(ui->uiTab, &ConfigureUi::languageChanged, this, &ConfigureDialog::onLanguageChanged);
|
||||
|
@@ -17,7 +17,8 @@ class ConfigureDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry);
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
|
||||
bool enable_web_config = true);
|
||||
~ConfigureDialog() override;
|
||||
|
||||
void applyConfiguration();
|
||||
|
@@ -118,3 +118,8 @@ void ConfigureWeb::OnLoginVerified() {
|
||||
void ConfigureWeb::retranslateUi() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ConfigureWeb::SetWebServiceConfigEnabled(bool enabled) {
|
||||
ui->label_disable_info->setVisible(!enabled);
|
||||
ui->groupBoxWebConfig->setEnabled(enabled);
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ public:
|
||||
void applyConfiguration();
|
||||
void retranslateUi();
|
||||
void setConfiguration();
|
||||
void SetWebServiceConfigEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
void RefreshTelemetryID();
|
||||
|
@@ -118,6 +118,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_disable_info">
|
||||
<property name="text">
|
||||
<string>Web Service configuration can only be changed when a public room isn't being hosted.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
|
@@ -421,6 +421,8 @@ void GameList::DonePopulating(QStringList watch_list) {
|
||||
if (childrenTotal > 0) {
|
||||
search_field->setFocus();
|
||||
}
|
||||
|
||||
emit PopulatingCompleted();
|
||||
}
|
||||
|
||||
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||
|
@@ -76,6 +76,7 @@ signals:
|
||||
void OpenDirectory(QString directory);
|
||||
void AddDirectory();
|
||||
void ShowList(bool show);
|
||||
void PopulatingCompleted();
|
||||
|
||||
private slots:
|
||||
void onItemExpanded(const QModelIndex& item);
|
||||
|
@@ -506,6 +506,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
||||
&GMainWindow::OnGameListAddDirectory);
|
||||
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
|
||||
connect(game_list, &GameList::PopulatingCompleted,
|
||||
[this] { multiplayer_state->UpdateGameList(game_list->GetModel()); });
|
||||
|
||||
connect(this, &GMainWindow::EmulationStarting, render_window,
|
||||
&GRenderWindow::OnEmulationStarting);
|
||||
@@ -1335,7 +1337,8 @@ void GMainWindow::OnCheats() {
|
||||
}
|
||||
|
||||
void GMainWindow::OnConfigure() {
|
||||
ConfigureDialog configureDialog(this, hotkey_registry);
|
||||
ConfigureDialog configureDialog(this, hotkey_registry,
|
||||
!multiplayer_state->IsHostingPublicRoom());
|
||||
connect(&configureDialog, &ConfigureDialog::languageChanged, this,
|
||||
&GMainWindow::OnLanguageChanged);
|
||||
auto old_theme = UISettings::values.theme;
|
||||
@@ -1350,6 +1353,8 @@ void GMainWindow::OnConfigure() {
|
||||
UpdateUITheme();
|
||||
if (UISettings::values.enable_discord_presence != old_discord_presence)
|
||||
SetDiscordEnabled(UISettings::values.enable_discord_presence);
|
||||
if (!multiplayer_state->IsHostingPublicRoom())
|
||||
multiplayer_state->UpdateCredentials();
|
||||
emit UpdateThemedIcons();
|
||||
SyncMenuUISettings();
|
||||
game_list->RefreshGameDirectory();
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <QImage>
|
||||
#include <QList>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaType>
|
||||
#include <QTime>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
@@ -40,13 +41,7 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||
|
||||
// Create a proxy to the game list to display the list of preferred games
|
||||
game_list = new QStandardItemModel;
|
||||
|
||||
for (int i = 0; i < list->rowCount(); i++) {
|
||||
auto parent = list->item(i, 0);
|
||||
for (int j = 0; j < parent->rowCount(); j++) {
|
||||
game_list->appendRow(parent->child(j)->clone());
|
||||
}
|
||||
}
|
||||
UpdateGameList(list);
|
||||
|
||||
proxy = new ComboBoxProxyModel;
|
||||
proxy->setSourceModel(game_list);
|
||||
@@ -78,6 +73,16 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||
|
||||
HostRoomWindow::~HostRoomWindow() = default;
|
||||
|
||||
void HostRoomWindow::UpdateGameList(QStandardItemModel* list) {
|
||||
game_list->clear();
|
||||
for (int i = 0; i < list->rowCount(); i++) {
|
||||
auto parent = list->item(i, 0);
|
||||
for (int j = 0; j < parent->rowCount(); j++) {
|
||||
game_list->appendRow(parent->child(j)->clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HostRoomWindow::RetranslateUi() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
@@ -110,6 +115,10 @@ void HostRoomWindow::Host() {
|
||||
NetworkMessage::ShowError(NetworkMessage::PORT_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if (ui->game_list->currentIndex() == -1) {
|
||||
NetworkMessage::ShowError(NetworkMessage::GAME_NOT_SELECTED);
|
||||
return;
|
||||
}
|
||||
if (auto member = Network::GetRoomMember().lock()) {
|
||||
if (member->GetState() == Network::RoomMember::State::Joining) {
|
||||
return;
|
||||
@@ -148,7 +157,22 @@ void HostRoomWindow::Host() {
|
||||
if (is_public) {
|
||||
if (auto session = announce_multiplayer_session.lock()) {
|
||||
// Register the room first to ensure verify_UID is present when we connect
|
||||
session->Register();
|
||||
Common::WebResult result = session->Register();
|
||||
if (result.result_code != Common::WebResult::Code::Success) {
|
||||
QMessageBox::warning(
|
||||
this, tr("Error"),
|
||||
tr("Failed to announce the room to the public lobby. In order to host a "
|
||||
"room publicly, you must have a valid Citra account configured in "
|
||||
"Emulation -> Configure -> Web. If you do not want to publish a room in "
|
||||
"the public lobby, then select Unlisted instead.\nDebug Message: ") +
|
||||
QString::fromStdString(result.result_string),
|
||||
QMessageBox::Ok);
|
||||
ui->host->setEnabled(true);
|
||||
if (auto room = Network::GetRoom().lock()) {
|
||||
room->Destroy();
|
||||
}
|
||||
return;
|
||||
}
|
||||
session->Start();
|
||||
} else {
|
||||
LOG_ERROR(Network, "Starting announce session failed");
|
||||
|
@@ -38,6 +38,11 @@ public:
|
||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||
~HostRoomWindow();
|
||||
|
||||
/**
|
||||
* Updates the dialog with a new game list model.
|
||||
* This model should be the original model of the game list.
|
||||
*/
|
||||
void UpdateGameList(QStandardItemModel* list);
|
||||
void RetranslateUi();
|
||||
|
||||
private:
|
||||
|
@@ -35,13 +35,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
|
||||
// Create a proxy to the game list to get the list of games owned
|
||||
game_list = new QStandardItemModel;
|
||||
|
||||
for (int i = 0; i < list->rowCount(); i++) {
|
||||
auto parent = list->item(i, 0);
|
||||
for (int j = 0; j < parent->rowCount(); j++) {
|
||||
game_list->appendRow(parent->child(j)->clone());
|
||||
}
|
||||
}
|
||||
UpdateGameList(list);
|
||||
|
||||
proxy = new LobbyFilterProxyModel(this, game_list);
|
||||
proxy->setSourceModel(model);
|
||||
@@ -88,6 +82,18 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
RefreshLobby();
|
||||
}
|
||||
|
||||
void Lobby::UpdateGameList(QStandardItemModel* list) {
|
||||
game_list->clear();
|
||||
for (int i = 0; i < list->rowCount(); i++) {
|
||||
auto parent = list->item(i, 0);
|
||||
for (int j = 0; j < parent->rowCount(); j++) {
|
||||
game_list->appendRow(parent->child(j)->clone());
|
||||
}
|
||||
}
|
||||
if (proxy)
|
||||
proxy->UpdateGameList(game_list);
|
||||
}
|
||||
|
||||
void Lobby::RetranslateUi() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
@@ -260,6 +266,10 @@ void Lobby::OnRefreshLobby() {
|
||||
LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list)
|
||||
: QSortFilterProxyModel(parent), game_list(list) {}
|
||||
|
||||
void LobbyFilterProxyModel::UpdateGameList(QStandardItemModel* list) {
|
||||
game_list = list;
|
||||
}
|
||||
|
||||
bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const {
|
||||
// Prioritize filters by fastest to compute
|
||||
|
||||
|
@@ -30,6 +30,11 @@ public:
|
||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||
~Lobby() = default;
|
||||
|
||||
/**
|
||||
* Updates the lobby with a new game list model.
|
||||
* This model should be the original model of the game list.
|
||||
*/
|
||||
void UpdateGameList(QStandardItemModel* list);
|
||||
void RetranslateUi();
|
||||
|
||||
public slots:
|
||||
@@ -76,9 +81,9 @@ private:
|
||||
*/
|
||||
QString PasswordPrompt();
|
||||
|
||||
QStandardItemModel* model;
|
||||
QStandardItemModel* game_list;
|
||||
LobbyFilterProxyModel* proxy;
|
||||
QStandardItemModel* model{};
|
||||
QStandardItemModel* game_list{};
|
||||
LobbyFilterProxyModel* proxy{};
|
||||
|
||||
QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
|
||||
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
||||
@@ -95,6 +100,13 @@ class LobbyFilterProxyModel : public QSortFilterProxyModel {
|
||||
|
||||
public:
|
||||
explicit LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list);
|
||||
|
||||
/**
|
||||
* Updates the filter with a new game list model.
|
||||
* This model should be the processed one created by the Lobby.
|
||||
*/
|
||||
void UpdateGameList(QStandardItemModel* list);
|
||||
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
||||
void sort(int column, Qt::SortOrder order) override;
|
||||
|
||||
|
@@ -16,6 +16,9 @@ const ConnectionError USERNAME_NOT_VALID_SERVER(
|
||||
QT_TR_NOOP("Username is already in use or not valid. Please choose another."));
|
||||
const ConnectionError IP_ADDRESS_NOT_VALID(QT_TR_NOOP("IP is not a valid IPv4 address."));
|
||||
const ConnectionError PORT_NOT_VALID(QT_TR_NOOP("Port must be a number between 0 to 65535."));
|
||||
const ConnectionError GAME_NOT_SELECTED(QT_TR_NOOP(
|
||||
"You must choose a Preferred Game to host a room. If you do not have any games in your game "
|
||||
"list yet, add a game folder by clicking on the plus icon in the game list."));
|
||||
const ConnectionError NO_INTERNET(
|
||||
QT_TR_NOOP("Unable to find an internet connection. Check your internet settings."));
|
||||
const ConnectionError UNABLE_TO_CONNECT(
|
||||
|
@@ -27,6 +27,7 @@ extern const ConnectionError ROOMNAME_NOT_VALID;
|
||||
extern const ConnectionError USERNAME_NOT_VALID_SERVER;
|
||||
extern const ConnectionError IP_ADDRESS_NOT_VALID;
|
||||
extern const ConnectionError PORT_NOT_VALID;
|
||||
extern const ConnectionError GAME_NOT_SELECTED;
|
||||
extern const ConnectionError NO_INTERNET;
|
||||
extern const ConnectionError UNABLE_TO_CONNECT;
|
||||
extern const ConnectionError ROOM_IS_FULL;
|
||||
|
@@ -174,14 +174,11 @@ void MultiplayerState::OnNetworkError(const Network::RoomMember::Error& error) {
|
||||
|
||||
void MultiplayerState::OnAnnounceFailed(const Common::WebResult& result) {
|
||||
announce_multiplayer_session->Stop();
|
||||
QMessageBox::warning(
|
||||
this, tr("Error"),
|
||||
tr("Failed to announce the room to the public lobby. In order to host a room publicly, you "
|
||||
"must have a valid Citra account configured in Emulation -> Configure -> Web. If you do "
|
||||
"not want to publish a room in the public lobby, then select Unlisted instead.\n"
|
||||
"Debug Message: ") +
|
||||
QString::fromStdString(result.result_string),
|
||||
QMessageBox::Ok);
|
||||
QMessageBox::warning(this, tr("Error"),
|
||||
tr("Failed to update the room information. Please check your Internet "
|
||||
"connection and try hosting the room again.\nDebug Message: ") +
|
||||
QString::fromStdString(result.result_string),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
|
||||
void MultiplayerState::UpdateThemedIcons() {
|
||||
@@ -281,3 +278,21 @@ void MultiplayerState::OnDirectConnectToRoom() {
|
||||
}
|
||||
BringWidgetToFront(direct_connect);
|
||||
}
|
||||
|
||||
bool MultiplayerState::IsHostingPublicRoom() const {
|
||||
return announce_multiplayer_session->IsRunning();
|
||||
}
|
||||
|
||||
void MultiplayerState::UpdateCredentials() {
|
||||
announce_multiplayer_session->UpdateCredentials();
|
||||
}
|
||||
|
||||
void MultiplayerState::UpdateGameList(QStandardItemModel* game_list) {
|
||||
game_list_model = game_list;
|
||||
if (lobby) {
|
||||
lobby->UpdateGameList(game_list);
|
||||
}
|
||||
if (host_room) {
|
||||
host_room->UpdateGameList(game_list);
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,20 @@ public:
|
||||
|
||||
void retranslateUi();
|
||||
|
||||
/**
|
||||
* Whether a public room is being hosted or not.
|
||||
* When this is true, Web Services configuration should be disabled.
|
||||
*/
|
||||
bool IsHostingPublicRoom() const;
|
||||
|
||||
void UpdateCredentials();
|
||||
|
||||
/**
|
||||
* Updates the multiplayer dialogs with a new game list model.
|
||||
* This model should be the original model of the game list.
|
||||
*/
|
||||
void UpdateGameList(QStandardItemModel* game_list);
|
||||
|
||||
public slots:
|
||||
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
||||
void OnNetworkError(const Network::RoomMember::Error& error);
|
||||
|
Reference in New Issue
Block a user