diff --git a/easyDiffractionApp/Gui/Pages/Summary/MainContentReport.qml b/easyDiffractionApp/Gui/Pages/Summary/MainContentReport.qml index eedc9e4d..4311e3df 100644 --- a/easyDiffractionApp/Gui/Pages/Summary/MainContentReport.qml +++ b/easyDiffractionApp/Gui/Pages/Summary/MainContentReport.qml @@ -83,9 +83,18 @@ Item { saveConfirmationDialog.open() } + // handlers for clicking the "Create Report" button in the side bar + signal reportRequested() + onReportRequested: { + ExGlobals.Constants.proxy.project.setReport(html) + webView.loadHtml(html) + } + Component.onCompleted: { ExGlobals.Variables.reportWebView = this + // Notify the python proxies ExGlobals.Constants.proxy.project.htmlExportingFinished.connect(htmlExportingFinished) + ExGlobals.Constants.proxy.project.reportRequested.connect(reportRequested) } } @@ -135,14 +144,23 @@ Item { } } - //} - onHtmlChanged: { - //print(html) - ExGlobals.Constants.proxy.project.setReport(html) - webView.loadHtml(html) + // when the state changes, the html display is reset + const list = [ + '', + '\n', + '\n', + head+'\n', + '\n', + '\n', + '\n', + '' + ] + const empty_html = list.join('\n') + ExGlobals.Constants.proxy.project.setReport(empty_html) + webView.loadHtml(empty_html) } - + ///////////// // HTML parts ///////////// diff --git a/easyDiffractionApp/Gui/Pages/Summary/SideBarBasic.qml b/easyDiffractionApp/Gui/Pages/Summary/SideBarBasic.qml index 8f654edd..6a4cd5db 100644 --- a/easyDiffractionApp/Gui/Pages/Summary/SideBarBasic.qml +++ b/easyDiffractionApp/Gui/Pages/Summary/SideBarBasic.qml @@ -18,10 +18,29 @@ import Gui.Pages.Summary 1.0 as ExSummaryPage EaComponents.SideBarColumn { + EaElements.GroupBox { + title: qsTr("Create report") + enabled: !ExGlobals.Constants.proxy.project.readOnly + collapsible: false + last: true + + // Create button + EaElements.SideBarButton { + wide: true + fontIcon: "flask" + text: qsTr("Create") + + onClicked: { + ExGlobals.Constants.proxy.project.requestReport() + } + + Component.onCompleted: ExGlobals.Variables.exportReportButton = this + } + } + EaElements.GroupBox { title: qsTr("Export report") - enabled: ExGlobals.Constants.proxy.project.projectCreated && - !ExGlobals.Constants.proxy.project.readOnly + enabled: !ExGlobals.Constants.proxy.project.readOnly collapsible: false last: true diff --git a/easyDiffractionApp/Logic/Proxies/Project.py b/easyDiffractionApp/Logic/Proxies/Project.py index fb9d25c7..3a187b03 100644 --- a/easyDiffractionApp/Logic/Proxies/Project.py +++ b/easyDiffractionApp/Logic/Proxies/Project.py @@ -12,6 +12,7 @@ class ProjectProxy(QObject): stateChanged = Signal(bool) htmlExportingFinished = Signal(bool, str) statusInfoChanged = Signal() + reportRequested = Signal() def __init__(self, parent=None, logic=None): # , interface=None): super().__init__(parent) @@ -131,6 +132,13 @@ def saveReport(self, filepath): success = self.logic.saveReport(filepath) self.htmlExportingFinished.emit(success, filepath) + @Slot() + def requestReport(self): + """ + Request a report generation + """ + self.reportRequested.emit() + # status @Property('QVariant', notify=statusInfoChanged) def statusModelAsObj(self):