Skip to content

Commit

Permalink
Refs #99. Improved SurveyService UIs and features
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Nov 29, 2024
1 parent 59ef910 commit 0493a4a
Show file tree
Hide file tree
Showing 8 changed files with 2,541 additions and 1,651 deletions.
5 changes: 5 additions & 0 deletions client/resources/stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ QPlainTextEdit {
color: black;
}

QPlainTextEdit:!enabled{
background-color: rgba(255,255,255,10%);
color: white;
}

/*
QListWidget
*/
Expand Down
1,881 changes: 1,087 additions & 794 deletions client/resources/translations/openteraplus_en.ts

Large diffs are not rendered by default.

1,903 changes: 1,062 additions & 841 deletions client/resources/translations/openteraplus_fr.ts

Large diffs are not rendered by default.

42 changes: 38 additions & 4 deletions client/src/services/SurveyService/SurveyEditorDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,62 @@
#include "SurveyEditorDialog.h"
#include "ui_SurveyEditorDialog.h"

#include <QWebEngineProfile>

SurveyEditorDialog::SurveyEditorDialog(SurveyComManager *surveyComManager, const QString& test_type_uuid, QWidget *parent)
: QDialog(parent)
, ui(new Ui::SurveyEditorDialog)
, m_surveyComManager(surveyComManager)
, m_testTypeUuid(test_type_uuid)
{
ui->setupUi(this);
ui->wdgWebView->hide();
ui->frameLoading->hide();
ui->frameError->hide();

// Setup loading icon animation
m_loadingIcon = new QMovie("://status/loading.gif");
ui->lblLoadingIcon->setMovie(m_loadingIcon);
m_loadingIcon->start();

m_webView = new QWebEngineView(ui->wdgWebView);
m_webView->setContextMenuPolicy(Qt::NoContextMenu);

QVBoxLayout *layout = new QVBoxLayout(ui->wdgWebView);
layout->addWidget(m_webView);

/*QWebEngineProfile * profile = new QWebEngineProfile("OpenTeraPlusSurveyService", m_webView);
profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
qDebug() << "Cache Path = " << profile->cachePath();*/

m_webPage = new QWebEnginePage(m_webView);

connect(m_webPage, &QWebEnginePage::certificateError, this, &SurveyEditorDialog::onCertificateError);
connect(m_webPage, &QWebEnginePage::loadingChanged, this, &SurveyEditorDialog::onPageLoadingChanged);
connect(m_webPage, &QWebEnginePage::loadProgress, this, &SurveyEditorDialog::onPageLoadingProcess);
m_webView->setPage(m_webPage);

loadEditor();
}

SurveyEditorDialog::~SurveyEditorDialog()
{
delete ui;
}

void SurveyEditorDialog::setCurrentTestTypeUuid(const QString &test_type_uuid)
{
m_testTypeUuid = test_type_uuid;
}

void SurveyEditorDialog::loadEditor()
{
ui->wdgWebView->hide();
QUrl editor_url = m_surveyComManager->getServerUrl();
editor_url.setPath(m_surveyComManager->getServiceEndpoint("editor"));
QUrlQuery args;
args.addQueryItem("token", m_surveyComManager->getCurrentToken());
args.addQueryItem("test_type_uuid", m_testTypeUuid);
editor_url.setQuery(args);
qDebug() << "SurveyEditorDialog - Loading " << editor_url.toString();
//qDebug() << "SurveyEditorDialog - Loading " << editor_url.toString();
m_webPage->load(editor_url);
}

Expand All @@ -55,8 +76,21 @@ void SurveyEditorDialog::onCertificateError(const QWebEngineCertificateError &ce

void SurveyEditorDialog::onPageLoadingChanged(const QWebEngineLoadingInfo &loadingInfo)
{
qDebug() << loadingInfo.status();
if (loadingInfo.status() == QWebEngineLoadingInfo::LoadStartedStatus){
ui->progressLoading->setValue(0);
}
ui->frameLoading->setVisible(loadingInfo.status() == QWebEngineLoadingInfo::LoadStartedStatus);
ui->frameError->setVisible(loadingInfo.status() == QWebEngineLoadingInfo::LoadFailedStatus);

ui->wdgWebView->setVisible(loadingInfo.status() == QWebEngineLoadingInfo::LoadSucceededStatus);

//qDebug() << loadingInfo.status();
if (loadingInfo.isErrorPage())
qDebug() << "Page loading error: " << loadingInfo.errorCode() << ": " << loadingInfo.errorString();
}

void SurveyEditorDialog::onPageLoadingProcess(int progress)
{
ui->progressLoading->setValue(progress);
}

5 changes: 5 additions & 0 deletions client/src/services/SurveyService/SurveyEditorDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SURVEYEDITORDIALOG_H

#include <QDialog>
#include <QMovie>
#include <QWebEngineView>
#include <QWebEngineCertificateError>
#include <QWebEngineLoadingInfo>
Expand All @@ -20,13 +21,15 @@ class SurveyEditorDialog : public QDialog
explicit SurveyEditorDialog(SurveyComManager *surveyComManager, const QString &test_type_uuid, QWidget *parent = nullptr);
~SurveyEditorDialog();

void setCurrentTestTypeUuid(const QString& test_type_uuid);
void loadEditor();

private slots:
void on_btnClose_clicked();

void onCertificateError(const QWebEngineCertificateError &certificateError);
void onPageLoadingChanged(const QWebEngineLoadingInfo &loadingInfo);
void onPageLoadingProcess(int progress);


private:
Expand All @@ -35,6 +38,8 @@ private slots:
QWebEngineView *m_webView = nullptr;
QWebEnginePage *m_webPage = nullptr;
QString m_testTypeUuid;

QMovie* m_loadingIcon;
};

#endif // SURVEYEDITORDIALOG_H
Loading

0 comments on commit 0493a4a

Please sign in to comment.