Merge pull request #974 from PhenomRetroShare/Fix_WebUI_SettingSaving

Fix WebUI Setting Saving.
This commit is contained in:
csoler 2017-07-30 18:45:56 +02:00 committed by GitHub
commit 39436f346d
3 changed files with 31 additions and 23 deletions

View File

@ -4,6 +4,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include <QSpinBox>
#include "util/misc.h" #include "util/misc.h"
#include "api/ApiServer.h" #include "api/ApiServer.h"
@ -26,6 +27,8 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
{ {
ui.setupUi(this); ui.setupUi(this);
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.allIp_CB, SIGNAL(clicked(bool)), this, SLOT(onAllIPCBClicked(bool)));
connect(ui.applyStartBrowser_PB, SIGNAL(clicked()), this, SLOT(onApplyClicked())); connect(ui.applyStartBrowser_PB, SIGNAL(clicked()), this, SLOT(onApplyClicked()));
} }
@ -63,11 +66,11 @@ bool WebuiPage::updateParams(QString &errmsg)
void WebuiPage::load() void WebuiPage::load()
{ {
std::cerr << "WebuiPage::load()" << std::endl; std::cerr << "WebuiPage::load()" << std::endl;
whileBlocking(ui.enableWebUI_CB)->setChecked(Settings->getWebinterfaceEnabled()); whileBlocking(ui.enableWebUI_CB)->setChecked(Settings->getWebinterfaceEnabled());
onEnableCBClicked(Settings->getWebinterfaceEnabled()); whileBlocking(ui.port_SB)->setValue(Settings->getWebinterfacePort());
whileBlocking(ui.port_SB)->setValue(Settings->getWebinterfacePort()); whileBlocking(ui.allIp_CB)->setChecked(Settings->getWebinterfaceAllowAllIps());
whileBlocking(ui.allIp_CB)->setChecked(Settings->getWebinterfaceAllowAllIps()); onEnableCBClicked(Settings->getWebinterfaceEnabled());
} }
QString WebuiPage::helpText() const QString WebuiPage::helpText() const
@ -139,19 +142,22 @@ QString WebuiPage::helpText() const
void WebuiPage::onEnableCBClicked(bool checked) void WebuiPage::onEnableCBClicked(bool checked)
{ {
if(checked) ui.params_GB->setEnabled(checked);
{ ui.applyStartBrowser_PB->setEnabled(checked);
ui.params_GB->setEnabled(true); QString S;
ui.applyStartBrowser_PB->setEnabled(true); updateParams(S);
} }
else
{
ui.params_GB->setEnabled(false);
ui.applyStartBrowser_PB->setEnabled(false);
}
QString S; void WebuiPage::onPortValueChanged(int /*value*/)
updateParams(S); {
QString S;
updateParams(S);
}
void WebuiPage::onAllIPCBClicked(bool /*checked*/)
{
QString S;
updateParams(S);
} }
void WebuiPage::onApplyClicked() void WebuiPage::onApplyClicked()

View File

@ -39,6 +39,8 @@ public:
public slots: public slots:
void onEnableCBClicked(bool checked); void onEnableCBClicked(bool checked);
void onPortValueChanged(int value);
void onAllIPCBClicked(bool checked);
void onApplyClicked(); void onApplyClicked();
private: private:

View File

@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>442</width> <width>497</width>
<height>404</height> <height>404</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="WebuiPageVLayout">
<item> <item>
<widget class="QCheckBox" name="enableWebUI_CB"> <widget class="QCheckBox" name="enableWebUI_CB">
<property name="text"> <property name="text">
@ -29,7 +29,7 @@
<property name="title"> <property name="title">
<string>Web parameters</string> <string>Web parameters</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="params_GBGLayout">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="port_SB"> <widget class="QSpinBox" name="port_SB">
<property name="minimum"> <property name="minimum">
@ -41,7 +41,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="port_Label">
<property name="text"> <property name="text">
<string>Port:</string> <string>Port:</string>
</property> </property>
@ -65,7 +65,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="noteLabel">
<property name="text"> <property name="text">
<string>Note: these settings do not affect retroshare-nogui. Retroshare-nogui has a command line switch to activate the web interface.</string> <string>Note: these settings do not affect retroshare-nogui. Retroshare-nogui has a command line switch to activate the web interface.</string>
</property> </property>
@ -75,7 +75,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="mainVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>