This commit is contained in:
Oscar Alvarez 2020-12-05 19:37:57 -05:00
parent b4a9df2b26
commit 5f9507fc6f
9 changed files with 186 additions and 119 deletions

View file

@ -36,13 +36,16 @@ class ButtonsFunction(QGridLayout):
columns = 5
if panel:
name_style = 'toolbar'
print('Name style :', name_style)
positions = [(i, j) for i in range(rows) for j in range(columns)]
for position, value in zip(positions, self.values):
name_icon = value[0][7:]
print('Name icon > ', name_icon)
button = CustomButton(
parent,
id=value[0],
size=parent.screen_size,
icon=get_icon(name_icon),
title=value[1],
method=value[2],
@ -95,9 +98,9 @@ class ButtonsFunction(QGridLayout):
['button_comment', self.tr('NOTE'), 'action_comment'],
['button_tip', self.tr('TIP'), 'action_tip'],
['button_tables', self.tr('TABLES'), 'action_tables'],
['button_reservations', self.tr('RESERVATIONS'), 'action_reservations'],
['button_consumer', self.tr('CONSUMER'), 'action_consumer'],
['button_print_order', self.tr('ORDER'), 'action_print_order']
# ['button_reservations', self.tr('RESERVATIONS'), 'action_reservations'],
# ['button_delete_line', self.tr('DELETE'), 'action_delete_line'],
])
@ -107,6 +110,10 @@ class ButtonsStacked(QHBoxLayout):
def __init__(self, parent):
super(ButtonsStacked, self).__init__()
self.stacked = QStackedWidget()
_size = 100
if parent.screen_size == 'small':
_size = 60
self.stacked.setMaximumHeight(_size)
self.button_accept = CustomButton(
id='button_accept',

View file

@ -1,4 +1,3 @@
import os
from pathlib import Path
from functools import partial
@ -20,8 +19,8 @@ __all__ = ['CustomButton']
class CustomButton(QPushButton):
def __init__(self, parent, id, icon=None, title=None, desc=None, method=None,
target=None, size='small', name_style='category_button'):
def __init__(self, parent, id, size='small', icon=None, title=None, desc=None,
method=None, target=None, name_style='category_button'):
"""
Create custom, responsive and nice button flat style,
with two subsections
@ -41,9 +40,14 @@ class CustomButton(QPushButton):
"""
super(CustomButton, self).__init__()
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
qsize = QSize(50, 50)
if name_style == 'toolbar_button':
if hasattr(parent, 'screen_size'):
size = parent.screen_size
if size == 'small' or name_style == 'toolbar_button':
qsize = QSize(35, 35)
else:
qsize = QSize(50, 50)
self.id = id
styles = []
@ -69,6 +73,7 @@ class CustomButton(QPushButton):
rows.append(label_icon)
if title:
print('label_title', size, name_style, title)
label_title = QLabel(title, self)
label_title.setWordWrap(True)
label_title.setAlignment(Qt.AlignCenter | Qt.AlignCenter)
@ -78,11 +83,11 @@ class CustomButton(QPushButton):
if desc:
if len(desc) > 29:
desc = desc[0:29]
label_desc = QLabel(desc, self)
label_desc.setAlignment(Qt.AlignCenter | Qt.AlignCenter)
label_desc.setObjectName('label_desc')
rows.append(label_desc)
if len(rows) > 1:
vbox = QVBoxLayout()
for w in rows:

View file

@ -33,6 +33,7 @@ class GridButtons(QWidget):
self.parent = parent
self.layout = QGridLayout()
self.setLayout(self.layout)
print('parent.screen_size', parent.screen_size)
self.button_size = parent.screen_size
self.rows = rows
self.action = action
@ -95,7 +96,7 @@ class MenuDash(QVBoxLayout):
self.create_categories()
pixmap = QPixmap(file_menu_img)
new_pixmap = pixmap.scaled(200, 60)
new_pixmap = pixmap.scaled(180, 55)
label_menu = QLabel('')
label_menu.setPixmap(new_pixmap)
@ -107,11 +108,11 @@ class MenuDash(QVBoxLayout):
self.addWidget(widget_head, 0)
self.pushButtonBack = QPushButton()
self.pushButtonBack.setIcon(QIcon(file_back_icon))
self.pushButtonBack.setIconSize(QSize(25, 25))
self.pushButtonBack.setMaximumWidth(35)
self.pushButtonBack.setIconSize(QSize(20, 20))
self.pushButtonBack.setMaximumWidth(20)
self.layout_head.addWidget(self.pushButtonBack, stretch=0)
self.layout_head.addWidget(label_menu, stretch=1)
self.layout_head.addWidget(self.pushButtonBack, stretch=1)
self.layout_head.addWidget(label_menu, stretch=0)
self.addWidget(self.category_area, 0)
self.pushButtonBack.clicked.connect(self.action_back)

View file

@ -43,6 +43,30 @@ QAbstractButton:pressed {
border-width: 0px;
}
#panel_left {
/* max-width: 50%; */
}
#field_state {
color : #424242;
min-height: 25px;
font : 16pt;
max-width: 100px;
}
#field_invoice {
color : #424242;
min-height: 25px;
font : 16pt;
}
#field_invoice_type {
color : #424242;
min-height: 25px;
font : 16pt;
min-width: 95px;
}
#button_ok {
background-color: rgb(55, 181, 228);
border-width: 0px;
@ -81,8 +105,8 @@ QAbstractButton:pressed {
#label_message {
font : 14pt;
min-height : 10px;
min-width : 10px;
min-height : 30px;
min-width : 150px;
}
#back_button {

