UI/UX improvements

pull/209/head
larteyoh 8 months ago
parent 101502e4d6
commit fd85ca9d26

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

@ -77,6 +77,7 @@
<file>assets/images/eye.png</file>
<file>assets/images/eye_slash.png</file>
<file>assets/images/file.png</file>
<file>assets/images/filter.png</file>
<file>assets/images/grid.png</file>
<file>assets/images/heart.png</file>
<file>assets/images/image.png</file>

@ -3,6 +3,8 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Qt.labs.platform 1.1 // FileDialog
import FontAwesome 1.0
import "." as NeroshopComponents
Popup {
@ -22,14 +24,69 @@ Popup {
background: Rectangle {
radius: 8
color: (NeroshopComponents.Style.darkTheme) ? (NeroshopComponents.Style.themeName == "PurpleDust" ? "#0e0e11" : "#101010") : "#f0f0f0"
// header
Rectangle {
id: titleBar
color: "#202020"
height: 40
width: parent.width
anchors.left: parent.left
anchors.right: parent.right
radius: 6
// Rounded top corners
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: parent.height / 2
color: parent.color
}
Label {
text: "Add item"
color: "#ffffff"
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
Button {
id: closeButton
width: 25
height: this.width
anchors.verticalCenter: titleBar.verticalCenter
anchors.right: titleBar.right
anchors.rightMargin: 10
text: qsTr(FontAwesome.xmark)
contentItem: Text {
text: closeButton.text
color: "#ffffff"
font.bold: true
font.family: FontAwesome.fontFamily
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
color: "#ff4d4d"
radius: 100
}
onClicked: {
productDialog.close()
mainScrollView.ScrollBar.vertical.position = 0.0 // reset scrollbar
}
}
}
}
contentItem: ScrollView {
id: mainScrollView
anchors.fill: parent
anchors.topMargin: 20; anchors.bottomMargin: anchors.topMargin////anchors.margins: 20
anchors.topMargin: titleBar.height + 20; anchors.bottomMargin: 20//anchors.topMargin////anchors.margins: 20
clip: true
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ScrollBar.vertical.policy: ScrollBar.AlwaysOn//AsNeeded
ColumnLayout {
width: productDialog.availableWidth; height: productDialog.availableHeight
spacing: 30
@ -41,7 +98,7 @@ Popup {
Column {
spacing: productDialog.titleSpacing
Text {
text: "Product name"
text: "Name / Title"
color: productDialog.palette.text
font.bold: true
}
@ -124,11 +181,34 @@ Popup {
Column {
spacing: productDialog.titleSpacing
Row {
spacing: 10
Text {
text: "Quantity"
text: qsTr("Quantity")
color: productDialog.palette.text
font.bold: true
//visible: false
}
Text {
text: qsTr(FontAwesome.circleInfo)
color: productDialog.optTextColor
font.bold: true
//font.pointSize:
anchors.verticalCenter: parent.children[0].verticalCenter
property bool hovered: false
NeroshopComponents.Hint {
x: parent.width + 10; y: ((parent.height - height) / 2) - 3
visible: parent.hovered
height: contentHeight + 20; width: contentWidth + 20
text: qsTr("The total number of items in stock")
pointer.visible: false;// delay: 0
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: parent.hovered = true
onExited: parent.hovered = false
}
}
}
TextField {
@ -625,7 +705,7 @@ Popup {
contentWidth: (210 * productImageRepeater.count) + (5 * (productImageRepeater.count - 1))//<- 5 is the Flow.spacing//; contentHeight: 210//<- contentHeight is not needed unless a newline is supported
clip: true
ScrollBar.horizontal: ScrollBar {
policy: ScrollBar.AsNeeded
policy: ScrollBar.AlwaysOn//AsNeeded
}
Flow {
width: parent.contentWidth; height: parent.height//anchors.fill: parent// Note: Flow width must be large enough to fit all items horizontally so that there won't be a need to move an item to a newline
@ -662,6 +742,44 @@ Popup {
//if(this.status == Image.Null) console.log("No image has been set" + parent.parent.index)
}
}
// Position the close button
Button {
id: removeImageButton
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 8
width: 20; height: 20//32
text: qsTr(FontAwesome.xmark)
hoverEnabled: true
visible: (parent.children[0].status === Image.Ready)
contentItem: Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: removeImageButton.text
color: removeImageButton.hovered ? "#ffffff" : "#000000"
font.bold: true
font.family: FontAwesome.fontFamily
}
background: Rectangle {
width: parent.width
height: parent.height
radius: 5//50
color: removeImageButton.hovered ? "firebrick" : "transparent"
opacity: 0.7
}
onClicked: {
parent.children[0].source = ""
}
MouseArea {
anchors.fill: parent
onPressed: mouse.accepted = false
cursorShape: Qt.PointingHandCursor
}
}
}
Button {
@ -735,7 +853,7 @@ Popup {
id: listProductButton
width: 333.333333333; height: contentItem.contentHeight + 30
hoverEnabled: true
text: qsTr("Add")
text: qsTr("Submit")
background: Rectangle {
color: parent.hovered ? "#698b22" : "#506a1a"
radius: productDialog.inputRadius
@ -750,6 +868,12 @@ Popup {
// Check input fields to see if entered info is valid
// ...
//---------------------------------------
if(productNameField.text.length < 3) {
messageBox.text = qsTr("Product name is too short")
messageBox.open()
return; // exit function
}
//---------------------------------------
let subcategory_ids = []//let subcategories = []
for (let i = 0; i < subCategoryRepeater.count; i++) {
subcategory_ids.push(Backend.getSubCategoryIdByName(subCategoryRepeater.itemAt(i).children[0].currentText))//subcategories.push(subCategoryRepeater.itemAt(i).children[0].currentText)//console.log("Added subcategory: ", subcategories[i])
@ -767,7 +891,12 @@ Popup {
let attributes = [];
let attribute_object = {};
if(productWeightField.text.length > 0 && Number(productWeightField.text) > 0.00) {
attribute_object.weight = productWeightField.text
if(weightMeasurementUnit.currentText !== "kg") {
console.log("weight is in " + weightMeasurementUnit.currentText + ". Converting to kg ...")
attribute_object.weight = Backend.weightToKg(Number(productWeightField.text), weightMeasurementUnit.currentText)
} else {
attribute_object.weight = Number(productWeightField.text)
}
}
// Add attribute obj to list as long as its filled with properties
if (Object.keys(attribute_object).length > 0) {
@ -799,7 +928,7 @@ Popup {
productNameField.text,
productDescriptionEdit.text,
attributes,
productCodeField.text,
productCodeType.currentText.toLowerCase() + ":" + productCodeField.text,
Backend.getCategoryIdByName(productCategoryBox.currentText),
(subCategoryRepeater.count > 0) ? subcategory_ids : [], // subcategoryIds
productTagsField.tags(),

@ -75,12 +75,55 @@ Page {
}
//GroupBox {
// title: qsTr("Sort")
// SortComboBox
NeroshopComponents.ComboBox {
id: sortByBox
Row {
anchors.right: parent.right
anchors.verticalCenter: viewToggle.verticalCenter
width: 250
spacing: 3
// Filter button
Button {
id: filterButton
text: qsTr("Filter")
//anchors.verticalCenter: parent.verticalCenter
//height: sortBox.height
checkable: true
checked: filterPopUp.visible
display: AbstractButton.IconOnly
icon.source: "qrc:/assets/images/filter.png"
icon.color: !this.checked ? "#605185" : "#ffffff"
background: Rectangle {
radius: 3
color: parent.checked ? "#605185" : "#e0e0e0"
}
onClicked: {
filterPopUp.visible = true
}
Popup {
id: filterPopUp
visible: false
x: (parent.width - width) / 2
y: parent.height + 1
width: 200
height: 300//implicitHeight: contentItem.implicitHeight
background: Rectangle {
radius: 5
color: "#e0e0e0"
}
contentItem: /*NeroshopComponents.FilterBox {*/Item {
Text {
text: qsTr("Coming soon!")
anchors.centerIn: parent
}
}
}
}
// SortComboBox
NeroshopComponents.ComboBox {
id: sortBox
//anchors.verticalCenter: parent.verticalCenter
width: 250; height: viewToggle.height
model: ["None", "Latest", "Oldest", "Alphabetical order", "Price - Lowest", "Price - Highest"]
Component.onCompleted: currentIndex = find("None")
displayText: "Sort: " + currentText
@ -116,6 +159,7 @@ Page {
}*/
}
}
} // Row
} // Rectangle
StackLayout {
id: catalogStack

@ -257,7 +257,7 @@ Page {
Button {
id: addProductButton
////anchors.right: parent.right // <- uncomment if not enclosed in row
text: qsTr("+ Add Product")
text: qsTr("+ Add Item")
width: 304/*inventoryManager.width*/; height: 100//width: 200; height: 100//width: 100; height: width
hoverEnabled: true
background: Rectangle {
@ -409,7 +409,7 @@ Page {
id: removeProductsMessageBox
x: mainWindow.x + (mainWindow.width - this.width) / 2
y: mainWindow.y + (mainWindow.height - this.height) / 2
title: qsTr("Remove product")
title: qsTr("Remove items")
text: qsTr("Are you sure you want to permanently remove the selected item(s)?")
buttonModel: ["No", "Yes"]
buttonRow.state: "centered"; buttonRow.width: 300 // buttons should fill the row width

@ -17,7 +17,7 @@
std::string neroshop::Converter::json_string ("");
//-------------------------------------------------------
//-------------------------------------------------------
double neroshop::Converter::to_kg(double amount, const std::string& unit_name) const {
double neroshop::Converter::to_kg(double amount, const std::string& unit_name) {
if(neroshop::string::lower(unit_name) == "lb" || neroshop::string::lower(unit_name) == "lbs" || neroshop::string::lower(unit_name) == "pound") {return lb_to_kg(amount);}
return 0.0;
}

@ -24,7 +24,7 @@ namespace neroshop {
class Converter {
public:
// weight (mass)
double to_kg(double amount, const std::string& unit_name) const;
static double to_kg(double amount, const std::string& unit_name);
static double lb_to_kg(double lb); //static double pound_to_kilogram(double pound); // The correct way of abbreviation in expressing singular or plural pounds is “lb.” though “lbs.”, which stands for libra, is the common abbreviation used in expressing pounds
static std::unique_ptr<PriceApi> make_price_source(PriceSource source);

@ -999,7 +999,7 @@ bool neroshop::Node::validate(const std::string& key, const std::string& value)
assert(json["expiration_date"].is_string());
std::string expiration_date = json["expiration_date"].get<std::string>();
if(neroshop_timestamp::is_expired(expiration_date)) {
std::cerr << "Data has expired (exp date: " << expiration_date << " UTC)\n";
std::cerr << "Data has expired (exp date: " << expiration_date << ")\n";
// Notify the other nodes that this data has expired (so that once they receive a put with the expired data, it will be removed from their local hash table as soon as it goes through the validate function)
////send_put(key, value); // this should propagate the expiration information to other nodes in the DHT until the expired data is removed once and for all. Hmmm this could cause an endless loop ...
// This won't work unless all data contain a mandatory expiration date set on creation. A consensus mechanism may be necessary

@ -86,6 +86,15 @@ QImage neroshop::Backend::base64ToImage(const QString& base64Data) {
}
//----------------------------------------------------------------
//----------------------------------------------------------------
double neroshop::Backend::weightToKg(double amount, const QString& unit_name) const {
return neroshop::Converter::to_kg(amount, unit_name.toStdString());
}
double neroshop::Backend::lgToKg(double amount) const {
return neroshop::Converter::lb_to_kg(amount);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
QStringList neroshop::Backend::getCurrencyList() const
{
QStringList currency_list;

@ -29,6 +29,9 @@ public:
QString imageToBase64(const QImage& image); // un-tested
QImage base64ToImage(const QString& base64Data); // un-tested
Q_INVOKABLE double weightToKg(double amount, const QString& unit_name) const;
Q_INVOKABLE double lgToKg(double amount) const;
Q_INVOKABLE QStringList getCurrencyList() const;
Q_INVOKABLE int getCurrencyDecimals(const QString& currency) const;
Q_INVOKABLE QString getCurrencySign(const QString& currency) const;

Loading…
Cancel
Save