Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ain_8541840?term=warehouse&page=1&position=5&origin=search&related_id=8541840

- yes/no icons
- updated product details dialog (2x vbox)
- updated customer deails dialog
- updated tasks crud (using enums)
  • Loading branch information
HardMax71 committed Aug 28, 2024
1 parent 8139662 commit 11d551d
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="./diagrams/app_icon.png" alt="NexusWare Icon" width="200" height="200">
<img src="./desktop_app/resources/icons/app_icon.png" alt="NexusWare Icon" width="200" height="200">
</p>
<p align="center">
<b><span style="font-size:24px;">NexusWare</span></b>
Expand Down
Binary file modified desktop_app/resources/icons/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop_app/resources/icons/no.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop_app/resources/icons/yes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 20 additions & 7 deletions desktop_app/src/ui/components/custom_widgets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from PySide6.QtCore import Qt, QPropertyAnimation, Property, QEasingCurve, Signal
from PySide6.QtGui import QPainter, QColor, QIcon
from PySide6.QtWidgets import (
QPushButton, QLineEdit, QComboBox, QLabel, QWidget, QVBoxLayout, QGraphicsOpacityEffect, QFrame, QStyle
QPushButton, QLineEdit, QComboBox, QLabel, QWidget, QVBoxLayout, QGraphicsOpacityEffect, QFrame, QStyle,
QGraphicsDropShadowEffect
)

from desktop_app.src.ui.icon_path_enum import IconPath
Expand Down Expand Up @@ -147,35 +148,47 @@ def __init__(self, parent=None):
super().__init__(parent)
self.setFixedSize(60, 30)
self._checked = False
self._opacity = QGraphicsOpacityEffect(opacity=0.5)

# Opacity effect for smooth transitions
self._opacity = QGraphicsOpacityEffect()
self._opacity.setOpacity(0.8)
self.setGraphicsEffect(self._opacity)
self._animation = QPropertyAnimation(self._opacity, b"opacity", self)
self._animation.setDuration(100)

# Shadow effect to make the thumb more visible
self._shadow_effect = QGraphicsDropShadowEffect(self)
self._shadow_effect.setBlurRadius(10)
self._shadow_effect.setOffset(0, 2)
self._shadow_effect.setColor(QColor(0, 0, 0, 150))
self.setGraphicsEffect(self._shadow_effect)

def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)

track_color = QColor(100, 100, 100) if not self._checked else QColor(0, 150, 0)
# Draw the track
track_color = QColor(180, 180, 180) if not self._checked else QColor(0, 150, 0)
painter.setPen(Qt.NoPen)
painter.setBrush(track_color)
painter.drawRoundedRect(0, 5, 60, 20, 10, 10)

thumb_position = 5 if not self._checked else 35
# Draw the thumb
thumb_position = 2 if not self._checked else 29
painter.setBrush(QColor(255, 255, 255))
painter.drawEllipse(thumb_position, 0, 30, 30)
painter.drawEllipse(thumb_position, 2, 26, 26)

def mousePressEvent(self, event):
self._checked = not self._checked
self._animation.setStartValue(0.5)
self._animation.setStartValue(0.8)
self._animation.setEndValue(1.0)
self._animation.start()
self.update()
self.toggled.emit(self._checked)

def mouseReleaseEvent(self, event):
self._animation.setStartValue(1.0)
self._animation.setEndValue(0.5)
self._animation.setEndValue(0.8)
self._animation.start()

def isChecked(self):
Expand Down
5 changes: 4 additions & 1 deletion desktop_app/src/ui/icon_path_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ class IconPath(Enum):
SAVE: str = "icons:save.png"

EYE_VIEW: str = "icons:eye_view.png"

VIEW: str = "icons:view.png"

EDIT: str = "icons:edit.png"
DELETE: str = "icons:delete.png"
ADJUST: str = "icons:adjust.png"
SHIP: str = "icons:ship.png"
TRACK: str = "icons:track.png"
LABEL: str = "icons:label.png"

YES: str = "icons:yes.png"
NO: str = "icons:no.png"

OFFLINE: str = "icons:offline.png"

SYNC: str = "icons:sync.png"
Expand Down
49 changes: 35 additions & 14 deletions desktop_app/src/ui/views/customers/customer_details_dialog.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import datetime

from PySide6.QtWidgets import (QVBoxLayout, QTableWidget, QTableWidgetItem,
from PySide6.QtWidgets import (QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem,
QHeaderView, QDialog, QFormLayout, QDialogButtonBox,
QMessageBox, QLabel)
QMessageBox, QLabel, QWidget, QGroupBox)

from public_api.api import CustomersAPI
from public_api.shared_schemas import Customer
Expand All @@ -17,24 +17,41 @@ def __init__(self, customer: Customer, customers_api: CustomersAPI, parent=None)

def init_ui(self):
self.setWindowTitle(f"Customer Details - {self.customer.name}")
self.setMinimumSize(550, 400)
layout = QVBoxLayout(self)
self.setMinimumSize(800, 400)
main_layout = QHBoxLayout(self)

form_layout = QFormLayout()
# Left side - Customer Info and OK button
left_widget = QWidget()
left_layout = QVBoxLayout(left_widget)

