Commit 1838cc5f authored by Robin Trioux's avatar Robin Trioux
Browse files

Major structure change for cleaner project management

parent 7ca8b674
Bière;2.0
Champagne;5.0
Cidre;1.5
Coca(Bouteille);2.0
Coca(25cl);0.5
Ice Tea(Bouteille);2.0
Ice Tea(25cl);0.5
Menu Number 9;3.5
Menu Number 7; 7.0
Menu Number 6; 6.0
Menu Number 45; 17.0
Blanquette de Veau; 20.0
# Installation procedure
This procedure describe how to get a development environment ready.
No matter your system we assume you have python 3 installed on your system.
On Windows don't forget to add python/pip in your PATH environment variable if you did let the installer wizzard do it for you.
On Windows don't forget to add python/pip in your PATH environment variable if you didn't let the installer wizzard do it for you.
##Raspberry(Raspbian)
......@@ -26,7 +26,7 @@ On Windows don't forget to add python/pip in your PATH environment variable if y
- Create a virtual environment (**virutalenv venv**)
- Source the environment (**source ./venv/bin/activate**)
- Install dependencies (**pip install -r requirements.txt**)
- launch program (**python main.py**)
- launch program (**./scripts/gmc**)
#!/usr/bin/python
#!/usr/bin/env python
import sys
from pathlib import Path
import os
GMC_DIR = Path(__file__).parents[1]
SRC_DIR = GMC_DIR / "src"
for i in SRC_DIR.glob('**/*'):
if i.is_dir() and i.name != "__pycache__":
sys.path.append(str(i))
os.environ['GMC_DIR'] = str(GMC_DIR)
# sys.path.append('../src/atoms')
# sys.path.append('../src/debug')
# sys.path.append('../src/euro')
# sys.path.append('../src/grpc')
# sys.path.append('../src/gui')
# sys.path.append('../src/managers')
# sys.path.append('../src/widgets')
# sys.path.append('../src/widgets/atoms')
# sys.path.append('../src/widgets/tree')
from GUI import *
# TODO: ENSURE BALANCE CAN'T HAVE ABSURDS VALUES (eg: 16.33333...) [OK Money class + string]
......
......@@ -6,6 +6,10 @@ from QUtils import *
from QItemTree import *
from QUIManager import QUIManager
from QNFCManager import QNFCManager
from Client import Client
from Euro import Eur
# TODO:SOLVE THIS ARCHITECTURE PROBLEM
# /!\ ARCHITECTURE PROBLEM... MANAGER CAN'T BE CALLED HERE SINCE QATOMS IS IMPORTED IN QMANAGER
......@@ -18,6 +22,71 @@ from QUIManager import QUIManager
######################
class QNFCInfo(QWidget):
def __init__(self, parent=None):
nfcm = QNFCManager()
uim = QUIManager()
super().__init__(parent)
# Definition
self.mainLayout = QVBoxLayout()
self.groupBox = QGroupBox()
self.groupBoxLayout = QVBoxLayout()
self.rowInfo = QRowInfo()
self.userHistoryButton = QPushButton()
self.user = QUser(User())
# Layout
self.groupBox.setLayout(self.groupBoxLayout)
self.groupBoxLayout.addWidget(self.rowInfo)
self.groupBoxLayout.addWidget(self.userHistoryButton)
# main layout
self.mainLayout.addWidget(self.groupBox)
self.setLayout(self.mainLayout)
# Settings
self.rowInfo.addRow("UID", nfcm.getCardUID())
self.rowInfo.addRow("Solde", Eur(0))
self.userHistoryButton.setText("Historique utilisateur")
self.groupBox.setTitle("Info utilisateur")
nfcm.cardInserted.connect(self.cardInserted)
nfcm.cardRemoved.connect(self.cardRemoved)
uim.balanceUpdated.connect(self.update)
self.userHistoryButton.clicked.connect(self.showUserInfo)
def cardInserted(self):
nfcm = QNFCManager()
client = Client()
cardUID = nfcm.getCardUID()
balance = client.requestUserBalance(customer_id=cardUID)
self.rowInfo.setRow(1, 1, balance)
self.rowInfo.setRow(0, 1, cardUID)
self.user.setId(cardUID)
self.user.setBalance(balance)
def cardRemoved(self):
self.rowInfo.setRow(1, 1, Eur(0))
self.rowInfo.setRow(0, 1, "00 00 00 00")
self.user.setId("00 00 00 00")
self.user.setBalance(Eur(0))
def update(self):
nfcm = QNFCManager()
client = Client()
cardUID = nfcm.getCardUID()
balance = client.requestUserBalance(customer_id=cardUID)
self.rowInfo.setRow(1, 1, balance)
def showUserInfo(self):
self.user.showInfoPannel()
class QBuyingInfo(QWidget):
def __init__(self, qBuying, parent=None):
super().__init__(parent)
......@@ -143,7 +212,7 @@ class QQuantity(QWidget):
def editingFinished(self):
try:
self.product.setQuantity(int(self.quantityEditLine.text()))
except:
except ValueError:
self.product.setQuantity(1)
self.quantity = self.product.getQuantity()
if self.quantityEditLine.text() != "":
......@@ -181,7 +250,7 @@ class QQuantity(QWidget):
class QUserInfo(QWidget):
def __init___(self, parent=None):
def __init__(self, user, parent=None):
super().__init__(parent)
uim = QUIManager()
......@@ -189,6 +258,29 @@ class QUserInfo(QWidget):
self.setWindowTitle("Informations utilisateur")
self.setWindowIcon(uim.getIcon("group"))
# Definition
self.mainLayout = QVBoxLayout()
self.userInfoGroupBox = QGroupBox()
self.userInfoGroupBoxLayout = QVBoxLayout()
self.historyTree = QUserHistory(["Transaction", "Montant", "Heure"], user)
# Layout
self.mainLayout.addWidget(self.userInfoGroupBox)
self.mainLayout.addWidget(self.historyTree)
self.userInfoGroupBox.setLayout(self.userInfoGroupBoxLayout)
# Settings
self.userInfoGroupBox.setTitle("Informations utilisateur")
self.setLayout(self.mainLayout)
# Window settings
self.setFixedSize(500, 500)
center(self)
self.setWindowTitle("Information utilisateur")
self.setWindowIcon(uim.getWindowIcon("group"))
class QProductInfo(QWidget):
def __init__(self, product, parent=None):
......@@ -263,6 +355,14 @@ class QAtom(QObject, Atom):
def getActionDict(self):
return self.actionDict
def addAction(self, actionName: str, function, icon: str = None):
if actionName in self.actionDict:
printW("{} already in action list".format(actionName))
self.actionDict[actionName] = {'fct': function, 'icon': icon}
def removeAction(self, actionName: str):
del self.actionDict[actionName]
def setActionDict(self, actionDict):
self.actionDict = actionDict
......@@ -271,7 +371,11 @@ class QAtom(QObject, Atom):
class QUser(QAtom, User):
def __init__(self, user):
super().__init__(user)
self.infoPannel = None
def showInfoPannel(self):
print(self)
self.infoPannel = QUserInfo(self)
self.infoPannel.show()
class QProduct(QAtom, Product):
......@@ -353,7 +457,7 @@ class QBuying(QOperation, Buying):
else:
self.sRefounded.emit()
else:
warningDialog = QWarningDialog("Mauvais utilisateur","L'utilisateur n'est pas concerné par cette transaction","Veuillez présenter une carte concernée par la transaction")
warningDialog = QWarningDialog("Mauvais utilisateur", "L'utilisateur n'est pas concerné par cette transaction", "Veuillez présenter une carte concernée par la transaction")
center(warningDialog)
warningDialog.exec()
......
......@@ -3,6 +3,7 @@ from PyQt5.QtCore import *
from PyQt5.QtGui import *
from QDataManager import QDataManager
from QUIManager import QUIManager
from QUtils import *
from QItemTree import *
......@@ -58,7 +59,8 @@ class QMainMenu(QMainWindow):
self.setWindowTitle("Gala.Manager.Core")
self.resize(1600, 1000)
self.setWindowIcon(QIcon("icon.ico"))
uim = QUIManager()
self.setWindowIcon(uim.getWindowIcon("icon"))
center(self)
self.MainTab = QMainTab()
......
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