def __init__(self, config, dbManager, categories, currentCategory=0, parent=None): super(ManualAddDialog, self).__init__(parent) self.setupUi(self) self.config = config self.dbManager = dbManager self.categories = categories # Remove title bar self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) scroller.setupScrolling(self.categoryComboBox.view()) # Set the combobox view to scroll per pixel so the kinetic scrolling via touchscreen isnt ridiculously fast self.categoryComboBox.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) # Disabling mouse tracking means that when you first use touchscreen to scroll through items, then it wont # select that item self.categoryComboBox.view().setMouseTracking(False) self.updateCategories() self.categoryComboBox.setCurrentIndex(currentCategory) self.warningLabel.setText("")
def __init__(self, centralWindow, config, dbManager, parent=None): super(PurchaseHistoryWindow, self).__init__(parent) self.setupUi(self) self.centralWindow = centralWindow self.config = config self.dbManager = dbManager self.model = SqlTableModel( self.dbManager.connection, displayColumnMapping=(2, 0, 1), displayHeaders=('Name', 'Purchase Date', 'Qty'), customQuery='SELECT date, qty, ' '(SELECT name FROM inventory WHERE item = history.item) AS name FROM purchase_history history ' ) self.model.setColumnAlignment(1, Qt.AlignCenter) self.model.setColumnAlignment(2, Qt.AlignCenter) self.historyView.setModel(self.model) # Setup sorting on the model and list view (default is the date column descending) self.model.setSort('date', Qt.DescendingOrder) self.historyView.sortByColumn(1, Qt.DescendingOrder) # Set the name column to stretch to fill the area while the qty column is resized to contents self.historyView.horizontalHeader().setStretchLastSection(False) self.historyView.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) self.historyView.horizontalHeader().setSectionResizeMode( 1, QHeaderView.ResizeToContents) self.historyView.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) scroller.setupScrolling(self.historyView)
def __init__(self, config, centralWindow, parent=None): super(CheckOutBox, self).__init__(parent) self.setupUi(self) self.config = config self.centralWindow = centralWindow # Remove title bar self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) scroller.setupScrolling(self.qty_combo.view()) self.qty_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.qty_combo.view().setMouseTracking(False) for q in range(1, 51): self.qty_combo.addItem(str(q)) self.callbackFunction = None self.callbackParam = None
def __init__(self, config, centralWindow, name, parent=None): super(ExpirationBox, self).__init__(parent) self.setupUi(self) self.config = config self.centralWindow = centralWindow if name: self.itemNameLabel.setText(name) # Remove title bar self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) scroller.setupScrolling(self.month_combo.view()) # Set the combobox view to scroll per pixel so the kinetic scrolling via touchscreen isnt ridiculously fast self.month_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) # Disabling mouse tracking means that when you first use touchscreen to scroll through items, then it wont # select that item self.month_combo.view().setMouseTracking(False) for d in range(1, 13): self.month_combo.addItem(str(d)) scroller.setupScrolling(self.day_combo.view()) self.day_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.day_combo.view().setMouseTracking(False) for d in range(1, 32): self.day_combo.addItem(str(d)) scroller.setupScrolling(self.year_combo.view()) self.year_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.year_combo.view().setMouseTracking(False) year = datetime.now().year for y in range(year, year + constants.maxExpirationYear + 1): self.year_combo.addItem(str(y)) scroller.setupScrolling(self.qty_combo.view()) self.qty_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.qty_combo.view().setMouseTracking(False) for q in range(1, 51): self.qty_combo.addItem(str(q)) self.callbackFunction = None self.callbackParam = None
def __init__(self, centralWindow, config, dbManager, parent=None): super(SettingsWindow, self).__init__(parent) self.setupUi(self) self.centralWindow = centralWindow self.config = config self.dbManager = dbManager # Set current index to first page self.settingsStack.setCurrentIndex(0) scroller.setupScrolling(self.shelfTimeSpinBox, ScrollingType.SpinBox) scroller.setupScrolling(self.usageRateSpinBox, ScrollingType.SpinBox) scroller.setupScrolling(self.expDateSpinBox, ScrollingType.SpinBox)
def __init__(self, parent=None, lineEdit=None, suggestionsListModel=None): super(VirtualKeyboard, self).__init__(parent) self.setupUi(self) # Move dialog to the top left corner of page self.move(0, 0) self.parentLineEdit = lineEdit if self.parentLineEdit: self.lineEdit.setAlignment(self.parentLineEdit.alignment()) self.lineEdit.setCompleter(self.parentLineEdit.completer()) self.lineEdit.setEchoMode(self.parentLineEdit.echoMode()) self.lineEdit.setMaxLength(self.parentLineEdit.maxLength()) self.lineEdit.setValidator(self.parentLineEdit.validator()) self.lineEdit.setText(self.parentLineEdit.text()) self.suggestionsListModel = suggestionsListModel if self.suggestionsListModel: self.suggestionsListView.setModel(suggestionsListModel) self.resize(self.WIDTH, self.HEIGHT_WITH_SUGGESTIONS) self.suggestionsListView.selectionModel().selectionChanged.connect( self.selectSuggestion) scroller.setupScrolling(self.suggestionsListView) else: self.gridLayout.removeWidget(self.suggestionsListView) self.suggestionsListView.setParent( None ) # This works for modal dialog boxes where deleteLater DOES NOT self.suggestionsListView = None self.resize(self.WIDTH, self.HEIGHT_NO_SUGGESTIONS) # Remove title bar self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) self.state = KeyboardState.Normal self.layout = \ [[self.tildeBtn, ['`', '~', '`']], [self.oneBtn, ['1', '!', '1']], [self.twoBtn, ['2', '@', '2']], [self.threeBtn, ['3', '#', '3']], [self.fourBtn, ['4', '$', '4']], [self.fiveBtn, ['5', '%', '5']], [self.sixBtn, ['6', '^', '6']], [self.sevenBtn, ['7', '&&', '7']], [self.eightBtn, ['8', '*', '8']], [self.nineBtn, ['9', '(', '9']], [self.zeroBtn, ['0', ')', '0']], [self.minusBtn, ['-', '_', '-']], [self.equalBtn, ['=', '+', '=']], [self.qBtn, ['q', 'Q', 'Q']], [self.wBtn, ['w', 'W', 'W']], [self.eBtn, ['e', 'E', 'E']], [self.rBtn, ['r', 'R', 'R']], [self.tBtn, ['t', 'T', 'T']], [self.yBtn, ['y', 'Y', 'Y']], [self.uBtn, ['u', 'U', 'U']], [self.iBtn, ['i', 'I', 'I']], [self.oBtn, ['o', 'O', 'O']], [self.pBtn, ['p', 'P', 'P']], [self.leftBraceBtn, ['[', '{', '[']], [self.rightBraceBtn, [']', '}', ']']], [self.backSlashBtn, ['\\', '|', '\\']], [self.aBtn, ['a', 'A', 'A']], [self.sBtn, ['s', 'S', 'S']], [self.dBtn, ['d', 'D', 'D']], [self.fBtn, ['f', 'F', 'F']], [self.gBtn, ['g', 'G', 'G']], [self.hBtn, ['h', 'H', 'H']], [self.jBtn, ['j', 'J', 'J']], [self.kBtn, ['k', 'K', 'K']], [self.lBtn, ['l', 'L', 'L']], [self.semicolonBtn, [';', ':', ';']], [self.quoteBtn, ['\'', '\"', '\'']], [self.zBtn, ['z', 'Z', 'Z']], [self.xBtn, ['x', 'X', 'X']], [self.cBtn, ['c', 'C', 'C']], [self.vBtn, ['v', 'V', 'V']], [self.bBtn, ['b', 'B', 'B']], [self.nBtn, ['n', 'N', 'N']], [self.mBtn, ['m', 'M', 'M']], [self.commaBtn, [',', '<', ',']], [self.periodBtn, ['.', '>', '.']], [self.forwardSlashBtn, ['/', '?', '/']]] for buttonInfo in self.layout: buttonInfo[0].pressed.connect(self.characterPressed)
def __init__(self, dbManager, config, categories, parent=None): super(NewItemDetails, self).__init__(parent) self.setupUi(self) self.dbManager = dbManager self.config = config self.categories = categories self.pending_category = None # Remove title bar self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) self.itemNameModel = SqlTableModel( self.dbManager.connection, columnSortName='rank', columnSortOrder=Qt.DescendingOrder, customQuery='SELECT item, name, CASE\n' 'WHEN name LIKE %s THEN 3\n' 'WHEN name ILIKE %s THEN 2\n' 'WHEN name LIKE %s THEN 1\n' 'ELSE 0 END AS rank FROM inventory\n' 'WHERE name ILIKE %s', filterArgs=('%', '%%', '%', '%%'), displayColumnMapping=(1, ), limitCount=10, hideItems=True) self.itemName_textBox.autocompleteModel = self.itemNameModel self.itemName_textBox.autocompleteUpdateCallback = self.itemName_updateSuggestions scroller.setupScrolling(self.category_combo.view()) # Set the combobox view to scroll per pixel so the kinetic scrolling via touchscreen isnt ridiculously fast self.category_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) # Disabling mouse tracking means that when you first use touchscreen to scroll through items, then it wont # select that item self.category_combo.view().setMouseTracking(False) self.updateCategories() scroller.setupScrolling(self.itemQty_combo.view()) self.itemQty_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.itemQty_combo.view().setMouseTracking(False) for q in range(1, 51): self.itemQty_combo.addItem(str(q)) scroller.setupScrolling(self.pkgQty_combo.view()) self.pkgQty_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.pkgQty_combo.view().setMouseTracking(False) for q in range(1, 51): self.pkgQty_combo.addItem(str(q)) scroller.setupScrolling(self.month_combo.view()) self.month_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.month_combo.view().setMouseTracking(False) for d in range(1, 13): self.month_combo.addItem(str(d)) scroller.setupScrolling(self.day_combo.view()) self.day_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.day_combo.view().setMouseTracking(False) for d in range(1, 32): self.day_combo.addItem(str(d)) scroller.setupScrolling(self.year_combo.view()) self.year_combo.view().setVerticalScrollMode( QAbstractItemView.ScrollPerPixel) self.year_combo.view().setMouseTracking(False) year = datetime.now().year for y in range(year, year + constants.maxExpirationYear + 1): self.year_combo.addItem(str(y))