added (not yet working) password field

This commit is contained in:
csoler 2019-11-10 22:39:21 +01:00
parent 9dc78d66c1
commit 93376d3461
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 51 additions and 17 deletions

View File

@ -98,7 +98,7 @@ class WebUIThread: public RsThread
public:
WebUIThread()
{
_service = std::make_shared<restbed::Service>();
_service = std::make_shared<restbed::Service>(); // this is a place holder, in case we request some internal values.
_listening_port = 1984;
}
@ -142,12 +142,9 @@ public:
_service->publish( resource2 );
_service->publish( resource3 );
std::cerr << "Starting web service on port " << std::dec << _listening_port << std::endl;
//_service->set_ready_handler( service_ready_handler );
try
{
std::cerr << "Starting web service on port " << std::dec << _listening_port << std::endl;
_service->start( settings );
}
catch(std::exception& e)

View File

@ -46,7 +46,9 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
connect(ui.enableWebUI_CB, SIGNAL(clicked(bool)), this, SLOT(onEnableCBClicked(bool)));
connect(ui.port_SB, SIGNAL(valueChanged(int)), this, SLOT(onPortValueChanged(int)));
connect(ui.allIp_CB, SIGNAL(clicked(bool)), this, SLOT(onAllIPCBClicked(bool)));
connect(ui.applyStartBrowser_PB, SIGNAL(clicked()), this, SLOT(onApplyClicked()));
connect(ui.apply_PB, SIGNAL(clicked()), this, SLOT(onApplyClicked()));
connect(ui.password_LE, SIGNAL(textChanged(QString)), this, SLOT(onPasswordValueChanged(QString)));
connect(ui.startWebBrowser_PB, SIGNAL(clicked()), this, SLOT(onStartWebBrowserClicked()));
connect(ui.webInterfaceFilesDirectory_PB, SIGNAL(clicked()), this, SLOT(selectWebInterfaceDirectory()));
}
@ -55,6 +57,10 @@ WebuiPage::~WebuiPage()
}
void WebuiPage::onPasswordValueChanged(QString password)
{
std::cerr << "Setting new password to \"" << password.toStdString() << "\"" << std::endl;
}
void WebuiPage::selectWebInterfaceDirectory()
{
QString dirname = QFileDialog::getExistingDirectory(NULL,tr("Please select the directory were to find retroshare webinterface files"),ui.webInterfaceFiles_LE->text());
@ -147,7 +153,8 @@ QString WebuiPage::helpText() const
void WebuiPage::onEnableCBClicked(bool checked)
{
ui.params_GB->setEnabled(checked);
ui.applyStartBrowser_PB->setEnabled(checked);
ui.apply_PB->setEnabled(checked);
ui.startWebBrowser_PB->setEnabled(checked);
QString S;
updateParams(S);
}
@ -163,7 +170,6 @@ void WebuiPage::onAllIPCBClicked(bool /*checked*/)
QString S;
updateParams(S);
}
void WebuiPage::onApplyClicked()
{
QString errmsg;
@ -173,5 +179,9 @@ void WebuiPage::onApplyClicked()
QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface.");
return;
}
}
void WebuiPage::onStartWebBrowserClicked()
{
QDesktopServices::openUrl(QUrl(QString("http://localhost:")+QString::number(ui.port_SB->value())));
}

View File

@ -58,11 +58,13 @@ public:
static void showWebui();
public slots:
void selectWebInterfaceDirectory();
void selectWebInterfaceDirectory();
void onEnableCBClicked(bool checked);
void onPortValueChanged(int value);
void onPasswordValueChanged(QString password);
void onAllIPCBClicked(bool checked);
void onApplyClicked();
void onStartWebBrowserClicked();
private:
/** Qt Designer generated object */

View File

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="WebuiPageVLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="enableWebUI_CB">
<property name="text">
@ -52,14 +52,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Web interface directory:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="webInterfaceFiles_LE">
@ -84,6 +84,20 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="password_LE">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -97,11 +111,22 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="applyStartBrowser_PB">
<property name="text">
<string>Apply setting and start browser</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="apply_PB">
<property name="text">
<string>Apply settings</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="startWebBrowser_PB">
<property name="text">
<string>Start web browser</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="noteLabel">