Commit 7ae6ad37 authored by Martin Straka's avatar Martin Straka

Updated QML file dialogue

parent ceae257c
......@@ -69,7 +69,11 @@ Dialog {
return (root.showDirs && !root.showFiles);
}
function raise(title, filters, showFiles) {
function raise(title, filters, showFiles, targetLocation) {
if (targetLocation !== "") {
folderNavigation.visible = false
folderModel.folder = "file://" + targetLocation
}
root.title = title
folderModel.folder = folderModel.folder
root.showFiles = showFiles
......@@ -121,71 +125,74 @@ Dialog {
contentItem: ColumnLayout {
spacing: formItemVerticalSpacing
AccessibleComboBox {
anchors {
left: parent.left;
right: parent.right;
}
accessibleDescription: qsTr("Select location type")
model: ListModel {
ListElement { label: qsTr("Desktop"); key: "desktop" }
ListElement { label: qsTr("Documents"); key: "document" }
ListElement { label: qsTr("Downloads"); key: "download" }
ListElement { label: qsTr("Pictures"); key: "picture" }
ListElement { label: qsTr("Temp"); key: "temp" }
}
onCurrentIndexChanged: {
var location = InteractionFilesystem.DESKTOP_LOCATION
if (currentKey() === "document") {
location = InteractionFilesystem.DOCUMENTS_LOCATION
} else if (currentKey() === "download") {
location = InteractionFilesystem.DOWNLOAD_LOCATION
} else if (currentKey() === "picture") {
location = InteractionFilesystem.PICTURE_LOCATION
} else if (currentKey() === "temp") {
location = InteractionFilesystem.TEMP_LOCATION
ColumnLayout {
id: folderNavigation
AccessibleComboBox {
anchors {
left: parent.left;
right: parent.right;
}
folderModel.folder = standardLocationUrl(location)
}
}
RowLayout {
anchors {
left: parent.left;
right: parent.right;
}
spacing: formItemVerticalSpacing
AccessibleButton {
id: upButton
text: "<"
accessibleName: qsTr("Up") /* Needs to be specified as "<" is not read. */
onClicked: {
/* Navigate to parent folder. */
if (folderModel.parentFolder !== "") {
folderModel.folder = folderModel.parentFolder
accessibleDescription: qsTr("Select location type")
model: ListModel {
ListElement { label: qsTr("Desktop"); key: "desktop" }
ListElement { label: qsTr("Documents"); key: "document" }
ListElement { label: qsTr("Downloads"); key: "download" }
ListElement { label: qsTr("Pictures"); key: "picture" }
ListElement { label: qsTr("Temp"); key: "temp" }
}
onCurrentIndexChanged: {
var location = InteractionFilesystem.DESKTOP_LOCATION
if (currentKey() === "document") {
location = InteractionFilesystem.DOCUMENTS_LOCATION
} else if (currentKey() === "download") {
location = InteractionFilesystem.DOWNLOAD_LOCATION
} else if (currentKey() === "picture") {
location = InteractionFilesystem.PICTURE_LOCATION
} else if (currentKey() === "temp") {
location = InteractionFilesystem.TEMP_LOCATION
}
folderModel.folder = standardLocationUrl(location)
}
}
AccessibleTextField {
id: pathField
Layout.fillWidth: true
text: stripUrlPrefix(folderModel.folder)
onEditingFinished: {
/* Navigate to supplied location if location exists. */
var path = interactionFilesystem.absoluteDirPath(text)
if (path !== "") {
folderModel.folder = "file://" + path
} else {
path = interactionFilesystem.absolutePath(text)
RowLayout {
anchors {
left: parent.left;
right: parent.right;
}
spacing: formItemVerticalSpacing
AccessibleButton {
id: upButton
text: "<"
accessibleName: qsTr("Up") /* Needs to be specified as "<" is not read. */
onClicked: {
/* Navigate to parent folder. */
if (folderModel.parentFolder !== "") {
folderModel.folder = folderModel.parentFolder
}
}
}
AccessibleTextField {
id: pathField
Layout.fillWidth: true
text: stripUrlPrefix(folderModel.folder)
onEditingFinished: {
/* Navigate to supplied location if location exists. */
var path = interactionFilesystem.absoluteDirPath(text)
if (path !== "") {
folderModel.folder = "file://" + path
} else {
/* Restore original location. */
text = stripUrlPrefix(folderModel.folder)
path = interactionFilesystem.absolutePath(text)
if (path !== "") {
folderModel.folder = "file://" + path
} else {
/* Restore original location. */
text = stripUrlPrefix(folderModel.folder)
}
}
}
}
}
} // RowLayout
} // RowLayout
} // ColumnLayout
ScrollableListView {
id: fileList
......
......@@ -80,11 +80,11 @@ Component {
property var funcs: {
"zfoFile": function callZfoFile() {
clearInfo()
fileDialogue.raise(qsTr("Select ZFO files"), ["*.zfo"], true)
fileDialogue.raise(qsTr("Select ZFO files"), ["*.zfo"], true, "")
},
"zfoDir": function callZfoDir() {
clearInfo()
fileDialogue.raise(qsTr("Select import directory"), ["*.*"], false)
fileDialogue.raise(qsTr("Select import directory"), ["*.*"], false, "")
}
}
......
......@@ -43,6 +43,7 @@ Item {
Component.onCompleted: {
var logTxt = files.loadLogContent(logFilePath)
logContent.text = "<b>" + qsTr("Log from current run:") + "</b><br/><br/>" + logTxt
logFilePath = files.getLocFileLocation()
}
/* File dialog for choose of files from the storage */
......@@ -115,7 +116,7 @@ Item {
font.pointSize: defaultTextFont.font.pointSize
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
fileDialogue.raise("Choose log file", ["*.log"], true)
fileDialogue.raise("Choose log file", ["*.log"], true, logFilePath)
}
}
}
......
......@@ -453,7 +453,7 @@ Item {
font.pointSize: defaultTextFont.font.pointSize
text: qsTr("Add file")
onClicked: {
fileDialogue.raise(qsTr("Select files"), ["*.*"], true)
fileDialogue.raise(qsTr("Select files"), ["*.*"], true, "")
}
}
Component {
......
......@@ -202,7 +202,7 @@ Item {
height: inputItemHeight
font.pointSize: defaultTextFont.font.pointSize
onClicked: {
fileDialogue.raise("Select certificate file", ["*.pem","*.p12","*.pfx"], true)
fileDialogue.raise("Select certificate file", ["*.pem","*.p12","*.pfx"], true, "")
}
}
AccessibleText {
......
......@@ -154,12 +154,16 @@ QByteArray Files::getFileRawContentFromDb(const QString &userName, int fileId)
return fDb->getFileFromDb(fileId).binaryContent();
}
QString Files::getLocFileLocation(void)
{
return appLogDirPath();
}
QString Files::loadLogContent(const QString &filePath)
{
debugFuncCall();
QString log;
//log.append("<ul>");
if (filePath.isEmpty()) {
MemoryLog *mLog = GlobInstcs::logPtr->memoryLog();
......@@ -192,7 +196,6 @@ QString Files::loadLogContent(const QString &filePath)
file.close();
}
//log.append("</ul>");
return log;
}
......
......@@ -115,10 +115,19 @@ public:
Q_INVOKABLE static
QByteArray getFileRawContentFromDb(const QString &userName, int fileId);
/*!
* @brief Get log file location.
*
* @return Full path to log directory.
*/
Q_INVOKABLE static
QString getLocFileLocation(void);
/*!
* @brief Load log content from file or memory into QML.
*
* @param[in] filePath Log file path (empty = use memory log).
* @return Log content as html.
*/
Q_INVOKABLE static
QString loadLogContent(const QString &filePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment