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: public:
WebUIThread() 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; _listening_port = 1984;
} }
@ -142,12 +142,9 @@ public:
_service->publish( resource2 ); _service->publish( resource2 );
_service->publish( resource3 ); _service->publish( resource3 );
std::cerr << "Starting web service on port " << std::dec << _listening_port << std::endl;
//_service->set_ready_handler( service_ready_handler );
try try
{ {
std::cerr << "Starting web service on port " << std::dec << _listening_port << std::endl;
_service->start( settings ); _service->start( settings );
} }
catch(std::exception& e) 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.enableWebUI_CB, SIGNAL(clicked(bool)), this, SLOT(onEnableCBClicked(bool)));
connect(ui.port_SB, SIGNAL(valueChanged(int)), this, SLOT(onPortValueChanged(int))); connect(ui.port_SB, SIGNAL(valueChanged(int)), this, SLOT(onPortValueChanged(int)));
connect(ui.allIp_CB, SIGNAL(clicked(bool)), this, SLOT(onAllIPCBClicked(bool))); 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())); 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() void WebuiPage::selectWebInterfaceDirectory()
{ {
QString dirname = QFileDialog::getExistingDirectory(NULL,tr("Please select the directory were to find retroshare webinterface files"),ui.webInterfaceFiles_LE->text()); 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) void WebuiPage::onEnableCBClicked(bool checked)
{ {
ui.params_GB->setEnabled(checked); ui.params_GB->setEnabled(checked);
ui.applyStartBrowser_PB->setEnabled(checked); ui.apply_PB->setEnabled(checked);
ui.startWebBrowser_PB->setEnabled(checked);
QString S; QString S;
updateParams(S); updateParams(S);
} }
@ -163,7 +170,6 @@ void WebuiPage::onAllIPCBClicked(bool /*checked*/)
QString S; QString S;
updateParams(S); updateParams(S);
} }
void WebuiPage::onApplyClicked() void WebuiPage::onApplyClicked()
{ {
QString errmsg; QString errmsg;
@ -173,5 +179,9 @@ void WebuiPage::onApplyClicked()
QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface.");
return; return;
} }
}
void WebuiPage::onStartWebBrowserClicked()
{
QDesktopServices::openUrl(QUrl(QString("http://localhost:")+QString::number(ui.port_SB->value()))); QDesktopServices::openUrl(QUrl(QString("http://localhost:")+QString::number(ui.port_SB->value())));
} }

View File

@ -61,8 +61,10 @@ public slots:
void selectWebInterfaceDirectory(); void selectWebInterfaceDirectory();
void onEnableCBClicked(bool checked); void onEnableCBClicked(bool checked);
void onPortValueChanged(int value); void onPortValueChanged(int value);
void onPasswordValueChanged(QString password);
void onAllIPCBClicked(bool checked); void onAllIPCBClicked(bool checked);
void onApplyClicked(); void onApplyClicked();
void onStartWebBrowserClicked();
private: private:
/** Qt Designer generated object */ /** Qt Designer generated object */

View File

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