Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions easyDiffractionApp/Gui/Pages/Summary/MainContentReport.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 = [
'<!DOCTYPE html>',
'<html>\n',
'<head>\n',
head+'\n',
'</head>\n',
'<body>\n',
'</body>\n',
'</html>'
]
const empty_html = list.join('\n')
ExGlobals.Constants.proxy.project.setReport(empty_html)
webView.loadHtml(empty_html)
}

/////////////
// HTML parts
/////////////
Expand Down
23 changes: 21 additions & 2 deletions easyDiffractionApp/Gui/Pages/Summary/SideBarBasic.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions easyDiffractionApp/Logic/Proxies/Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down