View file

@ -47,6 +47,19 @@ QAbstractButton:pressed {
border-width: 0px;
}
#field_state {
color : #424242;
min-height: 25px;
font : 16pt;
}
#field_invoice_type {
color : #424242;
min-height: 25px;
font : 16pt;
min-width: 95px;
}
#button_ok {
background-color: rgb(55, 181, 228);
border-width: 0px;

View file

@ -3,13 +3,13 @@
font-family: "DejaVu Sans";
border-style: groove;
font: 10pt;
color: rgb(102, 102, 102);
color: rgb(80, 80, 80);
background-color : white;
height: 60px;
height: 90px;
width : 130px;
border-width: 0px;
border-radius: 10px;
text-align: right;
text-align: center;
}
#product_button::hover {
@ -21,17 +21,18 @@
}
#label_title {
font : 11pt;
font : 14pt;
min-height : 32px;
width: 120px;
color: rgb(102, 102, 102);
color: rgb(80, 80, 80);
}
#label_desc {
font : 10pt;
font : 14pt;
height : 30px;
width: 110px;
color: rgb(152, 152, 152);
color: rgb(30, 30, 30);
text-align: center;
}
#label_icon {
@ -62,8 +63,8 @@
#toolbar_button {
font-family: "DejaVu Sans";
border-style: groove;
font: 19pt;
background-color : white;
font: 18pt;
background-color: white;
height: 55px;
width : 130px;
border-width: 0px;

View file

