aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/direct_connect_dialog.cpp12
-rw-r--r--src/widgets/server_editor_dialog.cpp49
-rw-r--r--src/widgets/server_editor_dialog.h5
3 files changed, 24 insertions, 42 deletions
diff --git a/src/widgets/direct_connect_dialog.cpp b/src/widgets/direct_connect_dialog.cpp
index db4cde62..6a09b77b 100644
--- a/src/widgets/direct_connect_dialog.cpp
+++ b/src/widgets/direct_connect_dialog.cpp
@@ -50,27 +50,29 @@ void DirectConnectDialog::onConnectPressed()
QString l_hostname = ui_direct_hostname_edit->text();
if (!SCHEME_PATTERN.match(l_hostname).hasMatch())
{
- l_hostname = "tcp://" % l_hostname;
+ l_hostname = "ws://" % l_hostname;
}
+
QUrl l_url(l_hostname);
if (!l_url.isValid())
{
call_error(tr("Invalid URL."));
return;
}
- if (!SERVER_CONNECTION_TYPE_STRING_MAP.contains(l_url.scheme()))
+
+ if (l_url.scheme() != "ws")
{
- call_error(tr("Scheme not recognized. Must be either of the following: ") % QStringList::fromVector(SERVER_CONNECTION_TYPE_STRING_MAP.keys().toVector()).join(", "));
+ call_error(tr("Invalid URL scheme. Only ws:// is supported."));
return;
}
+
if (l_url.port() == -1)
{
call_error(tr("Invalid server port."));
return;
}
ServerInfo l_server;
- l_server.socket_type = SERVER_CONNECTION_TYPE_STRING_MAP[l_url.scheme()];
- l_server.ip = l_url.host();
+ l_server.address = l_url.host();
l_server.port = l_url.port();
l_server.name = "Direct Connection";
diff --git a/src/widgets/server_editor_dialog.cpp b/src/widgets/server_editor_dialog.cpp
index 386950e3..150a4357 100644
--- a/src/widgets/server_editor_dialog.cpp
+++ b/src/widgets/server_editor_dialog.cpp
@@ -1,6 +1,7 @@
#include "server_editor_dialog.h"
#include "datatypes.h"
+#include "debug_functions.h"
#include "gui_utils.h"
#include "options.h"
@@ -30,7 +31,6 @@ ServerEditorDialog::ServerEditorDialog(QWidget *parent)
FROM_UI(QLineEdit, name);
FROM_UI(QLineEdit, hostname);
FROM_UI(QSpinBox, port);
- FROM_UI(QComboBox, protocol);
FROM_UI(QPlainTextEdit, description);
FROM_UI(QDialogButtonBox, button_box);
@@ -43,52 +43,35 @@ ServerEditorDialog::ServerEditorDialog(QWidget *parent)
connect(ui_button_box, &QDialogButtonBox::rejected, this, &ServerEditorDialog::reject);
}
+ServerEditorDialog::ServerEditorDialog(const ServerInfo &server, QWidget *parent)
+ : ServerEditorDialog(parent)
+{
+ ui_name->setText(server.name);
+ ui_hostname->setText(server.address);
+ ui_port->setValue(server.port);
+ ui_description->setPlainText(server.description);
+}
+
ServerInfo ServerEditorDialog::currentServerInfo() const
{
ServerInfo server;
server.name = ui_name->text();
- server.ip = ui_hostname->text();
+ server.address = ui_hostname->text();
server.port = ui_port->value();
server.description = ui_description->toPlainText();
- server.socket_type = ServerConnectionType(ui_protocol->currentIndex());
return server;
}
-void ServerEditorDialog::loadServerInfo(ServerInfo server)
-{
- ui_name->setText(server.name);
- ui_hostname->setText(server.ip);
- ui_port->setValue(server.port);
- ui_description->setPlainText(server.description);
- ui_protocol->setCurrentIndex(server.socket_type);
-}
-
void ServerEditorDialog::parseLegacyEntry()
{
QStringList entry = ui_legacy_edit->text().split(":");
- ServerInfo l_server_entry;
- if (entry.isEmpty())
+ if (entry.size() < 3)
{
- qDebug() << "Legacy entry empty.";
+ call_error("Invalid legacy server entry");
return;
}
- int item_count = entry.size();
- if (item_count >= 3)
- {
- ui_hostname->setText(entry.at(0));
- ui_port->setValue(entry.at(1).toInt());
- ui_name->setText(entry.at(2));
- if (item_count >= 4)
- {
- if (entry.at(3) == "ws")
- {
- ui_protocol->setCurrentIndex(1);
- }
- else
- {
- ui_protocol->setCurrentIndex(0);
- }
- }
- }
+ ui_hostname->setText(entry.at(0));
+ ui_port->setValue(entry.at(1).toInt());
+ ui_name->setText(entry.at(2));
}
diff --git a/src/widgets/server_editor_dialog.h b/src/widgets/server_editor_dialog.h
index 1ceb3524..a8844d4b 100644
--- a/src/widgets/server_editor_dialog.h
+++ b/src/widgets/server_editor_dialog.h
@@ -1,6 +1,6 @@
#pragma once
-#include "datatypes.h"
+#include "network/serverinfo.h"
#include <QComboBox>
#include <QDialog>
@@ -21,8 +21,6 @@ public:
ServerInfo currentServerInfo() const;
- void loadServerInfo(ServerInfo server);
-
private:
static const QString UI_FILE_PATH;
@@ -31,7 +29,6 @@ private:
QLineEdit *ui_name;
QLineEdit *ui_hostname;
QSpinBox *ui_port;
- QComboBox *ui_protocol;
QPlainTextEdit *ui_description;
QDialogButtonBox *ui_button_box;