Skip to content

Commit

Permalink
[FileMuncher] Rework code, create dir work, delete file work and many
Browse files Browse the repository at this point in the history
other.
  • Loading branch information
neochapay committed Oct 9, 2018
1 parent b25e44e commit a0a8536
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 265 deletions.
6 changes: 2 additions & 4 deletions glacier-filemuncher.pro
Expand Up @@ -29,11 +29,9 @@ desktop.path = /usr/share/applications
INSTALLS += desktop

# Input
SOURCES += src/main.cpp \
src/utils.cpp
SOURCES += src/main.cpp

HEADERS += \
src/utils.h
HEADERS +=

CONFIG += link_pkgconfig

Expand Down
2 changes: 1 addition & 1 deletion rpm/glacier-filemuncher.spec
Expand Up @@ -13,7 +13,7 @@ License: BSD
URL: https://github.com/nemomobile-ux/glacier-filemuncher
Source0: %{name}-%{version}.tar.bz2

Requires: qt-components-qt5
Requires: qt5-qtquickcontrols-nemo
Requires: nemo-qml-plugin-thumbnailer-qt5
Requires: nemo-qml-plugin-folderlistmodel
Requires: libglacierapp
Expand Down
6 changes: 0 additions & 6 deletions src/main.cpp
Expand Up @@ -41,8 +41,6 @@

#include <glacierapp.h>

#include "utils.h"