@ -2,14 +2,14 @@
#product_button {
font-family: "DejaVu Sans";
border-style: groove;
font: 10pt;
color: rgb(102, 102, 102);
font: 6pt;
color: rgb(80, 80, 80);
background-color : white;
height: 60px;
width : 130px;
height: 30px;
width : 110px;
border-width: 0px;
border-radius: 10px;
text-align: right;
border-radius: 5px;
text-align: center;
}
#product_button::hover {
@ -21,7 +21,7 @@
}
#label_title {
font : 11pt;
font : 8pt;
min-height : 32px;
width: 120px;
color: rgb(102, 102, 102);
@ -29,26 +29,26 @@
#label_desc {
font : 10pt;
height : 30px;
height : 20px;
width: 110px;
color: rgb(152, 152, 152);
}
#label_icon {
height : 35px;
width: 35px;
height : 20px;
width: 20px;
}
#category_button {
font-family: "DejaVu Sans";
border-style: groove;
font: 10pt;
font: 8pt;
color: rgb(102, 102, 102);
background-color : white;
height: 80px;
width : 130px;
height: 60px;
width : 120px;
border-width: 0px;
border-radius: 10px;
border-radius: 5px;
}
#category_button::hover {
@ -64,7 +64,7 @@
border-style: groove;
font: 9pt;
background-color : white;
height: 55px;
height: 50px;
width : 130px;
border-width: 0px;
}

View file

