mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
client add default sim option
This commit is contained in:
+20
-13
@@ -28,17 +28,23 @@ int main(int argc, char *argv[])
|
|||||||
parser.setApplicationDescription("unisim_cpp client");
|
parser.setApplicationDescription("unisim_cpp client");
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
|
||||||
QCommandLineOption hostOption(QStringList() << "s"
|
QCommandLineOption host_option(QStringList() << "s"
|
||||||
<< "server",
|
<< "server",
|
||||||
QCoreApplication::translate("main", "sim-us server host [default: localhost]."),
|
QCoreApplication::translate("main", "unisim_cpp server host [default: localhost]."),
|
||||||
QCoreApplication::translate("main", "host"), QLatin1String("localhost"));
|
QCoreApplication::translate("main", "host"), QLatin1String("localhost"));
|
||||||
parser.addOption(hostOption);
|
parser.addOption(host_option);
|
||||||
|
|
||||||
QCommandLineOption portOption(QStringList() << "p"
|
QCommandLineOption port_option(QStringList() << "p"
|
||||||
<< "port",
|
<< "port",
|
||||||
QCoreApplication::translate("main", "Port for echoserver [default: 9002]."),
|
QCoreApplication::translate("main", "Port for unisim_cpp [default: 9002]."),
|
||||||
QCoreApplication::translate("main", "port"), QLatin1String("9002"));
|
QCoreApplication::translate("main", "port"), QLatin1String("9002"));
|
||||||
parser.addOption(portOption);
|
parser.addOption(port_option);
|
||||||
|
|
||||||
|
QCommandLineOption default_sim_option(QStringList() << "d"
|
||||||
|
<< "default",
|
||||||
|
QCoreApplication::translate("main", "Default sim that loads on startup."),
|
||||||
|
QCoreApplication::translate("main", "default"), QLatin1String(""));
|
||||||
|
parser.addOption(default_sim_option);
|
||||||
|
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
// Initialize the logger
|
// Initialize the logger
|
||||||
@@ -46,9 +52,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("ws");
|
url.setScheme("ws");
|
||||||
url.setHost(parser.value(hostOption));
|
url.setHost(parser.value(host_option));
|
||||||
url.setPort(parser.value(portOption).toInt());
|
url.setPort(parser.value(port_option).toInt());
|
||||||
MainWindow w(url);
|
QString default_sim = parser.value(default_sim_option);
|
||||||
|
MainWindow w(url, default_sim);
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
typedef Simulator_base *(*Get_UI)(Web_socket_wrapper *, QWidget *);
|
typedef Simulator_base *(*Get_UI)(Web_socket_wrapper *, QWidget *);
|
||||||
|
|
||||||
MainWindow::MainWindow(QUrl ws_url, QWidget *parent)
|
MainWindow::MainWindow(QUrl ws_url, QString sim, QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow), m_web_socket(new Web_socket_wrapper(ws_url)),
|
: QMainWindow(parent), ui(new Ui::MainWindow), m_web_socket(new Web_socket_wrapper(ws_url)),
|
||||||
m_error_dialog(new NetworkError(this))
|
m_error_dialog(new NetworkError(this))
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,8 @@ MainWindow::MainWindow(QUrl ws_url, QWidget *parent)
|
|||||||
m_error_dialog->set_error("Connection timed out\nCheck if the server is running");
|
m_error_dialog->set_error("Connection timed out\nCheck if the server is running");
|
||||||
ui->connection->setText("Connected to " + ws_url.toString());
|
ui->connection->setText("Connected to " + ws_url.toString());
|
||||||
// Default sim
|
// Default sim
|
||||||
// defaultSim("CVS_I10");
|
if (!sim.isEmpty())
|
||||||
|
default_sim(sim);
|
||||||
|
|
||||||
connect(ui->pushButton, &QPushButton::clicked, this, [=, this] { open_sim(ui->comboBox->currentText()); });
|
connect(ui->pushButton, &QPushButton::clicked, this, [=, this] { open_sim(ui->comboBox->currentText()); });
|
||||||
connect(this, &MainWindow::quit, this, &QCoreApplication::quit, Qt::QueuedConnection);
|
connect(this, &MainWindow::quit, this, &QCoreApplication::quit, Qt::QueuedConnection);
|
||||||
@@ -70,7 +71,7 @@ void MainWindow::hideEvent(QHideEvent *event)
|
|||||||
disconnect(m_web_socket.get(), nullptr, nullptr, nullptr);
|
disconnect(m_web_socket.get(), nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::defaultSim(QString name)
|
void MainWindow::default_sim(QString name)
|
||||||
{
|
{
|
||||||
this->m_selected_sim_name = name;
|
this->m_selected_sim_name = name;
|
||||||
this->m_default_sim = true;
|
this->m_default_sim = true;
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ class MainWindow : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QUrl ws_url, QWidget *parent = nullptr);
|
explicit MainWindow(QUrl ws_url, QString sim, QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void defaultSim(QString name);
|
void default_sim(QString name);
|
||||||
void pase_sim_names(json &sims);
|
void pase_sim_names(json &sims);
|
||||||
void open_sim_window(void);
|
void open_sim_window(void);
|
||||||
void check_active_sim(QString name);
|
void check_active_sim(QString name);
|
||||||
|
|||||||
Reference in New Issue
Block a user