improved login of on/off and parameter display in webui/jsonapi config pages

This commit is contained in:
csoler 2023-09-11 22:55:42 +02:00
parent d83f0125f3
commit c877a6e5c8
4 changed files with 40 additions and 3 deletions

View File

@ -29,6 +29,8 @@
#include <QStringListModel>
#include <QProgressDialog>
#define IMAGE_LEDOFF ":/images/ledoff1.png"
#define IMAGE_LEDON ":/images/ledon1.png"
JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
{
@ -122,7 +124,19 @@ void JsonApiPage::load()
QString::fromStdString(it.first) + ":" +
QString::fromStdString(it.second) );
whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk));
whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk));
QStringList newTk2;
for(const auto& it : rsJsonApi->getResourceProviders())
newTk2.push_back( QString::fromStdString(it.get().getName())) ;
whileBlocking(ui.providersListView)->setModel(new QStringListModel(newTk2));
if(rsJsonApi->isRunning())
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
}
bool JsonApiPage::checkStartJsonApi()

View File

@ -27,6 +27,7 @@
#include <QSpinBox>
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "retroshare/rswebui.h"
#include "retroshare/rsjsonapi.h"
@ -40,6 +41,8 @@ resource_api::ApiServerLocal* WebuiPage::apiServerLocal = 0;
#endif
resource_api::RsControlModule* WebuiPage::controlModule = 0;
#define IMAGE_LEDOFF ":/images/ledoff1.png"
#define IMAGE_LEDON ":/images/ledon1.png"
WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
{
@ -50,6 +53,15 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
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()));
mEventsHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> /* event */)
{
std::cerr << "Caught JSONAPI event in webui!" << std::endl;
RsQThreadUtils::postToObject([=]() { load(); }, this );
},
mEventsHandlerId, RsEventType::JSON_API );
}
WebuiPage::~WebuiPage()
@ -127,6 +139,13 @@ void WebuiPage::loadParams()
if(it != smap.end())
whileBlocking(ui.password_LE)->setText(QString::fromStdString(it->second));
if(rsWebUi->isRunning() && rsJsonApi->isRunning())
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDON)) ;
else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
#else
ui.statusLabelLED->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_LEDOFF)) ;
#endif
}
@ -172,7 +191,6 @@ QString WebuiPage::helpText() const
void WebuiPage::onEnableCBClicked(bool checked)
{
ui.params_GB->setEnabled(checked);
ui.apply_PB->setEnabled(checked);
ui.startWebBrowser_PB->setEnabled(checked);
QString S;
}
@ -203,6 +221,7 @@ void WebuiPage::onApplyClicked()
else
checkShutdownWebui();
}
load();
}
void WebuiPage::onStartWebBrowserClicked() { showWebui(); }

View File

@ -20,6 +20,8 @@
#pragma once
#include "retroshare/rsevents.h"
#include "retroshare-gui/configpage.h"
#include "gui/common/FilesDefs.h"
#include "ui_WebuiPage.h"
@ -82,4 +84,6 @@ private:
static resource_api::ApiServerLocal* apiServerLocal;
#endif
static resource_api::RsControlModule* controlModule;
RsEventsHandlerId_t mEventsHandlerId;
};

View File

@ -39,7 +39,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>TextLabel</string>
<string>Status:</string>
</property>
</widget>
</item>