@ -7,13 +7,15 @@ import base64
from decimal import Decimal
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QDate
from .tools import get_icon, to_float, to_numeric
from .dialogs import (Help, ControlPanel, SearchSale, SearchParty, SearchProduct, Position,
from .dialogs import (
Help, ControlPanel, SearchSale, SearchParty, SearchProduct, Position,
Comment, DialogPayment, DialogSalesman, DialogVoucher, DialogPrintInvoice,
DialogGlobalDiscount, DialogPaymentTerm, DialogStock, DialogOrder,
DialogForceAssign, DialogTaxes, DialogCancelInvoice, SaleLine, DialogAgent,
DialogConsumer, DialogManageTables, DialogDeliveryMen, DialogChannel,
DialogTableMoneyCount, DialogGlobalDiscountTable, DeliveryPartySelected,
DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected)
DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected
)
from datetime import datetime, timedelta, date
from collections import OrderedDict
# from PyQt5.QtGui import QTouchEvent
@ -32,11 +34,11 @@ from .localdb import LocalStore
from .reporting import Receipt
from .buttonpad import Buttonpad, ButtonsFunction
from .states import STATES, RE_SIGN
from .constants import (PATH_PRINTERS, DELTA_LOCALE, STRETCH, alignRight,
alignLeft, alignCenter, alignHCenter, alignVCenter,
DIALOG_REPLY_NO, DIALOG_REPLY_YES, ZERO,
RATE_CREDIT_LIMIT, SCREENS, FILE_BANNER,
CONVERSION_DIGITS)
from .constants import (
PATH_PRINTERS, DELTA_LOCALE, STRETCH, alignRight, alignLeft, alignCenter,
alignHCenter, alignVCenter, DIALOG_REPLY_NO, DIALOG_REPLY_YES, ZERO,
RATE_CREDIT_LIMIT, SCREENS, FILE_BANNER, CONVERSION_DIGITS
)
INVOICE_TYPE = [('', '')]
MINIMUM_DATE = QDate(0, 1, 1)
@ -534,38 +536,44 @@ class MainWindow(FrontWindow):
def create_gui(self):
panels = QHBoxLayout()
panel_left = QVBoxLayout()
panel_left = QWidget()
panel_left.setObjectName('panel_left')
vbox_left = QVBoxLayout()
if self.screen_size == 'small':
max_size = 620
else:
max_size = 950
panel_left.setMaximumWidth(max_size)
panel_left.setLayout(vbox_left)
panel_right = QVBoxLayout()
panel_right.setObjectName('panel_right')
left_head = QHBoxLayout()
left_invoice = QHBoxLayout()
left_table = None
left_bottom = QHBoxLayout()
left_info_order = QHBoxLayout()
# LEFT HEAD COMPONENTS
self.message_bar = MessageBar()
self.label_input = QLabel()
self.label_input.setFocus()
self.label_input.setObjectName('label_input')
values = self.get_menu_control_panel()
self.menu_control_panel = ButtonsFunction(self, panel=True, values=values)
if self.enviroment == 'restaurant':
values = self.get_product_by_categories()
menu_dash = MenuDash(self, values, 'on_selected_item')
if not self.tablet_mode:
_label_type_invoice = QLabel(self.tr(' TYPE INVOICE:'))
_label_type_invoice.setObjectName('label_invoice')
_label_type_invoice.setAlignment(alignRight | alignVCenter)
self.field_amount = FieldNumeric(self, 'amount', {})
self.field_amount.setObjectName('field_amount')
self.field_sign = QLabel(' ')
self.field_sign.setObjectName('field_sign')
layout_message = QGridLayout()
layout_message.setColumnStretch(0, 1)
layout_message.addLayout(self.message_bar, 0, 0, 2, 0)
left_head.addLayout(self.message_bar, 1)
left_head.addWidget(self.field_sign, 0)
left_head.addWidget(self.field_amount, 1)
# LEFT INVOICE COMPONENTS
self.label_input = QLabel()
self.label_input.setFocus()
self.label_input.setObjectName('label_input')
size_input = 100
if self.screen_size == 'large':
size_input = 200
self.label_input.setMaximumWidth(size_input)
INVOICE_TYPE.append(('P', ('POS')))
if self.shop.get('credit_note_electronic_authorization'):
@ -579,22 +587,47 @@ class MainWindow(FrontWindow):
if self.shop.get('electronic_authorization'):
INVOICE_TYPE.append(('1', ('VENTA ELECTRONICA')))
self.field_invoice_type = ComboBox(self, 'invoice_type',
{'values': INVOICE_TYPE,
'on_change': 'action_invoice_type_selection_changed'
})
self.field_invoice_type = ComboBox(
self, 'invoice_type', {
'values': INVOICE_TYPE,
'on_change': 'action_invoice_type_selection_changed'
})
if not self.tablet_mode:
layout_message.addWidget(self.label_input, 2, 0)
layout_message.addWidget(_label_type_invoice, 2, 1)
layout_message.addWidget(self.field_invoice_type, 2, 2)
else:
layout_message.addWidget(self.label_input, 2, 0, 1, 2)
layout_message.addWidget(self.field_invoice_type, 2, 3)
left_invoice.addWidget(self.label_input, 1)
left_invoice.addWidget(self.field_invoice_type)
left_head.addLayout(layout_message, 0)
left_head.addWidget(self.field_sign, 0)
left_head.addWidget(self.field_amount, 0)
_label_type_invoice = QLabel(self.tr('INVOICE:'))
_label_type_invoice.setObjectName('label_invoice')
_label_type_invoice.setAlignment(alignRight | alignVCenter)
_invoice_fields = [
('invoice', {
'name': self.tr('INVOICE'),
'readonly': True,
'placeholder': False,
'size': self.screen_size,
'color': self.label_color
}),
]
self.field_invoice = QLineEdit('')
self.field_invoice.setReadOnly(True)
self.field_invoice.setObjectName('field_invoice')
left_invoice.addWidget(self.field_invoice, 1)
self.field_state = QLineEdit('STATE')
self.field_state.setReadOnly(True)
self.field_state.setObjectName('field_state')
left_invoice.addWidget(self.field_state)
# LEFT TABLE COMPONENTS
values = self.get_menu_control_panel()
self.menu_control_panel = ButtonsFunction(self, panel=True,
values=values)
if self.enviroment == 'restaurant':
values = self.get_product_by_categories()
menu_dash = MenuDash(self, values, 'on_selected_item')
info_fields = [
('party', {
@ -640,9 +673,6 @@ class MainWindow(FrontWindow):
'color': self.label_color
})
]
self.field_state = QLineEdit('STATE')
self.field_state.setReadOnly(True)
self.field_state.setObjectName('field_state')
if self._web_channel:
self.Channel = FastModel('sale.web_channel', self.ctx)
@ -728,15 +758,17 @@ class MainWindow(FrontWindow):
}))
col_sizes_tlines = [field['width'] for field in self.fields_sale_line]
left_table = TableView('model_sale_lines', self.model_sale_lines,
col_sizes_tlines, method_selected_row=self.sale_line_selected)
left_table = TableView('model_sale_lines',
self.model_sale_lines, col_sizes_tlines,
method_selected_row=self.sale_line_selected
)
self.table_sale_lines = left_table
for i, f in enumerate(self.model_sale_lines._fields, 0):
if f.get('invisible'):
self.table_sale_lines.hideColumn(i)
_fields_amounts = [
_fields_amounts1 = [
('untaxed_amount', {
'name': self.tr('SUBTOTAL'),
'readonly': True,
@ -759,6 +791,8 @@ class MainWindow(FrontWindow):
'size': self.screen_size,
'color': self.label_color
}),
]
_fields_amounts2 = [
('total_amount', {
'name': self.tr('TOTAL'),
'readonly': True,
@ -788,56 +822,38 @@ class MainWindow(FrontWindow):
'color': self.label_color_2 or 'orange'
})
]
if self.enviroment == 'retail':
_fields_amounts = _fields_amounts1 + _fields_amounts2
else:
_fields_amounts = _fields_amounts2
fields_amounts = OrderedDict(_fields_amounts)
self.grid_amounts = GridForm(self, fields_amounts, col=1)
self.buttonpad = Buttonpad(self)
self.pixmap_pos = Image(self, 'pixmap_pos', FILE_BANNER)
self.table_payment = TableView('table_payment', self.table_payment_lines,
[250, STRETCH])
panel_left.addLayout(left_head, 0)
panel_left.addWidget(left_table, 1)
self.table_payment = TableView('table_payment',
self.table_payment_lines, [250, STRETCH])
vbox_left.addLayout(left_head, 0)
vbox_left.addLayout(left_invoice, 0)
vbox_left.addWidget(left_table, 1)
panel_right.addWidget(self.pixmap_pos, 0)
_other_fields = [
('invoice', {
'name': self.tr('INVOICE'),
'readonly': True,
'placeholder': False,
'size': self.screen_size,
'color': self.label_color
}),
('state', {
'name': self.tr('STATE'),
'readonly': True,
'placeholder': False,
'size': self.screen_size,
'color': self.label_color
}),
]
# if self.enviroment == 'restaurant':
# info_fields.extend(_other_fields)
self.grid_info = GridForm(self, OrderedDict(info_fields), col=_cols)
other_fields = OrderedDict(_other_fields)
self.grid_other_fields = GridForm(self, other_fields, col=2)
left_bottom.addLayout(self.grid_info, 1)
if self.enviroment == 'restaurant':
panel_left.addLayout(self.buttonpad.functions, 1)
vbox_left.addLayout(self.buttonpad.functions, 1)
vbox_left.addLayout(self.grid_info, 0)
panel_right.addLayout(menu_dash, 1)
panel_right.addLayout(self.grid_amounts, 0)
panel_right.addLayout(self.buttonpad.stacked, 0)
panel_right.addLayout(self.grid_other_fields, 0)
else:
panel_right.addLayout(self.grid_amounts, 1)
panel_right.addLayout(self.buttonpad.functions, 1)
panel_right.addLayout(self.buttonpad.stacked, 0)
panel_right.addLayout(self.grid_other_fields, 1)
panel_right.addLayout(self.grid_info, 1)
panel_right.addWidget(self.table_payment)
panel_left.addLayout(left_bottom, 0)
panels.addLayout(panel_left, 1)
vbox_left.addLayout(left_info_order, 0)
panels.addWidget(panel_left, 1)
panels.addLayout(panel_right, 0)
widget = QWidget()
widget.setLayout(panels)

View file

@ -49,7 +49,7 @@ tablet_mode=False
#Theme for front windows ('base', 'dark')
#For theme white use: base
#For theme dark use: dark
theme=dark
theme=base
# Mode of window: fullscreen / maximized
mode_window=maximized