# Create a group box for customer data
customer_group = QGroupBox("Customer Data")
form_layout = QFormLayout(customer_group)
form_layout.addRow("Name:", QLabel(self.customer.name))
form_layout.addRow("Email:", QLabel(self.customer.email or "N/A"))
form_layout.addRow("Phone:", QLabel(self.customer.phone or "N/A"))
form_layout.addRow("Address:", QLabel(self.customer.address or "N/A"))

layout.addLayout(form_layout)
address_label = QLabel(self.customer.address or "N/A")
address_label.setWordWrap(True)
form_layout.addRow("Address:", address_label)

left_layout.addWidget(customer_group)
left_layout.addStretch(1)

# OK button
button_box = QDialogButtonBox(QDialogButtonBox.Ok)
button_box.accepted.connect(self.accept)
left_layout.addWidget(button_box)

# Right side - Customer Orders Table
right_widget = QWidget()
right_layout = QVBoxLayout(right_widget)

# Customer Orders
orders_table = QTableWidget()
orders_table.setColumnCount(4)
orders_table.setHorizontalHeaderLabels(["Order ID", "Date", "Total Amount", "Status"])
header = orders_table.horizontalHeader()
header.setSectionResizeMode(QHeaderView.Stretch)
# header.setSectionResizeMode(0, QHeaderView.Stretch)

try:
orders = self.customers_api.get_customer_orders(self.customer.id)
Expand All @@ -48,9 +65,13 @@ def init_ui(self):
except Exception as e:
QMessageBox.warning(self, "Error", f"Failed to load customer orders: {str(e)}")

layout.addWidget(QLabel("Customer Orders:"))
layout.addWidget(orders_table)
right_layout.addWidget(QLabel("Customer Orders:"))
right_layout.addWidget(orders_table)

button_box = QDialogButtonBox(QDialogButtonBox.Ok)
button_box.accepted.connect(self.accept)
layout.addWidget(button_box)
# Add left and right widgets to main layout
main_layout.addWidget(left_widget)
main_layout.addWidget(right_widget)

# Set layout proportions
main_layout.setStretch(0, 1) # Left side
main_layout.setStretch(1, 2) # Right side
48 changes: 37 additions & 11 deletions desktop_app/src/ui/views/products/product_details_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from datetime import datetime

from PySide6.QtWidgets import (QVBoxLayout, QTableWidget, QTableWidgetItem,
QHeaderView, QDialog, QFormLayout, QDialogButtonBox, QLabel)
from PySide6.QtWidgets import (QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem,
QHeaderView, QDialog, QFormLayout, QDialogButtonBox, QLabel, QWidget, QGroupBox)
from PySide6.QtCore import Qt

from public_api.api import LocationsAPI
from public_api.shared_schemas import ProductWithCategoryAndInventory
Expand All @@ -16,17 +17,37 @@ def __init__(self, product: ProductWithCategoryAndInventory, locations_api: Loca

def init_ui(self):
self.setWindowTitle(f"Product Details - {self.product.name}")
self.setMinimumWidth(500)
layout = QVBoxLayout(self)
self.setMinimumWidth(800)
self.setMinimumHeight(400)
main_layout = QHBoxLayout(self)

info_layout = QFormLayout()
# Left side - Product Info and OK button
left_widget = QWidget()
left_layout = QVBoxLayout(left_widget)

# Create a group box for product data
product_group = QGroupBox("Product Data")
info_layout = QFormLayout(product_group)
info_layout.addRow("SKU:", QLabel(self.product.sku))
info_layout.addRow("Name:", QLabel(self.product.name))
info_layout.addRow("Category:", QLabel(self.product.category.name if self.product.category else "N/A"))
info_layout.addRow("Price:", QLabel(f"${self.product.price:.2f}"))
info_layout.addRow("Description:", QLabel(self.product.description or "N/A"))

layout.addLayout(info_layout)
description_label = QLabel(self.product.description or "N/A")
description_label.setWordWrap(True)
info_layout.addRow("Description:", description_label)

left_layout.addWidget(product_group)
left_layout.addStretch(1)

# OK button
button_box = QDialogButtonBox(QDialogButtonBox.Ok)
button_box.accepted.connect(self.accept)
left_layout.addWidget(button_box)

# Right side - Available Locations Table
right_widget = QWidget()
right_layout = QVBoxLayout(right_widget)

inventory_table = QTableWidget()
inventory_table.setColumnCount(3)
Expand All @@ -47,8 +68,13 @@ def init_ui(self):
inventory_table.setItem(row, 2, QTableWidgetItem(
datetime.fromtimestamp(item.last_updated).strftime("%Y-%m-%d %H:%M:%S")))

layout.addWidget(inventory_table)
right_layout.addWidget(QLabel("Available Locations"))
right_layout.addWidget(inventory_table)

button_box = QDialogButtonBox(QDialogButtonBox.Ok)
button_box.accepted.connect(self.accept)
layout.addWidget(button_box)
# Add left and right widgets to main layout
main_layout.addWidget(left_widget)
main_layout.addWidget(right_widget)

# Set layout proportions
main_layout.setStretch(0, 1) # Left side
main_layout.setStretch(1, 2) # Right side
Loading

0 comments on commit 11d551d

Please sign in to comment.