Q_DECL_EXPORT int main(int argc, char **argv)
{
QGuiApplication *app = GlacierApp::app(argc, argv);
Expand All @@ -52,10 +50,6 @@ Q_DECL_EXPORT int main(int argc, char **argv)
QQmlApplicationEngine *engine = GlacierApp::engine(app);
QQmlContext *context = engine->rootContext();

Utils *utils = new Utils();

context->setContextProperty("fileBrowserUtils", utils);

// TODO: we could do with a plugin to access QDesktopServices paths
context->setContextProperty("homeDirectory", QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
context->setContextProperty("systemAvatarDirectory", QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
Expand Down
119 changes: 74 additions & 45 deletions src/qml/DetailViewSheet.qml
Expand Up @@ -36,15 +36,11 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import FBrowser 1.0

Sheet {
Page {
id: sheet
property QtObject model
property int selectedRow
property string originalFileName: model.data(sheet.selectedRow, "fileName")
acceptButtonText: "Save"
rejectButtonText: "Close"
property string originalFileName: model.fileName

Component.onCompleted: {
// we should only enable this if there is something to save, and if
Expand All @@ -54,53 +50,50 @@ Sheet {
function activateSave() {
console.log("activating save")
acceptButton.enabled = true
rejectButtonText = "Cancel"
rejectButton.text = qsTr("Cancel")
}

function deactivateSave() {
console.log("deactivating save");
acceptButton.enabled = false
rejectButtonText = "Close"
rejectButton.text = qsTr("Close")
}

onAccepted: {
if (nameField.text != originalFileName) {
var ret = model.rename(selectedRow, nameField.text)
Flickable {
width: parent.width-Theme.itemSpacingSmall*2
height: parent.height-Theme.itemSpacingSmall*2-Theme.itemHeightLarge

if (!ret) {
// TODO: show a dialog here
console.log("rename failed; but we can't block the sheet closing. TODO! error handling.")
}
anchors {
top: parent.top
topMargin: Theme.itemSpacingSmall
left: parent.left
leftMargin: Theme.itemSpacingSmall
}
}

content: Flickable {
anchors { margins: UiConstants.DefaultMargin; fill:parent }

Column {
anchors.fill: parent

Item {
id: nameContainer
height: 60
height: Theme.itemHeightMedium
anchors.left: parent.left
anchors.right: parent.right

Label {
id: nameLabel
text: "Name:"
text: qsTr("Name:")
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: UiConstants.DefaultMargin
anchors.rightMargin: Theme.itemSpacingSmall
}

TextField {
id: nameField
text: model.data(sheet.selectedRow, "fileName")
placeholderText: "Enter a new name"
text: model.fileName
placeholderText: qsTr("Enter a new name")
anchors.right: parent.right
anchors.left: nameLabel.right
anchors.leftMargin: UiConstants.DefaultMargin
anchors.leftMargin: Theme.itemSpacingSmall
anchors.verticalCenter: parent.verticalCenter
// workaround for onTextChange only emitting when preedit is committed
inputMethodHints: Qt.ImhNoPredictiveText
Expand All @@ -117,21 +110,21 @@ Sheet {

Item {
id: pathContainer
height: 60
height: Theme.itemHeightMedium
anchors.left: parent.left
anchors.right: parent.right

Label {
id: pathLabel
text: "Path:"
text: qsTr("Path:")
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: UiConstants.DefaultMargin
anchors.rightMargin: Theme.itemSpacingSmall
}

Label {
id: pathField
text: model.data(sheet.selectedRow, "filePath")
text: model.filePath
anchors.right: parent.right
anchors.left: pathLabel.right
horizontalAlignment: Text.AlignRight
Expand All @@ -143,23 +136,23 @@ Sheet {

Item {
id: sizeContainer
height: 60
height: Theme.itemHeightMedium
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: UiConstants.DefaultMargin
visible: model.data(sheet.selectedRow, "isFile")
anchors.topMargin: Theme.itemSpacingSmall
visible: model.isFile

Label {
id: sizeLabel
text: "Size:"
text: qsTr("Size:")
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: UiConstants.DefaultMargin
anchors.rightMargin: Theme.itemSpacingSmall
}

Label {
id: sizeField
text: model.data(sheet.selectedRow, "fileSize")
text: model.fileSize
anchors.right: parent.right
anchors.left: sizeLabel.right
horizontalAlignment: Text.AlignRight
Expand All @@ -171,22 +164,22 @@ Sheet {

Item {
id: createdContainer
height: 60
height: Theme.itemHeightMedium
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: UiConstants.DefaultMargin
anchors.topMargin: Theme.itemSpacingSmall

Label {
id: createdLabel
text: "Created:"
text: qsTr("Created:")
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: UiConstants.DefaultMargin
anchors.rightMargin:Theme.itemSpacingSmall
}

Label {
id: createdField
text: model.data(sheet.selectedRow, "creationDate")
text: model.creationDate
anchors.right: parent.right
anchors.left: createdLabel.right
horizontalAlignment: Text.AlignRight
Expand All @@ -198,22 +191,22 @@ Sheet {

Item {
id: modifiedContainer
height: 60
height: Theme.itemHeightMedium
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: UiConstants.DefaultMargin
anchors.topMargin: Theme.itemSpacingSmall

Label {
id: modifiedLabel
text: "Last Modified:"
text: qsTr("Last Modified:")
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: UiConstants.DefaultMargin
anchors.rightMargin: Theme.itemSpacingSmall
}

Label {
id: modifiedField
text: model.data(sheet.selectedRow, "modifiedDate")
text: model.modifiedDate
anchors.right: parent.right
anchors.left: modifiedLabel.right
horizontalAlignment: Text.AlignRight
Expand All @@ -224,5 +217,41 @@ Sheet {
}
}
}

Button {
id: rejectButton
width: parent.width / 2
height: Theme.itemHeightLarge
text: qsTr("Cancel")
anchors {
left: parent.left
bottom: parent.bottom
}
onClicked: {
pageStack.pop()
}
}

Button {
id: acceptButton
width: parent.width / 2
height: Theme.itemHeightLarge
text: qsTr("Ok")
anchors {
left: rejectButton.right
bottom: parent.bottom
}
onClicked: {
if (nameField.text != originalFileName) {
var ret = false
//TODO: rework rename function
if (!ret) {
// TODO: show a dialog here
nameField.text = originalFileName
console.log("rename failed; but we can't block the sheet closing. TODO! error handling.")
}
}
}
}
}

0 comments on commit a0a8536

Please sign in to comment.