diff --git a/brmbar3/brmbar-gui-qt4.py b/brmbar3/brmbar-gui-qt4.py index 274507f..cb89f19 100755 --- a/brmbar3/brmbar-gui-qt4.py +++ b/brmbar3/brmbar-gui-qt4.py @@ -102,6 +102,10 @@ class ShopAdapter(QtCore.QObject): def itemList(self): return [ self.acct_inventory_map(a) for a in shop.account_list("inventory") ] + @QtCore.Slot('QVariant', 'QVariant', result='QVariant') + def addBarcode(self, dbid, barcode): + return brmbar.Account.load(db, id = dbid).add_barcode(barcode) + db = psycopg2.connect("dbname=brmbar") shop = brmbar.Shop.new_with_defaults(db) currency = shop.currency diff --git a/brmbar3/brmbar-gui-qt4/ItemEdit.qml b/brmbar3/brmbar-gui-qt4/ItemEdit.qml index 15587f7..2110e35 100644 --- a/brmbar3/brmbar-gui-qt4/ItemEdit.qml +++ b/brmbar3/brmbar-gui-qt4/ItemEdit.qml @@ -10,6 +10,24 @@ Item { property variant dbid: "" property variant info: "" + property string barcode: "" + + BarcodeInput { + color: "#00ff00" /* just for debugging */ + onAccepted: { + var acct = shop.barcodeInput(text) + barcode = text + text = "" + if (typeof(acct) != "undefined") { + status_text.setStatus("Existing barcode: " + acct.name, "#ff4444") + /* TODO: Allow override. */ + return + } + shop.addBarcode(dbid, barcode) + status_text.setStatus("Barcode added.", "#ffff7c") + } + } + Text { id: item_name x: 65 @@ -138,12 +156,11 @@ Item { text: "Restock" } - BarButton { - id: add_barcode + BarTextHint { x: 65 y: 476 - width: 360 - text: "Add Barcode" + hint_goal: "Add barcode:" + hint_action: "Scan item now" } BarButton {